From: George Dunlap Subject: Re: [PATCH] small csched_cpu_pick() adjustments Date: Wed, 28 Oct 2009 10:57:56 +0000 Message-ID: References: <4AE70598020000780001C373@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <4AE70598020000780001C373@vpn.id2.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Jan Beulich Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Acked-by: George Dunlap On Tue, Oct 27, 2009 at 1:37 PM, Jan Beulich wrote: > When csched_cpu_pick() decides to move a vCPU to a different pCPU, so > far in the vast majority of cases it selected the first core/thread of > the most idle socket/core. When there are many short executing > entities, this will generally lead to them not getting evenly > distributed (since primary cores/threads will be preferred), making the > need for subsequent migration more likely. Instead, candidate > cores/threads should get treated as symmetrically as possible, and > hence this changes the selection logic to cycle through all candidates. > > Further, since csched_cpu_pick() will never move a vCPU between threads > of the same core (and since the weights calculated for individual > threads of the same core are always identical), rather than removing > just the selected pCPU from the mask that still needs looking at, all > siblings of the chosen pCPU can be removed at once without affecting > the outcome. > > Signed-off-by: Jan Beulich > > --- 2009-10-27.orig/xen/common/sched_credit.c =A0 2009-10-27 12:07:32.000= 000000 +0100 > +++ 2009-10-27/xen/common/sched_credit.c =A0 =A0 =A0 =A02009-10-27 14:27:= 28.000000000 +0100 > @@ -110,6 +110,7 @@ struct csched_pcpu { > =A0 =A0 uint32_t runq_sort_last; > =A0 =A0 struct timer ticker; > =A0 =A0 unsigned int tick; > + =A0 =A0unsigned int idle_bias; > =A0}; > > =A0/* > @@ -298,6 +299,7 @@ csched_pcpu_init(int cpu) > =A0 =A0 init_timer(&spc->ticker, csched_tick, (void *)(unsigned long)cpu,= cpu); > =A0 =A0 INIT_LIST_HEAD(&spc->runq); > =A0 =A0 spc->runq_sort_last =3D csched_priv.runq_sort; > + =A0 =A0spc->idle_bias =3D NR_CPUS - 1; > =A0 =A0 per_cpu(schedule_data, cpu).sched_priv =3D spc; > > =A0 =A0 /* Start off idling... */ > @@ -379,7 +381,7 @@ __csched_vcpu_is_migrateable(struct vcpu > =A0} > > =A0static int > -csched_cpu_pick(struct vcpu *vc) > +_csched_cpu_pick(struct vcpu *vc, bool_t commit) > =A0{ > =A0 =A0 cpumask_t cpus; > =A0 =A0 cpumask_t idlers; > @@ -438,8 +440,10 @@ csched_cpu_pick(struct vcpu *vc) > =A0 =A0 =A0 =A0 if ( ( (weight_cpu < weight_nxt) ^ sched_smt_power_saving= s ) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 && (weight_cpu !=3D weight_nxt) ) > =A0 =A0 =A0 =A0 { > - =A0 =A0 =A0 =A0 =A0 =A0cpu =3D nxt; > - =A0 =A0 =A0 =A0 =A0 =A0cpu_clear(cpu, cpus); > + =A0 =A0 =A0 =A0 =A0 =A0cpu =3D cycle_cpu(CSCHED_PCPU(nxt)->idle_bias, n= xt_idlers); > + =A0 =A0 =A0 =A0 =A0 =A0if ( commit ) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 CSCHED_PCPU(nxt)->idle_bias =3D cpu; > + =A0 =A0 =A0 =A0 =A0 =A0cpus_andnot(cpus, cpus, per_cpu(cpu_sibling_map,= cpu)); > =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 else > =A0 =A0 =A0 =A0 { > @@ -450,6 +454,12 @@ csched_cpu_pick(struct vcpu *vc) > =A0 =A0 return cpu; > =A0} > > +static int > +csched_cpu_pick(struct vcpu *vc) > +{ > + =A0 =A0return _csched_cpu_pick(vc, 1); > +} > + > =A0static inline void > =A0__csched_vcpu_acct_start(struct csched_vcpu *svc) > =A0{ > @@ -529,7 +539,7 @@ csched_vcpu_acct(unsigned int cpu) > =A0 =A0 { > =A0 =A0 =A0 =A0 __csched_vcpu_acct_start(svc); > =A0 =A0 } > - =A0 =A0else if ( csched_cpu_pick(current) !=3D cpu ) > + =A0 =A0else if ( _csched_cpu_pick(current, 0) !=3D cpu ) > =A0 =A0 { > =A0 =A0 =A0 =A0 CSCHED_VCPU_STAT_CRANK(svc, migrate_r); > =A0 =A0 =A0 =A0 CSCHED_STAT_CRANK(migrate_running); > > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel > >