Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1505130

[PATCH v5 4/9] powerpc/spinlock: support vcpu preempted check

From Pan Xinhui <xinhui.pan@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject [PATCH v5 4/9] powerpc/spinlock: support vcpu preempted check
Date 2016-10-20 19:40 +0200
Message-ID <suptU-2bV-45@gated-at.bofh.it> (permalink)
References <suptT-2bV-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


This is to fix some lock holder preemption issues. Some other locks
implementation do a spin loop before acquiring the lock itself.
Currently kernel has an interface of bool vcpu_is_preempted(int cpu). It
takes the cpu as parameter and return true if the cpu is preempted. Then
kernel can break the spin loops upon on the retval of vcpu_is_preempted.

As kernel has used this interface, So lets support it.

Only pSeries need support it. And the fact is powerNV are built into
same kernel image with pSeries. So we need return false if we are runnig
as powerNV. The another fact is that lppaca->yiled_count keeps zero on
powerNV. So we can just skip the machine type check.

Suggested-by: Boqun Feng <boqun.feng@gmail.com>
Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Pan Xinhui <xinhui.pan@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/spinlock.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h
index abb6b0f..f4a9524 100644
--- a/arch/powerpc/include/asm/spinlock.h
+++ b/arch/powerpc/include/asm/spinlock.h
@@ -52,6 +52,14 @@
 #define SYNC_IO
 #endif
 
+#ifdef CONFIG_PPC_PSERIES
+#define vcpu_is_preempted vcpu_is_preempted
+static inline bool vcpu_is_preempted(int cpu)
+{
+	return !!(be32_to_cpu(lppaca_of(cpu).yield_count) & 1);
+}
+#endif
+
 #if defined(CONFIG_PPC_SPLPAR)
 /* We only yield to the hypervisor if we are in shared processor mode */
 #define SHARED_PROCESSOR (lppaca_shared_proc(local_paca->lppaca_ptr))
-- 
2.4.11

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v5 0/9] implement vcpu preempted check Pan Xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-10-20 19:40 +0200
  [PATCH v5 2/9] locking/osq: Drop the overload of osq_lock() Pan Xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-10-20 19:40 +0200
  [PATCH v5 8/9] s390/spinlock: Provide vcpu_is_preempted Pan Xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-10-20 19:40 +0200
  [PATCH v5 3/9] kernel/locking: Drop the overload of {mutex,rwsem}_spin_on_owner Pan Xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-10-20 19:40 +0200
  [PATCH v5 1/9] kernel/sched: introduce vcpu preempted check interface Pan Xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-10-20 19:40 +0200
  [PATCH v5 7/9] x86, xen: support vcpu preempted check Pan Xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-10-20 19:40 +0200
    Re: [PATCH v5 7/9] x86, xen: support vcpu preempted check Juergen Gross <jgross@suse.com> - 2016-10-21 07:10 +0200
  [PATCH v5 5/9] x86, paravirt: Add interface to support kvm/xen vcpu preempted check Pan Xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-10-20 19:40 +0200
  [PATCH v5 9/9] Documentation: virtual: kvm: Support vcpu preempted check Pan Xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-10-20 19:40 +0200
    Re: [PATCH v5 9/9] Documentation: virtual: kvm: Support vcpu  preempted check Boqun Feng <boqun.feng@gmail.com> - 2016-10-21 03:30 +0200
    RE: [PATCH v5 9/9] Documentation: virtual: kvm: Support vcpu  preempted check David Laight <David.Laight@ACULAB.COM> - 2016-10-21 13:40 +0200
      Re: [PATCH v5 9/9] Documentation: virtual: kvm: Support vcpu  preempted check "rkrcmar@redhat.com" <rkrcmar@redhat.com> - 2016-10-21 20:50 +0200
        Re: [PATCH v5 9/9] Documentation: virtual: kvm: Support vcpu preempted  check xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-10-24 04:50 +0200
        Re: [PATCH v5 9/9] Documentation: virtual: kvm: Support vcpu  preempted check Paolo Bonzini <pbonzini@redhat.com> - 2016-10-24 16:50 +0200
          Re: [PATCH v5 9/9] Documentation: virtual: kvm: Support vcpu  preempted check "rkrcmar@redhat.com" <rkrcmar@redhat.com> - 2016-10-24 17:10 +0200
      Re: [PATCH v5 9/9] Documentation: virtual: kvm: Support vcpu preempted  check xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-10-24 04:50 +0200
    Re: [PATCH v5 9/9] Documentation: virtual: kvm: Support vcpu preempted  check xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-10-24 10:20 +0200
  [PATCH v5 4/9] powerpc/spinlock: support vcpu preempted check Pan Xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-10-20 19:40 +0200
  [PATCH v5 6/9] x86, kvm: support vcpu preempted check Pan Xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-10-20 19:40 +0200
    Re: [PATCH v5 6/9] x86, kvm: support vcpu preempted check xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-10-24 10:10 +0200
  Re: [PATCH v5 0/9] implement vcpu preempted check Peter Zijlstra <peterz@infradead.org> - 2016-10-21 07:50 +0200

csiph-web