Commit 5a2bf1ab authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'smp-hotplug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull CPU hotplug updates from Ingo Molnar:
 "Two changes in this cycle:

   - Make the /sys/devices/system/cpu/smt/* files available on all
     arches, so user space has a consistent way to detect whether SMT is
     enabled.

   - Sparse annotation fix"

* 'smp-hotplug-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  smpboot: Place the __percpu annotation correctly
  cpu/hotplug: Create SMT sysfs interface for all arches
parents e00d4135 d4645d30
...@@ -511,10 +511,12 @@ Description: Control Symetric Multi Threading (SMT) ...@@ -511,10 +511,12 @@ Description: Control Symetric Multi Threading (SMT)
control: Read/write interface to control SMT. Possible control: Read/write interface to control SMT. Possible
values: values:
"on" SMT is enabled "on" SMT is enabled
"off" SMT is disabled "off" SMT is disabled
"forceoff" SMT is force disabled. Cannot be changed. "forceoff" SMT is force disabled. Cannot be changed.
"notsupported" SMT is not supported by the CPU "notsupported" SMT is not supported by the CPU
"notimplemented" SMT runtime toggling is not
implemented for the architecture
If control status is "forceoff" or "notsupported" writes If control status is "forceoff" or "notsupported" writes
are rejected. are rejected.
...@@ -192,6 +192,7 @@ enum cpuhp_smt_control { ...@@ -192,6 +192,7 @@ enum cpuhp_smt_control {
CPU_SMT_DISABLED, CPU_SMT_DISABLED,
CPU_SMT_FORCE_DISABLED, CPU_SMT_FORCE_DISABLED,
CPU_SMT_NOT_SUPPORTED, CPU_SMT_NOT_SUPPORTED,
CPU_SMT_NOT_IMPLEMENTED,
}; };
#if defined(CONFIG_SMP) && defined(CONFIG_HOTPLUG_SMT) #if defined(CONFIG_SMP) && defined(CONFIG_HOTPLUG_SMT)
...@@ -199,7 +200,7 @@ extern enum cpuhp_smt_control cpu_smt_control; ...@@ -199,7 +200,7 @@ extern enum cpuhp_smt_control cpu_smt_control;
extern void cpu_smt_disable(bool force); extern void cpu_smt_disable(bool force);
extern void cpu_smt_check_topology(void); extern void cpu_smt_check_topology(void);
#else #else
# define cpu_smt_control (CPU_SMT_ENABLED) # define cpu_smt_control (CPU_SMT_NOT_IMPLEMENTED)
static inline void cpu_smt_disable(bool force) { } static inline void cpu_smt_disable(bool force) { }
static inline void cpu_smt_check_topology(void) { } static inline void cpu_smt_check_topology(void) { }
#endif #endif
......
...@@ -29,7 +29,7 @@ struct smpboot_thread_data; ...@@ -29,7 +29,7 @@ struct smpboot_thread_data;
* @thread_comm: The base name of the thread * @thread_comm: The base name of the thread
*/ */
struct smp_hotplug_thread { struct smp_hotplug_thread {
struct task_struct __percpu **store; struct task_struct * __percpu *store;
struct list_head list; struct list_head list;
int (*thread_should_run)(unsigned int cpu); int (*thread_should_run)(unsigned int cpu);
void (*thread_fn)(unsigned int cpu); void (*thread_fn)(unsigned int cpu);
......
...@@ -2041,19 +2041,6 @@ static const struct attribute_group cpuhp_cpu_root_attr_group = { ...@@ -2041,19 +2041,6 @@ static const struct attribute_group cpuhp_cpu_root_attr_group = {
#ifdef CONFIG_HOTPLUG_SMT #ifdef CONFIG_HOTPLUG_SMT
static const char *smt_states[] = {
[CPU_SMT_ENABLED] = "on",
[CPU_SMT_DISABLED] = "off",
[CPU_SMT_FORCE_DISABLED] = "forceoff",
[CPU_SMT_NOT_SUPPORTED] = "notsupported",
};
static ssize_t
show_smt_control(struct device *dev, struct device_attribute *attr, char *buf)
{
return snprintf(buf, PAGE_SIZE - 2, "%s\n", smt_states[cpu_smt_control]);
}
static void cpuhp_offline_cpu_device(unsigned int cpu) static void cpuhp_offline_cpu_device(unsigned int cpu)
{ {
struct device *dev = get_cpu_device(cpu); struct device *dev = get_cpu_device(cpu);
...@@ -2124,9 +2111,10 @@ static int cpuhp_smt_enable(void) ...@@ -2124,9 +2111,10 @@ static int cpuhp_smt_enable(void)
return ret; return ret;
} }
static ssize_t static ssize_t
store_smt_control(struct device *dev, struct device_attribute *attr, __store_smt_control(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
int ctrlval, ret; int ctrlval, ret;
...@@ -2164,14 +2152,44 @@ store_smt_control(struct device *dev, struct device_attribute *attr, ...@@ -2164,14 +2152,44 @@ store_smt_control(struct device *dev, struct device_attribute *attr,
unlock_device_hotplug(); unlock_device_hotplug();
return ret ? ret : count; return ret ? ret : count;
} }
#else /* !CONFIG_HOTPLUG_SMT */
static ssize_t
__store_smt_control(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
return -ENODEV;
}
#endif /* CONFIG_HOTPLUG_SMT */
static const char *smt_states[] = {
[CPU_SMT_ENABLED] = "on",
[CPU_SMT_DISABLED] = "off",
[CPU_SMT_FORCE_DISABLED] = "forceoff",
[CPU_SMT_NOT_SUPPORTED] = "notsupported",
[CPU_SMT_NOT_IMPLEMENTED] = "notimplemented",
};
static ssize_t
show_smt_control(struct device *dev, struct device_attribute *attr, char *buf)
{
const char *state = smt_states[cpu_smt_control];
return snprintf(buf, PAGE_SIZE - 2, "%s\n", state);
}
static ssize_t
store_smt_control(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
return __store_smt_control(dev, attr, buf, count);
}
static DEVICE_ATTR(control, 0644, show_smt_control, store_smt_control); static DEVICE_ATTR(control, 0644, show_smt_control, store_smt_control);
static ssize_t static ssize_t
show_smt_active(struct device *dev, struct device_attribute *attr, char *buf) show_smt_active(struct device *dev, struct device_attribute *attr, char *buf)
{ {
bool active = topology_max_smt_threads() > 1; return snprintf(buf, PAGE_SIZE - 2, "%d\n", sched_smt_active());
return snprintf(buf, PAGE_SIZE - 2, "%d\n", active);
} }
static DEVICE_ATTR(active, 0444, show_smt_active, NULL); static DEVICE_ATTR(active, 0444, show_smt_active, NULL);
...@@ -2187,21 +2205,17 @@ static const struct attribute_group cpuhp_smt_attr_group = { ...@@ -2187,21 +2205,17 @@ static const struct attribute_group cpuhp_smt_attr_group = {
NULL NULL
}; };
static int __init cpu_smt_state_init(void) static int __init cpu_smt_sysfs_init(void)
{ {
return sysfs_create_group(&cpu_subsys.dev_root->kobj, return sysfs_create_group(&cpu_subsys.dev_root->kobj,
&cpuhp_smt_attr_group); &cpuhp_smt_attr_group);
} }
#else
static inline int cpu_smt_state_init(void) { return 0; }
#endif
static int __init cpuhp_sysfs_init(void) static int __init cpuhp_sysfs_init(void)
{ {
int cpu, ret; int cpu, ret;
ret = cpu_smt_state_init(); ret = cpu_smt_sysfs_init();
if (ret) if (ret)
return ret; return ret;
...@@ -2222,7 +2236,7 @@ static int __init cpuhp_sysfs_init(void) ...@@ -2222,7 +2236,7 @@ static int __init cpuhp_sysfs_init(void)
return 0; return 0;
} }
device_initcall(cpuhp_sysfs_init); device_initcall(cpuhp_sysfs_init);
#endif #endif /* CONFIG_SYSFS && CONFIG_HOTPLUG_CPU */
/* /*
* cpu_bit_bitmap[] is a special, "compressed" data structure that * cpu_bit_bitmap[] is a special, "compressed" data structure that
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment