Skip to contentSkip to conversation

mwait-idle: updates from Linux 3.15

PATCH New Jan Beulich 1 participant 5 messages Jun 26, 2014

lore
Share & tools
lore
#1 lore raw

PATCH 1/4 mwait-idle: allow sparse sub-state numbering, for Bay Trail

From: Len Brown <[email protected]>

Like acpi_idle, mwait-idle compared sub-state numbers to the number of supported sub-states -- discarding sub-states numbers that were numbered >= the number of states.

But some Bay Trail SOCs use sparse sub-state numbers, so we can't make such a comparison if we are going to access those states.

So now we simply check that _some_ sub-states are supported for the given state, and assume that the sub-state number in our driver is valid.

In practice, the driver is correct, and even if it were not, the hardware clips invalid sub-state requests to valid ones.

No entries in the driver require this change,
but Bay Trail will need it.

xen/arch/x86/cpu/mwait-idle.c +4 -5
@@ -557,23 +557,22 @@ static int mwait_idle_cpu_init(struct no
 	dev->count = 1;
 
 	for (cstate = 0; cpuidle_state_table[cstate].target_residency; ++cstate) {
-		unsigned int num_substates, hint, state, substate;
+		unsigned int num_substates, hint, state;
 		struct acpi_processor_cx *cx;
 
 		hint = flg2MWAIT(cpuidle_state_table[cstate].flags);
 		state = MWAIT_HINT2CSTATE(hint) + 1;
-		substate = MWAIT_HINT2SUBSTATE(hint);
 
 		if (state > max_cstate) {
 			printk(PREFIX "max C-state %u reached\n", max_cstate);
 			break;
 		}
 
-		/* Does the state exist in CPUID.MWAIT? */
+		/* Number of sub-states for this state in CPUID.MWAIT. */
 		num_substates = (mwait_substates >> (state * 4))
 		                & MWAIT_SUBSTATE_MASK;
-		/* if sub-state in table is not enumerated by CPUID */
-		if (substate >= num_substates)
+		/* If NO sub-states for this state in CPUID, skip it. */
+		if (num_substates == 0)
 			continue;
 
 		if (dev->count >= ACPI_PROCESSOR_MAX_POWER) {

mwait-idle: allow sparse sub-state numbering, for Bay Trail

Like acpi_idle, mwait-idle compared sub-state numbers to the number of supported sub-states -- discarding sub-states numbers that were numbered >= the number of states.

But some Bay Trail SOCs use sparse sub-state numbers, so we can't make such a comparison if we are going to access those states.

So now we simply check that _some_ sub-states are supported for the given state, and assume that the sub-state number in our driver is valid.

In practice, the driver is correct, and even if it were not, the hardware clips invalid sub-state requests to valid ones.

No entries in the driver require this change,
but Bay Trail will need it.

xen/arch/x86/cpu/mwait-idle.c +4 -5
@@ -557,23 +557,22 @@ static int mwait_idle_cpu_init(struct no
 	dev->count = 1;
 
 	for (cstate = 0; cpuidle_state_table[cstate].target_residency; ++cstate) {
-		unsigned int num_substates, hint, state, substate;
+		unsigned int num_substates, hint, state;
 		struct acpi_processor_cx *cx;
 
 		hint = flg2MWAIT(cpuidle_state_table[cstate].flags);
 		state = MWAIT_HINT2CSTATE(hint) + 1;
-		substate = MWAIT_HINT2SUBSTATE(hint);
 
 		if (state > max_cstate) {
 			printk(PREFIX "max C-state %u reached\n", max_cstate);
 			break;
 		}
 
-		/* Does the state exist in CPUID.MWAIT? */
+		/* Number of sub-states for this state in CPUID.MWAIT. */
 		num_substates = (mwait_substates >> (state * 4))
 		                & MWAIT_SUBSTATE_MASK;
-		/* if sub-state in table is not enumerated by CPUID */
-		if (substate >= num_substates)
+		/* If NO sub-states for this state in CPUID, skip it. */
+		if (num_substates == 0)
 			continue;
 
 		if (dev->count >= ACPI_PROCESSOR_MAX_POWER) {

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw

PATCH 2/4 mwait-idle: support Bay Trail

In reply to Jan Beulich

From: Len Brown <[email protected]>

Bay Trail (BYT) is a family of Silvermont-core Atom Processor SOCs, including the Intel Atom Processor Z36xxx and Z37xxx Series.

Although it shares the Silvermont core with Avoton, BYT is optimized for mobile, and thus it supports different power saving CPU idle states.

Note that not all versions of Bay Trail HW support all of the states listed in the driver.

xen/arch/x86/cpu/mwait-idle.c +46 -0
@@ -187,6 +187,46 @@ static const struct cpuidle_state snb_cs
 	{}
 };
 
+static const struct cpuidle_state byt_cstates[] = {
+	{
+		.name = "C1-BYT",
+		.flags = MWAIT2flg(0x00),
+		.exit_latency = 1,
+		.target_residency = 1,
+	},
+	{
+		.name = "C1E-BYT",
+		.flags = MWAIT2flg(0x01),
+		.exit_latency = 15,
+		.target_residency = 30,
+	},
+	{
+		.name = "C6N-BYT",
+		.flags = MWAIT2flg(0x58) | CPUIDLE_FLAG_TLB_FLUSHED,
+		.exit_latency = 40,
+		.target_residency = 275,
+	},
+	{
+		.name = "C6S-BYT",
+		.flags = MWAIT2flg(0x52) | CPUIDLE_FLAG_TLB_FLUSHED,
+		.exit_latency = 140,
+		.target_residency = 560,
+	},
+	{
+		.name = "C7-BYT",
+		.flags = MWAIT2flg(0x60) | CPUIDLE_FLAG_TLB_FLUSHED,
+		.exit_latency = 1200,
+		.target_residency = 1500,
+	},
+	{
+		.name = "C7S-BYT",
+		.flags = MWAIT2flg(0x64) | CPUIDLE_FLAG_TLB_FLUSHED,
+		.exit_latency = 10000,
+		.target_residency = 20000,
+	},
+	{}
+};
+
 static const struct cpuidle_state ivb_cstates[] = {
 	{
 		.name = "C1-IVB",
@@ -444,6 +484,11 @@ static const struct idle_cpu idle_cpu_sn
 	.disable_promotion_to_c1e = 1,
 };
 
+static const struct idle_cpu idle_cpu_byt = {
+	.state_table = byt_cstates,
+	.disable_promotion_to_c1e = 1,
+};
+
 static const struct idle_cpu idle_cpu_ivb = {
 	.state_table = ivb_cstates,
 	.disable_promotion_to_c1e = 1,
@@ -476,6 +521,7 @@ static struct intel_idle_id {
 	ICPU(0x26, lincroft),
 	ICPU(0x2a, snb),
 	ICPU(0x2d, snb),
+	ICPU(0x37, byt),
 	ICPU(0x3a, ivb),
 	ICPU(0x3e, ivb),
 	ICPU(0x3c, hsw),

mwait-idle: support Bay Trail

Bay Trail (BYT) is a family of Silvermont-core Atom Processor SOCs, including the Intel Atom Processor Z36xxx and Z37xxx Series.

Although it shares the Silvermont core with Avoton, BYT is optimized for mobile, and thus it supports different power saving CPU idle states.

Note that not all versions of Bay Trail HW support all of the states listed in the driver.

xen/arch/x86/cpu/mwait-idle.c +46 -0

64 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw

PATCH 3/4 mwait-idle: add CPU model 54 (Atom N2000 series)

In reply to Jan Beulich

From: Jan Kiszka <[email protected]>

Add CPU ID for Atom N2600/N2800 processors. Datasheets indicate support for this, detailed information about potential quirks or limitations are missing, though. So we just reuse the definition for the previous ATOM series. Tests on N2800 systems showed that this addition is fine an can reduce power consumption by about 0.25 W (personally confirmed on Intel DN2800MT).

xen/arch/x86/cpu/mwait-idle.c +1 -0
@@ -521,6 +521,7 @@ static struct intel_idle_id {
 	ICPU(0x26, lincroft),
 	ICPU(0x2a, snb),
 	ICPU(0x2d, snb),
+	ICPU(0x36, atom),
 	ICPU(0x37, byt),
 	ICPU(0x3a, ivb),
 	ICPU(0x3e, ivb),

mwait-idle: add CPU model 54 (Atom N2000 series)

Add CPU ID for Atom N2600/N2800 processors. Datasheets indicate support for this, detailed information about potential quirks or limitations are missing, though. So we just reuse the definition for the previous ATOM series. Tests on N2800 systems showed that this addition is fine an can reduce power consumption by about 0.25 W (personally confirmed on Intel DN2800MT).

xen/arch/x86/cpu/mwait-idle.c +1 -0
@@ -521,6 +521,7 @@ static struct intel_idle_id {
 	ICPU(0x26, lincroft),
 	ICPU(0x2a, snb),
 	ICPU(0x2d, snb),
+	ICPU(0x36, atom),
 	ICPU(0x37, byt),
 	ICPU(0x3a, ivb),
 	ICPU(0x3e, ivb),

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#4 lore raw

PATCH 4/4 mwait-idle: fine-tune IVT residency targets

In reply to Jan Beulich

Ivy Town processors have slightly different properties than Ivy Bridge processors, particuarly as socket count grows. Here we add dedicated tables covering 1-2 socket, 3-4 socket, and > 4 socket IVT configurations.

This reduces the frequency of deep transitions on those systems, which can impact throughput.

Socket count determination needs to be done differently for us: The relevant code runs in a pre-SMP initcall, and hence can't use cpu_to_socket() (as only the boot CPU's cpu_data[].phys_proc_id got set up by that time). As a replacement the patch introduces apicid_to_socket(), thus estimating the socket count based on the boot CPU's internal topology information (if all CPUs in a system are the same, wich ought to be the common case, this estimate will be precise).

Note that apicid_to_socket() handles Intel topology determination only for now, as the mwait-idle driver currently only supports Intel CPUs.

---
This requires the patch at
http://lists.xenproject.org/archives/html/xen-devel/2014-06/msg03335.html
as a prerequisite.

xen/arch/x86/cpu/mwait-idle.c +124 -1
@@ -261,6 +261,90 @@ static const struct cpuidle_state ivb_cs
 	{}
 };
 
+static const struct cpuidle_state ivt_cstates[] = {
+	{
+		.name = "C1-IVT",
+		.flags = MWAIT2flg(0x00),
+		.exit_latency = 1,
+		.target_residency = 1,
+	},
+	{
+		.name = "C1E-IVT",
+		.flags = MWAIT2flg(0x01),
+		.exit_latency = 10,
+		.target_residency = 80,
+	},
+	{
+		.name = "C3-IVT",
+		.flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
+		.exit_latency = 59,
+		.target_residency = 156,
+	},
+	{
+		.name = "C6-IVT",
+		.flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
+		.exit_latency = 82,
+		.target_residency = 300,
+	},
+	{}
+};
+
+static const struct cpuidle_state ivt_cstates_4s[] = {
+	{
+		.name = "C1-IVT-4S",
+		.flags = MWAIT2flg(0x00),
+		.exit_latency = 1,
+		.target_residency = 1,
+	},
+	{
+		.name = "C1E-IVT-4S",
+		.flags = MWAIT2flg(0x01),
+		.exit_latency = 10,
+		.target_residency = 250,
+	},
+	{
+		.name = "C3-IVT-4S",
+		.flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
+		.exit_latency = 59,
+		.target_residency = 300,
+	},
+	{
+		.name = "C6-IVT-4S",
+		.flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
+		.exit_latency = 84,
+		.target_residency = 400,
+	},
+	{}
+};
+
+static const struct cpuidle_state ivt_cstates_8s[] = {
+	{
+		.name = "C1-IVT-8S",
+		.flags = MWAIT2flg(0x00),
+		.exit_latency = 1,
+		.target_residency = 1,
+	},
+	{
+		.name = "C1E-IVT-8S",
+		.flags = MWAIT2flg(0x01),
+		.exit_latency = 10,
+		.target_residency = 500,
+	},
+	{
+		.name = "C3-IVT-8S",
+		.flags = MWAIT2flg(0x10) | CPUIDLE_FLAG_TLB_FLUSHED,
+		.exit_latency = 59,
+		.target_residency = 600,
+	},
+	{
+		.name = "C6-IVT-8S",
+		.flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED,
+		.exit_latency = 88,
+		.target_residency = 700,
+	},
+	{}
+};
+
 static const struct cpuidle_state hsw_cstates[] = {
 	{
 		.name = "C1-HSW",
@@ -494,6 +578,11 @@ static const struct idle_cpu idle_cpu_iv
 	.disable_promotion_to_c1e = 1,
 };
 
+static const struct idle_cpu idle_cpu_ivt = {
+	.state_table = ivt_cstates,
+	.disable_promotion_to_c1e = 1,
+};
+
 static const struct idle_cpu idle_cpu_hsw = {
 	.state_table = hsw_cstates,
 	.disable_promotion_to_c1e = 1,
@@ -524,7 +613,7 @@ static struct intel_idle_id {
 	ICPU(0x36, atom),
 	ICPU(0x37, byt),
 	ICPU(0x3a, ivb),
-	ICPU(0x3e, ivb),
+	ICPU(0x3e, ivt),
 	ICPU(0x3c, hsw),
 	ICPU(0x3f, hsw),
 	ICPU(0x45, hsw),
@@ -533,6 +622,37 @@ static struct intel_idle_id {
 	{}
 };
 
+/*
+ * mwait_idle_state_table_update()
+ *
+ * Update the default state_table for this CPU-id
+ *
+ * Currently used to access tuned IVT multi-socket targets
+ * Assumption: num_sockets == (max_package_num + 1)
+ */
+static void __init mwait_idle_state_table_update(void)
+{
+	/* IVT uses a different table for 1-2, 3-4, and > 4 sockets */
+	if (boot_cpu_data.x86_model == 0x3e) { /* IVT */
+		unsigned int cpu, max_apicid = boot_cpu_physical_apicid;
+
+		for_each_present_cpu(cpu)
+			if (max_apicid < x86_cpu_to_apicid[cpu])
+				max_apicid = x86_cpu_to_apicid[cpu];
+		switch (apicid_to_socket(max_apicid)) {
+		case 0: case 1:
+			/* 1 and 2 socket systems use default ivt_cstates */
+			break;
+		case 2: case 3:
+			cpuidle_state_table = ivt_cstates_4s;
+			break;
+		default:
+			cpuidle_state_table = ivt_cstates_8s;
+			break;
+		}
+	}
+}
+
 static int __init mwait_idle_probe(void)
 {
 	unsigned int eax, ebx, ecx;
@@ -578,6 +698,9 @@ static int __init mwait_idle_probe(void)
 
 	pr_debug(PREFIX "lapic_timer_reliable_states %#x\n",
 		 lapic_timer_reliable_states);
+
+	mwait_idle_state_table_update();
+
 	return 0;
 }
 
xen/arch/x86/cpu/common.c +43 -1

62 lines not on this page · raw message

xen/include/asm-x86/processor.h +2 -0
@@ -220,6 +220,8 @@ static always_inline void detect_ht(stru
 #define cpu_to_core(_cpu)   (cpu_data[_cpu].cpu_core_id)
 #define cpu_to_socket(_cpu) (cpu_data[_cpu].phys_proc_id)
 
+unsigned int apicid_to_socket(unsigned int);
+
 /*
  * Generic CPUID function
  * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx

mwait-idle: fine-tune IVT residency targets

Ivy Town processors have slightly different properties than Ivy Bridge processors, particuarly as socket count grows. Here we add dedicated tables covering 1-2 socket, 3-4 socket, and > 4 socket IVT configurations.

This reduces the frequency of deep transitions on those systems, which can impact throughput.

Socket count determination needs to be done differently for us: The relevant code runs in a pre-SMP initcall, and hence can't use cpu_to_socket() (as only the boot CPU's cpu_data[].phys_proc_id got set up by that time). As a replacement the patch introduces apicid_to_socket(), thus estimating the socket count based on the boot CPU's internal topology information (if all CPUs in a system are the same, wich ought to be the common case, this estimate will be precise).

Note that apicid_to_socket() handles Intel topology determination only for now, as the mwait-idle driver currently only supports Intel CPUs.

---
This requires the patch at
http://lists.xenproject.org/archives/html/xen-devel/2014-06/msg03335.html
as a prerequisite.

xen/arch/x86/cpu/mwait-idle.c +124 -1

155 lines not on this page · raw message

xen/arch/x86/cpu/common.c +43 -1

62 lines not on this page · raw message

xen/include/asm-x86/processor.h +2 -0
@@ -220,6 +220,8 @@ static always_inline void detect_ht(stru
 #define cpu_to_core(_cpu)   (cpu_data[_cpu].cpu_core_id)
 #define cpu_to_socket(_cpu) (cpu_data[_cpu].phys_proc_id)
 
+unsigned int apicid_to_socket(unsigned int);
+
 /*
  * Generic CPUID function
  * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel