From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755323AbcI2NWR (ORCPT ); Thu, 29 Sep 2016 09:22:17 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54452 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751980AbcI2NWH (ORCPT ); Thu, 29 Sep 2016 09:22:07 -0400 Subject: Re: [PATCH] s390x/spinlock: Provide vcpu_is_preempted globally To: Martin Schwidefsky References: <1475150056-58774-1-git-send-email-borntraeger@de.ibm.com> <20160929151116.3b5e8f07@mschwide> Cc: Peter Zijlstra , Heiko Carstens , Pan Xinhui , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, xen-devel-request@lists.xenproject.org, benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, mingo@redhat.com, paulmck@linux.vnet.ibm.com, will.deacon@arm.com, kernellwp@gmail.com, jgross@suse.com, pbonzini@redhat.com, bsingharora@gmail.com From: Christian Borntraeger Date: Thu, 29 Sep 2016 15:21:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <20160929151116.3b5e8f07@mschwide> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16092913-0040-0000-0000-000002E4A2BE X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16092913-0041-0000-0000-00001D4A8419 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-09-29_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-1609020000 definitions=main-1609290233 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/29/2016 03:11 PM, Martin Schwidefsky wrote: > On Thu, 29 Sep 2016 13:54:16 +0200 > Christian Borntraeger wrote: > >> this implements the s390 backend for commit >> "kernel/sched: introduce vcpu preempted check interface" >> by simply reusing the existing cpu_is_preempted function. >> >> Signed-off-by: Christian Borntraeger >> --- >> Martin, Heiko, >> >> this patch is a minimal change by not touching all existing users of >> cpu_is_preempted in spinlock.c. If you want it differently, let me >> know. >> >> >> arch/s390/include/asm/spinlock.h | 7 +++++++ >> arch/s390/lib/spinlock.c | 3 ++- >> 2 files changed, 9 insertions(+), 1 deletion(-) >> >> diff --git a/arch/s390/include/asm/spinlock.h b/arch/s390/include/asm/spinlock.h >> index 63ebf37..6e82986 100644 >> --- a/arch/s390/include/asm/spinlock.h >> +++ b/arch/s390/include/asm/spinlock.h >> @@ -21,6 +21,13 @@ _raw_compare_and_swap(unsigned int *lock, unsigned int old, unsigned int new) >> return __sync_bool_compare_and_swap(lock, old, new); >> } >> >> +int arch_vcpu_is_preempted(int cpu); >> +#define vcpu_is_preempted cpu_is_preempted >> +static inline bool cpu_is_preempted(int cpu) >> +{ >> + return arch_vcpu_is_preempted(cpu); >> +} >> + >> /* >> * Simple spin lock operations. There are two variants, one clears IRQ's >> * on the local processor, one does not. >> diff --git a/arch/s390/lib/spinlock.c b/arch/s390/lib/spinlock.c >> index e5f50a7..9f473c8 100644 >> --- a/arch/s390/lib/spinlock.c >> +++ b/arch/s390/lib/spinlock.c >> @@ -37,7 +37,7 @@ static inline void _raw_compare_and_delay(unsigned int *lock, unsigned int old) >> asm(".insn rsy,0xeb0000000022,%0,0,%1" : : "d" (old), "Q" (*lock)); >> } >> >> -static inline int cpu_is_preempted(int cpu) >> +int arch_vcpu_is_preempted(int cpu) >> { >> if (test_cpu_flag_of(CIF_ENABLED_WAIT, cpu)) >> return 0; >> @@ -45,6 +45,7 @@ static inline int cpu_is_preempted(int cpu) >> return 0; >> return 1; >> } >> +EXPORT_SYMBOL(arch_vcpu_is_preempted); >> >> void arch_spin_lock_wait(arch_spinlock_t *lp) >> { > > Hmm, if I look at the code we now have an additional function for > the spinlock loops. The call arch_vcpu_is_preempted which test > CIF_ENABLED_WAIT and then calls smp_vcpu_scheduled(). The test > used to be inline. > > A better solution would be to move the CIF_ENABLED_WAIT test to the > smp_vcpu_scheduled() function, rename it to arch_vcpu_is_preempted() > and then export that function. The cpu_is_preempted() function is > replaced by arch_vcpu_is_preempted() which does make a lot of sense, > no? > Yes that makes sense, will spin a v2.