diff options
author | ogasawara@osdl.org <ogasawara@osdl.org> | 2004-06-26 01:18:31 -0700 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 21:36:21 -0700 |
commit | 9a52390cfe0882df3a24b75cc9d8b36878a3982d (patch) | |
tree | ee1825030f2813c00c82e856eb7486a3b7b605b7 | |
parent | b99f344fde90ddc131ea6e2ec8520e018e1274e2 (diff) |
[PATCH] udevstart performance increase
I noticed a comment in namedev.c which stated
"Figure out where the device symlink is at. For char devices this will
always be in the class_dev->path. But for block devices, it's
different. The main block device will have the device symlink in it's
path, but all partitions have the symlink in its parent directory. But
we need to watch out for block devices that do not have parents, yet
look like a partition (fd0, loop0, etc.). They all do not have a device
symlink yet. We do a sit and spin on waiting for them right now, we
should possibly have a whitelist for these devices here..."
I went ahead and created a whitelist for the block devices that look
like partitions (mainly by using devices.txt) and tested for any
performance increase that we would see. The whitelist only impacts
udevstart time depending on the state of UDEV_NO_SLEEP. Since the list
was short, I just did a sequential search and ordered the list in such a
way that those block devices which have more /dev entires (ex. loop0,
loop1, loop2, etc) appear sooner in the list and will thus be found
quicker. I've enclosed the patch and some of the performance results I
saw below. Basically, as the number of block devices without device
symlinks increased, the use of the whitelist improved udevstart
performance compared to just sitting and spinning. I just thought it
was interesting and thought I'd share. If you feel the patch is
beneficial please consider for merging. Also, if you'd be interested in
expanding the whitelist for other devices which are missing device
symlinks and seeing if there are added performance increases let me know
and I'll do what I can. Thanks,
Leann
Note: ex. loop represents all the loop devices (i.e. loop0, loop1,
loop2, etc)
block devices present with whitelist time
-rw-r--r-- | namedev.c | 48 |
1 files changed, 45 insertions, 3 deletions
@@ -602,6 +602,43 @@ static int match_place(struct config_device *dev, struct sysfs_class_device *cla return 0; } +static int whitelist_search(struct sysfs_class_device *class_dev) +{ + int i; + int list_size = 17; + int sysblock = 10; + + static char *list[] = { + "nb", + "ram", + "loop", + "fd", + "md", + "dos_cd", + "double", + "flash", + "msd", + "rflash", + "rom", + "rrom", + "sbpcd", + "pcd", + "pf", + "scd", + "ubd", + }; + + if (!strncmp(class_dev->path, "/sys/block", sysblock)) { + for (i=0; i < list_size; i++) { + if (!strncmp(class_dev->name, list[i], strlen(list[i]))) { + return 1; + } + } + } + + return 0; +} + static struct sysfs_device *get_sysfs_device(struct sysfs_class_device *class_dev) { struct sysfs_device *sysfs_device; @@ -615,8 +652,8 @@ static struct sysfs_device *get_sysfs_device(struct sysfs_class_device *class_de * all partitions have the symlink in its parent directory. * But we need to watch out for block devices that do not have parents, yet * look like a partition (fd0, loop0, etc.) They all do not have a device - * symlink yet. We do sit and spin on waiting for them right now, we should - * possibly have a whitelist for these devices here... + * symlink yet. We do sit and spin on waiting for them right now unless + * they happen to be in the whitelist in which case we exit. */ class_dev_parent = sysfs_get_classdev_parent(class_dev); if (class_dev_parent != NULL) @@ -626,8 +663,13 @@ static struct sysfs_device *get_sysfs_device(struct sysfs_class_device *class_de tspec.tv_nsec = 10000000; /* sleep 10 millisec */ loop = 10; while (loop--) { - if (udev_sleep) + if (udev_sleep) { + if (whitelist_search(class_dev)) { + sysfs_device = NULL; + goto exit; + } nanosleep(&tspec, NULL); + } if (class_dev_parent) sysfs_device = sysfs_get_classdev_device(class_dev_parent); |