From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751977AbcF0Nnn (ORCPT ); Mon, 27 Jun 2016 09:43:43 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:59305 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751806AbcF0NnA (ORCPT ); Mon, 27 Jun 2016 09:43:00 -0400 X-IBM-Helo: d03dlp03.boulder.ibm.com X-IBM-MailFrom: xinhui.pan@linux.vnet.ibm.com From: Pan Xinhui To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: paulmck@linux.vnet.ibm.com, peterz@infradead.org, mingo@redhat.com, mpe@ellerman.id.au, paulus@samba.org, benh@kernel.crashing.org, Waiman.Long@hpe.com, boqun.feng@gmail.com, will.deacon@arm.com, dave@stgolabs.net, Pan Xinhui Subject: [PATCH 2/3] powerpc/spinlock: support vcpu preempted check Date: Mon, 27 Jun 2016 13:41:29 -0400 X-Mailer: git-send-email 2.4.11 In-Reply-To: <1467049290-32359-1-git-send-email-xinhui.pan@linux.vnet.ibm.com> References: <1467049290-32359-1-git-send-email-xinhui.pan@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16062713-8235-0000-0000-000008AD4DDF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16062713-8236-0000-0000-000032998423 Message-Id: <1467049290-32359-3-git-send-email-xinhui.pan@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-06-27_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1606270146 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is to fix some holder preemption issues. Spinning at one vcpu which is preempted is meaningless. Kernel need such interfaces, So lets support it. We also should suooprt both the shared and dedicated mode. So add lppaca_dedicated_proc macro in lppaca.h Suggested-by: Boqun Feng Signed-off-by: Pan Xinhui --- arch/powerpc/include/asm/lppaca.h | 6 ++++++ arch/powerpc/include/asm/spinlock.h | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/arch/powerpc/include/asm/lppaca.h b/arch/powerpc/include/asm/lppaca.h index d0a2a2f..0a263d3 100644 --- a/arch/powerpc/include/asm/lppaca.h +++ b/arch/powerpc/include/asm/lppaca.h @@ -111,12 +111,18 @@ extern struct lppaca lppaca[]; * we will have to transition to something better. */ #define LPPACA_OLD_SHARED_PROC 2 +#define LPPACA_OLD_DEDICATED_PROC (1 << 6) static inline bool lppaca_shared_proc(struct lppaca *l) { return !!(l->__old_status & LPPACA_OLD_SHARED_PROC); } +static inline bool lppaca_dedicated_proc(struct lppaca *l) +{ + return !!(l->__old_status & LPPACA_OLD_DEDICATED_PROC); +} + /* * SLB shadow buffer structure as defined in the PAPR. The save_area * contains adjacent ESID and VSID pairs for each shadowed SLB. The diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h index 523673d..ae938ee 100644 --- a/arch/powerpc/include/asm/spinlock.h +++ b/arch/powerpc/include/asm/spinlock.h @@ -52,6 +52,21 @@ #define SYNC_IO #endif +/* For fixing some spinning issues in a guest. + * kernel would check if vcpu is preempted during a spin loop. + * we support that. + */ +#define arch_vcpu_is_preempted arch_vcpu_is_preempted +static inline bool arch_vcpu_is_preempted(int cpu) +{ + struct lppaca *lp = &lppaca_of(cpu); + + if (unlikely(!(lppaca_shared_proc(lp) || + lppaca_dedicated_proc(lp)))) + return false; + return !!(be32_to_cpu(lp->yield_count) & 1); +} + static __always_inline int arch_spin_value_unlocked(arch_spinlock_t lock) { return lock.slock == 0; -- 2.4.11