All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Grant Likely <grant.likely@secretlab.ca>,
	Mark Brown <broonie@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [RESEND] drivercore: deferral race condition fix
Date: Tue, 8 Apr 2014 16:16:29 +0300	[thread overview]
Message-ID: <5343F6AD.9050300@ti.com> (raw)
In-Reply-To: <CACxGe6sUSsTuVBOYj3siHOUUnRhzM_jmdmnj0xZg3kLtNMEzCw@mail.gmail.com>

On 04/08/2014 03:47 PM, Grant Likely wrote:
> On Tue, Apr 8, 2014 at 3:27 AM, Grant Likely <grant.likely@secretlab.ca> wrote:
>> On Thu, 3 Apr 2014 10:40:59 +0100, Mark Brown <broonie@kernel.org> wrote:
>>> On Thu, Apr 03, 2014 at 10:12:07AM +0300, Peter Ujfalusi wrote:
>>>> When the kernel is built with CONFIG_PREEMPT it is possible to reach a state
>>>> when all modules loaded but some driver still stuck in the deferred list
>>>> and there is a need for external event to kick the deferred queue to probe
>>>> these drivers.
>>>
>>> Acked-by: Mark Brown <broonie@linaro.org>
>>
>> It's a pretty crude solution though. The problem is any "in-flight"
>> probes that are going to defer will not get added to the active list.
>> Rerunning the entire active list is a bit much (but it does have the
>> advantage of still being conceptually simple). I think we can do better.
>>
>> Instead of running the entire list, we could add a check to
>> driver_deferred_probe_add() that adds the device to the active list
>> instead of pending list on the condition that another driver probe
>> completed while the deferred probe was in-flight.
>>
>> I'm playing with a solution now. I'll email a proposal shortly.
> 
> Thinking out loud now...
> 
> The race can occur whenever a probe in another thread completes
> successfully while the current probe is in-flight. If that has
> happened, then the defer condition may be resolved and the driver
> should be scheduled for retry immediately. If the core code can check
> for that condition, then we can add the driver directly to the active
> list and kick the workqueue.
> 
> The problem is that we don't currently have an easy way to test if a
> probe has completed in another thread. This patch handles it with a
> single flag that gets set whenever a probe completes while another
> probe is executing. I was worried that this approach would be racy,
> but after running through the scenarios I can't find a situation where
> it wouldn't get added. I only concern I have remaining on this
> approach is that it will trigger unnecessary retries, but even that
> isn't really a problem because the pending list will have been moved
> to the active list *anyway*. It isn't even a retry of the whole list
> that's happening because most likely the only device on the pending
> list will be the one that completed with -EPROBE_DEFER.

This code will only going to add one retry and it is going to that only under
the condition you have described:
the last driver which finishes it's probe ends up with -EPROBE_DEFER and while
it's probe was in-flight another driver loaded with success.
In all other cases this will not trigger a retry:
If you load only one driver which ends up deferring,
If the driver which differing is not the last driver to load - since we will
have other drivers to be loaded and they will kick the list anyways.

> So, I actually think this is the right approach now. I'll reply to the
> patch itself and make some comments on the code.

Thanks, I'll check the comments.

-- 
Péter

  reply	other threads:[~2014-04-08 13:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-03  7:12 [RESEND] drivercore: deferral race condition fix Peter Ujfalusi
2014-04-03  9:40 ` Mark Brown
2014-04-08 10:27   ` Grant Likely
2014-04-08 12:47     ` Grant Likely
2014-04-08 13:16       ` Peter Ujfalusi [this message]
2014-04-08 12:43 ` Grant Likely
2014-04-08 13:35   ` Peter Ujfalusi
2014-04-09  7:03     ` Peter Ujfalusi

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=5343F6AD.9050300@ti.com \
    --to=peter.ujfalusi@ti.com \
    --cc=broonie@kernel.org \
    --cc=grant.likely@secretlab.ca \
    --cc=gregkh@linuxfoundation.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.