Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'sched-urgent-2020-04-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull scheduler fixes from Ingo Molnar:
"Misc fixes:

- an uclamp accounting fix

- three frequency invariance fixes and a readability improvement"

* tag 'sched-urgent-2020-04-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
sched/core: Fix reset-on-fork from RT with uclamp
x86, sched: Move check for CPU type to caller function
x86, sched: Don't enable static key when starting secondary CPUs
x86, sched: Account for CPUs with less than 4 cores in freq. invariance
x86, sched: Bail out of frequency invariance if base frequency is unknown

+35 -21
+33 -14
arch/x86/kernel/smpboot.c
··· 147 147 *((volatile u32 *)phys_to_virt(TRAMPOLINE_PHYS_LOW)) = 0; 148 148 } 149 149 150 - static void init_freq_invariance(void); 150 + static void init_freq_invariance(bool secondary); 151 151 152 152 /* 153 153 * Report back to the Boot Processor during boot time or to the caller processor ··· 185 185 */ 186 186 set_cpu_sibling_map(raw_smp_processor_id()); 187 187 188 - init_freq_invariance(); 188 + init_freq_invariance(true); 189 189 190 190 /* 191 191 * Get our bogomips. ··· 1341 1341 set_sched_topology(x86_topology); 1342 1342 1343 1343 set_cpu_sibling_map(0); 1344 - init_freq_invariance(); 1344 + init_freq_invariance(false); 1345 1345 smp_sanity_check(); 1346 1346 1347 1347 switch (apic_intr_mode) { ··· 1877 1877 int err, i; 1878 1878 u64 msr; 1879 1879 1880 - if (!x86_match_cpu(has_knl_turbo_ratio_limits)) 1881 - return false; 1882 - 1883 1880 err = rdmsrl_safe(MSR_PLATFORM_INFO, base_freq); 1884 1881 if (err) 1885 1882 return false; ··· 1942 1945 1943 1946 static bool core_set_max_freq_ratio(u64 *base_freq, u64 *turbo_freq) 1944 1947 { 1948 + u64 msr; 1945 1949 int err; 1946 1950 1947 1951 err = rdmsrl_safe(MSR_PLATFORM_INFO, base_freq); 1948 1952 if (err) 1949 1953 return false; 1950 1954 1951 - err = rdmsrl_safe(MSR_TURBO_RATIO_LIMIT, turbo_freq); 1955 + err = rdmsrl_safe(MSR_TURBO_RATIO_LIMIT, &msr); 1952 1956 if (err) 1953 1957 return false; 1954 1958 1955 - *base_freq = (*base_freq >> 8) & 0xFF; /* max P state */ 1956 - *turbo_freq = (*turbo_freq >> 24) & 0xFF; /* 4C turbo */ 1959 + *base_freq = (*base_freq >> 8) & 0xFF; /* max P state */ 1960 + *turbo_freq = (msr >> 24) & 0xFF; /* 4C turbo */ 1961 + 1962 + /* The CPU may have less than 4 cores */ 1963 + if (!*turbo_freq) 1964 + *turbo_freq = msr & 0xFF; /* 1C turbo */ 1957 1965 1958 1966 return true; 1959 1967 } ··· 1974 1972 skx_set_max_freq_ratio(&base_freq, &turbo_freq, 1)) 1975 1973 goto out; 1976 1974 1977 - if (knl_set_max_freq_ratio(&base_freq, &turbo_freq, 1)) 1975 + if (x86_match_cpu(has_knl_turbo_ratio_limits) && 1976 + knl_set_max_freq_ratio(&base_freq, &turbo_freq, 1)) 1978 1977 goto out; 1979 1978 1980 1979 if (x86_match_cpu(has_skx_turbo_ratio_limits) && ··· 1988 1985 return false; 1989 1986 1990 1987 out: 1988 + /* 1989 + * Some hypervisors advertise X86_FEATURE_APERFMPERF 1990 + * but then fill all MSR's with zeroes. 1991 + */ 1992 + if (!base_freq) { 1993 + pr_debug("Couldn't determine cpu base frequency, necessary for scale-invariant accounting.\n"); 1994 + return false; 1995 + } 1996 + 1991 1997 arch_turbo_freq_ratio = div_u64(turbo_freq * SCHED_CAPACITY_SCALE, 1992 1998 base_freq); 1993 1999 arch_set_max_freq_ratio(turbo_disabled()); 1994 2000 return true; 1995 2001 } 1996 2002 1997 - static void init_counter_refs(void *arg) 2003 + static void init_counter_refs(void) 1998 2004 { 1999 2005 u64 aperf, mperf; 2000 2006 ··· 2014 2002 this_cpu_write(arch_prev_mperf, mperf); 2015 2003 } 2016 2004 2017 - static void init_freq_invariance(void) 2005 + static void init_freq_invariance(bool secondary) 2018 2006 { 2019 2007 bool ret = false; 2020 2008 2021 - if (smp_processor_id() != 0 || !boot_cpu_has(X86_FEATURE_APERFMPERF)) 2009 + if (!boot_cpu_has(X86_FEATURE_APERFMPERF)) 2022 2010 return; 2011 + 2012 + if (secondary) { 2013 + if (static_branch_likely(&arch_scale_freq_key)) { 2014 + init_counter_refs(); 2015 + } 2016 + return; 2017 + } 2023 2018 2024 2019 if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) 2025 2020 ret = intel_set_max_freq_ratio(); 2026 2021 2027 2022 if (ret) { 2028 - on_each_cpu(init_counter_refs, NULL, 1); 2023 + init_counter_refs(); 2029 2024 static_branch_enable(&arch_scale_freq_key); 2030 2025 } else { 2031 2026 pr_debug("Couldn't determine max cpu frequency, necessary for scale-invariant accounting.\n");
+2 -7
kernel/sched/core.c
··· 1232 1232 return; 1233 1233 1234 1234 for_each_clamp_id(clamp_id) { 1235 - unsigned int clamp_value = uclamp_none(clamp_id); 1236 - 1237 - /* By default, RT tasks always get 100% boost */ 1238 - if (unlikely(rt_task(p) && clamp_id == UCLAMP_MIN)) 1239 - clamp_value = uclamp_none(UCLAMP_MAX); 1240 - 1241 - uclamp_se_set(&p->uclamp_req[clamp_id], clamp_value, false); 1235 + uclamp_se_set(&p->uclamp_req[clamp_id], 1236 + uclamp_none(clamp_id), false); 1242 1237 } 1243 1238 } 1244 1239