public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: K Prateek Nayak <kprateek.nayak@amd.com>
To: Shrikanth Hegde <sshegde@linux.ibm.com>
Cc: 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>,
	Chen Yu <yu.c.chen@intel.com>,
	"Gautham R. Shenoy" <gautham.shenoy@amd.com>,
	"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>
Subject: Re: [PATCH v3 8/8] sched/fair: Simplify SIS_UTIL handling in select_idle_cpu()
Date: Fri, 23 Jan 2026 11:57:28 +0530	[thread overview]
Message-ID: <00a09fd8-6ed7-4ebf-a146-d054e98cc45b@amd.com> (raw)
In-Reply-To: <3017c721-e4cc-4c6a-b2fc-51e2c8e01711@linux.ibm.com>

Hello Shrikanth,

On 1/23/2026 11:36 AM, Shrikanth Hegde wrote:
>> +        /* because !--nr is the condition to stop scan */
>> +        nr = READ_ONCE(sd->shared->nr_idle_scan) + 1;
>> +        /* overloaded LLC is unlikely to have idle cpu/core */
>> +        if (nr == 1)
>> +            return -1;
>>       }
> 
> 
> I stared at sd->shared->nr_idle_scan for a while to see why it is safe
> even when lets say there is no LLC domain.
> 
> It is because it is sd_llc here. Not any other domains. and
> there is sd_llc check before calling select_idle_cpu.

Ack! We come here with a valid "sd_llc" from select_idle_sibling()
and "sd" and "sd->shared" are freed at the same time via call_rcu() when
the last reference is dropped so having a reference to "sd" guarantees
"sd->shared" is not freed and the topology bits will ensure
"sd_llc->shared" is always present (or it screams and we crash here).

> 
> So maybe add a comment here, saying null check for sd_llc is already there
> and that's why it is safe to call it directly.
> 
>>   +    if (!cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr))
>> +        return -1;
>> +
>>       if (static_branch_unlikely(&sched_cluster_active)) {
>>           struct sched_group *sg = sd->groups;
>>   
> 
> While reading this series, this reminded me we had discussed about unifying
> sd_llc->shared and sd_llc_shared thing into one (in v1 or v2).
> is that dropped or you plan to fix it after this series?

Must have slipped out of my mind! I believe the only other user of
"sd_llc_shared" directly would then be nohz_balancer_kick() and
{test,set}_idle_cores().

Out of those, I would only consider set_idle_core() from wakeup to
be a fast-path but we'll already have a "sd_llc" reference there
so we should be able to flip the idle_cores indicator without
needing an extra dereference.

We can only keep per-CPU "sd_llc" and remove "sd_llc_shared". I
hope that is what you were suggesting. Otherwise please let me
know if I misinterpreted the question.

> 
> 
> Other than minor comments and nits series looks good to me.
> So, for the series.
> 
> Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com>

Thank you for reviewing the series.

-- 
Thanks and Regards,
Prateek


  reply	other threads:[~2026-01-23  6:27 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-20 11:32 [PATCH v3 0/8] sched/topology: Optimize sd->shared allocation K Prateek Nayak
2026-01-20 11:32 ` [PATCH v3 1/8] sched/topology: Compute sd_weight considering cpuset partitions K Prateek Nayak
2026-01-21 14:45   ` Chen, Yu C
2026-01-21 15:42   ` Shrikanth Hegde
2026-01-22  2:51     ` K Prateek Nayak
2026-02-05 16:53   ` Valentin Schneider
2026-01-20 11:32 ` [PATCH v3 2/8] sched/topology: Allocate per-CPU sched_domain_shared in s_data K Prateek Nayak
2026-01-21 15:17   ` Chen, Yu C
2026-02-05 16:53   ` Valentin Schneider
2026-01-20 11:32 ` [PATCH v3 3/8] sched/topology: Switch to assigning "sd->shared" from s_data K Prateek Nayak
2026-01-21 15:26   ` Chen, Yu C
2026-01-22  2:49     ` K Prateek Nayak
2026-01-22  8:12   ` Shrikanth Hegde
2026-01-22  8:36     ` K Prateek Nayak
2026-01-23  4:08       ` Shrikanth Hegde
2026-01-23  4:53         ` K Prateek Nayak
2026-02-05 16:53   ` Valentin Schneider
2026-02-06  5:20     ` K Prateek Nayak
2026-02-06  9:38       ` Valentin Schneider
2026-02-14  3:04         ` Chen, Yu C
2026-02-16  3:50           ` K Prateek Nayak
2026-02-14  2:59       ` Chen, Yu C
2026-01-20 11:32 ` [PATCH v3 4/8] sched/topology: Remove sched_domain_shared allocation with sd_data K Prateek Nayak
2026-02-05 16:53   ` Valentin Schneider
2026-01-20 11:32 ` [PATCH v3 5/8] sched/core: Check for rcu_read_lock_any_held() in idle_get_state() K Prateek Nayak
2026-01-20 11:32 ` [PATCH v3 6/8] sched/fair: Remove superfluous rcu_read_lock() in the wakeup path K Prateek Nayak
2026-01-20 11:32 ` [PATCH v3 7/8] sched/fair: Simplify the entry condition for update_idle_cpu_scan() K Prateek Nayak
2026-02-14 15:41   ` Chen, Yu C
2026-01-20 11:32 ` [PATCH v3 8/8] sched/fair: Simplify SIS_UTIL handling in select_idle_cpu() K Prateek Nayak
2026-01-23  6:06   ` Shrikanth Hegde
2026-01-23  6:27     ` K Prateek Nayak [this message]
2026-01-23  7:14       ` Shrikanth Hegde
2026-02-14 15:56   ` Chen, Yu C
2026-01-21 16:16 ` [PATCH v3 0/8] sched/topology: Optimize sd->shared allocation Peter Zijlstra
2026-01-22  2:56   ` K Prateek Nayak
2026-01-23  9:54     ` Peter Zijlstra

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=00a09fd8-6ed7-4ebf-a146-d054e98cc45b@amd.com \
    --to=kprateek.nayak@amd.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=gautham.shenoy@amd.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=sshegde@linux.ibm.com \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --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