1d54a9658SValentin Schneider /* SPDX-License-Identifier: GPL-2.0 */ 2d54a9658SValentin Schneider /* 3d54a9658SValentin Schneider * sched-domains (multiprocessor balancing) flag declarations. 4d54a9658SValentin Schneider */ 5d54a9658SValentin Schneider 6d54a9658SValentin Schneider #ifndef SD_FLAG 7d54a9658SValentin Schneider # error "Incorrect import of SD flags definitions" 8d54a9658SValentin Schneider #endif 9d54a9658SValentin Schneider 10b6e862f3SValentin Schneider /* 114ee4ea44SValentin Schneider * Hierarchical metaflags 12b6e862f3SValentin Schneider * 13b6e862f3SValentin Schneider * SHARED_CHILD: These flags are meant to be set from the base domain upwards. 14b6e862f3SValentin Schneider * If a domain has this flag set, all of its children should have it set. This 15b6e862f3SValentin Schneider * is usually because the flag describes some shared resource (all CPUs in that 16b6e862f3SValentin Schneider * domain share the same resource), or because they are tied to a scheduling 17b6e862f3SValentin Schneider * behaviour that we want to disable at some point in the hierarchy for 18b6e862f3SValentin Schneider * scalability reasons. 19b6e862f3SValentin Schneider * 20b6e862f3SValentin Schneider * In those cases it doesn't make sense to have the flag set for a domain but 21b6e862f3SValentin Schneider * not have it in (some of) its children: sched domains ALWAYS span their child 22b6e862f3SValentin Schneider * domains, so operations done with parent domains will cover CPUs in the lower 23b6e862f3SValentin Schneider * child domains. 24b6e862f3SValentin Schneider * 25b6e862f3SValentin Schneider * 26b6e862f3SValentin Schneider * SHARED_PARENT: These flags are meant to be set from the highest domain 27b6e862f3SValentin Schneider * downwards. If a domain has this flag set, all of its parents should have it 28b6e862f3SValentin Schneider * set. This is usually for topology properties that start to appear above a 29b6e862f3SValentin Schneider * certain level (e.g. domain starts spanning CPUs outside of the base CPU's 30b6e862f3SValentin Schneider * socket). 31b6e862f3SValentin Schneider */ 32b6e862f3SValentin Schneider #define SDF_SHARED_CHILD 0x1 33b6e862f3SValentin Schneider #define SDF_SHARED_PARENT 0x2 34b6e862f3SValentin Schneider 35b6e862f3SValentin Schneider /* 364ee4ea44SValentin Schneider * Behavioural metaflags 374ee4ea44SValentin Schneider * 384ee4ea44SValentin Schneider * NEEDS_GROUPS: These flags are only relevant if the domain they are set on has 394ee4ea44SValentin Schneider * more than one group. This is usually for balancing flags (load balancing 404ee4ea44SValentin Schneider * involves equalizing a metric between groups), or for flags describing some 414ee4ea44SValentin Schneider * shared resource (which would be shared between groups). 424ee4ea44SValentin Schneider */ 434ee4ea44SValentin Schneider #define SDF_NEEDS_GROUPS 0x4 444ee4ea44SValentin Schneider 454ee4ea44SValentin Schneider /* 46b6e862f3SValentin Schneider * Balance when about to become idle 47b6e862f3SValentin Schneider * 48b6e862f3SValentin Schneider * SHARED_CHILD: Set from the base domain up to cpuset.sched_relax_domain_level. 494ee4ea44SValentin Schneider * NEEDS_GROUPS: Load balancing flag. 50b6e862f3SValentin Schneider */ 514ee4ea44SValentin Schneider SD_FLAG(SD_BALANCE_NEWIDLE, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS) 52b6e862f3SValentin Schneider 53b6e862f3SValentin Schneider /* 54b6e862f3SValentin Schneider * Balance on exec 55b6e862f3SValentin Schneider * 56b6e862f3SValentin Schneider * SHARED_CHILD: Set from the base domain up to the NUMA reclaim level. 574ee4ea44SValentin Schneider * NEEDS_GROUPS: Load balancing flag. 58b6e862f3SValentin Schneider */ 594ee4ea44SValentin Schneider SD_FLAG(SD_BALANCE_EXEC, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS) 60b6e862f3SValentin Schneider 61b6e862f3SValentin Schneider /* 62b6e862f3SValentin Schneider * Balance on fork, clone 63b6e862f3SValentin Schneider * 64b6e862f3SValentin Schneider * SHARED_CHILD: Set from the base domain up to the NUMA reclaim level. 654ee4ea44SValentin Schneider * NEEDS_GROUPS: Load balancing flag. 66b6e862f3SValentin Schneider */ 674ee4ea44SValentin Schneider SD_FLAG(SD_BALANCE_FORK, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS) 68b6e862f3SValentin Schneider 69b6e862f3SValentin Schneider /* 70b6e862f3SValentin Schneider * Balance on wakeup 71b6e862f3SValentin Schneider * 72b6e862f3SValentin Schneider * SHARED_CHILD: Set from the base domain up to cpuset.sched_relax_domain_level. 7394b858feSValentin Schneider * NEEDS_GROUPS: Load balancing flag. 74b6e862f3SValentin Schneider */ 7594b858feSValentin Schneider SD_FLAG(SD_BALANCE_WAKE, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS) 76b6e862f3SValentin Schneider 77b6e862f3SValentin Schneider /* 78b6e862f3SValentin Schneider * Consider waking task on waking CPU. 79b6e862f3SValentin Schneider * 80b6e862f3SValentin Schneider * SHARED_CHILD: Set from the base domain up to the NUMA reclaim level. 81b6e862f3SValentin Schneider */ 82b6e862f3SValentin Schneider SD_FLAG(SD_WAKE_AFFINE, SDF_SHARED_CHILD) 83b6e862f3SValentin Schneider 84b6e862f3SValentin Schneider /* 85b6e862f3SValentin Schneider * Domain members have different CPU capacities 864ee4ea44SValentin Schneider * 87c200191dSValentin Schneider * SHARED_PARENT: Set from the topmost domain down to the first domain where 88c200191dSValentin Schneider * asymmetry is detected. 894ee4ea44SValentin Schneider * NEEDS_GROUPS: Per-CPU capacity is asymmetric between groups. 90b6e862f3SValentin Schneider */ 91c200191dSValentin Schneider SD_FLAG(SD_ASYM_CPUCAPACITY, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS) 92b6e862f3SValentin Schneider 93b6e862f3SValentin Schneider /* 942309a05dSBeata Michalska * Domain members have different CPU capacities spanning all unique CPU 952309a05dSBeata Michalska * capacity values. 962309a05dSBeata Michalska * 972309a05dSBeata Michalska * SHARED_PARENT: Set from the topmost domain down to the first domain where 982309a05dSBeata Michalska * all available CPU capacities are visible 992309a05dSBeata Michalska * NEEDS_GROUPS: Per-CPU capacity is asymmetric between groups. 1002309a05dSBeata Michalska */ 1012309a05dSBeata Michalska SD_FLAG(SD_ASYM_CPUCAPACITY_FULL, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS) 1022309a05dSBeata Michalska 1032309a05dSBeata Michalska /* 104b6e862f3SValentin Schneider * Domain members share CPU capacity (i.e. SMT) 105b6e862f3SValentin Schneider * 106b6e862f3SValentin Schneider * SHARED_CHILD: Set from the base domain up until spanned CPUs no longer share 107b6e862f3SValentin Schneider * CPU capacity. 1084ee4ea44SValentin Schneider * NEEDS_GROUPS: Capacity is shared between groups. 109b6e862f3SValentin Schneider */ 1104ee4ea44SValentin Schneider SD_FLAG(SD_SHARE_CPUCAPACITY, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS) 111b6e862f3SValentin Schneider 112b6e862f3SValentin Schneider /* 113b95303e0SBarry Song * Domain members share CPU cluster (LLC tags or L2 cache) 114b95303e0SBarry Song * 115b95303e0SBarry Song * NEEDS_GROUPS: Clusters are shared between groups. 116b95303e0SBarry Song */ 117b95303e0SBarry Song SD_FLAG(SD_CLUSTER, SDF_NEEDS_GROUPS) 118b95303e0SBarry Song 119b95303e0SBarry Song /* 120*54de4427SAlex Shi * Domain members share CPU Last Level Caches 121b6e862f3SValentin Schneider * 122b6e862f3SValentin Schneider * SHARED_CHILD: Set from the base domain up until spanned CPUs no longer share 123b6e862f3SValentin Schneider * the same cache(s). 1244ee4ea44SValentin Schneider * NEEDS_GROUPS: Caches are shared between groups. 125b6e862f3SValentin Schneider */ 126*54de4427SAlex Shi SD_FLAG(SD_SHARE_LLC, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS) 127b6e862f3SValentin Schneider 128b6e862f3SValentin Schneider /* 129b6e862f3SValentin Schneider * Only a single load balancing instance 130b6e862f3SValentin Schneider * 131b6e862f3SValentin Schneider * SHARED_PARENT: Set for all NUMA levels above NODE. Could be set from a 132bdb7c802SValentin Schneider * different level upwards, but it doesn't change that if a 133bdb7c802SValentin Schneider * domain has this flag set, then all of its parents need to have 134bdb7c802SValentin Schneider * it too (otherwise the serialization doesn't make sense). 135bdb7c802SValentin Schneider * NEEDS_GROUPS: No point in preserving domain if it has a single group. 136b6e862f3SValentin Schneider */ 137bdb7c802SValentin Schneider SD_FLAG(SD_SERIALIZE, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS) 138b6e862f3SValentin Schneider 139b6e862f3SValentin Schneider /* 140b6e862f3SValentin Schneider * Place busy tasks earlier in the domain 141b6e862f3SValentin Schneider * 14233199b01SValentin Schneider * NEEDS_GROUPS: Load balancing flag. 143b6e862f3SValentin Schneider */ 144ca528cc5SRicardo Neri SD_FLAG(SD_ASYM_PACKING, SDF_NEEDS_GROUPS) 145b6e862f3SValentin Schneider 146b6e862f3SValentin Schneider /* 147b6e862f3SValentin Schneider * Prefer to place tasks in a sibling domain 148b6e862f3SValentin Schneider * 149b6e862f3SValentin Schneider * Set up until domains start spanning NUMA nodes. Close to being a SHARED_CHILD 150b6e862f3SValentin Schneider * flag, but cleared below domains with SD_ASYM_CPUCAPACITY. 1513a6712c7SValentin Schneider * 1523a6712c7SValentin Schneider * NEEDS_GROUPS: Load balancing flag. 153b6e862f3SValentin Schneider */ 1543a6712c7SValentin Schneider SD_FLAG(SD_PREFER_SIBLING, SDF_NEEDS_GROUPS) 155b6e862f3SValentin Schneider 156b6e862f3SValentin Schneider /* 157b6e862f3SValentin Schneider * sched_groups of this level overlap 158b6e862f3SValentin Schneider * 159b6e862f3SValentin Schneider * SHARED_PARENT: Set for all NUMA levels above NODE. 1603551e954SValentin Schneider * NEEDS_GROUPS: Overlaps can only exist with more than one group. 161b6e862f3SValentin Schneider */ 1623551e954SValentin Schneider SD_FLAG(SD_OVERLAP, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS) 163b6e862f3SValentin Schneider 164b6e862f3SValentin Schneider /* 165b6e862f3SValentin Schneider * Cross-node balancing 166b6e862f3SValentin Schneider * 167b6e862f3SValentin Schneider * SHARED_PARENT: Set for all NUMA levels above NODE. 1685f4a1c4eSValentin Schneider * NEEDS_GROUPS: No point in preserving domain if it has a single group. 169b6e862f3SValentin Schneider */ 1705f4a1c4eSValentin Schneider SD_FLAG(SD_NUMA, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS) 171