mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Valentin Schneider <vschneid@redhat.com>
To: Tianchen Ding <dtcccc@linux.alibaba.com>
Cc: Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Daniel Bristot de Oliveira <bristot@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] sched: Queue task on wakelist in the same llc if the wakee cpu is idle
Date: Tue, 31 May 2022 12:50:49 +0100	[thread overview]
Message-ID: <xhsmhilpl9azq.mognet@vschneid.remote.csb> (raw)
In-Reply-To: <1d0eb8f4-e474-86a9-751a-7c2e1788df85@linux.alibaba.com>

On 31/05/22 15:20, Tianchen Ding wrote:
> On 2022/5/31 00:24, Valentin Schneider wrote:
>> 
>> This feels a bit like a generalization of
>> 
>>    2ebb17717550 ("sched/core: Offload wakee task activation if it the wakee is descheduling")
>> 
>> Given rq->curr is updated before prev->on_cpu is cleared, the waker
>> executing ttwu_queue_cond() can observe:
>> 
>>    p->on_rq=0
>>    p->on_cpu=1
>>    rq->curr=swapper/x (aka idle task)
>> 
>> So your addition of available_idle_cpu() in ttwu_queue_cond() (sort of)
>> matches that when invoked via:
>> 
>>          if (smp_load_acquire(&p->on_cpu) &&
>>              ttwu_queue_wakelist(p, task_cpu(p), wake_flags | WF_ON_CPU))
>>                  goto unlock;
>> 
>> but it also affects
>> 
>>          ttwu_queue(p, cpu, wake_flags);
>> 
>> at the tail end of try_to_wake_up().
>
> Yes. This part is what we mainly want to affect. The above WF_ON_CPU is 
> not our point.
>

Right.

>> 
>> With all that in mind, I'm curious whether your patch is functionaly close
>> to the below.
>> 
>> ---
>> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
>> index 66c4e5922fe1..ffd43264722a 100644
>> --- a/kernel/sched/core.c
>> +++ b/kernel/sched/core.c
>> @@ -3836,7 +3836,7 @@ static inline bool ttwu_queue_cond(int cpu, int wake_flags)
>>   	 * the soon-to-be-idle CPU as the current CPU is likely busy.
>>   	 * nr_running is checked to avoid unnecessary task stacking.
>>   	 */
>> -	if ((wake_flags & WF_ON_CPU) && cpu_rq(cpu)->nr_running <= 1)
>> +	if (cpu_rq(cpu)->nr_running <= 1)
>>   		return true;
>>   
>>   	return false;
>
> It's a little different. This may bring extra IPIs when nr_running == 1 
> and the current task on wakee cpu is not the target wakeup task (i.e., 
> rq->curr == another_task && rq->curr != p). Then this another_task may 
> be disturbed by IPI which is not expected. So IMO the promise by 
> WF_ON_CPU is necessary.

You're right, actually taking a second look at that WF_ON_CPU path,
shouldn't the existing condition be:

	if ((wake_flags & WF_ON_CPU) && !cpu_rq(cpu)->nr_running)

? Per the p->on_rq and p->on_cpu ordering, if we have WF_ON_CPU here then
we must have !p->on_rq, so the deactivate has happened, thus the task
being alone on the rq implies nr_running==0.

@Mel, do you remember why you went for <=1 here? I couldn't find any clues
on the original posting.


  reply	other threads:[~2022-05-31 11:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-27  9:05 Tianchen Ding
2022-05-30 16:24 ` Valentin Schneider
2022-05-31  7:20   ` Tianchen Ding
2022-05-31 11:50     ` Valentin Schneider [this message]
2022-05-31 13:55       ` Mel Gorman
2022-05-31 15:38         ` Tianchen Ding
2022-05-31 15:56         ` Valentin Schneider
2022-06-01  5:54           ` Tianchen Ding
2022-06-01 10:58             ` Valentin Schneider
2022-06-01 12:02               ` Tianchen Ding

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=xhsmhilpl9azq.mognet@vschneid.remote.csb \
    --to=vschneid@redhat.com \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=dtcccc@linux.alibaba.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 \
    /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®