From: Wenyou Yang <WenYou.Yang@amd.com>
To: <alexander.deucher@amd.com>, <christian.koenig@amd.com>,
<Xinhui.Pan@amd.com>, <evan.quan@amd.com>,
<mario.limonciello@amd.com>, <bp@suse.de>, <peterz@infradead.org>,
<jpoimboe@kernel.org>, <kim.phillips@amd.com>,
<tglx@linutronix.de>
Cc: <weiyuan2@amd.com>, <richardqi.liang@amd.com>, <ying.li@amd.com>,
<kunliu13@amd.com>, <gpiccoli@igalia.com>,
<amd-gfx@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>,
Wenyou Yang <WenYou.Yang@amd.com>
Subject: [PATCH v3 1/2] cpu/smt: add a notifier to notify the SMT changes
Date: Wed, 29 Mar 2023 09:51:48 +0800 [thread overview]
Message-ID: <20230329015149.870132-2-WenYou.Yang@amd.com> (raw)
In-Reply-To: <20230329015149.870132-1-WenYou.Yang@amd.com>
Add the notifier chain to notify the cpu SMT status changes
Signed-off-by: Wenyou Yang <WenYou.Yang@amd.com>
---
include/linux/cpu.h | 5 +++++
kernel/cpu.c | 10 +++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index 314802f98b9d..9a842317fe2d 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -213,6 +213,11 @@ enum cpuhp_smt_control {
CPU_SMT_NOT_IMPLEMENTED,
};
+enum cpuhp_smt_status {
+ SMT_ENABLED,
+ SMT_DISABLED,
+};
+
#if defined(CONFIG_SMP) && defined(CONFIG_HOTPLUG_SMT)
extern enum cpuhp_smt_control cpu_smt_control;
extern void cpu_smt_disable(bool force);
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 6c0a92ca6bb5..1af66a3ffd99 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -89,6 +89,9 @@ static DEFINE_PER_CPU(struct cpuhp_cpu_state, cpuhp_state) = {
cpumask_t cpus_booted_once_mask;
#endif
+RAW_NOTIFIER_HEAD(smt_notifier_head);
+EXPORT_SYMBOL(smt_notifier_head);
+
#if defined(CONFIG_LOCKDEP) && defined(CONFIG_SMP)
static struct lockdep_map cpuhp_state_up_map =
STATIC_LOCKDEP_MAP_INIT("cpuhp_state-up", &cpuhp_state_up_map);
@@ -2281,8 +2284,10 @@ int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)
*/
cpuhp_offline_cpu_device(cpu);
}
- if (!ret)
+ if (!ret) {
cpu_smt_control = ctrlval;
+ raw_notifier_call_chain(&smt_notifier_head, SMT_DISABLED, NULL);
+ }
cpu_maps_update_done();
return ret;
}
@@ -2303,6 +2308,9 @@ int cpuhp_smt_enable(void)
/* See comment in cpuhp_smt_disable() */
cpuhp_online_cpu_device(cpu);
}
+ if (!ret)
+ raw_notifier_call_chain(&smt_notifier_head, SMT_ENABLED, NULL);
+
cpu_maps_update_done();
return ret;
}
--
2.39.2
next prev parent reply other threads:[~2023-03-29 1:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-29 1:51 [PATCH v3 0/2] send message to pmfw when SMT changes Wenyou Yang
2023-03-29 1:51 ` Wenyou Yang [this message]
2023-03-29 7:10 ` [PATCH v3 1/2] cpu/smt: add a notifier to notify the " Peter Zijlstra
2023-03-29 7:23 ` Yang, WenYou
2023-03-29 8:50 ` Peter Zijlstra
2023-03-29 9:43 ` Yang, WenYou
2023-03-31 5:49 ` Yang, WenYou
2023-03-31 21:52 ` Thomas Gleixner
2023-03-29 1:51 ` [PATCH v3 2/2] drm/amd/pm: vangogh: send the SMT enable message to pmfw Wenyou Yang
2023-03-29 4:18 ` Mario Limonciello
2023-03-29 7:26 ` Yang, WenYou
2023-03-29 6:15 ` Lazar, Lijo
2023-03-29 7:25 ` Yang, WenYou
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=20230329015149.870132-2-WenYou.Yang@amd.com \
--to=wenyou.yang@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=bp@suse.de \
--cc=christian.koenig@amd.com \
--cc=evan.quan@amd.com \
--cc=gpiccoli@igalia.com \
--cc=jpoimboe@kernel.org \
--cc=kim.phillips@amd.com \
--cc=kunliu13@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=peterz@infradead.org \
--cc=richardqi.liang@amd.com \
--cc=tglx@linutronix.de \
--cc=weiyuan2@amd.com \
--cc=ying.li@amd.com \
/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