xen: credit2: clear bit instead of skip step in runq_tickle()
PATCH 1/1 xen: credit2: clear bit instead of skip step in runq_tickle()
Since we are doing cpumask manipulation already, clear a bit in the mask at once. Doing that will save us an if, later in the code.
No functional change intended.
---
Cc: George Dunlap <[email protected]>
--- xen/common/sched_credit2.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
xen/common/sched_credit2.c +2 -3
@@ -985,7 +985,7 @@ runq_tickle(const struct scheduler *ops, struct csched2_vcpu *new, s_time_t now)cpumask_andnot (&mask, &rqd->active, &rqd->idle);cpumask_andnot (&mask, &mask, &rqd->tickled);cpumask_and (&mask, &mask, new->vcpu->cpu_hard_affinity); -if (cpumask_test_cpu (cpu, &mask) ) +if (__cpumask_test_and_clear_cpu (cpu, &mask) ) { cur =CSCHED2_VCPU (curr_on_cpu (cpu));burn_credits (rqd, cur, now);
@@ -1001,8 +1001,7 @@ runq_tickle(const struct scheduler *ops, struct csched2_vcpu *new, s_time_t now)for_each_cpu (i, &mask) {/* Already looked at this one above */ -if ( i == cpu ) -continue ; +ASSERT (i != cpu); cur =CSCHED2_VCPU (curr_on_cpu (i));
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 18 lines · Dario Faggioli
Since we are doing cpumask manipulation already, clear a bit in the mask at once. Doing that will save us an if, later in the code.
No functional change intended.
Signed-off-by Dario Faggioli <[email protected]>---
Cc: George Dunlap <[email protected]>--- xen/common/sched_credit2.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)xen/common/sched_credit2.c +0
-0
xen/common/sched_credit2.c runq_tickle(const struct scheduler *ops, struct csched2_vcpu *new, s_time_t now) · line 988
Quoted 5 lines
xen/common/sched_credit2.c +1
-1@@ -985,7 +985,7 @@ runq_tickle(const struct scheduler *ops, struct csched2_vcpu *new, s_time_t now)cpumask_andnot (&mask, &rqd->active, &rqd->idle);cpumask_andnot (&mask, &mask, &rqd->tickled);cpumask_and (&mask, &mask, new->vcpu->cpu_hard_affinity); -if (cpumask_test_cpu (cpu, &mask) ) +if (__cpumask_test_and_clear_cpu (cpu, &mask) )
Since we're micro-optimizing -- isn't test-and-clear a locked operation?
Would that be more expensive than the if() statement below?
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 18.01.17 at 11:21, <[email protected]> wrote:
xen/common/sched_credit2.c runq_tickle(const struct scheduler *ops, struct csched2_vcpu *new, s_time_t now) · line 988
Quoted 9 lines · Dario Faggioli
index ef8e0d8..d086264 100644
xen/common/sched_credit2.c +1
-1@@ -985,7 +985,7 @@ runq_tickle(const struct scheduler *ops, struct csched2_vcpu *new, s_time_t now)cpumask_andnot (&mask, &rqd->active, &rqd->idle);cpumask_andnot (&mask, &mask, &rqd->tickled);cpumask_and (&mask, &mask, new->vcpu->cpu_hard_affinity); -if (cpumask_test_cpu (cpu, &mask) ) +if (__cpumask_test_and_clear_cpu (cpu, &mask) )Since we're micro-optimizing -- isn't test-and-clear a locked operation?
Would that be more expensive than theif()statement below?
cpumask_test_and_clear_cpu() is, but __cpumask_test_and_clear_cpu() isn't.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 17 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 18.01.17 at 11:21, <[email protected]> wrote:
xen/common/sched_credit2.c runq_tickle(const struct scheduler *ops, · line 989
Quoted 10 lines · Dario Faggioli
xen/common/sched_credit2.c +1
-1@@ -985,7 +985,7 @@ runq_tickle(const struct scheduler *ops, struct csched2_vcpu *new, s_time_t now) cpumask_andnot(&mask, &rqd->active, &rqd->idle); cpumask_andnot(&mask, &mask, &rqd->tickled); cpumask_and(&mask, &mask, new->vcpu->cpu_hard_affinity); - if ( cpumask_test_cpu(cpu, &mask) ) + if ( __cpumask_test_and_clear_cpu(cpu, &mask) )Since we're micro-optimizing -- isn't test-and-clear a locked operation?
Would that be more expensive than theif()statement below?
Quoted 3 lines
cpumask_test_and_clear_cpu()is, but__cpumask_test_and_clear_cpu()isn't.
As Jan said.
And, FWIW, I personally like how the code looks after this patch better, even leaving aside performance.
I find it cleaner (probably because dislike 'continue'), and more in line with what we do in the rest of the file.
Thanks and Regadrs,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 17 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 18.01.17 at 11:21, <[email protected]> wrote:
xen/common/sched_credit2.c runq_tickle(const struct scheduler *ops, · line 989
Quoted 10 lines · Dario Faggioli
index ef8e0d8..d086264 100644
xen/common/sched_credit2.c +1
-1@@ -985,7 +985,7 @@ runq_tickle(const struct scheduler *ops, struct csched2_vcpu *new, s_time_t now) cpumask_andnot(&mask, &rqd->active, &rqd->idle); cpumask_andnot(&mask, &mask, &rqd->tickled); cpumask_and(&mask, &mask, new->vcpu->cpu_hard_affinity); - if ( cpumask_test_cpu(cpu, &mask) ) + if ( __cpumask_test_and_clear_cpu(cpu, &mask) )Since we're micro-optimizing -- isn't test-and-clear a locked operation?
Would that be more expensive than theif()statement below?
Quoted 3 lines
cpumask_test_and_clear_cpu()is, but__cpumask_test_and_clear_cpu()isn't.
George, ping?
Thanks and Regards,
Dario
Signature · 4 lines
<<This happens because I choose it to happen!>> (Raistlin Majere) ----------------------------------------------------------------- Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Quoted 18 lines · Dario Faggioli
Quoted 17 lines · Jan Beulich
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 18.01.17 at 11:21, <[email protected]> wrote:
xen/common/sched_credit2.c runq_tickle(const struct scheduler *ops, · line 989
Quoted 10 lines · Dario Faggioli
index ef8e0d8..d086264 100644
xen/common/sched_credit2.c +1
-1@@ -985,7 +985,7 @@ runq_tickle(const struct scheduler *ops, struct csched2_vcpu *new, s_time_t now) cpumask_andnot(&mask, &rqd->active, &rqd->idle);cpumask_andnot (&mask, &mask, &rqd->tickled);cpumask_and (&mask, &mask, new->vcpu->cpu_hard_affinity); -if (cpumask_test_cpu (cpu, &mask) ) +if (__cpumask_test_and_clear_cpu (cpu, &mask) )Since we're micro-optimizing -- isn't test-and-clear a locked operation?
Would that be more expensive than theif()statement below?
Quoted 4 lines
Quoted 3 lines
cpumask_test_and_clear_cpu()is, but__cpumask_test_and_clear_cpu()isn't.George, ping?
Yes, this looks fine then. But it didn't apply cleanly when I tried to apply it -- please re-send it with the other patches you have outstanding.
Thanks.
-George
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel