[PATCH 3/3] sched/topology: Simplify cache_nice_tries initialization
From: Srikar Dronamraju
Date: Thu Nov 19 2026 - 20:50:44 EST
sched_domain initialization currently starts with cache_nice_tries = 0
and later updates it based on the domain type. Most sched domains
eventually end up with cache_nice_tries set to 1, with LLC-sharing
domains and most non-NUMA domains explicitly overriding the initial
value.
As a result, the current code initializes cache_nice_tries to a value
that is not the common case and subsequently reassigns it during domain
setup.
The only domain type that retains a value of 0 is a
SD_SHARE_CPUCAPACITY domain, while NUMA domains use a value of 2 and
most remaining domains use a value of 1.
Initialize cache_nice_tries to 1 by default and only override it for
the special cases that require a different value. This reduces the
number of assignments required during sched-domain construction and
makes the resulting configuration easier to follow.
No functional change is intended. The resulting values remain unchanged:
SD_SHARE_CPUCAPACITY : 0
SD_SHARE_LLC : 1
other non-NUMA : 1
SD_NUMA : 2
Signed-off-by: Srikar Dronamraju <srikar@xxxxxxxxxxxxx>
---
kernel/sched/topology.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
index 99878da03bce..da4f1e127341 100644
--- a/kernel/sched/topology.c
+++ b/kernel/sched/topology.c
@@ -1979,7 +1979,7 @@ sd_init(struct sched_domain_topology_level *tl,
.busy_factor = 16,
.imbalance_pct = 117,
- .cache_nice_tries = 0,
+ .cache_nice_tries = 1,
.flags = 1*SD_BALANCE_NEWIDLE
| 1*SD_BALANCE_EXEC
@@ -2018,10 +2018,7 @@ sd_init(struct sched_domain_topology_level *tl,
*/
if (sd->flags & SD_SHARE_CPUCAPACITY) {
sd->imbalance_pct = 110;
-
- } else if (sd->flags & SD_SHARE_LLC) {
- sd->imbalance_pct = 117;
- sd->cache_nice_tries = 1;
+ sd->cache_nice_tries = 0;
#ifdef CONFIG_NUMA
} else if (sd->flags & SD_NUMA) {
@@ -2036,8 +2033,6 @@ sd_init(struct sched_domain_topology_level *tl,
}
#endif /* CONFIG_NUMA */
- } else {
- sd->cache_nice_tries = 1;
}
sd->private = sdd;
--
2.55.0