* [PATCH] s390x/spinlock: Provide vcpu_is_preempted globally
@ 2016-09-29 11:54 Christian Borntraeger
2016-09-29 13:11 ` Martin Schwidefsky
0 siblings, 1 reply; 3+ messages in thread
From: Christian Borntraeger @ 2016-09-29 11:54 UTC (permalink / raw)
To: Peter Zijlstra, Martin Schwidefsky, Heiko Carstens
Cc: Pan Xinhui, linux-kernel, virtualization, linux-s390, kvm,
xen-devel-request, benh, paulus, mpe, mingo, paulmck, will.deacon,
kernellwp, jgross, pbonzini, bsingharora, Christian Borntraeger
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 <borntraeger@de.ibm.com>
---
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)
{
--
2.5.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] s390x/spinlock: Provide vcpu_is_preempted globally
2016-09-29 11:54 [PATCH] s390x/spinlock: Provide vcpu_is_preempted globally Christian Borntraeger
@ 2016-09-29 13:11 ` Martin Schwidefsky
2016-09-29 13:21 ` Christian Borntraeger
0 siblings, 1 reply; 3+ messages in thread
From: Martin Schwidefsky @ 2016-09-29 13:11 UTC (permalink / raw)
To: Christian Borntraeger
Cc: Peter Zijlstra, Heiko Carstens, Pan Xinhui, linux-kernel,
virtualization, linux-s390, kvm, xen-devel-request, benh, paulus,
mpe, mingo, paulmck, will.deacon, kernellwp, jgross, pbonzini,
bsingharora
On Thu, 29 Sep 2016 13:54:16 +0200
Christian Borntraeger <borntraeger@de.ibm.com> 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 <borntraeger@de.ibm.com>
> ---
> 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?
--
blue skies,
Martin.
"Reality continues to ruin my life." - Calvin.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] s390x/spinlock: Provide vcpu_is_preempted globally
2016-09-29 13:11 ` Martin Schwidefsky
@ 2016-09-29 13:21 ` Christian Borntraeger
0 siblings, 0 replies; 3+ messages in thread
From: Christian Borntraeger @ 2016-09-29 13:21 UTC (permalink / raw)
To: Martin Schwidefsky
Cc: Peter Zijlstra, Heiko Carstens, Pan Xinhui, linux-kernel,
virtualization, linux-s390, kvm, xen-devel-request, benh, paulus,
mpe, mingo, paulmck, will.deacon, kernellwp, jgross, pbonzini,
bsingharora
On 09/29/2016 03:11 PM, Martin Schwidefsky wrote:
> On Thu, 29 Sep 2016 13:54:16 +0200
> Christian Borntraeger <borntraeger@de.ibm.com> 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 <borntraeger@de.ibm.com>
>> ---
>> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-29 13:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-29 11:54 [PATCH] s390x/spinlock: Provide vcpu_is_preempted globally Christian Borntraeger
2016-09-29 13:11 ` Martin Schwidefsky
2016-09-29 13:21 ` Christian Borntraeger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox