From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752237AbcEVJip (ORCPT ); Sun, 22 May 2016 05:38:45 -0400 Received: from merlin.infradead.org ([205.233.59.134]:41292 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752088AbcEVJin (ORCPT ); Sun, 22 May 2016 05:38:43 -0400 Date: Sun, 22 May 2016 11:38:28 +0200 From: Peter Zijlstra To: Manfred Spraul Cc: Boqun Feng , Davidlohr Bueso , Waiman.Long@hpe.com, mingo@kernel.org, torvalds@linux-foundation.org, ggherdovich@suse.com, mgorman@techsingularity.net, linux-kernel@vger.kernel.org, Paul McKenney , Will Deacon Subject: Re: sem_lock() vs qspinlocks Message-ID: <20160522093828.GM3193@twins.programming.kicks-ass.net> References: <20160520053926.GC31084@linux-uzut.site> <20160520115819.GF3193@twins.programming.kicks-ass.net> <20160520140533.GA20726@insomnia> <20160520152149.GH3193@twins.programming.kicks-ass.net> <20160520160436.GQ3205@twins.programming.kicks-ass.net> <48cb5e2c-f346-d702-30af-2a6666886df4@colorfullife.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <48cb5e2c-f346-d702-30af-2a6666886df4@colorfullife.com> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 22, 2016 at 10:43:08AM +0200, Manfred Spraul wrote: > How would we handle mixed spin_lock()/mutex_lock() code? > For the IPC code, I would like to replace the outer lock with a mutex. > The code only uses spinlocks, because at the time it was written, the mutex > code didn't contain a busy wait. > With a mutex, the code would become simpler (all the > lock/unlock/kmalloc/relock parts could be removed). > > The result would be something like: > > mutex_lock(A) spin_lock(B) > spin_unlock_wait(B) if (!mutex_is_locked(A)) > do_something() do_something() > Should work similarly, but we'll have to audit mutex for these same issues. I'll put it on todo.