Skip to contentSkip to conversation

Credit1: Tweak reset condition

PATCH In review George Dunlap 2 participants 3 messages Aug 9, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Credit1: Tweak reset condition

VMs that don't use their full timeslice are guaranteed to flip back and forth between "active" and "inactive". If we set credit to 0 when setting "inactive", then when the VM comes back to "active" again, it will effectively be behind most other vcpus in credit. This causes the credit1 to effectively discriminate *against* VMs which use less than their full timeslice.

Instead of setting credit to 0, divide it in half (shifting by one bit for more efficiency). This gets rid of some of the system credit while allowing non-cpu-bound VMs to keep some priority advantage.

xen/common/sched_credit.c +3 -1
diff -r 6f07d9ac1e7c -r 1a29b22ef2e9 xen/common/sched_credit.c
@@ -1069,7 +1069,9 @@
                 if ( credit > CSCHED_CREDITS_PER_TSLICE )
                 {
                     __csched_vcpu_acct_stop_locked(prv, svc);
-                    credit = 0;
+                    /* Divide credits in half, so that when it starts
+                     * accounting again, it starts a little bit "ahead" */
+                    credit >>= 1;
                     atomic_set(&svc->credit, credit);
                 }
             }
#1 lore raw

Hi,

Quoted 9 lines · George Dunlap

VMs that don't use their full timeslice are guaranteed to flip back and forth between "active" and "inactive". If we set credit to 0 when setting "inactive", then when the VM comes back to "active" again, it will effectively be behind most other vcpus in credit. This causes the credit1 to effectively discriminate *against* VMs which use less than their full timeslice.

Instead of setting credit to 0, divide it in half (shifting by one bit for more efficiency).

"credit" here is signed, and the compiler is allowed to use either a signed or an unsigned shift for >>. Better to code it as /=2 and trust the compiler to DTRT with a constant division.

Cheers,

Tim.

Quoted 25 lines

This gets rid of some of the
system credit while allowing non-cpu-bound VMs to keep some priority advantage.

diff -r 6f07d9ac1e7c -r 1a29b22ef2e9 xen/common/sched_credit.c

xen/common/sched_credit.c +3 -1
@@ -1069,7 +1069,9 @@
                 if ( credit > CSCHED_CREDITS_PER_TSLICE )
                 {
                     __csched_vcpu_acct_stop_locked(prv, svc);
-                    credit = 0;
+                    /* Divide credits in half, so that when it starts
+                     * accounting again, it starts a little bit "ahead" */
+                    credit >>= 1;
                     atomic_set(&svc->credit, credit);
                 }
             }

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

Signature · 3 lines
Tim Deegan <[email protected]>
Principal Software Engineer, XenServer Engineering
Citrix Systems UK Ltd.  (Company #02937203, SL9 0BG)
#2 lore raw

If we wanted to be clever, we could rely upon the fact that this condition only happens when credit > CSCHED_CREDITS_PER_TSLICE, which is a positive value.

But I'm all for being defensive and using /= 2 instead.

-George

Quoted 57 lines · Tim Deegan

Hi,

Quoted 9 lines · George Dunlap

VMs that don't use their full timeslice are guaranteed to flip back and forth between "active" and "inactive".  If we set credit to 0 when setting "inactive", then when the VM comes back to "active" again, it will effectively be behind most other vcpus in credit. This causes the credit1 to effectively discriminate *against* VMs which use less than their full timeslice.

Instead of setting credit to 0, divide it in half (shifting by one bit for more efficiency).

"credit" here is signed, and the compiler is allowed to use either a signed or an unsigned shift for >>.  Better to code it as /=2 and trust the compiler to DTRT with a constant division.

Cheers,

Tim.

Quoted 21 lines

 This gets rid of some of the
system credit while allowing non-cpu-bound VMs to keep some priority advantage.

diff -r 6f07d9ac1e7c -r 1a29b22ef2e9 xen/common/sched_credit.c

xen/common/sched_credit.c       Mon Aug 09 12:38:12 2010 +0100 renamed from xen/common/sched_credit.c       Thu Aug 05 14:41:14 2010 +0100 +3 -1
@@ -1069,7 +1069,9 @@
                  if ( credit > CSCHED_CREDITS_PER_TSLICE )
                  {
                      __csched_vcpu_acct_stop_locked(prv, svc);
-                    credit = 0;
+                    /* Divide credits in half, so that when it starts
+                     * accounting again, it starts a little bit "ahead" */
+                    credit >>= 1;
                      atomic_set(&svc->credit, credit);
                  }
              }
Quoted 4 lines

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

--
Tim Deegan <[email protected]>
Principal Software Engineer, XenServer Engineering Citrix Systems UK Ltd.  (Company #02937203, SL9 0BG)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel