* [PATCH] udevd: Use a tighter loop in compare_devpath()
@ 2008-10-25 16:01 Alan Jenkins
2008-10-25 17:42 ` Kay Sievers
2008-10-29 16:47 ` Kay Sievers
0 siblings, 2 replies; 3+ messages in thread
From: Alan Jenkins @ 2008-10-25 16:01 UTC (permalink / raw)
To: linux-hotplug
udevd: Use a tighter loop for compare_devpath()
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>
diff --git a/udev/udevd.c b/udev/udevd.c
index 4306597..381d560 100644
@@ -303,26 +285,24 @@ static int mem_size_mb(void)
static int compare_devpath(const char *running, const char *waiting)
{
- int i;
+ int i = 0;
- 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 */
return 0;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] udevd: Use a tighter loop in compare_devpath()
2008-10-25 16:01 [PATCH] udevd: Use a tighter loop in compare_devpath() Alan Jenkins
@ 2008-10-25 17:42 ` Kay Sievers
2008-10-29 16:47 ` Kay Sievers
1 sibling, 0 replies; 3+ messages in thread
From: Kay Sievers @ 2008-10-25 17:42 UTC (permalink / raw)
To: linux-hotplug
On Sat, Oct 25, 2008 at 18:01, Alan Jenkins <alan-jenkins@tuffmail.co.uk> wrote:
> udevd: Use a tighter loop for compare_devpath()
>
> 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.
Yeah, I've seen that too some times. Nice! Applied.
Thanks,
Kay
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] udevd: Use a tighter loop in compare_devpath()
2008-10-25 16:01 [PATCH] udevd: Use a tighter loop in compare_devpath() Alan Jenkins
2008-10-25 17:42 ` Kay Sievers
@ 2008-10-29 16:47 ` Kay Sievers
1 sibling, 0 replies; 3+ messages in thread
From: Kay Sievers @ 2008-10-29 16:47 UTC (permalink / raw)
To: linux-hotplug
On Sat, Oct 25, 2008 at 18:42, Kay Sievers <kay.sievers@vrfy.org> wrote:
> On Sat, Oct 25, 2008 at 18:01, Alan Jenkins <alan-jenkins@tuffmail.co.uk> wrote:
>> udevd: Use a tighter loop for compare_devpath()
>>
>> 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.
>
> Yeah, I've seen that too some times. Nice! Applied.
I've merged the udevd exec and run queue now to have always a sorted
list. We remember the seqnum of the last event that caused an event to
be delayed. Next time we need to check, we do not do the devpath
string compare for all the events that we already checked in the
earlier run. This saves us ~70% of the calls to compare_devpath().
Kay
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-10-29 16:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-25 16:01 [PATCH] udevd: Use a tighter loop in compare_devpath() Alan Jenkins
2008-10-25 17:42 ` Kay Sievers
2008-10-29 16:47 ` Kay Sievers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).