From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751949AbcF1DYd (ORCPT ); Mon, 27 Jun 2016 23:24:33 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:64775 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751673AbcF1DYb (ORCPT ); Mon, 27 Jun 2016 23:24:31 -0400 X-IBM-Helo: d23dlp03.au.ibm.com X-IBM-MailFrom: xinhui.pan@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org Date: Tue, 28 Jun 2016 11:23:57 +0800 From: xinhui User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: Peter Zijlstra 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 References: <1467049290-32359-1-git-send-email-xinhui.pan@linux.vnet.ibm.com> <1467049290-32359-3-git-send-email-xinhui.pan@linux.vnet.ibm.com> <20160627141735.GC30909@twins.programming.kicks-ass.net> In-Reply-To: <20160627141735.GC30909@twins.programming.kicks-ass.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16062803-0008-0000-0000-0000009E3488 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16062803-0009-0000-0000-0000078CBD62 Message-Id: <5771EDCD.5070400@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-06-28_02:,, 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-1606280031 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >> >