Skip to content

Commit adb35e8

Browse files
committed
Merge tag 'sched-core-2020-12-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull scheduler updates from Thomas Gleixner: - migrate_disable/enable() support which originates from the RT tree and is now a prerequisite for the new preemptible kmap_local() API which aims to replace kmap_atomic(). - A fair amount of topology and NUMA related improvements - Improvements for the frequency invariant calculations - Enhanced robustness for the global CPU priority tracking and decision making - The usual small fixes and enhancements all over the place * tag 'sched-core-2020-12-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (61 commits) sched/fair: Trivial correction of the newidle_balance() comment sched/fair: Clear SMT siblings after determining the core is not idle sched: Fix kernel-doc markup x86: Print ratio freq_max/freq_base used in frequency invariance calculations x86, sched: Use midpoint of max_boost and max_P for frequency invariance on AMD EPYC x86, sched: Calculate frequency invariance for AMD systems irq_work: Optimize irq_work_single() smp: Cleanup smp_call_function*() irq_work: Cleanup sched: Limit the amount of NUMA imbalance that can exist at fork time sched/numa: Allow a floating imbalance between NUMA nodes sched: Avoid unnecessary calculation of load imbalance at clone time sched/numa: Rename nr_running and break out the magic number sched: Make migrate_disable/enable() independent of RT sched/topology: Condition EAS enablement on FIE support arm64: Rebuild sched domains on invariance status changes sched/topology,schedutil: Wrap sched domains rebuild sched/uclamp: Allow to reset a task uclamp constraint value sched/core: Fix typos in comments Documentation: scheduler: fix information on arch SD flags, sched_domain and sched_debug ...
2 parents 533369b + 5b78f2d commit adb35e8

59 files changed

Lines changed: 1906 additions & 619 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/scheduler/sched-domains.rst‎

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,17 @@ of the SMP domain will span the entire machine, with each group having the
6565
cpumask of a node. Or, you could do multi-level NUMA or Opteron, for example,
6666
might have just one domain covering its one NUMA level.
6767

68-
The implementor should read comments in include/linux/sched.h:
69-
struct sched_domain fields, SD_FLAG_*, SD_*_INIT to get an idea of
70-
the specifics and what to tune.
68+
The implementor should read comments in include/linux/sched/sd_flags.h:
69+
SD_* to get an idea of the specifics and what to tune for the SD flags
70+
of a sched_domain.
7171

72-
Architectures may retain the regular override the default SD_*_INIT flags
73-
while using the generic domain builder in kernel/sched/core.c if they wish to
74-
retain the traditional SMT->SMP->NUMA topology (or some subset of that). This
75-
can be done by #define'ing ARCH_HASH_SCHED_TUNE.
76-
77-
Alternatively, the architecture may completely override the generic domain
78-
builder by #define'ing ARCH_HASH_SCHED_DOMAIN, and exporting your
79-
arch_init_sched_domains function. This function will attach domains to all
80-
CPUs using cpu_attach_domain.
72+
Architectures may override the generic domain builder and the default SD flags
73+
for a given topology level by creating a sched_domain_topology_level array and
74+
calling set_sched_topology() with this array as the parameter.
8175

8276
The sched-domains debugging infrastructure can be enabled by enabling
83-
CONFIG_SCHED_DEBUG. This enables an error checking parse of the sched domains
84-
which should catch most possible errors (described above). It also prints out
85-
the domain structure in a visual format.
77+
CONFIG_SCHED_DEBUG and adding 'sched_debug' to your cmdline. If you forgot to
78+
tweak your cmdline, you can also flip the /sys/kernel/debug/sched_debug
79+
knob. This enables an error checking parse of the sched domains which should
80+
catch most possible errors (described above). It also prints out the domain
81+
structure in a visual format.

‎arch/arm64/kernel/topology.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ static DEFINE_STATIC_KEY_FALSE(amu_fie_key);
223223

