From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751908AbcF0Jnc (ORCPT ); Mon, 27 Jun 2016 05:43:32 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:48756 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751860AbcF0Jnb (ORCPT ); Mon, 27 Jun 2016 05:43:31 -0400 X-IBM-Helo: d28dlp03.in.ibm.com X-IBM-MailFrom: xinhui.pan@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org Date: Mon, 27 Jun 2016 17:42: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: linux-kernel@vger.kernel.org, mingo@redhat.com, boqun.feng@gmail.com Subject: Re: [PATCH 1/2] kernel/sched: introduce vcpu preempted interface References: <1466937715-6683-1-git-send-email-xinhui.pan@linux.vnet.ibm.com> <1466937715-6683-2-git-send-email-xinhui.pan@linux.vnet.ibm.com> <20160627084250.GZ30154@twins.programming.kicks-ass.net> In-Reply-To: <20160627084250.GZ30154@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: 16062709-0048-0000-0000-000002A7C728 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16062709-0049-0000-0000-00000D6065CB Message-Id: <5770F521.1080705@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-06-27_06:,, 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-1606270110 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016年06月27日 16:42, Peter Zijlstra wrote: > On Sun, Jun 26, 2016 at 06:41:54AM -0400, Pan Xinhui wrote: > >> +#ifdef arch_vcpu_is_preempted >> +static inline bool vcpu_is_preempted(int cpu) >> +{ >> + return arch_vcpu_is_preempted(cpu); >> +} >> +#else >> +static inline bool vcpu_is_preempted(int cpu) >> +{ >> + return 0; >> +} >> +#endif >> + >> +#ifdef arch_vcpu_get_yield_count >> +static inline unsigned int vcpu_get_yield_count(int cpu) >> +{ >> + return arch_vcpu_get_yield_count(cpu); >> +} >> +#else >> +static inline unsigned int vcpu_get_yield_count(int cpu) >> +{ >> + return 0; >> +} >> +#endif > > > Please, just do something like: > > #ifndef vcpu_is_preempted > static inline bool vcpu_is_preempted(int cpu) > { > return false; > } > #endif > > No point in making it more complicated. > right, vcpu_is_preempted() is good enough to handle our osq issue. >> +static inline bool >> +need_yield_to(int vcpu, unsigned int old_yield_count) > > namespace... this thing should be called: vcpu_something() > >> +{ >> + /* if we find the vcpu is preempted, >> + * then we may want to kick it, IOW, yield to it >> + */ >> + return vcpu_is_preempted(vcpu) || >> + (vcpu_get_yield_count(vcpu) != old_yield_count); >> +} > > And can you make doubly sure (and mention in the Changelog) that the OSQ > code compiles all this away when using these definitions. > vimdiff shows the osq_lock.o has a little difference because osq read the yield_count and prev, even they are not used. however, as you suggest above, IF I remove the vcpu_get_yield_count() and relevant code in osq_lock, then the binary is same.