Skip to contentSkip to conversation

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

PATCH Superseded Eslam Elnikety 3 participants 4 messages May 3, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

---
 xen/common/sched_credit.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
xen/common/sched_credit.c +3 -1
index 3abe20def8..8eb1aba12a 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,8 @@ csched_acct(void* dummy)
                      */
                     SCHED_STAT_CRANK(vcpu_unpark);
                     vcpu_unpause(svc->vcpu);
+                    /* Now clear the PARKED flag */
+                    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
Acked-by on v1 1/1
#1 lore raw
Quoted 11 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 2 lines

Original patch author credit: Xi Xiong.

Mmm... I'm not an expert of these things, but doesn't this means we need a "Signed-off-by: Xi Xiong <[email protected]>" then? Cc-ing Lars...

Quoted 4 lines

About the patch itself:

With just one suggestion...

Quoted 16 lines
xen/common/sched_credit.c +0 -0
@@ -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()

xen/common/sched_credit.c csched_acct(void* dummy) · line 1552

Quoted 6 lines
xen/common/sched_credit.c +2 -0
@@ -1547,6 +1547,8 @@ csched_acct(void* dummy)
                      */
                     SCHED_STAT_CRANK(vcpu_unpark);
                     vcpu_unpause(svc->vcpu);
+                    /* Now clear the PARKED flag */
+                    clear_bit(CSCHED_FLAG_VCPU_PARKED, &svc->flags);
 

I don't think adding the comment here is necessary. The one which is already present, explains things well enough, and this one does not add much.

Acked-by stands anyway, but I'd prefer it to be removed (which I think could be done when committing the patch?).

Regards

Signature · 6 lines
Dario Faggioli, Ph.D
http://about.me/dario.faggioli
Virtualization Software Engineer
SUSE Labs, SUSE https://www.suse.com/
-------------------------------------------------------------------
<<This happens because _I_ choose it to happen!>> (Raistlin Majere)

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

#2 lore raw
Quoted 16 lines · Dario Faggioli
Quoted 11 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 4 lines
Quoted 2 lines

Original patch author credit: Xi Xiong.

Mmm... I'm not an expert of these things, but doesn't this means we need a "Signed-off-by: Xi Xiong <[email protected]>" then? Cc-ing Lars...

As far as I can tell from a quick search on xen-devel@ Xi Xiong is or was an Amazon employee so a signed-off-by is not strictly necessary but you may want to say something like.

Original patch author credit: Xi Xiong of Amazon

Lars

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

#3 lore raw

On 3. May 2019, at 20:56, Lars Kurth <[email protected]<mailto:[email protected]>> wrote:

On 3 May 2019, at 10:48, Dario Faggioli <[email protected]<mailto:[email protected]>> wrote:

On Fri, 2019-05-03 at 15:38 +0000, Eslam Elnikety wrote:
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.

Mmm... I'm not an expert of these things, but doesn't this means we
need a "Signed-off-by: Xi Xiong <[email protected]<mailto:[email protected]>>" then? Cc-ing Lars...

As far as I can tell from a quick search on xen-devel@ Xi Xiong is or was an Amazon employee so a signed-off-by is not strictly necessary but you may want to say something like.

Original patch author credit: Xi Xiong of Amazon

Lars

Thanks for the prompt responses, Lars and Dario.

Indeed. Xi was with Amazon. I will adjust the commit message accordingly. (I will also omit the additional comment as pointed out by Dario).

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