Skip to contentSkip to conversation

sched/credit: avoid priority boost for capped domains when unpark

PATCH In review Eslam Elnikety 2 participants 2 messages May 3, 2019 – May 6, 2019

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sched/credit: avoid priority boost for capped domains when unpark

When unpausing a capped domain, the scheduler currently clears the CSCHED_FLAG_VCPU_PARKED flag before vcpu_wake(). This, in turn, causes the vcpu_wake to set CSCHED_PRI_TS_BOOST, resulting in an unfair credit boost. The comment around the changed lines already states that clearing the flag should happen AFTER the unpause. This bug was introduced in commit be650750945 "credit1: Use atomic bit operations for the flags structure".

Original patch author credit: Xi Xiong while at Amazon.

---
Changes in v2:
- Adjusted commit message, adding Xi's previous affiliation
- Dropped comment: /* Now clear the PARKED flag */
- Added Dario's A-b

---
 xen/common/sched_credit.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
xen/common/sched_credit.c +2 -1
index 3abe20def8..7b7facbace 100644
@@ -1538,7 +1538,7 @@ csched_acct(void* dummy)
                 svc->pri = CSCHED_PRI_TS_UNDER;
 
                 /* Unpark any capped domains whose credits go positive */
-                if ( test_and_clear_bit(CSCHED_FLAG_VCPU_PARKED, &svc->flags) )
+                if ( test_bit(CSCHED_FLAG_VCPU_PARKED, &svc->flags) )
                 {
                     /*
                      * It's important to unset the flag AFTER the unpause()
@@ -1547,6 +1547,7 @@ csched_acct(void* dummy)
                      */
                     SCHED_STAT_CRANK(vcpu_unpark);
                     vcpu_unpause(svc->vcpu);
+                    clear_bit(CSCHED_FLAG_VCPU_PARKED, &svc->flags);
                 }
 
                 /* Upper bound on credits means VCPU stops earning */
Signature · 7 lines
2.15.3.AMZN


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 7 lines · Eslam Elnikety

When unpausing a capped domain, the scheduler currently clears the CSCHED_FLAG_VCPU_PARKED flag before vcpu_wake(). This, in turn, causes the vcpu_wake to set CSCHED_PRI_TS_BOOST, resulting in an unfair credit boost. The comment around the changed lines already states that clearing the flag should happen AFTER the unpause. This bug was introduced in commit be650750945 "credit1: Use atomic bit operations for the flags structure".

Quoted 6 lines

Original patch author credit: Xi Xiong while at Amazon.

Pulled into x86-next.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel