Skip to content

Commit 12633e8

Browse files
Nathan Fontenotozbenh
authored andcommitted
sysfs/cpu: Add probe/release files
Version 3 of this patch is updated with documentation added to Documentation/ABI. There are no changes to any of the C code from v2 of the patch. In order to support kernel DLPAR of CPU resources we need to provide an interface to add (probe) and remove (release) the resource from the system. This patch Creates new generic probe and release sysfs files to facilitate cpu probe/release. The probe/release interface provides for allowing each arch to supply their own routines for implementing the backend of adding and removing cpus to/from the system. This also creates the powerpc specific stubs to handle the arch callouts from writes to the sysfs files. The creation and use of these files is regulated by the CONFIG_ARCH_CPU_PROBE_RELEASE option so that only architectures that need the capability will have the files created. Signed-off-by: Nathan Fontenot <[email protected]> Signed-off-by: Benjamin Herrenschmidt <[email protected]>
1 parent ab519a0 commit 12633e8

File tree

6 files changed

+77
-0
lines changed

6 files changed

+77
-0
lines changed

Documentation/ABI/testing/sysfs-devices-system-cpu

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,21 @@ Description: CPU topology files that describe kernel limits related to
6262
See Documentation/cputopology.txt for more information.
6363

6464

65+
What: /sys/devices/system/cpu/probe
66+
/sys/devices/system/cpu/release
67+
Date: November 2009
68+
Contact: Linux kernel mailing list <[email protected]>
69+
Description: Dynamic addition and removal of CPU's. This is not hotplug
70+
removal, this is meant complete removal/addition of the CPU
71+
from the system.
72+
73+
probe: writes to this file will dynamically add a CPU to the
74+
system. Information written to the file to add CPU's is
75+
architecture specific.
76+
77+
release: writes to this file dynamically remove a CPU from
78+
the system. Information writtento the file to remove CPU's
79+
is architecture specific.
6580

6681
What: /sys/devices/system/cpu/cpu#/node
6782
Date: October 2009

arch/powerpc/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,10 @@ config HOTPLUG_CPU
320320

321321
Say N if you are unsure.
322322

323+
config ARCH_CPU_PROBE_RELEASE
324+
def_bool y
325+
depends on HOTPLUG_CPU
326+
323327
config ARCH_ENABLE_MEMORY_HOTPLUG
324328
def_bool y
325329

arch/powerpc/include/asm/machdep.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,11 @@ struct machdep_calls {
266266
void (*suspend_disable_irqs)(void);
267267
void (*suspend_enable_irqs)(void);
268268
#endif
269+
270+
#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
271+
ssize_t (*cpu_probe)(const char *, size_t);
272+
ssize_t (*cpu_release)(const char *, size_t);
273+
#endif
269274
};
270275

271276
extern void e500_idle(void);

arch/powerpc/kernel/sysfs.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,25 @@ static void unregister_cpu_online(unsigned int cpu)
461461

462462
cacheinfo_cpu_offline(cpu);
463463
}
464+
465+
#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
466+
ssize_t arch_cpu_probe(const char *buf, size_t count)
467+
{
468+
if (ppc_md.cpu_probe)
469+
return ppc_md.cpu_probe(buf, count);
470+
471+
return -EINVAL;
472+
}
473+
474+
ssize_t arch_cpu_release(const char *buf, size_t count)
475+
{
476+
if (ppc_md.cpu_release)
477+
return ppc_md.cpu_release(buf, count);
478+
479+
return -EINVAL;
480+
}
481+
#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */
482+
464483
#endif /* CONFIG_HOTPLUG_CPU */
465484

466485
static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,

drivers/base/cpu.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,38 @@ void unregister_cpu(struct cpu *cpu)
7272
per_cpu(cpu_sys_devices, logical_cpu) = NULL;
7373
return;
7474
}
75+
76+
#ifdef CONFIG_ARCH_CPU_PROBE_RELEASE
77+
static ssize_t cpu_probe_store(struct class *class, const char *buf,
78+
size_t count)
79+
{
80+
return arch_cpu_probe(buf, count);
81+
}
82+
83+
static ssize_t cpu_release_store(struct class *class, const char *buf,
84+
size_t count)
85+
{
86+
return arch_cpu_release(buf, count);
87+
}
88+
89+
static CLASS_ATTR(probe, S_IWUSR, NULL, cpu_probe_store);
90+
static CLASS_ATTR(release, S_IWUSR, NULL, cpu_release_store);
91+
92+
int __init cpu_probe_release_init(void)
93+
{
94+
int rc;
95+
96+
rc = sysfs_create_file(&cpu_sysdev_class.kset.kobj,
97+
&class_attr_probe.attr);
98+
if (!rc)
99+
rc = sysfs_create_file(&cpu_sysdev_class.kset.kobj,
100+
&class_attr_release.attr);
101+
102+
return rc;
103+
}
104+
device_initcall(cpu_probe_release_init);
105+
#endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */
106+
75107
#else /* ... !CONFIG_HOTPLUG_CPU */
76108
static inline void register_cpu_control(struct cpu *cpu)
77109
{

include/linux/cpu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ extern int sched_create_sysfs_power_savings_entries(struct sysdev_class *cls);
4343

4444
#ifdef CONFIG_HOTPLUG_CPU
4545
extern void unregister_cpu(struct cpu *cpu);
46+
extern ssize_t arch_cpu_probe(const char *, size_t);
47+
extern ssize_t arch_cpu_release(const char *, size_t);
4648
#endif
4749
struct notifier_block;
4850

0 commit comments

Comments
 (0)