sched: Dec __cfs_bandwith_used in destroy_cfs_bandwidth()
Quoted 33 lines · Zhang Qiao
Quoted 6 lines
__cfs_bandwith_uesdis astatic_keyto control cfs bandwidth feature. When adding acfs_bandwidthgroup, we need increase the key, and decrease it when removing. But currently when we remove acfs_bandwidthgroup, we don't decrease the key and this switch will always be on even if there is no cfs bandwidth group in the system.Yep, that's broken.
Quoted 14 lines
Therefore, when removing a cfs bandwidth group, we decrease
__cfs_bandwith_usedby callingcfs_bandwidth_usage_dec().Fixes 56f570e512ee ("sched: use jump labels to reduce overhead when bandwidth control is inactive")Signed-off-by Zhang Qiao <[email protected]>--- kernel/sched/fair.c | 3 +++ 1 file changed, 3 insertions(+)kernel/sched/fair.c +0
-0kernel/sched/fair.c static void destroy_cfs_bandwidth(struct cfs_bandwidth *cfs_b) · line 5348
Quoted 5 lines
kernel/sched/fair.c +2
-0@@ -5344,6 +5344,9 @@ static void destroy_cfs_bandwidth(struct cfs_bandwidth *cfs_b)if (!cfs_b->throttled_cfs_rq.next)return ; +if (cfs_b->quota !=RUNTIME_INF ) +cfs_bandwidth_usage_dec ();This calls
static_key_slow_dec_cpuslocked, butdestroy_cfs_bandwidthisn't holding the hotplug lock.
Quoted 4 lines
The other caller of
cfs_bandwidth_usage_decneeds to hold it for another reason, so what about having bothcfs_bandwidth_usage_dec()andcfs_bandwidth_usage_dec_cpuslocked()? In that case, the_incone could be renamed similarly so this isn't a stumbling block later on.
Hi Jordan, thanks for your comments.It is valuable to me.
And i have another thought is that we can hold the hotplug lock before calling cfs_bandwidth_usage_dec(). This way, fewer modifications are involved. What do you think about it?
thanks.
Quoted 8 lines
Quoted 8 lines
kernel/sched/fair.c +1
-0+hrtimer_cancel (&cfs_b->period_timer);hrtimer_cancel (&cfs_b->slack_timer); }Signature · 1 line
2.18.0.huawei.25
Quoted 4 lines · Zhang Qiao
And i have another thought is that we can hold the hotplug lock before calling
cfs_bandwidth_usage_dec(). This way, fewer modifications are involved. What do you think about it?
It is fewer lines, but then hotplug lock is taken pointlessly for !JUMP_LABEL. Not a huge deal in a slow path like this, just a bit lame. Adding a new variant seems cleaner if more verbose.
Quoted 9 lines · Daniel Jordan
Quoted 4 lines · Zhang Qiao
And i have another thought is that we can hold the hotplug lock before calling
cfs_bandwidth_usage_dec(). This way, fewer modifications are involved. What do you think about it?It is fewer lines, but then hotplug lock is taken pointlessly for !JUMP_LABEL. Not a huge deal in a slow path like this, just a bit lame. Adding a new variant seems cleaner if more verbose.
make sense. And I will modify in next version.
thanks.
Quoted 2 lines
.