* Question on Credit accounting in Credit Scheduler
@ 2010-07-29 13:21 Thomas Pfeuffer
2010-07-29 13:35 ` Tim Deegan
2010-07-29 13:40 ` AW: " Heiko Wundram
0 siblings, 2 replies; 5+ messages in thread
From: Thomas Pfeuffer @ 2010-07-29 13:21 UTC (permalink / raw)
To: xen-devel@lists.xensource.com
Hello,
I have looked through the source code of Credit Scheduler.
In csched_acct(), the number of credits a domain gets (i.e credit_fair),
is calculated as follows:
credit_fair = ( ( credit_total * sdom->weight) + ( weight_total -1)
) / weigth_total
But I would expect, that the Credits are calculated by
credit_fair = (credit_total * sdom->weight) / weigth_total
Does anybody know, what function the term (weight_total -1) has?
Later, the credits a vcpu gets is calculated by
credit_fair = ( credit_fair + (sdom->active_vcpu_count -1)
) / sdom->active_vcpu_count -1
Again, I would expect that the credits are calculated by
credit_fair = credit_fair / sdom->active_vcpu_count
I do not understand why the term (sdom->active_vcpu_count -1 ) is
neccessary.
Best regards,
Thomas Pfeuffer
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: Question on Credit accounting in Credit Scheduler 2010-07-29 13:21 Question on Credit accounting in Credit Scheduler Thomas Pfeuffer @ 2010-07-29 13:35 ` Tim Deegan 2010-07-29 13:42 ` George Dunlap 2010-07-29 13:40 ` AW: " Heiko Wundram 1 sibling, 1 reply; 5+ messages in thread From: Tim Deegan @ 2010-07-29 13:35 UTC (permalink / raw) To: Thomas Pfeuffer; +Cc: xen-devel@lists.xensource.com At 14:21 +0100 on 29 Jul (1280413287), Thomas Pfeuffer wrote: > Hello, > > I have looked through the source code of Credit Scheduler. > > In csched_acct(), the number of credits a domain gets (i.e credit_fair), > is calculated as follows: > > credit_fair = ( ( credit_total * sdom->weight) + ( weight_total -1) > ) / weigth_total > > But I would expect, that the Credits are calculated by > > credit_fair = (credit_total * sdom->weight) / weigth_total > > Does anybody know, what function the term (weight_total -1) has? It makes the integer division round up instead of rounding down. Tim. -- Tim Deegan <Tim.Deegan@citrix.com> Principal Software Engineer, XenServer Engineering Citrix Systems UK Ltd. (Company #02937203, SL9 0BG) ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Question on Credit accounting in Credit Scheduler 2010-07-29 13:35 ` Tim Deegan @ 2010-07-29 13:42 ` George Dunlap 0 siblings, 0 replies; 5+ messages in thread From: George Dunlap @ 2010-07-29 13:42 UTC (permalink / raw) To: Tim Deegan; +Cc: xen-devel@lists.xensource.com, Thomas Pfeuffer I'd thought of writing a div_round_up() macro that would make this a bit more clear, something like: /* Divide x by y, rounding up */ #div_round_up(x, y) (((x)+((y)-1))/(y)) -George On Thu, Jul 29, 2010 at 2:35 PM, Tim Deegan <Tim.Deegan@citrix.com> wrote: > At 14:21 +0100 on 29 Jul (1280413287), Thomas Pfeuffer wrote: >> Hello, >> >> I have looked through the source code of Credit Scheduler. >> >> In csched_acct(), the number of credits a domain gets (i.e credit_fair), >> is calculated as follows: >> >> credit_fair = ( ( credit_total * sdom->weight) + ( weight_total -1) >> ) / weigth_total >> >> But I would expect, that the Credits are calculated by >> >> credit_fair = (credit_total * sdom->weight) / weigth_total >> >> Does anybody know, what function the term (weight_total -1) has? > > It makes the integer division round up instead of rounding down. > > Tim. > > -- > Tim Deegan <Tim.Deegan@citrix.com> > Principal Software Engineer, XenServer Engineering > Citrix Systems UK Ltd. (Company #02937203, SL9 0BG) > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xensource.com > http://lists.xensource.com/xen-devel > ^ permalink raw reply [flat|nested] 5+ messages in thread
* AW: Question on Credit accounting in Credit Scheduler 2010-07-29 13:21 Question on Credit accounting in Credit Scheduler Thomas Pfeuffer 2010-07-29 13:35 ` Tim Deegan @ 2010-07-29 13:40 ` Heiko Wundram 2010-07-30 6:25 ` Thomas Pfeuffer 1 sibling, 1 reply; 5+ messages in thread From: Heiko Wundram @ 2010-07-29 13:40 UTC (permalink / raw) To: 'Thomas Pfeuffer', xen-devel > -----Ursprüngliche Nachricht----- > Von: xen-devel-bounces@lists.xensource.com [mailto:xen-devel- > bounces@lists.xensource.com] Im Auftrag von Thomas Pfeuffer > Gesendet: Donnerstag, 29. Juli 2010 15:21 > An: xen-devel@lists.xensource.com > Betreff: [Xen-devel] Question on Credit accounting in Credit Scheduler > > I have looked through the source code of Credit Scheduler. > > In csched_acct(), the number of credits a domain gets (i.e > credit_fair), > is calculated as follows: > > credit_fair = ( ( credit_total * sdom->weight) + ( weight_total - > 1) > ) / weigth_total > > But I would expect, that the Credits are calculated by > > credit_fair = (credit_total * sdom->weight) / weigth_total > > Does anybody know, what function the term (weight_total -1) has? Without knowing details of the Xen scheduling algorithm (i.e., I'm guessing that the above is integer-only math), all it does is "round up" the (fair) credits a domain gets [(x+y-1)/y means division with always rounding up, think of the "Gaußklammer", don't know the german name, in reverse]; basically, if the above calculation is done for all domains, the respective sum of all calculated credit_fair will always be equal to or higher than credit_total, which wouldn't be the case (because of truncation when just doing x/y) when using your function, i.e. the sum of all credit_fair might be less than credit_total. For a scheduling algorithm, you'll want to always give away _at least_ all available credits, and this is a simple enough method to do just that without resorting to floating point calculations. --- Heiko. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: AW: Question on Credit accounting in Credit Scheduler 2010-07-29 13:40 ` AW: " Heiko Wundram @ 2010-07-30 6:25 ` Thomas Pfeuffer 0 siblings, 0 replies; 5+ messages in thread From: Thomas Pfeuffer @ 2010-07-30 6:25 UTC (permalink / raw) To: Heiko Wundram, Tim.Deegan; +Cc: dunlapg, xen-devel [-- Attachment #1.1: Type: text/plain, Size: 1803 bytes --] Hello, thanks for your answer. Best regards, Thomas Heiko Wundram wrote: >>-----Ursprüngliche Nachricht----- >>Von: xen-devel-bounces@lists.xensource.com [mailto:xen-devel- >>bounces@lists.xensource.com] Im Auftrag von Thomas Pfeuffer >>Gesendet: Donnerstag, 29. Juli 2010 15:21 >>An: xen-devel@lists.xensource.com >>Betreff: [Xen-devel] Question on Credit accounting in Credit Scheduler >> >>I have looked through the source code of Credit Scheduler. >> >>In csched_acct(), the number of credits a domain gets (i.e >>credit_fair), >>is calculated as follows: >> >> credit_fair = ( ( credit_total * sdom->weight) + ( weight_total - >>1) >> ) / weigth_total >> >>But I would expect, that the Credits are calculated by >> >> credit_fair = (credit_total * sdom->weight) / weigth_total >> >>Does anybody know, what function the term (weight_total -1) has? >> >> > >Without knowing details of the Xen scheduling algorithm (i.e., I'm guessing >that the above is integer-only math), all it does is "round up" the (fair) >credits a domain gets [(x+y-1)/y means division with always rounding up, >think of the "Gaußklammer", don't know the german name, in reverse]; >basically, if the above calculation is done for all domains, the respective >sum of all calculated credit_fair will always be equal to or higher than >credit_total, which wouldn't be the case (because of truncation when just >doing x/y) when using your function, i.e. the sum of all credit_fair might >be less than credit_total. > >For a scheduling algorithm, you'll want to always give away _at least_ all >available credits, and this is a simple enough method to do just that >without resorting to floating point calculations. > >--- Heiko. > > > > [-- Attachment #1.2: Type: text/html, Size: 2467 bytes --] [-- Attachment #2: Type: text/plain, Size: 138 bytes --] _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-07-30 6:25 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-07-29 13:21 Question on Credit accounting in Credit Scheduler Thomas Pfeuffer 2010-07-29 13:35 ` Tim Deegan 2010-07-29 13:42 ` George Dunlap 2010-07-29 13:40 ` AW: " Heiko Wundram 2010-07-30 6:25 ` Thomas Pfeuffer
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.