From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753528AbbKLRmJ (ORCPT ); Thu, 12 Nov 2015 12:42:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44005 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753076AbbKLRmG (ORCPT ); Thu, 12 Nov 2015 12:42:06 -0500 Date: Thu, 12 Nov 2015 19:38:07 +0100 From: Oleg Nesterov To: Boqun Feng Cc: Peter Zijlstra , mingo@kernel.org, linux-kernel@vger.kernel.org, paulmck@linux.vnet.ibm.com, corbet@lwn.net, mhocko@kernel.org, dhowells@redhat.com, torvalds@linux-foundation.org, will.deacon@arm.com, Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras Subject: Re: [PATCH 4/4] locking: Introduce smp_cond_acquire() Message-ID: <20151112183807.GA7538@redhat.com> References: <20151102132901.157178466@infradead.org> <20151102134941.005198372@infradead.org> <20151103175958.GA4800@redhat.com> <20151111093939.GA6314@fixme-laptop.cn.ibm.com> <20151111121232.GN17308@twins.programming.kicks-ass.net> <20151111193953.GA23515@redhat.com> <20151112070915.GC6314@fixme-laptop.cn.ibm.com> <20151112150058.GA30321@redhat.com> <20151112151839.GE6314@fixme-laptop.cn.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151112151839.GE6314@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 11/12, Boqun Feng wrote: > > On Thu, Nov 12, 2015 at 04:00:58PM +0100, Oleg Nesterov wrote: > > > > No? > > > > do_exit() is surely buggy if spin_lock() could work in this way. OK, good ;) so we need to fix spin_lock() on PPC ? Or add mb__after_unlock_lock() but this leads to other questions... Or change do_exit() to do lock() + unlock(). > > > And smp_mb__before_spinlock() looks wrong too then. > > > > Maybe not? As smp_mb__before_spinlock() is used before a LOCK operation, > which has both LOAD part and STORE part unlike spin_unlock_wait()? Maybe not. But let me remind that the original purpose of this mb__before_spinlock() was to ensure that "CONDITION = true" before ttwu() can not be reordered with if (!(p->state & state)) goto out; // do not wakeup inside try_to_wake_up(). Otherwise CONDITION = true; try_to_wake_up(p); can race with "p" doing set_current_state(...); // implies mb(); if (CONDITION) return; schedule(); because try_to_wake_up() can read p->state before it sets CONDITION = 1 and then it won't wakeup "p" which has already checked this CONDITION. Now. If try_to_wake_up() can read p->state before it writes to *pi_lock, then how smp_mb__before_spinlock() == wmb() can help to serialize STORE and LOAD? It seems that PPC needs to define smp_mb__before_spinlock() as full mb(), no? Oleg.