Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions arch/x86/include/asm/topology.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ extern bool __read_mostly sysctl_sched_itmt_enabled;

/* Interface to set priority of a cpu */
void sched_set_itmt_core_prio(int prio, int core_cpu);
void sched_set_itmt_power_ratio(int power_ratio, int core_cpu);

/* Interface to notify scheduler that system supports ITMT */
int sched_set_itmt_support(void);
Expand Down
4 changes: 4 additions & 0 deletions arch/x86/kernel/cpu/intel_epb.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ static ssize_t energy_perf_bias_store(struct device *dev,
if (ret < 0)
return ret;

/* update the ITMT scheduler logic to use the power policy data */
/* scale the val up by 2 so the range is 224 - 256 */
sched_set_itmt_power_ratio(256 - val * 2, cpu);

return count;
}

Expand Down
29 changes: 28 additions & 1 deletion arch/x86/kernel/itmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

static DEFINE_MUTEX(itmt_update_mutex);
DEFINE_PER_CPU_READ_MOSTLY(int, sched_core_priority);
DEFINE_PER_CPU_READ_MOSTLY(int, sched_power_ratio);

/* Boolean to track if system has ITMT capabilities */
static bool __read_mostly sched_itmt_capable;
Expand Down Expand Up @@ -167,7 +168,12 @@ void sched_clear_itmt_support(void)

int arch_asym_cpu_priority(int cpu)
{
return per_cpu(sched_core_priority, cpu);
int power_ratio = per_cpu(sched_power_ratio, cpu);

/* a power ratio of 0 (uninitialized) is assumed to be maximum */
if (power_ratio == 0)
power_ratio = 256 - 2 * 6;
return per_cpu(sched_core_priority, cpu) * power_ratio / 256;
}

/**
Expand All @@ -188,3 +194,24 @@ void sched_set_itmt_core_prio(int prio, int cpu)
{
per_cpu(sched_core_priority, cpu) = prio;
}

/**
* sched_set_itmt_power_ratio() - Set CPU priority based on ITMT
* @power_ratio: The power scaling ratio [1..256] for the core
* @core_cpu: The cpu number associated with the core
*
* Set a scaling to the cpu performance based on long term power
* settings (like EPB).
*
* Note this is for the policy not for the actual dynamic frequency;
* the frequency will increase itself as workloads run on a core.
*/

void sched_set_itmt_power_ratio(int power_ratio, int core_cpu)
{
int cpu;

for_each_cpu(cpu, topology_sibling_cpumask(core_cpu)) {
per_cpu(sched_power_ratio, cpu) = power_ratio;
}
}
3 changes: 3 additions & 0 deletions arch/x86/kernel/tsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1597,6 +1597,9 @@ unsigned long calibrate_delay_is_known(void)
if (!constant_tsc || !mask)
return 0;

if (cpu != 0)
return cpu_data(0).loops_per_jiffy;

sibling = cpumask_any_but(mask, cpu);
if (sibling < nr_cpu_ids)
return cpu_data(sibling).loops_per_jiffy;
Expand Down
15 changes: 13 additions & 2 deletions block/early-lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
#include <linux/blkdev.h>
#include <linux/ctype.h>
#include <linux/delay.h>

