Re: [PATCH 1/2] Documentation/scheduler: Add cache aware scheduling documentation
From: Tim Chen
Date: Tue Dec 01 2026 - 18:32:15 EST
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@xxxxxxxxxxxxx/#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