[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200628131813.GM4817@hirez.programming.kicks-ass.net>
Date: Sun, 28 Jun 2020 15:18:13 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Oleg Nesterov <oleg@...hat.com>, Nick Piggin <npiggin@...il.com>,
Mel Gorman <mgorman@...hsingularity.net>,
Jan Kara <jack@...e.cz>, Davidlohr Bueso <dave@...olabs.net>,
Andi Kleen <ak@...ux.intel.com>,
Lukas Czerner <lczerner@...hat.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: wait_on_page_bit_common(TASK_KILLABLE, EXCLUSIVE) can miss
wakeup?
On Sat, Jun 27, 2020 at 10:39:20PM -0700, Linus Torvalds wrote:
> Ugh.
Heh, I was afraid of that..
> So how about the attached trivial two-liner? We solve the problem by
> simply marking ourselves TASK_RUNNING, which means that we won't be
> counted as an exclusive wakeup.
>
> Ok, so the "one" line to do that is that is actually two lines:
>
> __set_current_state(TASK_RUNNING);
> smp_mb__before_atomic();
>
> and there's four lines of comments to go with it, but it really is
> very simple: if we do that before we do the test_and_set_bit_lock(),
> no wakeups will be lost, because we won't be sleeping for that wakeup.
>
> I'm not entirely happy about that "smp_mb__before_atomic()". I think
> it's right in practice that test_and_set_bit_lock() (when it actually
> does a write) has at LEAST atomic seqmantics, so I think it's good.
> But it's not pretty.
Hurm... yes. I think I agree this solves it. However... the wait loop is
'weird'. It isn't shaped like our other loops.
On the one hand, who cares, that's just my OCD, on the other hand, it
does mean you have to think harder every time you look at this thing.
Powered by blists - more mailing lists