From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752227AbbINVIQ (ORCPT ); Mon, 14 Sep 2015 17:08:16 -0400 Received: from mx2.suse.de ([195.135.220.15]:35186 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751357AbbINVIP (ORCPT ); Mon, 14 Sep 2015 17:08:15 -0400 Date: Mon, 14 Sep 2015 14:08:06 -0700 From: Davidlohr Bueso To: Peter Zijlstra 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: <20150914210806.GG19736@linux-q0g1.site> References: <1442216244-4409-1-git-send-email-dave@stgolabs.net> <1442216244-4409-2-git-send-email-dave@stgolabs.net> <20150914123241.GR18489@twins.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20150914123241.GR18489@twins.programming.kicks-ass.net> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 14 Sep 2015, Peter Zijlstra wrote: >On Mon, Sep 14, 2015 at 12:37:23AM -0700, Davidlohr Bueso wrote: >> /* >> + * 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. Well, I was just taking advantage of removing the upper barrier. Considering that the formal semantics, you are right that we need not actual acquire per-se (ie for node->next) but instead merely ensure a barrier in wake_q_add(). This is kind of why I had hinted of going full _relaxed(). We could also rephrase the comment, something like: * Use ACQUIRE semantics to add the next pointer, such that * wake_q_add() implies a full barrier. This pairs with the * write barrier implied by the wakeup in wake_up_list(). */ What do you think?