linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chen Yu <yu.c.chen@intel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Vincent Guittot <vincent.guittot@linaro.org>,
	Tim Chen <tim.c.chen@intel.com>,
	Mel Gorman <mgorman@techsingularity.net>,
	Juri Lelli <juri.lelli@redhat.com>,
	Rik van Riel <riel@surriel.com>, Aaron Lu <aaron.lu@intel.com>,
	Abel Wu <wuyun.abel@bytedance.com>,
	K Prateek Nayak <kprateek.nayak@amd.com>,
	Yicong Yang <yangyicong@hisilicon.com>,
	"Gautham R . Shenoy" <gautham.shenoy@amd.com>,
	Ingo Molnar <mingo@redhat.com>,
	"Dietmar Eggemann" <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>,
	Daniel Bristot de Oliveira <bristot@redhat.com>,
	Valentin Schneider <vschneid@redhat.com>,
	Hillf Danton <hdanton@sina.com>,
	Honglei Wang <wanghonglei@didichuxing.com>,
	Len Brown <len.brown@intel.com>, Chen Yu <yu.chen.surf@gmail.com>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH v2 2/2] sched/fair: Choose the CPU where short task is running during wake up
Date: Fri, 4 Nov 2022 12:35:57 +0800	[thread overview]
Message-ID: <Y2SWraIliUCXHUth@chenyu5-mobl1> (raw)
In-Reply-To: <Y2O8a/Ohk1i1l8ao@hirez.programming.kicks-ass.net>

On 2022-11-03 at 14:04:43 +0100, Peter Zijlstra wrote:
> On Sun, Oct 23, 2022 at 11:33:39PM +0800, Chen Yu wrote:
> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> > index 8820d0d14519..3a8ee6232c59 100644
> > --- a/kernel/sched/fair.c
> > +++ b/kernel/sched/fair.c
> > @@ -6249,6 +6249,11 @@ wake_affine_idle(int this_cpu, int prev_cpu, int sync)
> >  	if (available_idle_cpu(prev_cpu))
> >  		return prev_cpu;
> >  
> > +	/* The only running task is a short duration one. */
> > +	if (cpu_rq(this_cpu)->nr_running == 1 &&
> > +	    is_short_task(cpu_curr(this_cpu)))
> > +		return this_cpu;
> > +
> >  	return nr_cpumask_bits;
> >  }
> 
> This is very close to using is_short_task() as dynamic WF_SYNC hint, no?
>
Yes. I think a short task waker is a subset of WF_SYNC wake up, because a short
task waker might go to sleep soon after wakeup the wakee.
> > @@ -6623,6 +6628,23 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, bool
> >  			/* overloaded LLC is unlikely to have idle cpu/core */
> >  			if (nr == 1)
> >  				return -1;
> > +
> > +			/*
> > +			 * If nr is smaller than 60% of llc_weight, it
> > +			 * indicates that the util_avg% is higher than 50%.
> > +			 * This is calculated by SIS_UTIL in
> > +			 * update_idle_cpu_scan(). The 50% util_avg indicates
> > +			 * a half-busy LLC domain. System busier than this
> > +			 * level could lower its bar to choose a compromised
> > +			 * "idle" CPU, so as to avoid the overhead of cross
> > +			 * CPU wakeup. If the task on target CPU is a short
> > +			 * duration one, and it is the only running task, pick
> > +			 * target directly.
> > +			 */
> > +			if (!has_idle_core && (5 * nr < 3 * sd->span_weight) &&
> > +			    cpu_rq(target)->nr_running == 1 &&
> > +			    is_short_task(cpu_curr(target)))
> > +				return target;
> >  		}
> >  	}
> 
> And here you're basically saying that if the domain is 'busy' and the
> task is short, don't spend time searching for a better location.
> 
> Should we perhaps only consider shortness; after all, spending more time
> searching for an idle cpu than the task would've taken to run is daft.
> Business of the domain seems unrelated to that.
I see, the this_sd->avg_scan_cost could be used for the comparison, I'll
have a try.
> 
> 
> Also, I'm not sure on your criteria for short; but I don't have enough
> thoughts on that yet.
Yes, the criteria to define a short task is arbitrary. If we compare the
avg_duration of a task with the sd->avg_scan_cost then we can skip the
defination of short task.

thanks,
Chenyu

  reply	other threads:[~2022-11-04  4:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-23 15:31 [RFC PATCH v2 0/2] sched/fair: Choose the CPU where short task is running during wake up Chen Yu
2022-10-23 15:32 ` [RFC PATCH v2 1/2] sched/fair: Introduce short duration task check Chen Yu
2022-10-24 10:10   ` Abel Wu
2022-10-25  5:16     ` Chen Yu
2022-11-03 12:44   ` Peter Zijlstra
2022-11-04  4:09     ` Chen Yu
2022-10-23 15:33 ` [RFC PATCH v2 2/2] sched/fair: Choose the CPU where short task is running during wake up Chen Yu
2022-11-02  8:18   ` kernel test robot
2022-11-03 13:04   ` Peter Zijlstra
2022-11-04  4:35     ` Chen Yu [this message]
2022-11-22 10:31 ` [RFC PATCH v2 0/2] " K Prateek Nayak
2022-11-30  4:03   ` Chen Yu
2022-12-02  3:21     ` K Prateek Nayak

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=Y2SWraIliUCXHUth@chenyu5-mobl1 \
    --to=yu.c.chen@intel.com \
    --cc=aaron.lu@intel.com \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=gautham.shenoy@amd.com \
    --cc=hdanton@sina.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@techsingularity.net \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=riel@surriel.com \
    --cc=rostedt@goodmis.org \
    --cc=tim.c.chen@intel.com \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=wanghonglei@didichuxing.com \
    --cc=wuyun.abel@bytedance.com \
    --cc=yangyicong@hisilicon.com \
    --cc=yu.chen.surf@gmail.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;
as well as URLs for NNTP newsgroup(s).