mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	linux-kernel@vger.kernel.org,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
	Valentin Schneider <vschneid@redhat.com>,
	"Gautham R. Shenoy" <gautham.shenoy@amd.com>,
	Swapnil Sapkal <swapnil.sapkal@amd.com>
Subject: Re: [RFC PATCH 3/5] sched/fair: Update overloaded mask in presence of pushable task
Date: Mon, 21 Apr 2025 10:50:18 +0530	[thread overview]
Message-ID: <2dae733a-689c-4574-a4dc-f59f11fb0893@linux.ibm.com> (raw)
In-Reply-To: <20250409111539.23791-4-kprateek.nayak@amd.com>



On 4/9/25 16:45, K Prateek Nayak wrote:

Hi Prateek. Feel free to cc me in the future versions.
This seems interesting way if it can get us rid of newidle balance overheads.

> In presence of pushable tasks on the CPU, set it on the newly introduced
> "overloaded+mask" in sched_domain_shared struct. This will be used by
> the newidle balance to limit the scanning to these overloaded CPUs since
> they contain tasks that could be run on the newly idle target.
> 
> Signed-off-by: K Prateek Nayak <kprateek.nayak@amd.com>
> ---
>   kernel/sched/fair.c | 24 ++++++++++++++++++++++++
>   1 file changed, 24 insertions(+)
> 
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 98d3ed2078cd..834fcdd15cac 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -8559,6 +8559,24 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
>   	return target;
>   }
>   
> +static inline void update_overloaded_mask(int cpu, bool contains_pushable)
> +{
> +	struct sched_domain_shared *sd_share = rcu_dereference(per_cpu(sd_llc_shared, cpu));
> +	cpumask_var_t overloaded_mask;
> +
> +	if (!sd_share)
> +		return;
> +
> +	overloaded_mask = sd_share->overloaded_mask;
> +	if (!overloaded_mask)
> +		return;
> +
> +	if (contains_pushable)
> +		cpumask_set_cpu(cpu, overloaded_mask);
> +	else
> +		cpumask_clear_cpu(cpu, overloaded_mask);
> +}
> +

I was getting below error when compiling. Noticed that overloaded_mask is a local update and it wouldn't
update the actual overloaded_mask.

Compilation Error:
kernel/sched/fair.c: In function ‘update_overloaded_mask’:
kernel/sched/fair.c:8570:25: error: assignment to expression with array type
  8570 |         overloaded_mask = sd_share->overloaded_mask;
       |                         ^
kernel/sched/fair.c:8571:13: warning: the address of ‘overloaded_mask’ will always evaluate as ‘true’ [-Waddress]
  8571 |         if (!overloaded_mask)



Made the below change. Also you would need rcu protection for sd_share i think.

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index bca3db5d0ac0..818d4769ec55 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8562,19 +8562,18 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
  static inline void update_overloaded_mask(int cpu, bool contains_pushable)
  {
         struct sched_domain_shared *sd_share = rcu_dereference(per_cpu(sd_llc_shared, cpu));
-       cpumask_var_t overloaded_mask;
  
         if (!sd_share)
                 return;
  
-       overloaded_mask = sd_share->overloaded_mask;
-       if (!overloaded_mask)
+       if (!sd_share->overloaded_mask)
                 return;
  
+       guard(rcu)();
         if (contains_pushable)
-               cpumask_set_cpu(cpu, overloaded_mask);
+               cpumask_set_cpu(cpu, sd_share->overloaded_mask);
         else
-               cpumask_clear_cpu(cpu, overloaded_mask);
+               cpumask_clear_cpu(cpu, sd_share->overloaded_mask);
  }

>   static inline bool fair_push_task(struct task_struct *p)
>   {
>   	if (!task_on_rq_queued(p))
> @@ -8606,11 +8624,17 @@ static inline void fair_queue_pushable_tasks(struct rq *rq)
>   static void fair_remove_pushable_task(struct rq *rq, struct task_struct *p)
>   {
>   	plist_del(&p->pushable_tasks, &rq->cfs.pushable_tasks);
> +
> +	if (!has_pushable_tasks(rq))
> +		update_overloaded_mask(rq->cpu, false);
>   }
>   
>   static void fair_add_pushable_task(struct rq *rq, struct task_struct *p)
>   {
>   	if (fair_push_task(p)) {
> +		if (!has_pushable_tasks(rq))
> +			update_overloaded_mask(rq->cpu, true);
> +
>   		plist_del(&p->pushable_tasks, &rq->cfs.pushable_tasks);
>   		plist_node_init(&p->pushable_tasks, p->prio);
>   		plist_add(&p->pushable_tasks, &rq->cfs.pushable_tasks);


  parent reply	other threads:[~2025-04-21  5:20 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-09 11:15 [RFC PATCH 0/5] K Prateek Nayak
2025-04-09 11:15 ` [RFC PATCH 1/5] sched/fair: Add push task framework K Prateek Nayak
2025-04-10 10:00   ` Peter Zijlstra
2025-04-10 15:25     ` K Prateek Nayak
2025-04-09 11:15 ` [RFC PATCH 2/5] sched/fair: Introduce overloaded_mask in sched_domain_shared K Prateek Nayak
2025-04-10 10:03   ` Peter Zijlstra
2025-04-10 15:26     ` K Prateek Nayak
2025-04-09 11:15 ` [RFC PATCH 3/5] sched/fair: Update overloaded mask in presence of pushable task K Prateek Nayak
2025-04-14  2:28   ` Aaron Lu
2025-04-14  3:13     ` K Prateek Nayak
2025-04-21  5:20   ` Shrikanth Hegde [this message]
2025-04-21  5:54     ` K Prateek Nayak
2025-04-21  8:03       ` Shrikanth Hegde
2025-04-21  8:54         ` K Prateek Nayak
2025-04-09 11:15 ` [RFC PATCH 4/5] sched/fair: Rework inter-NUMA newidle balancing K Prateek Nayak
2025-04-10 10:14   ` Peter Zijlstra
2025-04-10 15:27     ` K Prateek Nayak
2025-04-09 11:15 ` [RFC PATCH 5/5] sched/fair: Proactive idle balance using push mechanism K Prateek Nayak
2025-04-10 10:29   ` Peter Zijlstra
2025-04-10 15:37     ` K Prateek Nayak
2025-04-09 11:17 ` [RFC PATCH 0/5] sched/fair: Idle and newidle balancing " 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=2dae733a-689c-4574-a4dc-f59f11fb0893@linux.ibm.com \
    --to=sshegde@linux.ibm.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=gautham.shenoy@amd.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=swapnil.sapkal@amd.com \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.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

all inboxes | Powered by JetHome®