From: Tim Chen <tim.c.chen@linux.intel.com>
To: Shrikanth Hegde <sshegde@linux.ibm.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Jonathan Corbet <corbet@lwn.net>
Cc: 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>,
Valentin Schneider <vschneid@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
Chen Yu <yu.c.chen@intel.com>,
Jemmy Wong <jemmywong512@gmail.com>,
Randy Dunlap <rdunlap@infradead.org>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] Documentation/scheduler: Add cache aware scheduling documentation
Date: Tue, 01 Dec 2026 15:31:59 -0800 [thread overview]
Message-ID: <3aae2e10d163775fa43490757cae20ee14e509e3.camel@linux.intel.com> (raw)
In-Reply-To: <7dd698a5-cbf6-446c-91ce-f026b46a6e18@linux.ibm.com>
On Tue, 2026-12-01 at 23:27 +0530, Shrikanth Hegde wrote:
> Hi tim, A few nits.
>
Shrikanth,
Thanks for your review, much appreciated.
<snip>
> >
> > diff --git a/Documentation/scheduler/index.rst b/Documentation/scheduler/index.rst
> > index 791178ac8bec..67cf466a169b 100644
> > --- a/Documentation/scheduler/index.rst
> > +++ b/Documentation/scheduler/index.rst
> > @@ -16,6 +16,7 @@ Scheduler
> > sched-domains
> > sched-capacity
> > sched-energy
> > + sched-cache
> > schedutil
> > sched-util-clamp
> > sched-nice-design
>
> Should the new entry be added at the end? I don't think the above is sorted.
Right, the list is not sorted. I put it after sched-domains,
sched-capacity and sched-energy on purpose, because those are the
other topology related documents and sched-cache.rst refers to the
same concepts. I would prefer to keep it there, but I don't feel
strongly about it. I can move it to the end if you or Jon prefer.
>
> > +
> > +5. When the preference is withdrawn
> > +-----------------------------------
> > +
> > +The preferred LLC of a cache group is cleared (grp->cpu = -1) if any of the
> > +following conditions holds. The tasks of the group are then balanced like
> > +any other task.
> > +
> > + (a) The group has not been scanned for more than epoch_affinity_timeout
> > + epochs (by default 5 epochs, about 50 ms). The data is stale, because
> > + the group became idle or its behavior changed.
> > +
> > + (b) Too many threads run at the same time. The check is::
> > +
> > + fits_capacity(nr_running_avg * SMT_threads, scale * llc_cpus)
> > +
>
> Should this be fits_llc_nr to better match the code?
> Also capacity always perceived as multiple of 1024, whereas here it is
> number of threads.
>
The doc was written against v7.4-rc1. Yes, fits_llc_nr has been introduced
since. I will rebase and change this to:
fits_llc_nr(nr_running_avg * SMT_threads, scale * llc_cpus)
and describe the limit as a thread count (the running threads must
stay below 80% of the LLC's CPUs) instead of a capacity margin.
> > + where llc_cpus is the number of CPUs in the LLC, SMT_threads is the
> > + number of hardware threads per core, and scale is derived from
> > + aggr_tolerance (see Section 7.2). fits_capacity() keeps a ~20% margin.
> > + For an LLC of 16 CPUs with SMT-2 and the default aggr_tolerance, at
> > + most 6 threads can run at the same time.
> > +
<snip>
> > +Example 3.
> > + The tables below show the decisions with the default values
> > + (overaggr_pct = 50, imb_pct = 20, SMT system). The values are the LLC
> > + utilizations after the move, as a percentage of LLC capacity.
> > +
> > + Moving toward the preferred LLC (dst is the preferred LLC)::
> > +
> > + src \ dst 30% 45% 50% 60%
> > + 30% Y Y N N
> > + 45% Y Y Y N
> > + 50% Y Y G G
> > + 60% Y Y G G
> > +
> > + Moving out of the preferred LLC (src is the preferred LLC)::
> > +
> > + src \ dst 30% 45% 50% 60%
> > + 30% N N N N
> > + 45% N N N N
> > + 50% Y N G G
> > + 60% Y Y G G
> > +
> > + A task can move from a 45% LLC into its preferred LLC that becomes 50%
> > + busy, because 50% is within 20% of 45%. But a task in a 50% busy
> > + preferred LLC is not moved out to a 45% busy LLC, for the same reason.
> > + If it was, the next balance would move it back and cause ping-pong
> > + migrations. A task cannot move from a 30% LLC into its preferred LLC
> > + that becomes 50% busy, because 50% is more than 20% above 30%.
> > +
>
> Maybe worth explaining the 45%->60% field as well.
Sure. I take it you mean the N in the first table, next to the Y for
45% -> 50%. I will add:
A task also cannot move from a 45% LLC into its preferred LLC that
becomes 60% busy, because 60% is more than 20% above 45%
(45% * 1.2 = 54%).
>
> > + The code compares absolute utilizations, not percentages. The tables
> > + assume that both LLCs have the same capacity.
> > +
<snip>
> > +
> > +8.3 - Cache size information
> > +^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > +
> > +The LLC size is read from the generic cacheinfo framework. Architectures
> > +that do not populate it (currently PowerPC, which has its own cacheinfo
> > +implementation) report an LLC size of 0. When NUMA balancing is active,
> > +any non-zero footprint then fails the check of Section 5 (c), so cache
> > +aware scheduling is effectively disabled on these platforms.
>
> Hopefully below should help.
>
> https://lore.kernel.org/all/20261127152242.306333-1-sshegde@linux.ibm.com/#t
Thanks, moving powerpc to the generic cacheinfo is the right fix.
I will drop the mention of PowerPC from this paragraph and keep only
the general statement, so the document does not become stale when
your series is merged.
>
> > +
> > +8.4 - NUMA balancing
> > +^^^^^^^^^^^^^^^^^^^^
> > +
> > +The footprint estimate of Section 5 (c) comes from NUMA balancing fault
> > +statistics. Without NUMA balancing, the footprint check is skipped, and
> > +groups with a working set much larger than one LLC can still be aggregated.
> > +With NUMA balancing, the scan is also limited to the relevant nodes, which
> > +reduces its cost on large systems.
> > +
> > +8.5 - Multithreading (SMT)
> > +^^^^^^^^^^^^^^^^^^^^^^^^^^
> > +
> > +The thread limit of Section 5 (b) multiplies the number of running threads
> > +by the number of hardware threads per core. Thus, it effectively counts
> > +cores. On systems with many threads per core and small LLCs (for example
> > +SMT-4 with 4 CPUs per LLC), almost every multi-threaded process fails this
> > +check unless aggr_tolerance is raised.
>
> Due to above restriction is there a merit in adding a "status" debugfs entry
> either per-proc or in llc_balancing where it indicates if the llc_balancing is
> effectively disabled due to above HW limitations.
I agree that it is hard to tell today why a process is not
aggregated. The cases are a bit different though:
- No sched domain partition spans more than one LLC. This is a global
state. It is only reported in dmesg with sched_verbose today, and
reading "enabled" returns what the user asked for, not what is in
effect. A read-only file in llc_balancing/ could show it.
- llc_bytes is 0. This is per LLC domain, so it would fit better in
the per domain debugfs directory. Your cacheinfo series should
remove the main case anyway.
- The SMT / LLC size limit above. This is not really a hardware
state. It depends on nr_running_avg of each process and on
aggr_tolerance, so a global file cannot report it. It would need
something per process.
This is a code change, so I would like to keep it out of this
documentation series for now and look at it as a follow-up.
Tim
next prev parent reply other threads:[~2026-12-01 23:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 18:21 [PATCH 0/2] sched/cahce: Document cache aware scheduling Tim Chen
2026-11-12 18:21 ` [PATCH 1/2] Documentation/scheduler: Add cache aware scheduling documentation Tim Chen
2026-12-01 17:57 ` Shrikanth Hegde
2026-12-01 23:31 ` Tim Chen [this message]
2026-11-12 18:21 ` [PATCH 2/2] sched/cache: Fix decision matrix comment above can_migrate_llc() Tim Chen
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=3aae2e10d163775fa43490757cae20ee14e509e3.camel@linux.intel.com \
--to=tim.c.chen@linux.intel.com \
--cc=bsegall@google.com \
--cc=corbet@lwn.net \
--cc=dietmar.eggemann@arm.com \
--cc=jemmywong512@gmail.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rdunlap@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
all inboxes | Powered by JetHome®