Re: [PATCH] device model: Do a quickcheck for driver binding beforedoing an expensive check

From: Cornelia Huck
Date: Mon Sep 15 2008 - 07:33:21 EST


On Sun, 14 Sep 2008 08:32:06 -0700,
Arjan van de Ven <arjan@xxxxxxxxxxxxx> wrote:

> 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.

Hm, you call bus->match twice now; once without dev->sem held and once
with it. For the busses I'm familiar with that shouldn't be a problem,
but are you sure there aren't busses which want dev->sem held?
(Although I think not relying on dev->sem would be the sane thing...)
>
> 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.

I've always thought of ->match being a quick check which just looks at
the IDs with ->probe doing the heavier stuff, so this should be
reasonable (if all busses play nicely). But driver_probe_device() still
calls ->match a second time, and device_attach() will thus always call
->match under the lock. Should it be moved out of the lock there as
well?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/