From: Arjan van de Ven <arjan@infradead.org>
To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org
Cc: greg@kroah.com
Subject: [PATCH] device model: Do a quickcheck for driver binding before doing an expensive check
Date: Sun, 14 Sep 2008 08:32:06 -0700 [thread overview]
Message-ID: <20080914083206.0f42b2a7@infradead.org> (raw)
From: Arjan van de Ven <arjan@linux.intel.com>
Subject: [PATCH] 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>
---
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 3ac443b..20febc0 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -257,6 +257,9 @@ static int __driver_attach(struct device *dev, void *data)
* is an error.
*/
+ if (drv->bus->match && !drv->bus->match(dev, drv))
+ return 0;
+
if (dev->parent) /* Needed for USB */
down(&dev->parent->sem);
down(&dev->sem);
--
1.5.5.1
--
Arjan van de Ven Intel Open Source Technology Centre
For development, discussion and tips for power savings,
visit http://www.lesswatts.org
next reply other threads:[~2008-09-14 15:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-14 15:32 Arjan van de Ven [this message]
2008-09-15 11:32 ` Cornelia Huck
2008-09-15 14:06 ` Arjan van de Ven
2008-09-15 14:53 ` Cornelia Huck
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=20080914083206.0f42b2a7@infradead.org \
--to=arjan@infradead.org \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®