On 1/2/19 11:55 AM, Linus Torvalds wrote: > On Wed, Jan 2, 2019 at 10:14 AM Jens Axboe <axboe@xxxxxxxxx> 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