From mboxrd@z Thu Jan 1 00:00:00 1970 From: Linus Torvalds Subject: Re: [PATCH] fs-writeback: drop wb->list_lock during blk_finish_plug() Date: Fri, 18 Sep 2015 08:32:15 -0700 Message-ID: References: <20150917021453.GO3902@dastard> <20150917224230.GF8624@ret.masoncoding.com> <20150917235647.GG8624@ret.masoncoding.com> <20150918003735.GR3902@dastard> <20150918054044.GT3902@dastard> <20150918131615.GI8624@ret.masoncoding.com> <55FC1E72.3040500@fb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Cc: Chris Mason , Dave Chinner , Jan Kara , Josef Bacik , LKML , linux-fsdevel , Neil Brown , Christoph Hellwig , Tejun Heo To: Jens Axboe , Ingo Molnar , Peter Zijlstra , Frederic Weisbecker Return-path: In-Reply-To: <55FC1E72.3040500@fb.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Fri, Sep 18, 2015 at 7:23 AM, Jens Axboe wrote: > > It makes no sense for preemption schedule to NOT unplug, the fact that it > doesn't is news to me as well. It was never the intent of the > unplug-on-schedule to NOT unplug for certain schedule out events, that seems > like very odd behavior. Actually, even a *full* schedule doesn't unplug, unless the process is going to sleep. See sched_submit_work(), which will only call the unplugging if the process is actually going to sleep (ok, so it's a bit subtle if you don't know the state rules, but it's the "!tsk->state" check there) So preemption and cond_resched() isn't _that_ odd. We've basically treated a non-sleeping schedule as a no-op for the task work. The thinking was probably that it might be better to delay starting the IO in case we get scheduled back quickly, and we're obviously not actually _sleeping_, so it's likely not too bad. Now, that's probably bogus, and I think that we should perhaps just make the rule be that "if we actually switch to another task, we run blk_schedule_flush_plug()". But it should be noted that that really *does* introduce a lot of new potential races. Traditionally, our block layer plugging has been entirely thread-synchronous, and would never happen asynchronously. But with preemption, that "switch to another thread" really *does* happen asynchronously. So making things always happen on task switch is actually fairly dangerous, and potentially adds the need for much more synchronization for the IO submission. What we possibly *could* make the scheduler rule be: - if it's not an actual PREEMPT_ACTIVE (ie in a random place) - _and_ we actually switch to another thread - _then_ do the whole blk_schedule_flush_plug(tsk) thing. adding some scheduler people to the explicit cc list. That said, the "cond_resched[_lock]()" functions currently always set PREEMPT_ACTIVE (indirectly - they use preempt_schedule_common()), so even though those are synchronous, right now they *look* asynchronous to the scheduler, so we'd still have to sort that out. Ingo/Peter/Frederic? Comments? Linus