Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752134AbdF3MhH (ORCPT ); Fri, 30 Jun 2017 08:37:07 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:48606 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751668AbdF3Mfg (ORCPT ); Fri, 30 Jun 2017 08:35:36 -0400 Date: Fri, 30 Jun 2017 05:35:29 -0700 From: "Paul E. McKenney" To: Arnd Bergmann Cc: Linux Kernel Mailing List , netfilter-devel@vger.kernel.org, Networking , Oleg Nesterov , Andrew Morton , Ingo Molnar , dave@stgolabs.net, manfred@colorfullife.com, Tejun Heo , linux-arch , Will Deacon , Peter Zijlstra , Alan Stern , parri.andrea@gmail.com, Linus Torvalds Subject: Re: [PATCH RFC 03/26] sched: Replace spin_unlock_wait() with lock/unlock pair Reply-To: paulmck@linux.vnet.ibm.com References: <20170629235918.GA6445@linux.vnet.ibm.com> <1498780894-8253-3-git-send-email-paulmck@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 17063012-0052-0000-0000-000002336DF7 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007297; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00880856; UDB=6.00439161; IPR=6.00661009; BA=6.00005448; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016023; XFM=3.00000015; UTC=2017-06-30 12:35:34 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17063012-0053-0000-0000-00005128D751 Message-Id: <20170630123529.GS2393@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-06-30_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706300200 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1675 Lines: 38 On Fri, Jun 30, 2017 at 12:31:50PM +0200, Arnd Bergmann wrote: > On Fri, Jun 30, 2017 at 2:01 AM, Paul E. McKenney > wrote: > > There is no agreed-upon definition of spin_unlock_wait()'s semantics, > > and it appears that all callers could do just as well with a lock/unlock > > pair. This commit therefore replaces the spin_unlock_wait() call in > > do_task_dead() with spin_lock() followed immediately by spin_unlock(). > > This should be safe from a performance perspective because the lock is > > this tasks ->pi_lock, and this is called only after the task exits. > > > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > > index e91138fcde86..6dea3d9728c8 100644 > > --- a/kernel/sched/core.c > > +++ b/kernel/sched/core.c > > @@ -3461,7 +3461,8 @@ void __noreturn do_task_dead(void) > > * is held by try_to_wake_up() > > */ > > smp_mb(); > > - raw_spin_unlock_wait(¤t->pi_lock); > > + raw_spin_lock(¤t->pi_lock); > > + raw_spin_unlock(¤t->pi_lock); > > Does the raw_spin_lock()/raw_spin_unlock() imply an smp_mb() or stronger? > Maybe it would be clearer to remove the extra barrier if so. No, it does not in general, but it does on most architectures, and there are ways to allow those architectures to gain the benefit of their stronger locks. For example, would this work? > > * is held by try_to_wake_up() > > */ > > - smp_mb(); > > - raw_spin_unlock_wait(¤t->pi_lock); > > + smp_mb__before_spinlock(); > > + raw_spin_lock(¤t->pi_lock); > > + raw_spin_unlock(¤t->pi_lock); Thanx, Paul