Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757171AbcDMDDK (ORCPT ); Tue, 12 Apr 2016 23:03:10 -0400 Received: from g1t6214.austin.hp.com ([15.73.96.122]:42877 "EHLO g1t6214.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756002AbcDMDDJ (ORCPT ); Tue, 12 Apr 2016 23:03:09 -0400 X-Greylist: delayed 11241 seconds by postgrey-1.27 at vger.kernel.org; Tue, 12 Apr 2016 23:03:09 EDT Message-ID: <1460516537.2709.7.camel@j-VirtualBox> Subject: [PATCH v2] MCS spinlock: Use smp_cond_load_acquire() From: Jason Low To: Peter Zijlstra , Will Deacon , Linus Torvalds Cc: linux-kernel@vger.kernel.org, mingo@redhat.com, paulmck@linux.vnet.ibm.com, terry.rudd@hpe.com, waiman.long@hpe.com, boqun.feng@gmail.com, dave@stgolabs.net, jason.low2@hp.com, kbuild test robot , kbuild-all@01.org Date: Tue, 12 Apr 2016 20:02:17 -0700 Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1413 Lines: 46 For qspinlocks on ARM64, we would like to use WFE instead of purely spinning. Qspinlocks internally have lock contenders spin on an MCS lock. Update arch_mcs_spin_lock_contended() such that it uses the new smp_cond_load_acquire() so that ARM64 can also override this spin loop with its own implementation using WFE. On x86, it can also cheaper to use this than spinning on smp_load_acquire(). Signed-off-by: Jason Low --- Changes from v1: - Pass l instead of &l to smp_cond_load_acquire() since l is already a pointer to the lock variable. kernel/locking/mcs_spinlock.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/locking/mcs_spinlock.h b/kernel/locking/mcs_spinlock.h index c835270..1c55987 100644 --- a/kernel/locking/mcs_spinlock.h +++ b/kernel/locking/mcs_spinlock.h @@ -22,13 +22,13 @@ struct mcs_spinlock { #ifndef arch_mcs_spin_lock_contended /* - * Using smp_load_acquire() provides a memory barrier that ensures - * subsequent operations happen after the lock is acquired. + * Using smp_cond_load_acquire() provides the acquire semantics + * required so that subsequent operations happen after the + * lock is acquired. */ #define arch_mcs_spin_lock_contended(l) \ do { \ - while (!(smp_load_acquire(l))) \ - cpu_relax_lowlatency(); \ + smp_cond_load_acquire(l, VAL); \ } while (0) #endif -- 2.1.4