224224
static int __init init_amu_fie(void)
225225
{
226+
bool invariance_status = topology_scale_freq_invariant();
226227
cpumask_var_t valid_cpus;
227228
bool have_policy = false;
228229
int ret = 0;
@@ -269,6 +270,15 @@ static int __init init_amu_fie(void)
269270
if (!topology_scale_freq_invariant())
270271
static_branch_disable(&amu_fie_key);
271272

273+
/*
274+
* Task scheduler behavior depends on frequency invariance support,
275+
* either cpufreq or counter driven. If the support status changes as
276+
* a result of counter initialisation and use, retrigger the build of
277+
* scheduling domains to ensure the information is propagated properly.
278+
*/
279+
if (invariance_status != topology_scale_freq_invariant())
280+
rebuild_sched_domains_energy();
281+
272282
free_valid_mask:
273283
free_cpumask_var(valid_cpus);
274284

‎arch/mips/kernel/process.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,6 @@ unsigned long arch_align_stack(unsigned long sp)
702702
return sp & ALMASK;
703703
}
704704

705-
static DEFINE_PER_CPU(call_single_data_t, backtrace_csd);
706705
static struct cpumask backtrace_csd_busy;
707706

708707
static void handle_backtrace(void *info)
@@ -711,6 +710,9 @@ static void handle_backtrace(void *info)
711710
cpumask_clear_cpu(smp_processor_id(), &backtrace_csd_busy);
712711
}
713712

713+
static DEFINE_PER_CPU(call_single_data_t, backtrace_csd) =
714+
CSD_INIT(handle_backtrace, NULL);
715+
714716
static void raise_backtrace(cpumask_t *mask)
715717
{
716718
call_single_data_t *csd;
@@ -730,7 +732,6 @@ static void raise_backtrace(cpumask_t *mask)
730732
}
731733

732734
csd = &per_cpu(backtrace_csd, cpu);
733-
csd->func = handle_backtrace;
734735
smp_call_function_single_async(cpu, csd);
735736
}
736737
}

‎arch/mips/kernel/smp.c‎

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -687,36 +687,23 @@ EXPORT_SYMBOL(flush_tlb_one);
687687

688688
#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
689689

690-
static DEFINE_PER_CPU(call_single_data_t, tick_broadcast_csd);
691-
692-
void tick_broadcast(const struct cpumask *mask)
693-
{
694-
call_single_data_t *csd;
695-
int cpu;
696-
697-
for_each_cpu(cpu, mask) {
698-
csd = &per_cpu(tick_broadcast_csd, cpu);
699-
smp_call_function_single_async(cpu, csd);
700-
}
701-
}
702-
703690
static void tick_broadcast_callee(void *info)
704691
{
705692
tick_receive_broadcast();
706693
}
707694

708-
static int __init tick_broadcast_init(void)
695+
static DEFINE_PER_CPU(call_single_data_t, tick_broadcast_csd) =
696+
CSD_INIT(tick_broadcast_callee, NULL);
697+
698+
void tick_broadcast(const struct cpumask *mask)
709699
{
710700
call_single_data_t *csd;
711701
int cpu;
712702

713-
for (cpu = 0; cpu < NR_CPUS; cpu++) {
703+
for_each_cpu(cpu, mask) {
714704
csd = &per_cpu(tick_broadcast_csd, cpu);
715-
csd->func = tick_broadcast_callee;
705+
smp_call_function_single_async(cpu, csd);
716706
}
717-
718-
return 0;
719707
}
720-
early_initcall(tick_broadcast_init);
721708

722709
#endif /* CONFIG_GENERIC_CLOCKEVENTS_BROADCAST */

‎arch/s390/pci/pci_irq.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,7 @@ static void zpci_handle_fallback_irq(void)
179179
if (atomic_inc_return(&cpu_data->scheduled) > 1)
180180
continue;
181181

182-
cpu_data->csd.func = zpci_handle_remote_irq;
183-
cpu_data->csd.info = &cpu_data->scheduled;
184-
cpu_data->csd.flags = 0;
182+
INIT_CSD(&cpu_data->csd, zpci_handle_remote_irq, &cpu_data->scheduled);
185183
smp_call_function_single_async(cpu, &cpu_data->csd);
186184
}
187185
}