struct uuidcmp {
const char *uuid;
Expand Down Expand Up @@ -243,8 +244,18 @@ static int __init devt_from_devnum(const char *name, dev_t *devt)
*/
int __init early_lookup_bdev(const char *name, dev_t *devt)
{
if (strncmp(name, "PARTUUID=", 9) == 0)
return devt_from_partuuid(name + 9, devt);
if (strncmp(name, "PARTUUID=", 9) == 0) {
int res;
int needtowait = 40<<1;
res = devt_from_partuuid(name + 9, devt);
if (!res) return res;
while (res && needtowait) {
msleep(500);
res = devt_from_partuuid(name + 9, devt);
needtowait--;
}
return res;
}
if (strncmp(name, "PARTLABEL=", 10) == 0)
return devt_from_partlabel(name + 10, devt);
if (strncmp(name, "/dev/", 5) == 0)
Expand Down
7 changes: 7 additions & 0 deletions drivers/cpufreq/intel_pstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,13 @@ static void intel_pstate_set_itmt_prio(int cpu)
* update them at any time after it has been called.
*/
sched_set_itmt_core_prio(cppc_perf.highest_perf, cpu);
/*
* On some systems with overclocking enabled, CPPC.highest_perf is hardcoded to 0xff.
* In this case we can't use CPPC.highest_perf to enable ITMT.
* In this case we can look at MSR_HWP_CAPABILITIES bits [8:0] to decide.
*/
if (cppc_perf.highest_perf == 0xff)
cppc_perf.highest_perf = HWP_HIGHEST_PERF(READ_ONCE(all_cpu_data[cpu]->hwp_cap_cached));

if (max_highest_perf <= min_highest_perf) {
if (cppc_perf.highest_perf > max_highest_perf)
Expand Down
56 changes: 28 additions & 28 deletions drivers/idle/intel_idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,55 +594,55 @@ static struct cpuidle_state hsw_cstates[] __initdata = {
.desc = "MWAIT 0x01",
.flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
.exit_latency = 10,
.target_residency = 20,
.target_residency = 120,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
.name = "C3",
.desc = "MWAIT 0x10",
.flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
.exit_latency = 33,
.target_residency = 100,
.target_residency = 900,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
.name = "C6",
.desc = "MWAIT 0x20",
.flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
.exit_latency = 133,
.target_residency = 400,
.target_residency = 1000,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
.name = "C7s",
.desc = "MWAIT 0x32",
.flags = MWAIT2flg(0x32) | CPUIDLE_FLAG_TLB_FLUSHED,
.exit_latency = 166,
.target_residency = 500,
.target_residency = 1500,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
.name = "C8",
.desc = "MWAIT 0x40",
.flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED,
.exit_latency = 300,
.target_residency = 900,
.target_residency = 2000,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
.name = "C9",
.desc = "MWAIT 0x50",
.flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED,
.exit_latency = 600,
.target_residency = 1800,
.target_residency = 5000,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
.name = "C10",
.desc = "MWAIT 0x60",
.flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
.exit_latency = 2600,
.target_residency = 7700,
.target_residency = 9000,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
Expand All @@ -662,55 +662,55 @@ static struct cpuidle_state bdw_cstates[] __initdata = {
.desc = "MWAIT 0x01",
.flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
.exit_latency = 10,
.target_residency = 20,
.target_residency = 120,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
.name = "C3",
.desc = "MWAIT 0x10",
.flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
.exit_latency = 40,
.target_residency = 100,
.target_residency = 1000,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
.name = "C6",
.desc = "MWAIT 0x20",
.flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
.exit_latency = 133,
.target_residency = 400,
.target_residency = 1000,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
.name = "C7s",
.desc = "MWAIT 0x32",
.flags = MWAIT2flg(0x32) | CPUIDLE_FLAG_TLB_FLUSHED,
.exit_latency = 166,
.target_residency = 500,
.target_residency = 2000,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
.name = "C8",
.desc = "MWAIT 0x40",
.flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED,
.exit_latency = 300,
.target_residency = 900,
.target_residency = 4000,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
.name = "C9",
.desc = "MWAIT 0x50",
.flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED,
.exit_latency = 600,
.target_residency = 1800,
.target_residency = 7000,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
.name = "C10",
.desc = "MWAIT 0x60",
.flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
.exit_latency = 2600,
.target_residency = 7700,
.target_residency = 9000,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
Expand All @@ -731,55 +731,55 @@ static struct cpuidle_state skl_cstates[] __initdata = {
.desc = "MWAIT 0x01",
.flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
.exit_latency = 10,
.target_residency = 20,
.target_residency = 120,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
.name = "C3",
.desc = "MWAIT 0x10",
.flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
.exit_latency = 70,
.target_residency = 100,
.target_residency = 1000,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
.name = "C6",
.desc = "MWAIT 0x20",
.flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED | CPUIDLE_FLAG_IBRS,
.exit_latency = 85,
.target_residency = 200,
.target_residency = 600,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
.name = "C7s",
.desc = "MWAIT 0x33",
.flags = MWAIT2flg(0x33) | CPUIDLE_FLAG_TLB_FLUSHED | CPUIDLE_FLAG_IBRS,
.exit_latency = 124,
.target_residency = 800,
.target_residency = 3000,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
.name = "C8",
.desc = "MWAIT 0x40",
.flags = MWAIT2flg(0x40) | CPUIDLE_FLAG_TLB_FLUSHED | CPUIDLE_FLAG_IBRS,
.exit_latency = 200,
.target_residency = 800,
.target_residency = 3200,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
.name = "C9",
.desc = "MWAIT 0x50",
.flags = MWAIT2flg(0x50) | CPUIDLE_FLAG_TLB_FLUSHED | CPUIDLE_FLAG_IBRS,
.exit_latency = 480,
.target_residency = 5000,
.target_residency = 9000,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
.name = "C10",
.desc = "MWAIT 0x60",
.flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED | CPUIDLE_FLAG_IBRS,
.exit_latency = 890,
.target_residency = 5000,
.target_residency = 9000,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
Expand All @@ -800,7 +800,7 @@ static struct cpuidle_state skx_cstates[] __initdata = {
.desc = "MWAIT 0x01",
.flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
.exit_latency = 10,
.target_residency = 20,
.target_residency = 300,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
Expand Down Expand Up @@ -829,15 +829,15 @@ static struct cpuidle_state icx_cstates[] __initdata = {
.desc = "MWAIT 0x01",
.flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
.exit_latency = 4,
.target_residency = 4,
.target_residency = 40,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
.name = "C6",
.desc = "MWAIT 0x20",
.flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
.exit_latency = 170,
.target_residency = 600,
.target_residency = 900,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
Expand Down Expand Up @@ -987,7 +987,7 @@ static struct cpuidle_state gmt_cstates[] __initdata = {
.desc = "MWAIT 0x01",
.flags = MWAIT2flg(0x01) | CPUIDLE_FLAG_ALWAYS_ENABLE,
.exit_latency = 2,
.target_residency = 4,
.target_residency = 40,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
Expand Down Expand Up @@ -1041,7 +1041,7 @@ static struct cpuidle_state spr_cstates[] __initdata = {
.flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED |
CPUIDLE_FLAG_INIT_XSTATE,
.exit_latency = 290,
.target_residency = 800,
.target_residency = 1200,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
Expand Down Expand Up @@ -1072,7 +1072,7 @@ static struct cpuidle_state gnr_cstates[] __initdata = {
CPUIDLE_FLAG_INIT_XSTATE |
CPUIDLE_FLAG_PARTIAL_HINT_MATCH,
.exit_latency = 170,
.target_residency = 650,
.target_residency = 1250,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
Expand All @@ -1082,7 +1082,7 @@ static struct cpuidle_state gnr_cstates[] __initdata = {
CPUIDLE_FLAG_INIT_XSTATE |
CPUIDLE_FLAG_PARTIAL_HINT_MATCH,
.exit_latency = 210,
.target_residency = 1000,
.target_residency = 2000,
.enter = intel_idle,
.enter_s2idle = intel_idle_s2idle, },
{
Expand Down
Loading