linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: willy@linux.intel.com (Matthew Wilcox)
Subject: [PATCH 2/2] nvme: fix the placement of set_current_state to TASK_INTERRUPTIBLE
Date: Tue, 19 Feb 2013 10:05:38 -0500	[thread overview]
Message-ID: <20130219150538.GA4530@linux.intel.com> (raw)
In-Reply-To: <51103A15.8010508@linux.intel.com>

On Mon, Feb 04, 2013@02:45:41PM -0800, Arjan van de Ven wrote:
> the nvme driver has a kthread that processes certain events periodically.
> However, the kthread also gets woken for certain urgent actions.
> 
> The current code does not use the current_state logic correctly;
> it calls set_current_state(TASK_INTERRUPTIBLE); right before doing
> a schedule_timeout(), with the result that there is a race condition
> where a wakeup can get lost, and thus delayed by one second.
> 
> This patch moves the set_current_state(TASK_INTERRUPTIBLE); to before
> the place where the queue of outstanding work is checked, to close
> the race condition

The thing is, that's not a queue of outstanding work, that's the list
of devices that exist in the system.  Your patch makes the kthread do
all of its work in the TASK_INTERRUPTIBLE state, which I don't think is
right either (is it?)

We could add a flag to indicate that there's urgent work to be done
(checked after setting TASK_INTERRUPTIBLE), or just live with the
occasional race.

Alternatively, we could get rid of the kthread in favour of timers
for cancelling commands and a workqueue for dealing with urgent work.
I have this on my long-term todo list, but in the absence of having
hardware to test with on large-scale systems, I didn't want to make such
a large change.

       reply	other threads:[~2013-02-19 15:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <51103A15.8010508@linux.intel.com>
2013-02-19 15:05 ` Matthew Wilcox [this message]
2013-02-19 16:30   ` [PATCH 2/2] nvme: fix the placement of set_current_state to TASK_INTERRUPTIBLE Arjan van de Ven

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=20130219150538.GA4530@linux.intel.com \
    --to=willy@linux.intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).