diff options
author | Arjan van de Ven <arjan@linux.intel.com> | 2008-09-14 11:32:06 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-10-16 12:24:50 -0400 |
commit | 6cd49586090187a2a145bb6570fb2392f121aa22 (patch) | |
tree | 67373f2686b61e6a30f402190bf5ac3ec34a0f13 | |
parent | 286661b3777897220ecfcd774bccc68a34667f39 (diff) |
device model: Do a quickcheck for driver binding before doing an expensive check
This patch adds a quick check for the driver<->device match before
taking the locks and doin gthe expensive checks. Taking the lock hurts
in asynchronous boot context where the device lock gets hit; one of the
init functions takes the lock and goes to do an expensive hardware init;
the other init functions walk the same PCI list and get stuck on the
lock as a result.
For the common case, we can know there's no chance whatsoever of a match
if the device isn't in the drivers ID table... so this patch does that
check as a best-effort-avoid-the-lock approach.
Bootcharts for before and after can be seen at
http://www.fenrus.org/before.svg
http://www.fenrus.org/after.svg
Note the long time "agp_ali_init" takes in the first graph; my laptop
doesn't even have an ALI chip in it! (the bootgraphs look a bit
dissimilar, but that's the point, the first one has a bunch of arbitrary
delays in it that cause it to look very different)
This reduces my kernel boot time by about 20%
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/base/dd.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 3ac443b2ac08..20febc00a525 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c | |||
@@ -257,6 +257,9 @@ static int __driver_attach(struct device *dev, void *data) | |||
257 | * is an error. | 257 | * is an error. |
258 | */ | 258 | */ |
259 | 259 | ||
260 | if (drv->bus->match && !drv->bus->match(dev, drv)) | ||
261 | return 0; | ||
262 | |||
260 | if (dev->parent) /* Needed for USB */ | 263 | if (dev->parent) /* Needed for USB */ |
261 | down(&dev->parent->sem); | 264 | down(&dev->parent->sem); |
262 | down(&dev->sem); | 265 | down(&dev->sem); |