From: Davidlohr Bueso Subject: Re: [PATCH 1/6] sched: Unbreak wakeups Date: Wed, 2 Jun 2021 12:43:59 -0700 Message-ID: <20210602194359.pxujd4rx4lxv2ldm@offworld> References: <20210602131225.336600299@infradead.org> <20210602133040.271625424@infradead.org> Mime-Version: 1.0 Return-path: Content-Disposition: inline In-Reply-To: <20210602133040.271625424@infradead.org> List-ID: Content-Type: text/plain; charset="us-ascii"; format="flowed" Content-Transfer-Encoding: 7bit To: Peter Zijlstra Cc: Thomas Gleixner , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Jens Axboe , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, "David S. Miller" , Jakub Kicinski , Felipe Balbi , Greg Kroah-Hartman , Alexander Viro , Tejun Heo On Wed, 02 Jun 2021, Peter Zijlstra wrote: >Remove broken task->state references and let wake_up_process() DTRT. > >The anti-pattern in these patches breaks the ordering of ->state vs >COND as described in the comment near set_current_state() and can lead >to missed wakeups: > > (OoO load, observes RUNNING)<-. > for (;;) { | > t->state = UNINTERRUPTIBLE; | > smp_mb(); ,-----> ,' (OoO load, observed !COND) > | | > | | COND = 1; > | `- if (t->state != RUNNING) > | wake_up_process(t); // not done > if (COND) ---------' > break; > schedule(); // forever waiting > } > t->state = TASK_RUNNING; > >Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Davidlohr Bueso