mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: QiaoChong <qiaochong@loongson.cn>
Cc: Ingo Molnar <mingo@redhat.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched/fair: update_curr changed sum_exec_runtime to 1 when sum_exec_runtime is 0 beacuse some kernel code use sum_exec_runtime==0 to test task just be forked.
Date: Tue, 27 Aug 2019 16:36:32 +0200	[thread overview]
Message-ID: <20190827143632.GF2332@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20190826114650.10948-1-qiaochong@loongson.cn>

On Mon, Aug 26, 2019 at 07:46:50PM +0800, QiaoChong wrote:
> From: Chong Qiao <qiaochong@loongson.cn>
> 
> Such as:
> cpu_cgroup_attach>
>  sched_move_task>
>   task_change_group_fair>
>    task_move_group_fair>
>     detach_task_cfs_rq>
>      vruntime_normalized>
> 
> 	/*
> 	 * When !on_rq, vruntime of the task has usually NOT been normalized.
> 	 * But there are some cases where it has already been normalized:
> 	 *
> 	 * - A forked child which is waiting for being woken up by
> 	 *   wake_up_new_task().
> 	 * - A task which has been woken up by try_to_wake_up() and
> 	 *   waiting for actually being woken up by sched_ttwu_pending().
> 	 */
> 	if (!se->sum_exec_runtime ||
> 	    (p->state == TASK_WAKING && p->sched_remote_wakeup))
> 		return true;
> 
> p->se.sum_exec_runtime is 0, does not mean task not been run (A forked child which is waiting for being woken up by  wake_up_new_task()).
> 
> Task may have been scheduled multimes, but p->se.sum_exec_runtime is still 0, because delta_exec maybe 0 in update_curr.
> 
> static void update_curr(struct cfs_rq *cfs_rq)
> {
> ...
> 	delta_exec = now - curr->exec_start;
> 	if (unlikely((s64)delta_exec <= 0))
> 		return;
> ...
> 
> 	curr->sum_exec_runtime += delta_exec;
> ...
> }
> 
> Task has been run and is stopped(on_rq == 0), vruntime not been normalized, but se->sum_exec_runtime == 0.
> This cause vruntime_normalized set on_rq 1, and does not normalize vruntime.
> This may cause task use old vruntime in old cgroup, which maybe very large than task's vruntime in new cgroup.
> Which may cause task may not scheduled in run queue for long time after been waked up.
> 
> Now I change sum_exec_runtime to 1 when sum_exec_runtime == 0 in update_curr to make sun_exec_runtime not 0.

Have you actually observed this? It is very hard to have a 0 delta
between two scheduling events.

  reply	other threads:[~2019-08-27 14:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-26 11:46 QiaoChong
2019-08-27 14:36 ` Peter Zijlstra [this message]
2019-08-28  5:02   ` 乔崇

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=20190827143632.GF2332@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=qiaochong@loongson.cn \
    /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

all inboxes | Powered by JetHome®