Skip to content

Commit

Permalink
Merge tag 'sched-urgent-2021-05-15' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/kernel/git/tip/tip

Pull scheduler fixes from Ingo Molnar:
 "Fix an idle CPU selection bug, and an AMD Ryzen maximum frequency
  enumeration bug"

* tag 'sched-urgent-2021-05-15' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86, sched: Fix the AMD CPPC maximum performance value on certain AMD Ryzen generations
  sched/fair: Fix clearing of has_idle_cores flag in select_idle_cpu()
  • Loading branch information
torvalds committed May 15, 2021
2 parents e7c425b + 3743d55 commit c12a29e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
2 changes: 2 additions & 0 deletions arch/x86/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -787,8 +787,10 @@ DECLARE_PER_CPU(u64, msr_misc_features_shadow);

#ifdef CONFIG_CPU_SUP_AMD
extern u32 amd_get_nodes_per_socket(void);
extern u32 amd_get_highest_perf(void);
#else
static inline u32 amd_get_nodes_per_socket(void) { return 0; }
static inline u32 amd_get_highest_perf(void) { return 0; }
#endif

static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
Expand Down
16 changes: 16 additions & 0 deletions arch/x86/kernel/cpu/amd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1165,3 +1165,19 @@ void set_dr_addr_mask(unsigned long mask, int dr)
break;
}
}

u32 amd_get_highest_perf(void)
{
struct cpuinfo_x86 *c = &boot_cpu_data;

if (c->x86 == 0x17 && ((c->x86_model >= 0x30 && c->x86_model < 0x40) ||
(c->x86_model >= 0x70 && c->x86_model < 0x80)))
return 166;

if (c->x86 == 0x19 && ((c->x86_model >= 0x20 && c->x86_model < 0x30) ||
(c->x86_model >= 0x40 && c->x86_model < 0x70)))
return 166;

return 255;
}
EXPORT_SYMBOL_GPL(amd_get_highest_perf);
2 changes: 1 addition & 1 deletion arch/x86/kernel/smpboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -2043,7 +2043,7 @@ static bool amd_set_max_freq_ratio(void)
return false;
}

highest_perf = perf_caps.highest_perf;
highest_perf = amd_get_highest_perf();
nominal_perf = perf_caps.nominal_perf;

if (!highest_perf || !nominal_perf) {
Expand Down
6 changes: 5 additions & 1 deletion drivers/cpufreq/acpi-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,11 @@ static u64 get_max_boost_ratio(unsigned int cpu)
return 0;
}

highest_perf = perf_caps.highest_perf;
if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
highest_perf = amd_get_highest_perf();
else
highest_perf = perf_caps.highest_perf;

nominal_perf = perf_caps.nominal_perf;

if (!highest_perf || !nominal_perf) {
Expand Down
2 changes: 1 addition & 1 deletion kernel/sched/fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -6217,7 +6217,7 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, bool
}

if (has_idle_core)
set_idle_cores(this, false);
set_idle_cores(target, false);

if (sched_feat(SIS_PROP) && !has_idle_core) {
time = cpu_clock(this) - time;
Expand Down

0 comments on commit c12a29e

Please sign in to comment.