public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Valentin Schneider <valentin.schneider@arm.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Chen Yu <yu.c.chen@intel.com>,
	linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>
Subject: Re: [PATCH 2/2] sched: Extract the task putting code from pick_next_task()
Date: Mon, 20 Apr 2020 23:55:21 +0100	[thread overview]
Message-ID: <jhjwo69lqcm.mognet@arm.com> (raw)
In-Reply-To: <20200420183232.16b83374@gandalf.local.home>


(There's a v2 at cover.1587393807.git.yu.c.chen@intel.com but I think this
still applies)

On 20/04/20 23:32, Steven Rostedt wrote:
>> @@ -3904,6 +3904,28 @@ static inline void schedule_debug(struct task_struct *prev, bool preempt)
>>      schedstat_inc(this_rq()->sched_count);
>>  }
>>
>> +static void finish_prev_task(struct rq *rq, struct task_struct *prev,
>> +			     struct rq_flags *rf)
>> +{
>> +	const struct sched_class *class;
>> +#ifdef CONFIG_SMP
>> +	/*
>> +	 * We must do the balancing pass before put_next_task(), such
>
> I know this is just a cut and paste move, but I'm thinking that this
> comment is wrong. Shouldn't this be "put_prev_task()" as we have no
> "put_next_task()" function.
>

Oh, I think you're right.

>
>> +	 * that when we release the rq->lock the task is in the same
>> +	 * state as before we took rq->lock.
>> +	 *
>> +	 * We can terminate the balance pass as soon as we know there is
>> +	 * a runnable task of @class priority or higher.
>> +	 */
>> +	for_class_range(class, prev->sched_class, &idle_sched_class) {
>> +		if (class->balance(rq, prev, rf))
>> +			break;
>> +	}
>> +#endif
>> +
>> +	put_prev_task(rq, prev);
>> +}
>> +
>>  /*
>>   * Pick up the highest-prio task:
>>   */
>> @@ -3937,22 +3959,7 @@ pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
>>      }
>>
>>  restart:
>> -#ifdef CONFIG_SMP
>> -	/*
>> -	 * We must do the balancing pass before put_next_task(), such
>> -	 * that when we release the rq->lock the task is in the same
>> -	 * state as before we took rq->lock.
>> -	 *
>> -	 * We can terminate the balance pass as soon as we know there is
>> -	 * a runnable task of @class priority or higher.
>> -	 */
>> -	for_class_range(class, prev->sched_class, &idle_sched_class) {
>> -		if (class->balance(rq, prev, rf))
>> -			break;
>> -	}
>> -#endif
>> -
>> -	put_prev_task(rq, prev);
>> +	finish_prev_task(rq, prev, rf);
>
> I'm not sure I like the name of this function. Perhaps
> "balance_and_put_prev_task()"? Something more in kind to what the function
> does.
>

The 'finish' thing isn't too far from the truth; it's the last thing we
need to do with the prev task (in terms of sched bookkeeping, I mean) -
and in Chen's defence ISTR Peter suggested that name.

Seeing as it's a "supercharged" put_prev_task(), I could live with the
marginally shorter "put_prev_task_balance()".

> -- Steve
>
>>
>>      for_each_class(class) {
>>              p = class->pick_next_task(rq);

  reply	other threads:[~2020-04-20 22:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-19 16:31 [PATCH 0/2] sched: Clean up newidle_balance() and pick_next_task() Chen Yu
2020-04-19 16:31 ` [PATCH 1/2] sched: Make newidle_balance() static again Chen Yu
2020-04-19 16:31 ` [PATCH 2/2] sched: Extract the task putting code from pick_next_task() Chen Yu
2020-04-20 22:32   ` Steven Rostedt
2020-04-20 22:55     ` Valentin Schneider [this message]
2020-04-20 23:13       ` Peter Zijlstra
2020-04-21  2:23         ` Steven Rostedt
2020-04-21  7:42           ` Vincent Guittot
2020-04-21  8:38             ` Chen Yu
2020-04-21  8:28     ` Chen Yu

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=jhjwo69lqcm.mognet@arm.com \
    --to=valentin.schneider@arm.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.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=yu.c.chen@intel.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