linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	Christoph Hellwig <hch@lst.de>
Subject: Re: block: only use __set_current_state() for polled IO
Date: Wed, 2 Jan 2019 11:59:23 -0700	[thread overview]
Message-ID: <eebec8c9-af48-6b9f-b1ba-2b10ea9a5a96@kernel.dk> (raw)
In-Reply-To: <CAHk-=whz9-ren=HOTcofA0hCROWnVijTDGUgKaEVwkVjf2_CZg@mail.gmail.com>

On 1/2/19 11:55 AM, Linus Torvalds wrote:
> On Wed, Jan 2, 2019 at 10:14 AM Jens Axboe <axboe@kernel.dk> wrote:
>>
>> Note that the blk-mq hunk is fine, since that's ONLY used for polling.
> 
> Actually, it's fine for another reason too: using
> "__set_current_state()" is always safe when the state you're setting
> things to is TASK_RUNNING. Even if there's a concurrent wakeup, that's
> only going to set things running anyway, so there's no race.

Right, that is of course correct, guess I glanced too quickly at that
one for the revert.

> But yes, if something is truly just polling, then it shouldn't touch
> the task state at all.

Exactly, and I agree this was going down the wrong path. I'll work
on getting rid of the state setting for polled IO, that makes a lot
more sense than trying to fiddle with __set_current_state() when
we aren't going to be sleeping at all.

> That said, some of the "polling" code looks mis-named. For example,
> the blk_poll() call in mm/page_io.c looks like it's polling, but it
> can actually sleep (ie blk_mq_poll_hybrid() gets called even when
> "spin" is true).

That's another case that needs a bit of cleanup, the hybrid polling
only really makes sense for sync polling. FWIW, the 'spin == true'
doesn't control if we're going to be sleeping or not, it's the
caller saying "keep going until you find a completion we care about".

> But the sleeping case looks like it handles the task state thing on
> its own, so all those polling codepaths should probably be inspected.
> 
> In the meantime, the attached is what I committed.

Looks good to me, matches my manual revert.


-- 
Jens Axboe


      reply	other threads:[~2019-01-02 18:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-02 17:55 block: only use __set_current_state() for polled IO Jens Axboe
2019-01-02 18:07 ` Linus Torvalds
2019-01-02 18:10   ` Jens Axboe
2019-01-02 18:11   ` Linus Torvalds
2019-01-02 18:14     ` Jens Axboe
2019-01-02 18:55       ` Linus Torvalds
2019-01-02 18:59         ` Jens Axboe [this message]

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=eebec8c9-af48-6b9f-b1ba-2b10ea9a5a96@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).