This crops up in my threaded udevd profiles from time to time.
It's not consistent - probably due to variations in the number
of concurrent events - but it can hit 4% user time and higher.
The change halves the user time spent in compare_devpath().
Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
static int compare_devpath(const char *running, const char *waiting)
{
static int compare_devpath(const char *running, const char *waiting)
{
- for (i = 0; i < UTIL_PATH_SIZE; i++) {
- /* identical device event found */
- if (running[i] == '\0' && waiting[i] == '\0')
- return 1;
+ while (running[i] == waiting[i] && running[i] != '\0')
+ i++;
- /* parent device event found */
- if (running[i] == '\0' && waiting[i] == '/')
- return 2;
+ /* identical device event found */
+ if (running[i] == '\0' && waiting[i] == '\0')
+ return 1;
- /* child device event found */
- if (running[i] == '/' && waiting[i] == '\0')
- return 3;
+ /* parent device event found */
+ if (running[i] == '\0' && waiting[i] == '/')
+ return 2;
- /* no matching event */
- if (running[i] != waiting[i])
- break;
- }
+ /* child device event found */
+ if (running[i] == '/' && waiting[i] == '\0')
+ return 3;
+ /* no matching event */