diff mbox

[05/19] xen: credit2: do not warn if calling burn_credits more than once

Message ID 146620511277.29766.6122289936385803242.stgit@Solace.fritz.box (mailing list archive)
State New, archived
Headers show

Commit Message

Dario Faggioli June 17, 2016, 11:11 p.m. UTC
on the same vcpu, without NOW() having changed.

This is, in fact, a legitimate use case. If it happens,
we should just do nothing, without producing any warning
or debug message.

While there, fix style and add a couple of branching
hints.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
---
Cc: George Dunlap <george.dunlap@citrix.com>
Cc: Anshul Makkar <anshul.makkar@citrix.com>
Cc: David Vrabel <david.vrabel@citrix.com>
---
 xen/common/sched_credit2.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

George Dunlap July 6, 2016, 4:05 p.m. UTC | #1
On Sat, Jun 18, 2016 at 12:11 AM, Dario Faggioli
<dario.faggioli@citrix.com> wrote:
> on the same vcpu, without NOW() having changed.
>
> This is, in fact, a legitimate use case. If it happens,
> we should just do nothing, without producing any warning
> or debug message.
>
> While there, fix style and add a couple of branching
> hints.
>
> Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>

Reviewed-by: George Dunlap <george.dunlap@citrix.com>

And queued.
diff mbox

Patch

diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c
index ef199e3..9e8e561 100644
--- a/xen/common/sched_credit2.c
+++ b/xen/common/sched_credit2.c
@@ -738,14 +738,15 @@  static void reset_credit(const struct scheduler *ops, int cpu, s_time_t now,
     /* No need to resort runqueue, as everyone's order should be the same. */
 }
 
-void burn_credits(struct csched2_runqueue_data *rqd, struct csched2_vcpu *svc, s_time_t now)
+void burn_credits(struct csched2_runqueue_data *rqd,
+                  struct csched2_vcpu *svc, s_time_t now)
 {
     s_time_t delta;
 
     /* Assert svc is current */
     ASSERT(svc==CSCHED2_VCPU(curr_on_cpu(svc->vcpu->processor)));
 
-    if ( is_idle_vcpu(svc->vcpu) )
+    if ( unlikely(is_idle_vcpu(svc->vcpu)) )
     {
         BUG_ON(svc->credit != CSCHED2_IDLE_CREDIT);
         return;
@@ -753,13 +754,16 @@  void burn_credits(struct csched2_runqueue_data *rqd, struct csched2_vcpu *svc, s
 
     delta = now - svc->start_time;
 
-    if ( delta > 0 ) {
+    if ( likely(delta > 0) )
+    {
         SCHED_STAT_CRANK(burn_credits_t2c);
         t2c_update(rqd, delta, svc);
         svc->start_time = now;
 
         d2printk("b %pv c%d\n", svc->vcpu, svc->credit);
-    } else {
+    }
+    else if ( delta < 0 )
+    {
         d2printk("%s: Time went backwards? now %"PRI_stime" start %"PRI_stime"\n",
                __func__, now, svc->start_time);
     }