From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751900AbcF0IoC (ORCPT ); Mon, 27 Jun 2016 04:44:02 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:35326 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751248AbcF0IoA (ORCPT ); Mon, 27 Jun 2016 04:44:00 -0400 Date: Mon, 27 Jun 2016 10:42:50 +0200 From: Peter Zijlstra To: Pan Xinhui Cc: linux-kernel@vger.kernel.org, mingo@redhat.com, boqun.feng@gmail.com Subject: Re: [PATCH 1/2] kernel/sched: introduce vcpu preempted interface Message-ID: <20160627084250.GZ30154@twins.programming.kicks-ass.net> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1466937715-6683-2-git-send-email-xinhui.pan@linux.vnet.ibm.com> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > +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.