All of lore.kernel.org
 help / color / mirror / Atom feed
From: xinhui <xinhui.pan@linux.vnet.ibm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	paulmck@linux.vnet.ibm.com, 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
Subject: Re: [PATCH 2/3] powerpc/spinlock: support vcpu preempted check
Date: Tue, 28 Jun 2016 11:23:57 +0800	[thread overview]
Message-ID: <5771EDCD.5070400@linux.vnet.ibm.com> (raw)
In-Reply-To: <20160627141735.GC30909@twins.programming.kicks-ass.net>



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
>>
>

  reply	other threads:[~2016-06-28  3:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-27 17:41 [PATCH 0/3] implement vcpu preempted check Pan Xinhui
2016-06-27 17:41 ` [PATCH 1/3] kernel/sched: introduce vcpu preempted check interface Pan Xinhui
2016-06-27 14:00   ` Peter Zijlstra
2016-06-27 14:02     ` Peter Zijlstra
2016-06-28  3:14       ` xinhui
2016-06-28  7:00     ` Heiko Carstens
2016-06-28  9:47       ` xinhui
2016-06-27 14:05   ` Boqun Feng
2016-06-28  3:15     ` xinhui
2016-06-27 17:41 ` [PATCH 2/3] powerpc/spinlock: support vcpu preempted check Pan Xinhui
2016-06-27 14:17   ` Peter Zijlstra
2016-06-28  3:23     ` xinhui [this message]
2016-06-27 14:58   ` Boqun Feng
2016-06-28  3:39     ` xinhui
2016-06-28  5:03       ` Boqun Feng
2016-06-28  5:38         ` xinhui
2016-06-27 17:41 ` [PATCH 3/3] locking/osq: Drop the overload of osq_lock() Pan Xinhui
2016-06-27 14:21   ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5771EDCD.5070400@linux.vnet.ibm.com \
    --to=xinhui.pan@linux.vnet.ibm.com \
    --cc=Waiman.Long@hpe.com \
    --cc=benh@kernel.crashing.org \
    --cc=boqun.feng@gmail.com \
    --cc=dave@stgolabs.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mingo@redhat.com \
    --cc=mpe@ellerman.id.au \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=paulus@samba.org \
    --cc=peterz@infradead.org \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.