All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Haifeng Xu <haifeng.xu@shopee.com>
Cc: peterz@infradead.org, mingo@redhat.com,
	vincent.guittot@linaro.org, juri.lelli@redhat.com,
	dietmar.eggemann@arm.com, rostedt@goodmis.org,
	bsegall@google.com, mgorman@suse.de, bristot@redhat.com,
	vschneid@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched: Filter root_task_group at the beginning
Date: Thu, 28 Sep 2023 23:03:17 +0200	[thread overview]
Message-ID: <ZRXqFScg/vORHoqw@gmail.com> (raw)
In-Reply-To: <20230922094336.394865-1-haifeng.xu@shopee.com>


* Haifeng Xu <haifeng.xu@shopee.com> wrote:

> We can't change the weight of the root cgroup. Let's handle
> root_task_group before doing any real work including acquiring
> the shares_mutex.
> 
> Signed-off-by: Haifeng Xu <haifeng.xu@shopee.com>
> ---
>  kernel/sched/fair.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index a80a73909dc2..1ac2df87e070 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -12594,6 +12594,9 @@ int sched_group_set_shares(struct task_group *tg, unsigned long shares)
>  {
>  	int ret;
>  
> +	if (tg == &root_task_group)
> +		return -EINVAL;
> +
>  	mutex_lock(&shares_mutex);
>  	if (tg_is_idle(tg))
>  		ret = -EINVAL;

So what's the motivation, how common is this case? 

Normally this should be a -EINVAL error code path, which sane user-space
presumably never conscisously tries to call in that fashion, right?

It's not worth optimizing pathological cases, especially
since we check for the root CG inside __sched_group_set_shares()
already:

        /*
         * We can't change the weight of the root cgroup.
         */
        if (!tg->se[0])
                return -EINVAL;


Thanks,

	Ingo

  reply	other threads:[~2023-09-28 21:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-22  9:43 [PATCH] sched: Filter root_task_group at the beginning Haifeng Xu
2023-09-28 21:03 ` Ingo Molnar [this message]
2023-09-29 11:56   ` Haifeng Xu

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=ZRXqFScg/vORHoqw@gmail.com \
    --to=mingo@kernel.org \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=haifeng.xu@shopee.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 \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.