[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Xen-devel] [PATCH 03 of 11 v4] xen: sched_credit: when picking, make sure we get an idle one, if any
 
- To: Jan Beulich <JBeulich@xxxxxxxx>
 
- From: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
 
- Date: Mon, 18 Mar 2013 14:02:56 +0000
 
- Cc: Marcus Granado <Marcus.Granado@xxxxxxxxxxxxx>,	Dan Magenheimer <dan.magenheimer@xxxxxxxxxx>,	Ian Campbell <Ian.Campbell@xxxxxxxxxx>, AnilMadhavapeddy <anil@xxxxxxxxxx>,	Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>,	Dario Faggioli <dario.faggioli@xxxxxxxxxx>,	Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>,	Xen-Devel <xen-devel@xxxxxxxxxxxxx>, Matt Wilson <msw@xxxxxxxxxx>,	Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>,	Juergen Gross <juergen.gross@xxxxxxxxxxxxxx>
 
- Delivery-date: Mon, 18 Mar 2013 14:03:16 +0000
 
- List-id: Xen developer discussion <xen-devel.lists.xen.org>
 
 
 
On 15/03/13 10:55, Jan Beulich wrote:
 
On 15.03.13 at 11:37, Dario Faggioli <dario.faggioli@xxxxxxxxxx> 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
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
 
 
    
     |