Skip to content

Commit 3f91691

Browse files
mpeKAGA-KOKO
authored andcommitted
cpu/SMT: Move SMT prototypes into cpu_smt.h
In order to export the cpuhp_smt_control enum as part of the interface between generic and architecture code, the architecture code needs to include asm/topology.h. But that leads to circular header dependencies. So split the enum and related declarations into a separate header. [ ldufour: Reworded the commit's description ] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Laurent Dufour <ldufour@linux.ibm.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Zhang Rui <rui.zhang@intel.com> Link: https://lore.kernel.org/r/20230705145143.40545-3-ldufour@linux.ibm.com
1 parent 7a4dcb4 commit 3f91691

File tree

4 files changed

+33
-24
lines changed

4 files changed

+33
-24
lines changed

arch/x86/include/asm/topology.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ static inline int topology_max_smt_threads(void)
136136
return __max_smt_threads;
137137
}
138138

139+
#include <linux/cpu_smt.h>
140+
139141
int topology_update_package_map(unsigned int apicid, unsigned int cpu);
140142
int topology_update_die_map(unsigned int dieid, unsigned int cpu);
141143
int topology_phys_to_logical_pkg(unsigned int pkg);

include/linux/cpu.h

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/compiler.h>
1919
#include <linux/cpumask.h>
2020
#include <linux/cpuhotplug.h>
21+
#include <linux/cpu_smt.h>
2122

2223
struct device;
2324
struct device_node;
@@ -204,30 +205,6 @@ void cpuhp_report_idle_dead(void);
204205
static inline void cpuhp_report_idle_dead(void) { }
205206
#endif /* #ifdef CONFIG_HOTPLUG_CPU */
206207

207-
enum cpuhp_smt_control {
208-
CPU_SMT_ENABLED,
209-
CPU_SMT_DISABLED,
210-
CPU_SMT_FORCE_DISABLED,
211-
CPU_SMT_NOT_SUPPORTED,
212-
CPU_SMT_NOT_IMPLEMENTED,
213-
};
214-
215-
#if defined(CONFIG_SMP) && defined(CONFIG_HOTPLUG_SMT)
216-
extern enum cpuhp_smt_control cpu_smt_control;
217-
extern void cpu_smt_disable(bool force);
218-
extern void cpu_smt_check_topology(void);
219-
extern bool cpu_smt_possible(void);
220-
extern int cpuhp_smt_enable(void);
221-
extern int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval);
222-
#else
223-
# define cpu_smt_control (CPU_SMT_NOT_IMPLEMENTED)
224-
static inline void cpu_smt_disable(bool force) { }
225-
static inline void cpu_smt_check_topology(void) { }
226-
static inline bool cpu_smt_possible(void) { return false; }
227-
static inline int cpuhp_smt_enable(void) { return 0; }
228-
static inline int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval) { return 0; }
229-
#endif
230-
231208
extern bool cpu_mitigations_off(void);
232209
extern bool cpu_mitigations_auto_nosmt(void);
233210

include/linux/cpu_smt.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _LINUX_CPU_SMT_H_
3+
#define _LINUX_CPU_SMT_H_
4+
5+
enum cpuhp_smt_control {
6+
CPU_SMT_ENABLED,
7+
CPU_SMT_DISABLED,
8+
CPU_SMT_FORCE_DISABLED,
9+
CPU_SMT_NOT_SUPPORTED,
10+
CPU_SMT_NOT_IMPLEMENTED,
11+
};
12+
13+
#if defined(CONFIG_SMP) && defined(CONFIG_HOTPLUG_SMT)
14+
extern enum cpuhp_smt_control cpu_smt_control;
15+
extern void cpu_smt_disable(bool force);
16+
extern void cpu_smt_check_topology(void);
17+
extern bool cpu_smt_possible(void);
18+
extern int cpuhp_smt_enable(void);
19+
extern int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval);
20+
#else
21+
# define cpu_smt_control (CPU_SMT_NOT_IMPLEMENTED)
22+
static inline void cpu_smt_disable(bool force) { }
23+
static inline void cpu_smt_check_topology(void) { }
24+
static inline bool cpu_smt_possible(void) { return false; }
25+
static inline int cpuhp_smt_enable(void) { return 0; }
26+
static inline int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval) { return 0; }
27+
#endif
28+
29+
#endif /* _LINUX_CPU_SMT_H_ */

kernel/cpu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ static void lockdep_release_cpus_lock(void)
592592
void __weak arch_smt_update(void) { }
593593

594594
#ifdef CONFIG_HOTPLUG_SMT
595+
595596
enum cpuhp_smt_control cpu_smt_control __read_mostly = CPU_SMT_ENABLED;
596597

597598
void __init cpu_smt_disable(bool force)

0 commit comments

Comments
 (0)