‎arch/x86/include/asm/topology.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,9 @@ static inline void arch_set_max_freq_ratio(bool turbo_disabled)
218218
}
219219
#endif
220220

221+
#ifdef CONFIG_ACPI_CPPC_LIB
222+
void init_freq_invariance_cppc(void);
223+
#define init_freq_invariance_cppc init_freq_invariance_cppc
224+
#endif
225+
221226
#endif /* _ASM_X86_TOPOLOGY_H */

‎arch/x86/kernel/cpuid.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@ static ssize_t cpuid_read(struct file *file, char __user *buf,
7474

7575
init_completion(&cmd.done);
7676
for (; count; count -= 16) {
77-
call_single_data_t csd = {
78-
.func = cpuid_smp_cpuid,
79-
.info = &cmd,
80-
};
77+
call_single_data_t csd;
78+
79+
INIT_CSD(&csd, cpuid_smp_cpuid, &cmd);
8180

8281
cmd.regs.eax = pos;
8382
cmd.regs.ecx = pos >> 32;

‎arch/x86/kernel/smpboot.c‎

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@
8282
#include <asm/hw_irq.h>
8383
#include <asm/stackprotector.h>
8484

85+
#ifdef CONFIG_ACPI_CPPC_LIB
86+
#include <acpi/cppc_acpi.h>
87+
#endif
88+
8589
/* representing HT siblings of each logical CPU */
8690
DEFINE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_sibling_map);
8791
EXPORT_PER_CPU_SYMBOL(cpu_sibling_map);
@@ -148,7 +152,7 @@ static inline void smpboot_restore_warm_reset_vector(void)
148152
*((volatile u32 *)phys_to_virt(TRAMPOLINE_PHYS_LOW)) = 0;
149153
}
150154

151-
static void init_freq_invariance(bool secondary);
155+
static void init_freq_invariance(bool secondary, bool cppc_ready);
152156

153157
/*
154158
* Report back to the Boot Processor during boot time or to the caller processor
@@ -186,7 +190,7 @@ static void smp_callin(void)
186190
*/
187191
set_cpu_sibling_map(raw_smp_processor_id());
188192

189-
init_freq_invariance(true);
193+
init_freq_invariance(true, false);
190194

191195
/*
192196
* Get our bogomips.
@@ -1341,7 +1345,7 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus)
13411345
set_sched_topology(x86_topology);
13421346

13431347
set_cpu_sibling_map(0);
1344-
init_freq_invariance(false);
1348+
init_freq_invariance(false, false);
13451349
smp_sanity_check();
13461350

13471351
switch (apic_intr_mode) {
@@ -2028,6 +2032,48 @@ static bool intel_set_max_freq_ratio(void)
20282032
return true;
20292033
}
20302034

2035+
#ifdef CONFIG_ACPI_CPPC_LIB
2036+
static bool amd_set_max_freq_ratio(void)
2037+
{
2038+
struct cppc_perf_caps perf_caps;
2039+
u64 highest_perf, nominal_perf;
2040+
u64 perf_ratio;
2041+
int rc;
2042+
2043+
rc = cppc_get_perf_caps(0, &perf_caps);
2044+
if (rc) {
2045+
pr_debug("Could not retrieve perf counters (%d)\n", rc);
2046+
return false;
2047+
}
2048+
2049+
highest_perf = perf_caps.highest_perf;
2050+
nominal_perf = perf_caps.nominal_perf;
2051+
2052+
if (!highest_perf || !nominal_perf) {
2053+
pr_debug("Could not retrieve highest or nominal performance\n");
2054+
return false;
2055+
}
2056+
2057+
perf_ratio = div_u64(highest_perf * SCHED_CAPACITY_SCALE, nominal_perf);
2058+
/* midpoint between max_boost and max_P */
2059+
perf_ratio = (perf_ratio + SCHED_CAPACITY_SCALE) >> 1;
2060+
if (!perf_ratio) {
2061+
pr_debug("Non-zero highest/nominal perf values led to a 0 ratio\n");
2062+
return false;
2063+
}
2064+
2065+
arch_turbo_freq_ratio = perf_ratio;
2066+
arch_set_max_freq_ratio(false);
2067+
2068+
return true;
2069+
}
2070+
#else
2071+
static bool amd_set_max_freq_ratio(void)
2072+
{
2073+
return false;
2074+
}
2075+
#endif
2076+
20312077
static void init_counter_refs(void)
20322078
{
20332079
u64 aperf, mperf;
@@ -2039,7 +2085,7 @@ static void init_counter_refs(void)
20392085
this_cpu_write(arch_prev_mperf, mperf);
20402086
}
20412087

