[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACVXFVPu_nbVCVR_HTt9H764+4JKC3=GPyhsf8Lpsch4Fa=xqQ@mail.gmail.com>
Date: Fri, 25 May 2012 08:33:35 +0800
From: Ming Lei <ming.lei@...onical.com>
To: Alan Stern <stern@...land.harvard.edu>
Cc: Greg KH <gregkh@...uxfoundation.org>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Wedson Almeida Filho <wedsonaf@...il.com>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-kernel@...r.kernel.org,
Linux PM List <linux-pm@...r.kernel.org>
Subject: Re: Race condition between driver_probe_device and device_shutdown
On Thu, May 24, 2012 at 10:37 PM, Alan Stern <stern@...land.harvard.edu> wrote:
>
> The code there is racy already. It does:
>
> } else if (dev->driver && dev->driver->shutdown) {
>
> without any locking protection. If the driver is unbound while this
> statement runs then dev->driver could be non-NULL for the first test
> and NULL for the second.
Yes, I missed this one, :-)
>
>> > to fix the race by prevent driver core from probing or releasing once
>> > shutdown is started.
>> >
>> > How about the below patch?
>>
>> How about waiting for the original poster to respond as to exactly how
>> they are hitting this race before doing anything?
>
> In addition, the patch is too complicated. For this type of
> synchronization you should use SRCU. See
> Documentation/RCU/whatisRCU.txt and related files.
Yes, the synchronization should be a many reader vs. one
writer problem, RCU should be suitable.
Looks we think alike, :-)
I have studied RCU yesterday, but was afraid that may introduce
much more code, so not applied it in the patch. Will study it further
to figure out a new version.
Thanks,
--
Ming Lei
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists