[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160901221743.GJ10168@twins.programming.kicks-ass.net>
Date: Fri, 2 Sep 2016 00:17:43 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Oleg Nesterov <oleg@...hat.com>
Cc: Ingo Molnar <mingo@...nel.org>, Al Viro <viro@...IV.linux.org.uk>,
Bart Van Assche <bvanassche@....org>,
Johannes Weiner <hannes@...xchg.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Neil Brown <neilb@...e.de>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] sched/wait: avoid abort_exclusive_wait() in
__wait_on_bit_lock()
On Thu, Sep 01, 2016 at 09:01:41PM +0200, Peter Zijlstra wrote:
> On Fri, Aug 26, 2016 at 02:45:52PM +0200, Oleg Nesterov wrote:
>
> > We do not need anything tricky to avoid the race,
>
> The race being:
>
> CPU0 CPU1 CPU2
>
> __wait_on_bit_lock()
> bit_wait_io()
> io_schedule()
>
> clear_bit_unlock()
> __wake_up_common(.nr_exclusive=1)
> list_for_each_entry()
> if (curr->func() && --nr_exclusive)
> break
>
> signal()
>
> if (signal_pending_state()) == TRUE
> return -EINTR
>
> And no progress because CPU1 exits without acquiring the lock and CPU0
> thinks its done because it woke someone.
FWIW, the way the mutex code avoids this issue is by doing the
signal_pending test while holding the q->lock, that way its exclusive
with wakeup.
Powered by blists - more mailing lists