public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Zhang Qiao <zhangqiao22@huawei.com>
To: Chuyi Zhou <zhouchuyi@bytedance.com>, <mingo@redhat.com>,
	<peterz@infradead.org>, <juri.lelli@redhat.com>,
	<vincent.guittot@linaro.org>, <dietmar.eggemann@arm.com>,
	<rostedt@goodmis.org>, <bsegall@google.com>, <mgorman@suse.de>,
	<vschneid@redhat.com>
Cc: <chengming.zhou@linux.dev>, <linux-kernel@vger.kernel.org>,
	<joshdon@google.com>
Subject: Re: [PATCH 1/2] sched/fair: Decrease cfs bandwidth usage in task_group destruction
Date: Mon, 22 Jul 2024 11:47:01 +0800	[thread overview]
Message-ID: <91e88019-52f7-4fa6-a14b-ca5ecb8e63cf@huawei.com> (raw)
In-Reply-To: <20240721125208.5348-2-zhouchuyi@bytedance.com>



Hi, Chuyi

在 2024/7/21 20:52, Chuyi Zhou 写道:
> The static key __cfs_bandwidth_used is used to indicate whether bandwidth
> control is enabled in the system. Currently, it is only decreased when a
> task group disables bandwidth control. This is incorrect because if there
> was a task group in the past that enabled bandwidth control, the
> __cfs_bandwidth_used will never go to zero, even if there are no task_group
> using bandwidth control now.
> 
> This patch tries to fix this issue by decrsasing bandwidth usage in
> destroy_cfs_bandwidth().
> 
> Signed-off-by: Chuyi Zhou <zhouchuyi@bytedance.com>
> ---
>  kernel/sched/fair.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index b1e07ce90284..7ad50dc31a93 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -6447,6 +6447,9 @@ static void destroy_cfs_bandwidth(struct cfs_bandwidth *cfs_b)
>  	hrtimer_cancel(&cfs_b->period_timer);
>  	hrtimer_cancel(&cfs_b->slack_timer);
>  
> +	if (cfs_b->quota != RUNTIME_INF)
> +		cfs_bandwidth_usage_dec();

This calls static_key_slow_dec_cpuslocked, but destroy_cfs_bandwidth
isn't holding the hotplug lock [1].

For fixing this issue, i also sent a patch, but it be not merged into mainline [2].

[1]: https://lore.kernel.org/all/20210712162655.w3j6uczwbfkzazvt@oracle.com/
[2]: https://lore.kernel.org/all/20210910094139.184582-1-zhangqiao22@huawei.com/

Thanks,

-- 
Qiao Zhang.

> +
>  	/*
>  	 * It is possible that we still have some cfs_rq's pending on a CSD
>  	 * list, though this race is very rare. In order for this to occur, we

  reply	other threads:[~2024-07-22  3:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-21 12:52 [PATCH 0/2] minor cpu bandwidth control fix Chuyi Zhou
2024-07-21 12:52 ` [PATCH 1/2] sched/fair: Decrease cfs bandwidth usage in task_group destruction Chuyi Zhou
2024-07-22  3:47   ` Zhang Qiao [this message]
2024-07-22  6:04     ` Chuyi Zhou
2024-07-22  7:16       ` Zhang Qiao
2024-07-22  7:46         ` Chuyi Zhou
2024-07-22  8:16           ` Zhang Qiao
2024-07-22 22:20             ` Benjamin Segall
2024-07-21 12:52 ` [PATCH 2/2] sched/core: Avoid unnecessary update in tg_set_cfs_bandwidth Chuyi Zhou
2024-07-22  7:21   ` Chengming Zhou
2024-07-22 22:24   ` Benjamin Segall
2024-07-23  2:34     ` Chuyi Zhou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=91e88019-52f7-4fa6-a14b-ca5ecb8e63cf@huawei.com \
    --to=zhangqiao22@huawei.com \
    --cc=bsegall@google.com \
    --cc=chengming.zhou@linux.dev \
    --cc=dietmar.eggemann@arm.com \
    --cc=joshdon@google.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=zhouchuyi@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox