From mboxrd@z Thu Jan 1 00:00:00 1970 From: peb1611 Subject: Re: Question about the credit2 sources in xen-unstable tree. Date: Tue, 05 Apr 2011 21:33:48 +0900 Message-ID: <4D9B0C2C.60505@gmail.com> References: <4D9AD016.1060304@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: George Dunlap Cc: xen devel List-Id: xen-devel@lists.xenproject.org Thanks for your very kind explanation :-) Now, I'm totally make sense of what the code would say and I'm sorry=20 about asking you withoug thoughtful consideration. and then, I hope that the credit2 works well for not only latency=20 sensitive apps but also any other apps. Thank you once again. 2011-04-05 =EC=98=A4=ED=9B=84 6:12, George Dunlap =EC=93=B4 =EA=B8=80: > Hmm, I seem not to have documented that bit of code very well. :-) > > The idea is this: > 1) Start with runtime =3D amount of time until this vcpu's credit reach= es 0: > time =3D c2t(rqd, snext->credit, snext); > 2) Then, if there's another vcpu on the runqueue, calculate how much > time until the current vcpu's credit matches that vcpu's credit: > ntime =3D c2t(rqd, snext->credit - svc->credit, snext); > if ( time> ntime ) > time =3D ntime; > 3) Finally, never let the time go outside of the minimum and maximum > schedule times: > if ( time< CSCHED_MIN_TIMER ) > time =3D CSCHED_MIN_TIMER; > else if ( time> CSCHED_MAX_TIMER ) > time =3D CSCHED_MAX_TIMER; > > Does that make sense? > > So let's say snext has 10 ms of credit, and there's a vcpu on the > runqueue with 5ms of credit. Then it will be scheduled to run for 2 > ms (since right now MAX_TIMER is set to 2ms). But if the vcpu on the > runqueue has 9ms of credit, it snext will only be allowed to run for > 1ms (so that when it finishes, both will have about 9ms of credit). > If, however, the next vcpu on the runqueue has 9.9ms of credit, snext > will be schedule to run for 0.5ms (since MIN_TIMER is set to 500us). > > Does that make sense? > > I chose MIN_TIMER and MAX_TIMER rather arbitrarily -- they probably > could use some tweaking. > > -George > > 2011/4/5 peb1611: >> Hi, all >> >> I am analyzing the credit2 scheduler in order to adopt to my own priva= te >> cloud, which should satisfy the conditions of some latency sensitive >> applications. >> >> In the latest xen-unstable repository, which is tip tags, I found some >> codes that is not understandable to me. >> >> In the xen/common/sched_credit2.c, >> >> /* How long should we let this vcpu run for? */ >> static s_time_t >> csched_runtime(const struct scheduler *ops, int cpu, struct csched_vcp= u >> *snext) >> { >> s_time_t time =3D CSCHED_MAX_TIMER; >> struct csched_runqueue_data *rqd =3D RQD(ops, cpu); >> struct list_head *runq =3D&rqd->runq; >> >> if ( is_idle_vcpu(snext->vcpu) ) >> return CSCHED_MAX_TIMER; >> >> /* Basic time */ >> time =3D c2t(rqd, snext->credit, snext); >> >> /* Next guy on runqueue */ >> if ( ! list_empty(runq) ) >> { >> struct csched_vcpu *svc =3D __runq_elem(runq->next); >> s_time_t ntime; >> >> if ( ! is_idle_vcpu(svc->vcpu) ) >> { >> ntime =3D c2t(rqd, snext->credit - svc->credit, snext); >> >> if ( time> ntime ) >> time =3D ntime; >> } >> } >> >> /* Check limits */ >> if ( time< CSCHED_MIN_TIMER ) >> time =3D CSCHED_MIN_TIMER; >> else if ( time> CSCHED_MAX_TIMER ) >> time =3D CSCHED_MAX_TIMER; >> >> return time; >> } >> >> As I understand, this function is used to determining the next vcpu's >> running time-slice from now to the next scheduling event. >> >> So, what does this code mean? >> >> if ( time> ntime ) >> time =3D ntime; >> >> actually, I think it is not different as >> >> if ( svc->credit> 0 ) >> time =3D ntime; >> >> If so, It means that if credits of the next guy on runqueue are not >> negative caculated time-slice is snext's time, or time of the next guy >> is selected and then eventually saturated by the CSCHED_MIN_TIMER. >> >> what is the implication of it? >> >> Am I correct ? If not, would you please kindly let me know about the >> mecahnism of caculating the next-time slice? >> >> Thanks >> >> -- >> Eunbyung Park >> >> >> _______________________________________________ >> Xen-devel mailing list >> Xen-devel@lists.xensource.com >> http://lists.xensource.com/xen-devel >> --=20 Eunbyung Park