| .. | .. |
|---|
| 4 | 4 | |
|---|
| 5 | 5 | #include <linux/topology.h> |
|---|
| 6 | 6 | #include <linux/android_kabi.h> |
|---|
| 7 | +#include <linux/android_vendor.h> |
|---|
| 7 | 8 | |
|---|
| 8 | 9 | #include <linux/sched/idle.h> |
|---|
| 9 | 10 | |
|---|
| .. | .. |
|---|
| 12 | 13 | */ |
|---|
| 13 | 14 | #ifdef CONFIG_SMP |
|---|
| 14 | 15 | |
|---|
| 15 | | -#define SD_LOAD_BALANCE 0x0001 /* Do load balancing on this domain. */ |
|---|
| 16 | | -#define SD_BALANCE_NEWIDLE 0x0002 /* Balance when about to become idle */ |
|---|
| 17 | | -#define SD_BALANCE_EXEC 0x0004 /* Balance on exec */ |
|---|
| 18 | | -#define SD_BALANCE_FORK 0x0008 /* Balance on fork, clone */ |
|---|
| 19 | | -#define SD_BALANCE_WAKE 0x0010 /* Balance on wakeup */ |
|---|
| 20 | | -#define SD_WAKE_AFFINE 0x0020 /* Wake task to waking CPU */ |
|---|
| 21 | | -#define SD_ASYM_CPUCAPACITY 0x0040 /* Domain members have different CPU capacities */ |
|---|
| 22 | | -#define SD_SHARE_CPUCAPACITY 0x0080 /* Domain members share CPU capacity */ |
|---|
| 23 | | -#define SD_SHARE_POWERDOMAIN 0x0100 /* Domain members share power domain */ |
|---|
| 24 | | -#define SD_SHARE_PKG_RESOURCES 0x0200 /* Domain members share CPU pkg resources */ |
|---|
| 25 | | -#define SD_SERIALIZE 0x0400 /* Only a single load balancing instance */ |
|---|
| 26 | | -#define SD_ASYM_PACKING 0x0800 /* Place busy groups earlier in the domain */ |
|---|
| 27 | | -#define SD_PREFER_SIBLING 0x1000 /* Prefer to place tasks in a sibling domain */ |
|---|
| 28 | | -#define SD_OVERLAP 0x2000 /* sched_domains of this level overlap */ |
|---|
| 29 | | -#define SD_NUMA 0x4000 /* cross-node balancing */ |
|---|
| 16 | +/* Generate SD flag indexes */ |
|---|
| 17 | +#define SD_FLAG(name, mflags) __##name, |
|---|
| 18 | +enum { |
|---|
| 19 | + #include <linux/sched/sd_flags.h> |
|---|
| 20 | + __SD_FLAG_CNT, |
|---|
| 21 | +}; |
|---|
| 22 | +#undef SD_FLAG |
|---|
| 23 | +/* Generate SD flag bits */ |
|---|
| 24 | +#define SD_FLAG(name, mflags) name = 1 << __##name, |
|---|
| 25 | +enum { |
|---|
| 26 | + #include <linux/sched/sd_flags.h> |
|---|
| 27 | +}; |
|---|
| 28 | +#undef SD_FLAG |
|---|
| 29 | + |
|---|
| 30 | +#ifdef CONFIG_SCHED_DEBUG |
|---|
| 31 | + |
|---|
| 32 | +struct sd_flag_debug { |
|---|
| 33 | + unsigned int meta_flags; |
|---|
| 34 | + char *name; |
|---|
| 35 | +}; |
|---|
| 36 | +extern const struct sd_flag_debug sd_flag_debug[]; |
|---|
| 37 | + |
|---|
| 38 | +#endif |
|---|
| 30 | 39 | |
|---|
| 31 | 40 | #ifdef CONFIG_SCHED_SMT |
|---|
| 32 | 41 | static inline int cpu_smt_flags(void) |
|---|
| .. | .. |
|---|
| 68 | 77 | atomic_t nr_busy_cpus; |
|---|
| 69 | 78 | int has_idle_cores; |
|---|
| 70 | 79 | |
|---|
| 71 | | - bool overutilized; |
|---|
| 80 | + ANDROID_VENDOR_DATA(1); |
|---|
| 72 | 81 | }; |
|---|
| 73 | 82 | |
|---|
| 74 | 83 | struct sched_domain { |
|---|
| 75 | 84 | /* These fields must be setup */ |
|---|
| 76 | | - struct sched_domain *parent; /* top domain must be null terminated */ |
|---|
| 77 | | - struct sched_domain *child; /* bottom domain must be null terminated */ |
|---|
| 85 | + struct sched_domain __rcu *parent; /* top domain must be null terminated */ |
|---|
| 86 | + struct sched_domain __rcu *child; /* bottom domain must be null terminated */ |
|---|
| 78 | 87 | struct sched_group *groups; /* the balancing groups of the domain */ |
|---|
| 79 | 88 | unsigned long min_interval; /* Minimum balance interval ms */ |
|---|
| 80 | 89 | unsigned long max_interval; /* Maximum balance interval ms */ |
|---|
| 81 | 90 | unsigned int busy_factor; /* less balancing by factor if busy */ |
|---|
| 82 | 91 | unsigned int imbalance_pct; /* No balance until over watermark */ |
|---|
| 83 | 92 | unsigned int cache_nice_tries; /* Leave cache hot tasks for # tries */ |
|---|
| 84 | | - unsigned int busy_idx; |
|---|
| 85 | | - unsigned int idle_idx; |
|---|
| 86 | | - unsigned int newidle_idx; |
|---|
| 87 | | - unsigned int wake_idx; |
|---|
| 88 | | - unsigned int forkexec_idx; |
|---|
| 89 | | - unsigned int smt_gain; |
|---|
| 90 | 93 | |
|---|
| 91 | 94 | int nohz_idle; /* NOHZ IDLE status */ |
|---|
| 92 | 95 | int flags; /* See SD_* */ |
|---|
| .. | .. |
|---|
| 155 | 158 | * by attaching extra space to the end of the structure, |
|---|
| 156 | 159 | * depending on how many CPUs the kernel has booted up with) |
|---|
| 157 | 160 | */ |
|---|
| 158 | | - unsigned long span[0]; |
|---|
| 161 | + unsigned long span[]; |
|---|
| 159 | 162 | }; |
|---|
| 160 | 163 | |
|---|
| 161 | 164 | static inline struct cpumask *sched_domain_span(struct sched_domain *sd) |
|---|
| 162 | 165 | { |
|---|
| 163 | 166 | return to_cpumask(sd->span); |
|---|
| 164 | 167 | } |
|---|
| 168 | + |
|---|
| 169 | +extern void partition_sched_domains_locked(int ndoms_new, |
|---|
| 170 | + cpumask_var_t doms_new[], |
|---|
| 171 | + struct sched_domain_attr *dattr_new); |
|---|
| 165 | 172 | |
|---|
| 166 | 173 | extern void partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[], |
|---|
| 167 | 174 | struct sched_domain_attr *dattr_new); |
|---|
| .. | .. |
|---|
| 203 | 210 | # define SD_INIT_NAME(type) |
|---|
| 204 | 211 | #endif |
|---|
| 205 | 212 | |
|---|
| 206 | | -#ifndef arch_scale_cpu_capacity |
|---|
| 207 | | -static __always_inline |
|---|
| 208 | | -unsigned long arch_scale_cpu_capacity(struct sched_domain *sd, int cpu) |
|---|
| 209 | | -{ |
|---|
| 210 | | - if (sd && (sd->flags & SD_SHARE_CPUCAPACITY) && (sd->span_weight > 1)) |
|---|
| 211 | | - return sd->smt_gain / sd->span_weight; |
|---|
| 212 | | - |
|---|
| 213 | | - return SCHED_CAPACITY_SCALE; |
|---|
| 214 | | -} |
|---|
| 215 | | -#endif |
|---|
| 216 | | - |
|---|
| 217 | 213 | #else /* CONFIG_SMP */ |
|---|
| 218 | 214 | |
|---|
| 219 | 215 | struct sched_domain_attr; |
|---|
| 216 | + |
|---|
| 217 | +static inline void |
|---|
| 218 | +partition_sched_domains_locked(int ndoms_new, cpumask_var_t doms_new[], |
|---|
| 219 | + struct sched_domain_attr *dattr_new) |
|---|
| 220 | +{ |
|---|
| 221 | +} |
|---|
| 220 | 222 | |
|---|
| 221 | 223 | static inline void |
|---|
| 222 | 224 | partition_sched_domains(int ndoms_new, cpumask_var_t doms_new[], |
|---|
| .. | .. |
|---|
| 229 | 231 | return true; |
|---|
| 230 | 232 | } |
|---|
| 231 | 233 | |
|---|
| 234 | +#endif /* !CONFIG_SMP */ |
|---|
| 235 | + |
|---|
| 232 | 236 | #ifndef arch_scale_cpu_capacity |
|---|
| 237 | +/** |
|---|
| 238 | + * arch_scale_cpu_capacity - get the capacity scale factor of a given CPU. |
|---|
| 239 | + * @cpu: the CPU in question. |
|---|
| 240 | + * |
|---|
| 241 | + * Return: the CPU scale factor normalized against SCHED_CAPACITY_SCALE, i.e. |
|---|
| 242 | + * |
|---|
| 243 | + * max_perf(cpu) |
|---|
| 244 | + * ----------------------------- * SCHED_CAPACITY_SCALE |
|---|
| 245 | + * max(max_perf(c) : c \in CPUs) |
|---|
| 246 | + */ |
|---|
| 233 | 247 | static __always_inline |
|---|
| 234 | | -unsigned long arch_scale_cpu_capacity(void __always_unused *sd, int cpu) |
|---|
| 248 | +unsigned long arch_scale_cpu_capacity(int cpu) |
|---|
| 235 | 249 | { |
|---|
| 236 | 250 | return SCHED_CAPACITY_SCALE; |
|---|
| 237 | 251 | } |
|---|
| 238 | 252 | #endif |
|---|
| 239 | 253 | |
|---|
| 240 | | -#endif /* !CONFIG_SMP */ |
|---|
| 254 | +#ifndef arch_scale_thermal_pressure |
|---|
| 255 | +static __always_inline |
|---|
| 256 | +unsigned long arch_scale_thermal_pressure(int cpu) |
|---|
| 257 | +{ |
|---|
| 258 | + return 0; |
|---|
| 259 | +} |
|---|
| 260 | +#endif |
|---|
| 261 | + |
|---|
| 262 | +#ifndef arch_set_thermal_pressure |
|---|
| 263 | +static __always_inline |
|---|
| 264 | +void arch_set_thermal_pressure(const struct cpumask *cpus, |
|---|
| 265 | + unsigned long th_pressure) |
|---|
| 266 | +{ } |
|---|
| 267 | +#endif |
|---|
| 241 | 268 | |
|---|
| 242 | 269 | static inline int task_node(const struct task_struct *p) |
|---|
| 243 | 270 | { |
|---|