From: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
rafael.j.wysocki@intel.com, len.brown@intel.com,
artem.bityutskiy@linux.intel.com, dave.hansen@linux.intel.com,
patryk.wlazlyn@linux.intel.com
Subject: [PATCH 3/3] intel_idle: Identify the deepest cstate for cpu offline code
Date: Thu, 10 Oct 2024 15:39:55 +0200 [thread overview]
Message-ID: <20241010133955.7749-4-patryk.wlazlyn@linux.intel.com> (raw)
In-Reply-To: <20241010133955.7749-1-patryk.wlazlyn@linux.intel.com>
On some platforms, for example Sierra Forest, the mwait hints for
subsequent idle states are not continuous, resulting in play_dead() code
not computing the most optimized idle state when CPU is put offline.
This in turn prevents from entering PC6 state when any of the CPUs in
the package is offline. Force the known, best mwait hint for the deepest
cstate.
Signed-off-by: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
---
drivers/idle/intel_idle.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
index 9aab7abc2ae9..d0b4b231d9ad 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
@@ -48,6 +48,7 @@
#include <trace/events/power.h>
#include <linux/sched.h>
#include <linux/sched/smt.h>
+#include <linux/smp.h>
#include <linux/notifier.h>
#include <linux/cpu.h>
#include <linux/moduleparam.h>
@@ -1645,6 +1646,7 @@ static bool __init intel_idle_acpi_cst_extract(void)
static void __init intel_idle_init_cstates_acpi(struct cpuidle_driver *drv)
{
int cstate, limit = min_t(int, CPUIDLE_STATE_MAX, acpi_state_table.count);
+ unsigned int mwait_hint_deepest = 0;
/*
* If limit > 0, intel_idle_cst_usable() has returned 'true', so all of
@@ -1678,6 +1680,7 @@ static void __init intel_idle_init_cstates_acpi(struct cpuidle_driver *drv)
state->target_residency *= 3;
state->flags = MWAIT2flg(cx->address);
+ mwait_hint_deepest = cx->address;
if (cx->type > ACPI_STATE_C2)
state->flags |= CPUIDLE_FLAG_TLB_FLUSHED;
@@ -1690,6 +1693,9 @@ static void __init intel_idle_init_cstates_acpi(struct cpuidle_driver *drv)
state->enter = intel_idle;
state->enter_s2idle = intel_idle_s2idle;
}
+
+ if (mwait_hint_deepest)
+ smp_set_mwait_play_dead_hint(mwait_hint_deepest);
}
static bool __init intel_idle_off_by_default(u32 mwait_hint)
@@ -1988,6 +1994,7 @@ static void state_update_enter_method(struct cpuidle_state *state, int cstate)
static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
{
+ unsigned int mwait_hint_deepest = 0;
int cstate;
switch (boot_cpu_data.x86_vfm) {
@@ -2037,6 +2044,8 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
if (!intel_idle_verify_cstate(mwait_hint))
continue;
+ mwait_hint_deepest = mwait_hint;
+
/* Structure copy. */
drv->states[drv->state_count] = cpuidle_state_table[cstate];
state = &drv->states[drv->state_count];
@@ -2060,6 +2069,9 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
wrmsrl(MSR_CC6_DEMOTION_POLICY_CONFIG, 0);
wrmsrl(MSR_MC6_DEMOTION_POLICY_CONFIG, 0);
}
+
+ if (mwait_hint_deepest)
+ smp_set_mwait_play_dead_hint(mwait_hint_deepest);
}
/**
--
2.46.2
prev parent reply other threads:[~2024-10-10 13:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-10 13:39 [PATCH 0/3] SRF: Fix offline CPU preventing pc6 entry Patryk Wlazlyn
2024-10-10 13:39 ` [PATCH 1/3] x86/smp: Move mwait hint computation out of mwait_play_dead Patryk Wlazlyn
2024-10-10 13:39 ` [PATCH 2/3] x86/smp: Allow forcing the mwait hint for play dead loop Patryk Wlazlyn
2024-10-10 13:39 ` Patryk Wlazlyn [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241010133955.7749-4-patryk.wlazlyn@linux.intel.com \
--to=patryk.wlazlyn@linux.intel.com \
--cc=artem.bityutskiy@linux.intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®