2042-
static void init_freq_invariance(bool secondary)
2088+
static void init_freq_invariance(bool secondary, bool cppc_ready)
20432089
{
20442090
bool ret = false;
20452091

@@ -2055,15 +2101,38 @@ static void init_freq_invariance(bool secondary)
20552101

20562102
if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
20572103
ret = intel_set_max_freq_ratio();
2104+
else if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) {
2105+
if (!cppc_ready) {
2106+
return;
2107+
}
2108+
ret = amd_set_max_freq_ratio();
2109+
}
20582110

20592111
if (ret) {
20602112
init_counter_refs();
20612113
static_branch_enable(&arch_scale_freq_key);
2114+
pr_info("Estimated ratio of average max frequency by base frequency (times 1024): %llu\n", arch_max_freq_ratio);
20622115
} else {
20632116
pr_debug("Couldn't determine max cpu frequency, necessary for scale-invariant accounting.\n");
20642117
}
20652118
}
20662119

2120+
#ifdef CONFIG_ACPI_CPPC_LIB
2121+
static DEFINE_MUTEX(freq_invariance_lock);
2122+
2123+
void init_freq_invariance_cppc(void)
2124+
{
2125+
static bool secondary;
2126+
2127+
mutex_lock(&freq_invariance_lock);
2128+
2129+
init_freq_invariance(secondary, true);
2130+
secondary = true;
2131+
2132+
mutex_unlock(&freq_invariance_lock);
2133+
}
2134+
#endif
2135+
20672136
static void disable_freq_invariance_workfn(struct work_struct *work)
20682137
{
20692138
static_branch_disable(&arch_scale_freq_key);
@@ -2113,7 +2182,7 @@ void arch_scale_freq_tick(void)
21132182
schedule_work(&disable_freq_invariance_work);
21142183
}
21152184
#else
2116-
static inline void init_freq_invariance(bool secondary)
2185+
static inline void init_freq_invariance(bool secondary, bool cppc_ready)
21172186
{
21182187
}
21192188
#endif /* CONFIG_X86_64 */

‎arch/x86/lib/msr-smp.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,11 @@ static void __wrmsr_safe_on_cpu(void *info)
169169
int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
170170
{
171171
struct msr_info_completion rv;
172-
call_single_data_t csd = {
173-
.func = __rdmsr_safe_on_cpu,
174-
.info = &rv,
175-
};
172+
call_single_data_t csd;
176173
int err;
177174

175+
INIT_CSD(&csd, __rdmsr_safe_on_cpu, &rv);
176+
178177
memset(&rv, 0, sizeof(rv));
179178
init_completion(&rv.done);
180179
rv.msr.msr_no = msr_no;

‎block/blk-mq.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -671,9 +671,7 @@ bool blk_mq_complete_request_remote(struct request *rq)
671671
return false;
672672

673673
if (blk_mq_complete_need_ipi(rq)) {
674-
rq->csd.func = __blk_mq_complete_request_remote;
675-
rq->csd.info = rq;
676-
rq->csd.flags = 0;
674+
INIT_CSD(&rq->csd, __blk_mq_complete_request_remote, rq);
677675
smp_call_function_single_async(rq->mq_ctx->cpu, &rq->csd);
678676
} else {
679677
if (rq->q->nr_hw_queues > 1)

0 commit comments

Comments
 (0)