xref: /OK3568_Linux_fs/kernel/include/linux/sched/sd_flags.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * sched-domains (multiprocessor balancing) flag declarations.
4*4882a593Smuzhiyun  */
5*4882a593Smuzhiyun 
6*4882a593Smuzhiyun #ifndef SD_FLAG
7*4882a593Smuzhiyun # error "Incorrect import of SD flags definitions"
8*4882a593Smuzhiyun #endif
9*4882a593Smuzhiyun 
10*4882a593Smuzhiyun /*
11*4882a593Smuzhiyun  * Hierarchical metaflags
12*4882a593Smuzhiyun  *
13*4882a593Smuzhiyun  * SHARED_CHILD: These flags are meant to be set from the base domain upwards.
14*4882a593Smuzhiyun  * If a domain has this flag set, all of its children should have it set. This
15*4882a593Smuzhiyun  * is usually because the flag describes some shared resource (all CPUs in that
16*4882a593Smuzhiyun  * domain share the same resource), or because they are tied to a scheduling
17*4882a593Smuzhiyun  * behaviour that we want to disable at some point in the hierarchy for
18*4882a593Smuzhiyun  * scalability reasons.
19*4882a593Smuzhiyun  *
20*4882a593Smuzhiyun  * In those cases it doesn't make sense to have the flag set for a domain but
21*4882a593Smuzhiyun  * not have it in (some of) its children: sched domains ALWAYS span their child
22*4882a593Smuzhiyun  * domains, so operations done with parent domains will cover CPUs in the lower
23*4882a593Smuzhiyun  * child domains.
24*4882a593Smuzhiyun  *
25*4882a593Smuzhiyun  *
26*4882a593Smuzhiyun  * SHARED_PARENT: These flags are meant to be set from the highest domain
27*4882a593Smuzhiyun  * downwards. If a domain has this flag set, all of its parents should have it
28*4882a593Smuzhiyun  * set. This is usually for topology properties that start to appear above a
29*4882a593Smuzhiyun  * certain level (e.g. domain starts spanning CPUs outside of the base CPU's
30*4882a593Smuzhiyun  * socket).
31*4882a593Smuzhiyun  */
32*4882a593Smuzhiyun #define SDF_SHARED_CHILD       0x1
33*4882a593Smuzhiyun #define SDF_SHARED_PARENT      0x2
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun /*
36*4882a593Smuzhiyun  * Behavioural metaflags
37*4882a593Smuzhiyun  *
38*4882a593Smuzhiyun  * NEEDS_GROUPS: These flags are only relevant if the domain they are set on has
39*4882a593Smuzhiyun  * more than one group. This is usually for balancing flags (load balancing
40*4882a593Smuzhiyun  * involves equalizing a metric between groups), or for flags describing some
41*4882a593Smuzhiyun  * shared resource (which would be shared between groups).
42*4882a593Smuzhiyun  */
43*4882a593Smuzhiyun #define SDF_NEEDS_GROUPS       0x4
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun /*
46*4882a593Smuzhiyun  * Balance when about to become idle
47*4882a593Smuzhiyun  *
48*4882a593Smuzhiyun  * SHARED_CHILD: Set from the base domain up to cpuset.sched_relax_domain_level.
49*4882a593Smuzhiyun  * NEEDS_GROUPS: Load balancing flag.
50*4882a593Smuzhiyun  */
51*4882a593Smuzhiyun SD_FLAG(SD_BALANCE_NEWIDLE, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
52*4882a593Smuzhiyun 
53*4882a593Smuzhiyun /*
54*4882a593Smuzhiyun  * Balance on exec
55*4882a593Smuzhiyun  *
56*4882a593Smuzhiyun  * SHARED_CHILD: Set from the base domain up to the NUMA reclaim level.
57*4882a593Smuzhiyun  * NEEDS_GROUPS: Load balancing flag.
58*4882a593Smuzhiyun  */
59*4882a593Smuzhiyun SD_FLAG(SD_BALANCE_EXEC, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun /*
62*4882a593Smuzhiyun  * Balance on fork, clone
63*4882a593Smuzhiyun  *
64*4882a593Smuzhiyun  * SHARED_CHILD: Set from the base domain up to the NUMA reclaim level.
65*4882a593Smuzhiyun  * NEEDS_GROUPS: Load balancing flag.
66*4882a593Smuzhiyun  */
67*4882a593Smuzhiyun SD_FLAG(SD_BALANCE_FORK, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun /*
70*4882a593Smuzhiyun  * Balance on wakeup
71*4882a593Smuzhiyun  *
72*4882a593Smuzhiyun  * SHARED_CHILD: Set from the base domain up to cpuset.sched_relax_domain_level.
73*4882a593Smuzhiyun  * NEEDS_GROUPS: Load balancing flag.
74*4882a593Smuzhiyun  */
75*4882a593Smuzhiyun SD_FLAG(SD_BALANCE_WAKE, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
76*4882a593Smuzhiyun 
77*4882a593Smuzhiyun /*
78*4882a593Smuzhiyun  * Consider waking task on waking CPU.
79*4882a593Smuzhiyun  *
80*4882a593Smuzhiyun  * SHARED_CHILD: Set from the base domain up to the NUMA reclaim level.
81*4882a593Smuzhiyun  */
82*4882a593Smuzhiyun SD_FLAG(SD_WAKE_AFFINE, SDF_SHARED_CHILD)
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun /*
85*4882a593Smuzhiyun  * Domain members have different CPU capacities
86*4882a593Smuzhiyun  *
87*4882a593Smuzhiyun  * SHARED_PARENT: Set from the topmost domain down to the first domain where
88*4882a593Smuzhiyun  *                asymmetry is detected.
89*4882a593Smuzhiyun  * NEEDS_GROUPS: Per-CPU capacity is asymmetric between groups.
90*4882a593Smuzhiyun  */
91*4882a593Smuzhiyun SD_FLAG(SD_ASYM_CPUCAPACITY, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS)
92*4882a593Smuzhiyun 
93*4882a593Smuzhiyun /*
94*4882a593Smuzhiyun  * Domain members share CPU capacity (i.e. SMT)
95*4882a593Smuzhiyun  *
96*4882a593Smuzhiyun  * SHARED_CHILD: Set from the base domain up until spanned CPUs no longer share
97*4882a593Smuzhiyun  *               CPU capacity.
98*4882a593Smuzhiyun  * NEEDS_GROUPS: Capacity is shared between groups.
99*4882a593Smuzhiyun  */
100*4882a593Smuzhiyun SD_FLAG(SD_SHARE_CPUCAPACITY, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
101*4882a593Smuzhiyun 
102*4882a593Smuzhiyun /*
103*4882a593Smuzhiyun  * Domain members share CPU package resources (i.e. caches)
104*4882a593Smuzhiyun  *
105*4882a593Smuzhiyun  * SHARED_CHILD: Set from the base domain up until spanned CPUs no longer share
106*4882a593Smuzhiyun  *               the same cache(s).
107*4882a593Smuzhiyun  * NEEDS_GROUPS: Caches are shared between groups.
108*4882a593Smuzhiyun  */
109*4882a593Smuzhiyun SD_FLAG(SD_SHARE_PKG_RESOURCES, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
110*4882a593Smuzhiyun 
111*4882a593Smuzhiyun /*
112*4882a593Smuzhiyun  * Only a single load balancing instance
113*4882a593Smuzhiyun  *
114*4882a593Smuzhiyun  * SHARED_PARENT: Set for all NUMA levels above NODE. Could be set from a
115*4882a593Smuzhiyun  *                different level upwards, but it doesn't change that if a
116*4882a593Smuzhiyun  *                domain has this flag set, then all of its parents need to have
117*4882a593Smuzhiyun  *                it too (otherwise the serialization doesn't make sense).
118*4882a593Smuzhiyun  * NEEDS_GROUPS: No point in preserving domain if it has a single group.
119*4882a593Smuzhiyun  */
120*4882a593Smuzhiyun SD_FLAG(SD_SERIALIZE, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS)
121*4882a593Smuzhiyun 
122*4882a593Smuzhiyun /*
123*4882a593Smuzhiyun  * Place busy tasks earlier in the domain
124*4882a593Smuzhiyun  *
125*4882a593Smuzhiyun  * SHARED_CHILD: Usually set on the SMT level. Technically could be set further
126*4882a593Smuzhiyun  *               up, but currently assumed to be set from the base domain
127*4882a593Smuzhiyun  *               upwards (see update_top_cache_domain()).
128*4882a593Smuzhiyun  * NEEDS_GROUPS: Load balancing flag.
129*4882a593Smuzhiyun  */
130*4882a593Smuzhiyun SD_FLAG(SD_ASYM_PACKING, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
131*4882a593Smuzhiyun 
132*4882a593Smuzhiyun /*
133*4882a593Smuzhiyun  * Prefer to place tasks in a sibling domain
134*4882a593Smuzhiyun  *
135*4882a593Smuzhiyun  * Set up until domains start spanning NUMA nodes. Close to being a SHARED_CHILD
136*4882a593Smuzhiyun  * flag, but cleared below domains with SD_ASYM_CPUCAPACITY.
137*4882a593Smuzhiyun  *
138*4882a593Smuzhiyun  * NEEDS_GROUPS: Load balancing flag.
139*4882a593Smuzhiyun  */
140*4882a593Smuzhiyun SD_FLAG(SD_PREFER_SIBLING, SDF_NEEDS_GROUPS)
141*4882a593Smuzhiyun 
142*4882a593Smuzhiyun /*
143*4882a593Smuzhiyun  * sched_groups of this level overlap
144*4882a593Smuzhiyun  *
145*4882a593Smuzhiyun  * SHARED_PARENT: Set for all NUMA levels above NODE.
146*4882a593Smuzhiyun  * NEEDS_GROUPS: Overlaps can only exist with more than one group.
147*4882a593Smuzhiyun  */
148*4882a593Smuzhiyun SD_FLAG(SD_OVERLAP, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS)
149*4882a593Smuzhiyun 
150*4882a593Smuzhiyun /*
151*4882a593Smuzhiyun  * Cross-node balancing
152*4882a593Smuzhiyun  *
153*4882a593Smuzhiyun  * SHARED_PARENT: Set for all NUMA levels above NODE.
154*4882a593Smuzhiyun  * NEEDS_GROUPS: No point in preserving domain if it has a single group.
155*4882a593Smuzhiyun  */
156*4882a593Smuzhiyun SD_FLAG(SD_NUMA, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS)
157