From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932349AbbKCSXM (ORCPT ); Tue, 3 Nov 2015 13:23:12 -0500 Received: from casper.infradead.org ([85.118.1.10]:58320 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932293AbbKCSXJ (ORCPT ); Tue, 3 Nov 2015 13:23:09 -0500 Date: Tue, 3 Nov 2015 19:23:05 +0100 From: Peter Zijlstra To: Oleg Nesterov Cc: mingo@kernel.org, linux-kernel@vger.kernel.org, paulmck@linux.vnet.ibm.com, boqun.feng@gmail.com, corbet@lwn.net, mhocko@kernel.org, dhowells@redhat.com, torvalds@linux-foundation.org, will.deacon@arm.com Subject: Re: [PATCH 4/4] locking: Introduce smp_cond_acquire() Message-ID: <20151103182304.GF17308@twins.programming.kicks-ass.net> References: <20151102132901.157178466@infradead.org> <20151102134941.005198372@infradead.org> <20151103175958.GA4800@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151103175958.GA4800@redhat.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 Tue, Nov 03, 2015 at 06:59:58PM +0100, Oleg Nesterov wrote: > > - raw_spin_unlock_wait(&task->pi_lock); > > - smp_mb(); > > + smp_cond_acquire(!raw_spin_is_locked(&task->pi_lock)); > > Unfortunately this doesn't look exactly right... > > spin_unlock_wait() is not equal to "while (locked) relax", the latter > is live-lockable or at least sub-optimal: we do not really need to spin > until we observe !spin_is_locked(), we only need to synchronize with the > current owner of this lock. Once it drops the lock we can proceed, we > do not care if another thread takes the same lock right after that. Ah indeed. And while every use of spin_unlock_wait() has 'interesting' barriers associated, they all seem different.