From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753266AbbINMcr (ORCPT ); Mon, 14 Sep 2015 08:32:47 -0400 Received: from casper.infradead.org ([85.118.1.10]:36479 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750968AbbINMcp (ORCPT ); Mon, 14 Sep 2015 08:32:45 -0400 Date: Mon, 14 Sep 2015 14:32:41 +0200 From: Peter Zijlstra To: Davidlohr Bueso Cc: Ingo Molnar , Thomas Gleixner , "Paul E. McKenney" , linux-kernel@vger.kernel.org, Davidlohr Bueso Subject: Re: [PATCH -tip 2/3] sched/wake_q: Relax to acquire semantics Message-ID: <20150914123241.GR18489@twins.programming.kicks-ass.net> References: <1442216244-4409-1-git-send-email-dave@stgolabs.net> <1442216244-4409-2-git-send-email-dave@stgolabs.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1442216244-4409-2-git-send-email-dave@stgolabs.net> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 14, 2015 at 12:37:23AM -0700, Davidlohr Bueso wrote: > The barrier parings for wake-queues are very straightforward, and thus > we can ease the barrier requirements, for archs that support it, for > wake_q_add by relying on acquire semantics. As such, (i) we keep the > pairing structure/logic and (ii) users, such as mqueues, can continue to > rely on a full barrier after the successful [Rmw]. > Signed-off-by: Davidlohr Bueso > --- > kernel/sched/core.c | 12 ++++++------ > 1 file changed, 6 insertions(+), 6 deletions(-) > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 6ab415a..7567603 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -523,14 +523,14 @@ void wake_q_add(struct wake_q_head *head, struct task_struct *task) > struct wake_q_node *node = &task->wake_q; > > /* > + * Atomically grab the task. If ->wake_q is non-nil (failed cmpxchg) > + * then the task is already queued (by us or someone else) and will > + * get the wakeup due to that. > * > + * Use acquire semantics to add the next pointer, which pairs with the > + * write barrier implied by the wakeup in wake_up_list(). > */ > + if (cmpxchg_acquire(&node->next, NULL, WAKE_Q_TAIL)) > return; > > get_task_struct(task); I'm not seeing a _why_ on the acquire semantics. Not saying the patch is wrong, just saying I want words on why acquire is correct.