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


Groups > linux.kernel > #1432434

Re: [PATCH 2/3] powerpc/spinlock: support vcpu preempted check

From xinhui <xinhui.pan@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject Re: [PATCH 2/3] powerpc/spinlock: support vcpu preempted check
Date 2016-06-28 05:30 +0200
Message-ID <rORSN-1dK-7@gated-at.bofh.it> (permalink)
References <rOF5f-Uh-5@gated-at.bofh.it> <rOF5f-Uh-13@gated-at.bofh.it> <rOFyh-1kx-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On 2016年06月27日 22:17, Peter Zijlstra wrote:
> On Mon, Jun 27, 2016 at 01:41:29PM -0400, Pan Xinhui wrote:
>> 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.
>> + */
>
> If you look around in that file you'll notice that the above comment
> style is inconsistent.
>
> Nor is the comment really clarifying things, for one you fail to mention
> the problem by its known name. You also forget to explain how this
> interface will help. How about something like this:
>
> /*
>   * In order to deal with a various lock holder preemption issues provide
>   * an interface to see if a vCPU is currently running or not.
>   *
>   * This allows us to terminate optimistic spin loops and block,
>   * analogous to the native optimistic spin heuristic of testing if the
>   * lock owner task is running or not.
>   */
thanks!!!

>
> Also, since you now have a useful comment, which is not architecture
> specific, I would place it with the common vcpu_is_preempted()
> definition in sched.h.
>
agree with you. Will do that. I will also add Suggested-by with you.
thanks

> Hmm?
>
>> +#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
>>
>

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


Thread

[PATCH 0/3] implement vcpu preempted check Pan Xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-06-27 15:50 +0200
  [PATCH 2/3] powerpc/spinlock: support vcpu preempted check Pan Xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-06-27 15:50 +0200
    Re: [PATCH 2/3] powerpc/spinlock: support vcpu preempted check Peter Zijlstra <peterz@infradead.org> - 2016-06-27 16:20 +0200
      Re: [PATCH 2/3] powerpc/spinlock: support vcpu preempted check xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-06-28 05:30 +0200
    Re: [PATCH 2/3] powerpc/spinlock: support vcpu preempted check Boqun Feng <boqun.feng@gmail.com> - 2016-06-27 17:00 +0200
      Re: [PATCH 2/3] powerpc/spinlock: support vcpu preempted check xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-06-28 05:50 +0200
        Re: [PATCH 2/3] powerpc/spinlock: support vcpu preempted check Boqun Feng <boqun.feng@gmail.com> - 2016-06-28 07:10 +0200
          Re: [PATCH 2/3] powerpc/spinlock: support vcpu preempted check xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-06-28 07:40 +0200
  [PATCH 1/3] kernel/sched: introduce vcpu preempted check interface Pan Xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-06-27 15:50 +0200
    Re: [PATCH 1/3] kernel/sched: introduce vcpu preempted check  interface Peter Zijlstra <peterz@infradead.org> - 2016-06-27 16:10 +0200
      Re: [PATCH 1/3] kernel/sched: introduce vcpu preempted check  interface Peter Zijlstra <peterz@infradead.org> - 2016-06-27 16:10 +0200
        Re: [PATCH 1/3] kernel/sched: introduce vcpu preempted check interface xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-06-28 05:20 +0200
      Re: [PATCH 1/3] kernel/sched: introduce vcpu preempted check  interface Heiko Carstens <heiko.carstens@de.ibm.com> - 2016-06-28 09:10 +0200
        Re: [PATCH 1/3] kernel/sched: introduce vcpu preempted check interface xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-06-28 11:50 +0200
    Re: [PATCH 1/3] kernel/sched: introduce vcpu preempted check  interface Boqun Feng <boqun.feng@gmail.com> - 2016-06-27 16:10 +0200
      Re: [PATCH 1/3] kernel/sched: introduce vcpu preempted check interface xinhui <xinhui.pan@linux.vnet.ibm.com> - 2016-06-28 05:20 +0200

csiph-web