From: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] udevd: Use a tighter loop in compare_devpath()
Date: Sat, 25 Oct 2008 16:01:21 +0000 [thread overview]
Message-ID: <490342D1.9090906@tuffmail.co.uk> (raw)
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;
}
next reply other threads:[~2008-10-25 16:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-25 16:01 Alan Jenkins [this message]
2008-10-25 17:42 ` [PATCH] udevd: Use a tighter loop in compare_devpath() Kay Sievers
2008-10-29 16:47 ` Kay Sievers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=490342D1.9090906@tuffmail.co.uk \
--to=alan-jenkins@tuffmail.co.uk \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.