From: Nicholas Piggin <npiggin@gmail.com>
Cc: linux-arch@vger.kernel.org, Peter Zijlstra <peterz@infradead.org>,
linuxppc-dev@lists.ozlabs.org, Boqun Feng <boqun.feng@gmail.com>,
linux-kernel@vger.kernel.org, Nicholas Piggin <npiggin@gmail.com>,
virtualization@lists.linux-foundation.org,
Ingo Molnar <mingo@redhat.com>,
kvm-ppc@vger.kernel.org, Waiman Long <longman@redhat.com>,
Will Deacon <will@kernel.org>
Subject: [PATCH 8/8] powerpc/64s: remove paravirt from simple spinlocks (RFC only)
Date: Thu, 2 Jul 2020 17:48:39 +1000 [thread overview]
Message-ID: <20200702074839.1057733-9-npiggin@gmail.com> (raw)
In-Reply-To: <20200702074839.1057733-1-npiggin@gmail.com>
RFC until we settle on queued spinlocks for 64s and remove the
option to go back to simple locks. If other sub-archs want to keep
simple spinlocks, the code can be nicely simplified.
---
arch/powerpc/include/asm/simple_spinlock.h | 61 +-------------------
arch/powerpc/kvm/book3s_hv_rm_mmu.c | 6 --
arch/powerpc/lib/Makefile | 4 --
arch/powerpc/lib/locks.c | 65 ----------------------
4 files changed, 2 insertions(+), 134 deletions(-)
delete mode 100644 arch/powerpc/lib/locks.c
diff --git a/arch/powerpc/include/asm/simple_spinlock.h b/arch/powerpc/include/asm/simple_spinlock.h
index e048c041c4a9..5f0980dea001 100644
--- a/arch/powerpc/include/asm/simple_spinlock.h
+++ b/arch/powerpc/include/asm/simple_spinlock.h
@@ -16,23 +16,10 @@
* (the type definitions are in asm/simple_spinlock_types.h)
*/
#include <linux/irqflags.h>
-#include <asm/paravirt.h>
-#ifdef CONFIG_PPC64
-#include <asm/paca.h>
-#endif
#include <asm/synch.h>
#include <asm/ppc-opcode.h>
-#ifdef CONFIG_PPC64
-/* use 0x800000yy when locked, where yy == CPU number */
-#ifdef __BIG_ENDIAN__
-#define LOCK_TOKEN (*(u32 *)(&get_paca()->lock_token))
-#else
-#define LOCK_TOKEN (*(u32 *)(&get_paca()->paca_index))
-#endif
-#else
#define LOCK_TOKEN 1
-#endif
static __always_inline int arch_spin_value_unlocked(arch_spinlock_t lock)
{
@@ -74,43 +61,14 @@ static inline int arch_spin_trylock(arch_spinlock_t *lock)
return __arch_spin_trylock(lock) == 0;
}
-/*
- * On a system with shared processors (that is, where a physical
- * processor is multiplexed between several virtual processors),
- * there is no point spinning on a lock if the holder of the lock
- * isn't currently scheduled on a physical processor. Instead
- * we detect this situation and ask the hypervisor to give the
- * rest of our timeslice to the lock holder.
- *
- * So that we can tell which virtual processor is holding a lock,
- * we put 0x80000000 | smp_processor_id() in the lock when it is
- * held. Conveniently, we have a word in the paca that holds this
- * value.
- */
-
-#if defined(CONFIG_PPC_SPLPAR)
-/* We only yield to the hypervisor if we are in shared processor mode */
-void splpar_spin_yield(arch_spinlock_t *lock);
-void splpar_rw_yield(arch_rwlock_t *lock);
-#else /* SPLPAR */
-static inline void splpar_spin_yield(arch_spinlock_t *lock) {};
-static inline void splpar_rw_yield(arch_rwlock_t *lock) {};
-#endif
-
static inline void spin_yield(arch_spinlock_t *lock)
{
- if (is_shared_processor())
- splpar_spin_yield(lock);
- else
- barrier();
+ barrier();
}
static inline void rw_yield(arch_rwlock_t *lock)
{
- if (is_shared_processor())
- splpar_rw_yield(lock);
- else
- barrier();
+ barrier();
}
static inline void arch_spin_lock(arch_spinlock_t *lock)
@@ -120,8 +78,6 @@ static inline void arch_spin_lock(arch_spinlock_t *lock)
break;
do {
HMT_low();
- if (is_shared_processor())
- splpar_spin_yield(lock);
} while (unlikely(lock->slock != 0));
HMT_medium();
}
@@ -139,8 +95,6 @@ void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
local_irq_restore(flags);
do {
HMT_low();
- if (is_shared_processor())
- splpar_spin_yield(lock);
} while (unlikely(lock->slock != 0));
HMT_medium();
local_irq_restore(flags_dis);
@@ -166,13 +120,7 @@ static inline void arch_spin_unlock(arch_spinlock_t *lock)
* read-locks.
*/
-#ifdef CONFIG_PPC64
-#define __DO_SIGN_EXTEND "extsw %0,%0\n"
-#define WRLOCK_TOKEN LOCK_TOKEN /* it's negative */
-#else
-#define __DO_SIGN_EXTEND
#define WRLOCK_TOKEN (-1)
-#endif
/*
* This returns the old value in the lock + 1,
@@ -184,7 +132,6 @@ static inline long __arch_read_trylock(arch_rwlock_t *rw)
__asm__ __volatile__(
"1: " PPC_LWARX(%0,0,%1,1) "\n"
- __DO_SIGN_EXTEND
" addic. %0,%0,1\n\
ble- 2f\n"
" stwcx. %0,0,%1\n\
@@ -227,8 +174,6 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
break;
do {
HMT_low();
- if (is_shared_processor())
- splpar_rw_yield(rw);
} while (unlikely(rw->lock < 0));
HMT_medium();
}
@@ -241,8 +186,6 @@ static inline void arch_write_lock(arch_rwlock_t *rw)
break;
do {
HMT_low();
- if (is_shared_processor())
- splpar_rw_yield(rw);
} while (unlikely(rw->lock != 0));
HMT_medium();
}
diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
index 88da2764c1bb..909025083161 100644
--- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
+++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
@@ -410,12 +410,6 @@ long kvmppc_h_enter(struct kvm_vcpu *vcpu, unsigned long flags,
&vcpu->arch.regs.gpr[4]);
}
-#ifdef __BIG_ENDIAN__
-#define LOCK_TOKEN (*(u32 *)(&get_paca()->lock_token))
-#else
-#define LOCK_TOKEN (*(u32 *)(&get_paca()->paca_index))
-#endif
-
static inline int is_mmio_hpte(unsigned long v, unsigned long r)
{
return ((v & HPTE_V_ABSENT) &&
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index d66a645503eb..158e71abc14c 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -41,10 +41,6 @@ obj-$(CONFIG_PPC_BOOK3S_64) += copyuser_power7.o copypage_power7.o \
obj64-y += copypage_64.o copyuser_64.o mem_64.o hweight_64.o \
memcpy_64.o memcpy_mcsafe_64.o
-ifndef CONFIG_PPC_QUEUED_SPINLOCKS
-obj64-$(CONFIG_SMP) += locks.o
-endif
-
obj64-$(CONFIG_ALTIVEC) += vmx-helper.o
obj64-$(CONFIG_KPROBES_SANITY_TEST) += test_emulate_step.o \
test_emulate_step_exec_instr.o
diff --git a/arch/powerpc/lib/locks.c b/arch/powerpc/lib/locks.c
deleted file mode 100644
index e35fd1a16992..000000000000
--- a/arch/powerpc/lib/locks.c
+++ /dev/null
@@ -1,65 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Spin and read/write lock operations.
- *
- * Copyright (C) 2001-2004 Paul Mackerras <paulus@au.ibm.com>, IBM
- * Copyright (C) 2001 Anton Blanchard <anton@au.ibm.com>, IBM
- * Copyright (C) 2002 Dave Engebretsen <engebret@us.ibm.com>, IBM
- * Rework to support virtual processors
- */
-
-#include <linux/kernel.h>
-#include <linux/spinlock.h>
-#include <linux/export.h>
-#include <linux/smp.h>
-
-/* waiting for a spinlock... */
-#if defined(CONFIG_PPC_SPLPAR)
-#include <asm/hvcall.h>
-#include <asm/smp.h>
-
-void splpar_spin_yield(arch_spinlock_t *lock)
-{
- unsigned int lock_value, holder_cpu, yield_count;
-
- lock_value = lock->slock;
- if (lock_value == 0)
- return;
- holder_cpu = lock_value & 0xffff;
- BUG_ON(holder_cpu >= NR_CPUS);
-
- yield_count = yield_count_of(holder_cpu);
- if ((yield_count & 1) == 0)
- return; /* virtual cpu is currently running */
- smp_rmb();
- if (lock->slock != lock_value)
- return; /* something has changed */
- yield_to_preempted(holder_cpu, yield_count);
-}
-EXPORT_SYMBOL_GPL(splpar_spin_yield);
-
-/*
- * Waiting for a read lock or a write lock on a rwlock...
- * This turns out to be the same for read and write locks, since
- * we only know the holder if it is write-locked.
- */
-void splpar_rw_yield(arch_rwlock_t *rw)
-{
- int lock_value;
- unsigned int holder_cpu, yield_count;
-
- lock_value = rw->lock;
- if (lock_value >= 0)
- return; /* no write lock at present */
- holder_cpu = lock_value & 0xffff;
- BUG_ON(holder_cpu >= NR_CPUS);
-
- yield_count = yield_count_of(holder_cpu);
- if ((yield_count & 1) == 0)
- return; /* virtual cpu is currently running */
- smp_rmb();
- if (rw->lock != lock_value)
- return; /* something has changed */
- yield_to_preempted(holder_cpu, yield_count);
-}
-#endif
--
2.23.0
prev parent reply other threads:[~2020-07-02 8:08 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-02 7:48 [PATCH 0/8] powerpc: queued spinlocks and rwlocks Nicholas Piggin
2020-07-02 7:48 ` [PATCH 1/8] powerpc/powernv: must include hvcall.h to get PAPR defines Nicholas Piggin
2020-07-02 7:48 ` [PATCH 2/8] powerpc/pseries: use smp_rmb() in H_CONFER spin yield Nicholas Piggin
2020-07-02 8:28 ` Peter Zijlstra
2020-07-02 10:36 ` Nicholas Piggin
2020-07-02 7:48 ` [PATCH 3/8] powerpc/pseries: move some PAPR paravirt functions to their own file Nicholas Piggin
2020-07-02 7:48 ` [PATCH 4/8] powerpc: move spinlock implementation to simple_spinlock Nicholas Piggin
2020-07-02 7:48 ` [PATCH 5/8] powerpc/64s: implement queued spinlocks and rwlocks Nicholas Piggin
2020-07-02 8:02 ` Will Deacon
2020-07-02 10:25 ` Nicholas Piggin
2020-07-02 10:35 ` Will Deacon
2020-07-02 10:47 ` Nicholas Piggin
2020-07-02 10:48 ` Will Deacon
2020-07-03 10:52 ` Michael Ellerman
2020-07-02 7:48 ` [PATCH 6/8] powerpc/pseries: implement paravirt qspinlocks for SPLPAR Nicholas Piggin
2020-07-02 16:15 ` kernel test robot
2020-07-03 0:36 ` Waiman Long
2020-07-02 21:01 ` Waiman Long
2020-07-02 7:48 ` [PATCH 7/8] powerpc/qspinlock: optimised atomic_try_cmpxchg_lock that adds the lock hint Nicholas Piggin
2020-07-02 7:48 ` Nicholas Piggin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200702074839.1057733-9-npiggin@gmail.com \
--to=npiggin@gmail.com \
--cc=boqun.feng@gmail.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=longman@redhat.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=virtualization@lists.linux-foundation.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).