From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751871AbdGGJc4 (ORCPT ); Fri, 7 Jul 2017 05:32:56 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:33983 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750768AbdGGJcy (ORCPT ); Fri, 7 Jul 2017 05:32:54 -0400 Date: Fri, 7 Jul 2017 11:32:49 +0200 From: Ingo Molnar To: Peter Zijlstra Cc: David Laight , "'paulmck@linux.vnet.ibm.com'" , "linux-kernel@vger.kernel.org" , "netfilter-devel@vger.kernel.org" , "netdev@vger.kernel.org" , "oleg@redhat.com" , "akpm@linux-foundation.org" , "mingo@redhat.com" , "dave@stgolabs.net" , "manfred@colorfullife.com" , "tj@kernel.org" , "arnd@arndb.de" , "linux-arch@vger.kernel.org" , "will.deacon@arm.com" , "stern@rowland.harvard.edu" , "parri.andrea@gmail.com" , "torvalds@linux-foundation.org" Subject: Re: [PATCH v2 0/9] Remove spin_unlock_wait() Message-ID: <20170707093249.3pskpxhf3ozfhrsr@gmail.com> References: <20170629235918.GA6445@linux.vnet.ibm.com> <20170705232955.GA15992@linux.vnet.ibm.com> <063D6719AE5E284EB5DD2968C1650D6DD0033F01@AcuExch.aculab.com> <20170706160555.xc63yydk77gmttae@hirez.programming.kicks-ass.net> <20170707080621.dmhw2ryes7n3kgag@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170707080621.dmhw2ryes7n3kgag@gmail.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Ingo Molnar wrote: > > * Peter Zijlstra wrote: > > > > It might even be that this is the defined semantics of spin_unlock_wait(). > > > > As is, spin_unlock_wait() is somewhat ill defined. IIRC it grew from an > > optimization by Oleg and subsequently got used elsewhere. And it being the > > subtle bugger it is, there were bugs. > > I believe the historical, original spin_unlock_wait() came from early SMP > optimizations of the networking code - and then spread elsewhere, step by step. > All but one of the networking uses went away since then - so I don't think there's > any original usecase left. No - the original usecase was task teardown: I still remembered that but didn't find the commit - but it's there in very old Linux kernel patches, done by DaveM originally in v2.1.36 (!): --- a/kernel/exit.c +++ b/kernel/exit.c @@ -136,6 +136,12 @@ void release(struct task_struct * p) } for (i=1 ; iprocessor != NO_PROC_ID) + barrier(); + spin_unlock_wait(&scheduler_lock); +#endif Other code learned to use spin_unlock_wait(): the original version of [hard]irq_enter() was the second user, net_family_read_lock() was the third user, followed by more uses in networking. All but one of those are not present in the current upstream kernel anymore. This task-teardown FIXME was fixed in v2.1.114 (was replaced by an open coded poll loop), but the spin_unlock_wait() primitive remained. The rest is history! ;-) Thanks, Ingo