[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230329015149.870132-2-WenYou.Yang@amd.com>
Date: Wed, 29 Mar 2023 09:51:48 +0800
From: Wenyou Yang <WenYou.Yang@....com>
To: <alexander.deucher@....com>, <christian.koenig@....com>,
<Xinhui.Pan@....com>, <evan.quan@....com>,
<mario.limonciello@....com>, <bp@...e.de>, <peterz@...radead.org>,
<jpoimboe@...nel.org>, <kim.phillips@....com>, <tglx@...utronix.de>
CC: <weiyuan2@....com>, <richardqi.liang@....com>, <ying.li@....com>,
<kunliu13@....com>, <gpiccoli@...lia.com>,
<amd-gfx@...ts.freedesktop.org>, <linux-kernel@...r.kernel.org>,
Wenyou Yang <WenYou.Yang@....com>
Subject: [PATCH v3 1/2] cpu/smt: add a notifier to notify the SMT changes
Add the notifier chain to notify the cpu SMT status changes
Signed-off-by: Wenyou Yang <WenYou.Yang@....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
Powered by blists - more mailing lists