From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753338AbbIJR6s (ORCPT ); Thu, 10 Sep 2015 13:58:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59872 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752130AbbIJR6p (ORCPT ); Thu, 10 Sep 2015 13:58:45 -0400 Date: Thu, 10 Sep 2015 19:55:57 +0200 From: Oleg Nesterov To: Boqun Feng Cc: "Paul E. McKenney" , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Jonathan Corbet , Michal Hocko , Peter Zijlstra , David Howells , Linus Torvalds Subject: Re: [PATCH] Documentation: Remove misleading examples of the barriers in wake_*() Message-ID: <20150910175557.GA20640@redhat.com> References: <1441674841-11498-1-git-send-email-boqun.feng@gmail.com> <20150909192822.GM4029@linux.vnet.ibm.com> <20150910021612.GC18494@fixme-laptop.cn.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150910021612.GC18494@fixme-laptop.cn.ibm.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/10, Boqun Feng wrote: > > On Wed, Sep 09, 2015 at 12:28:22PM -0700, Paul E. McKenney wrote: > > My feeling is > > that we should avoid saying too much about the internals of wait_event() > > and wake_up(). I feel the same. I simply can't understand what we are trying to document ;) For example, > A STORE-LOAD barrier is implied after setting task state by wait-related functions: > > prepare_to_wait(); > prepare_to_wait_exclusive(); > prepare_to_wait_event(); I won't argue, but to me this looks misleading too. Yes, prepare_to_wait()->set_current_state() implies mb() and thus a STORE-LOAD barrier. But this has nothing to do with the explanation above. We do not need this barrier to avoid the race with wake_up(). Again, again, we can safely rely on wq->lock and acquire/release semantics. This barrier is only needed if you do, say, CONDITION = 1; if (waitqueue_active(wq)) wake_up(wq); And note that the code above is wrong without another mb() after CONDITION = 1. Oleg.