From mboxrd@z Thu Jan 1 00:00:00 1970 From: George Dunlap Subject: Re: [PATCH 03 of 11 v4] xen: sched_credit: when picking, make sure we get an idle one, if any Date: Mon, 18 Mar 2013 14:02:56 +0000 Message-ID: <51471E90.5060104@eu.citrix.com> References: <8a9328d89750c7019e02.1363314645@hit-nxdomain.opendns.com> <5142E68102000078000C5CEE@nat28.tlf.novell.com> <1363343874.3912.21.camel@Solace> <51430C4902000078000C5D9C@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <51430C4902000078000C5D9C@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: Marcus Granado , Dan Magenheimer , Ian Campbell , AnilMadhavapeddy , Andrew Cooper , Dario Faggioli , Ian Jackson , Xen-Devel , Matt Wilson , Daniel De Graaf , Juergen Gross List-Id: xen-devel@lists.xenproject.org On 15/03/13 10:55, Jan Beulich wrote: >>>> On 15.03.13 at 11:37, Dario Faggioli wrote: >> On ven, 2013-03-15 at 08:14 +0000, Jan Beulich wrote: >> Perhaps I can turn the condition into something like this: >> >> if ( !cpumask_test_cpu(cpu, &cpus) ) >> cpu = cpumask_empty(&cpus) ? cpu : cpumask_cycle(cpu, &cpus); >> >> So that we pay the price less frequently? > Given cpu < nr_cpu_ids before this, yes, that sounds right. Or > you could simply switch the operands of the && in your original > if(). Yet less expensive would be if you stored the result of > cpumask_cycle() in another variable and copied it into "cpu" > only if less than nr_cpu_ids. That would eliminate the need for > cpumask_empty() altogether. It seems to me like just switching the order would result in more readable code. Wouldn't hurt to add "Do the quick test first" to the comment so no one switches it back. :-) -George