The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Chengming Zhou <zhouchengming@bytedance.com>
Cc: vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	mingo@redhat.com, rostedt@goodmis.org, bsegall@google.com,
	vschneid@redhat.com, linux-kernel@vger.kernel.org, tj@kernel.org
Subject: Re: [PATCH v5 7/9] sched/fair: allow changing cgroup of new forked task
Date: Thu, 18 Aug 2022 12:36:21 +0200	[thread overview]
Message-ID: <Yv4WJQAGw0zgU3nH@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <20220818034343.87625-8-zhouchengming@bytedance.com>

On Thu, Aug 18, 2022 at 11:43:41AM +0800, Chengming Zhou wrote:

> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 8e3f1c3f0b2c..157f7461a08a 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -4550,11 +4550,11 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p)
>  {
>  	__sched_fork(clone_flags, p);
>  	/*
> -	 * We mark the process as NEW here. This guarantees that
> +	 * We mark the process as running here. This guarantees that
>  	 * nobody will actually run it, and a signal or other external
>  	 * event cannot wake it up and insert it on the runqueue either.
>  	 */
> -	p->__state = TASK_NEW;
> +	p->__state = TASK_RUNNING;
>  
>  	/*
>  	 * Make sure we do not leak PI boosting priority to the child.
> @@ -4672,7 +4672,6 @@ void wake_up_new_task(struct task_struct *p)
>  	struct rq *rq;
>  
>  	raw_spin_lock_irqsave(&p->pi_lock, rf.flags);
> -	WRITE_ONCE(p->__state, TASK_RUNNING);
>  #ifdef CONFIG_SMP
>  	/*
>  	 * Fork balancing, do it here and not earlier because:
> @@ -10290,36 +10289,19 @@ static void cpu_cgroup_css_free(struct cgroup_subsys_state *css)
>  	sched_unregister_group(tg);
>  }

> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index eba8a64f905a..e0d34ecdabae 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -11840,6 +11840,13 @@ void init_cfs_rq(struct cfs_rq *cfs_rq)
>  #ifdef CONFIG_FAIR_GROUP_SCHED
>  static void task_change_group_fair(struct task_struct *p)
>  {
> +	/*
> +	 * We couldn't detach or attach a forked task which
> +	 * hasn't been woken up by wake_up_new_task().
> +	 */
> +	if (!p->on_rq && !p->se.sum_exec_runtime)
> +		return;
> +
>  	detach_task_cfs_rq(p);

Wouldn't that be much clearer when expressed in TASK_NEW ?

  reply	other threads:[~2022-08-18 10:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-18  3:43 [PATCH v5 0/9] sched/fair: task load tracking optimization and cleanup Chengming Zhou
2022-08-18  3:43 ` [PATCH v5 1/9] sched/fair: maintain task se depth in set_task_rq() Chengming Zhou
2022-08-18  3:43 ` [PATCH v5 2/9] sched/fair: remove redundant cpu_cgrp_subsys->fork() Chengming Zhou
2022-08-18  3:43 ` [PATCH v5 3/9] sched/fair: reset sched_avg last_update_time before set_task_rq() Chengming Zhou
2022-08-18  3:43 ` [PATCH v5 4/9] sched/fair: update comments in enqueue/dequeue_entity() Chengming Zhou
2022-08-18  3:43 ` [PATCH v5 5/9] sched/fair: combine detach into dequeue when migrating task Chengming Zhou
2022-08-18  3:43 ` [PATCH v5 6/9] sched/fair: fix another detach on unattached task corner case Chengming Zhou
2022-08-18  3:43 ` [PATCH v5 7/9] sched/fair: allow changing cgroup of new forked task Chengming Zhou
2022-08-18 10:36   ` Peter Zijlstra [this message]
2022-08-18 10:48     ` Chengming Zhou
2022-08-18  3:43 ` [PATCH v5 8/9] sched/fair: defer task sched_avg attach to enqueue_entity() Chengming Zhou
2022-08-18 10:39   ` Peter Zijlstra
2022-08-18 11:03     ` Chengming Zhou
2022-08-18  3:43 ` [PATCH v5 9/9] sched/fair: don't init util/runnable_avg for !fair task Chengming 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=Yv4WJQAGw0zgU3nH@worktop.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=tj@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=zhouchengming@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