Skip to contentSkip to conversation

don't create cpu/online sysfs file

RFC Dave Hansen 4 participants 16 messages Jun 4, 2004 – Jun 9, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw
Quoted 6 lines · Ashok Raj

place a file in /sys/devices/system/cpuinfo, which when one does a cat on can display

cpu0: online, not offlinable
cpu1: online
cpu2: offline (meaning present)

This might be a little bit more than is intended for a sysfs file, especially if the information can be obtained some other way. Here's what I was thinking of:

cat /sys/devices/system/cpu/cpuX/online
doesn't exist: online, not offlinable
1: online
0: offline (meaning present)

If you want to get information like you have above, it's pretty trivial to write a little script to do it.

Quoted 4 lines

the reason this cannot be determined at early time, is say if a set of cpu's are in a special mode, i.e only those 4 cpu's can retrieve a set of platform registers. for error processing. And i can offline each of those, until i run into the last of those 4 cpus.

Are you saying that you don't know if a CPU can be offlined at the time that the sysfs files are created? If so, I bet we could delay the creation of the kobjects until a more appropriate time. I don't think anything in early boot actually needs them.

Quoted 6 lines

I would prefer to not have a macro to preventy its creation, but have a facility to know the offlineable status via a single information file, and let __cpu_disable() determine if offline should fail based on current ability to offline a cpu.

what do you think?

I just worry that any single information file doesn't fit in well with the sysfs model.

-- Dave

#1 lore raw

On Fri, Jun 04, 2004 at 04:04:17PM -0700, Dave Hansen wrote:

Dave,

I think your solution can be easily solved if all you want to do is "your platform does not support cpuhotplug", which case just dont create for any cpu, or even better dont do anything in register_cpu() related to control file creation. Forcing all implementations to behave one way just to do what you want seems not right approach, and limiting all to least common denominator.

The preferable way to this would be.

- platfform_supports_cpuhotplug(), like in your case, dont create the online file for any.
- __cpu_is_hotpluggable(cpu#) can also exist if this is a static decision to be made, say if the platform says that a certain cpu cannot be removed.

But you should not always assume this is a static decision just because its the case in one platform. In my earlier example, if you have 8 cpu system, but cpu0-3 are special, and atleast 1 needs to exist for the system to work.

I can remove any of of cpu0-3 until i have atleast one of the cpu0-3 left. The last one is not removable.

Keep it simple please:-)

Cheers,
ashok

Quoted 42 lines · Ashok Raj
Quoted 6 lines

place a file in /sys/devices/system/cpuinfo, which when one does a cat on can display

cpu0: online, not offlinable
cpu1: online
cpu2: offline (meaning present)

This might be a little bit more than is intended for a sysfs file, especially if the information can be obtained some other way. Here's what I was thinking of:

cat /sys/devices/system/cpu/cpuX/online
doesn't exist: online, not offlinable
1: online
0: offline (meaning present)

If you want to get information like you have above, it's pretty trivial to write a little script to do it.

Quoted 4 lines

the reason this cannot be determined at early time, is say if a set of cpu's are in a special mode, i.e only those 4 cpu's can retrieve a set of platform registers. for error processing. And i can offline each of those, until i run into the last of those 4 cpus.

Are you saying that you don't know if a CPU can be offlined at the time that the sysfs files are created? If so, I bet we could delay the creation of the kobjects until a more appropriate time. I don't think anything in early boot actually needs them.

Quoted 6 lines

I would prefer to not have a macro to preventy its creation, but have a facility to know the offlineable status via a single information file, and let __cpu_disable() determine if offline should fail based on current ability to offline a cpu.

what do you think?

I just worry that any single information file doesn't fit in well with the sysfs model.

-- Dave

#2 lore raw
In reply to Dave Hansen
Quoted 6 lines · Ashok Raj

I think your solution can be easily solved if all you want to do is "your platform does not support cpuhotplug", which case just dont create for any cpu, or even better dont do anything in register_cpu() related to control file creation. Forcing all implementations to behave one way just to do what you want seems not right approach, and limiting all to least common denominator.

That's originally what I did. A single global function to see if the platform supported cpu hotplug at runtime. The addition of passing the 'struct cpu' to it was so trivial that I figured it might be useful to someone down the line. I'm regretting my "foresight" now :)

Quoted 6 lines

The preferable way to this would be.

- platfform_supports_cpuhotplug(), like in your case, dont create the online file for any.
- __cpu_is_hotpluggable(cpu#) can also exist if this is a static decision to be made, say if the platform says that a certain cpu cannot be removed.

That seems to be a pretty sensible way to do it. However, we keep the number of interfaces from generic to arch code down if we keep the interface confined to 1 function. It would be trivial to make any architecture that needs it do this:

int __cpu_is_hotpluggable(struct cpu *cpu)

{
	if (!platfform_supports_cpuhotplug())
		return 0;

	lots();
	of_complex_arch_code();
	here();
	...
}

That ensures that there's only 1 function that needs to be defined
globally: __cpu_is_hotpluggable().

But, I definitely see the merit in what you want.

Quoted 8 lines

But you should not always assume this is a static decision just because its the case in one platform. In my earlier example, if you have 8 cpu system, but cpu0-3 are special, and atleast 1 needs to exist for the system to work.

I can remove any of of cpu0-3 until i have atleast one of the cpu0-3 left. The last one is not removable.

Keep it simple please:-)

That's what I'm trying to to :)

I was thinking that cpuX/online is only there to say whether hotplug _operations_ are supported on the cpu, not if it can be hotplugged right now. The "can currently be hotplugged" question is another can of worms that can't really be answered until the hotplug request is made anyway, so I'd prefer to keep from trying to decide that by the presence of the file.

The purpose of the patch is originally only to keep ppc64 systems from making firmware calls that they couldn't support. (Someone tried to offline a CPU on a system when it wasn't supported and the firmware got mad)

-- Dave

#3 lore raw
In reply to Dave Hansen
Quoted 29 lines · Dave Hansen

That's originally what I did. A single global function to see if the platform supported cpu hotplug at runtime. The addition of passing the 'struct cpu' to it was so trivial that I figured it might be useful to someone down the line. I'm regretting my "foresight" now :)

Quoted 6 lines

The preferable way to this would be.

- platfform_supports_cpuhotplug(), like in your case, dont create the online file for any.
- __cpu_is_hotpluggable(cpu#) can also exist if this is a static decision to be made, say if the platform says that a certain cpu cannot be removed.

That seems to be a pretty sensible way to do it. However, we keep the number of interfaces from generic to arch code down if we keep the interface confined to 1 function. It would be trivial to make any architecture that needs it do this:

int __cpu_is_hotpluggable(struct cpu *cpu)

{
	if (!platfform_supports_cpuhotplug())
		return 0;

	lots();
	of_complex_arch_code();
	here();
	...
}
Quoted 3 lines

That ensures that there's only 1 function that needs to be defined
globally: __cpu_is_hotpluggable().

I feel the __cpu_disable() should be just sufficient to be the only function interface from generic to arch code. You run this __cpu_is_hotpluggable(cpu) only in ppc64, where you check and return error. maybe also printing to console saying the platform doesnt support it.

you are adding an extra arch function just for a trivial thing, not to create a control file.

Quoted 11 lines
Quoted 2 lines

Keep it simple please:-)

That's what I'm trying to to :)

I was thinking that cpuX/online is only there to say whether hotplug _operations_ are supported on the cpu, not if it can be hotplugged right now. The "can currently be hotplugged" question is another can of worms that can't really be answered until the hotplug request is made anyway, so I'd prefer to keep from trying to decide that by the presence of the file.

My recommendation is to not do anything, and just let __cpu_disable() handle it. print some verbose message for the operator that this aint going to work should be more than sufficient. There is not a whole lot of realusefullness for this to work.

we if overdo something here, then memory hotplug, node hotplug would all need to do the same hack, __is_node_hotpluggable(node), is_memsection_hotpluggabe(mem) and so on....

Cheers,
ashok

#4 lore raw
In reply to Dave Hansen
Quoted 4 lines · Ashok Raj

I feel the __cpu_disable() should be just sufficient to be the only function interface from generic to arch code. You run this __cpu_is_hotpluggable(cpu) only in ppc64, where you check and return error. maybe also printing to console saying the platform doesnt support it.

Actually __cpu_is_hotpluggable(cpu) does get called on ia64, it's just a trivially-defined 'return 1' for now. Are there ever any plans to run an kernel with CONFIG_HOTPLUG_CPU on an ia64 machine that doesn't really support cpu hotplug? If so, I'd be happy to include the same functionality on ia64 that I put for ppc64.

BTW, the reason that this is done on ppc64 is that we can run the same kernel on a wide variety of hardware, so it makes the distributions' jobs a bit easier.

Quoted 2 lines

you are adding an extra arch function just for a trivial thing, not to create a control file.

...

Quoted 4 lines

My recommendation is to not do anything, and just let __cpu_disable() handle it. print some verbose message for the operator that this aint going to work should be more than sufficient. There is not a whole lot of realusefullness for this to work.

The non-trivial thing that this patch tries to do is give the user some knowledge about the system from the pure layout of sysfs. Waiting until __cpu_disable() to tell the user that there was no possibility of the cpu being offlined seems a bit late in the process. Your idea about the cpuinfo file in sysfs is definitely right; it has *exactly* the information that I'm trying to present. But, the current sysfs guidelines tend to discourage single files with lots of information like those in /proc.

-- Dave

#5 lore raw
In reply to Dave Hansen
Quoted 7 lines · Dave Hansen

knowledge about the system from the pure layout of sysfs. Waiting until __cpu_disable() to tell the user that there was no possibility of the cpu being offlined seems a bit late in the process. Your idea about the cpuinfo file in sysfs is definitely right; it has *exactly* the information that I'm trying to present. But, the current sysfs guidelines tend to discourage single files with lots of information like those in /proc.

How does the attached patch look? I would try to keep away from proliferation of common->arch->platform code as little as possible. What i have done is send a hint for suppressing the control file creation based on what was set in the struct cpu, before calling register_cpu() by the arch specific topology_init() functions. No new __arch/__platform functions.

here is the untested patch for PPC64, does this seem to do what you need?

Cheers,
ashok

D: This file provides ability for caller of register_cpu() to either create
D: a control file, or not. This can be handy if a particular platform decides
D: that certain CPU's are not removable. Hence would like to not create
D: a control file.

---

 linux-2.6.7-rc2-root/arch/ppc64/kernel/sysfs.c |   10 ++++++++++
 linux-2.6.7-rc2-root/drivers/base/cpu.c        |    2 +-
 linux-2.6.7-rc2-root/include/linux/cpu.h       |    1 +
 3 files changed, 12 insertions(+), 1 deletion(-)
include/linux/cpu.h renamed from include/linux/cpu.h~cpu_control_file +1 -0
diff -puN include/linux/cpu.h~cpu_control_file include/linux/cpu.h
@@ -27,6 +27,7 @@
 
 struct cpu {
 	int node_id;		/* The node which contains the CPU */
+	int not_removable;	/* This cpu is not removable */
 	struct sys_device sysdev;
 };
 
drivers/base/cpu.c renamed from drivers/base/cpu.c~cpu_control_file +1 -1
diff -puN drivers/base/cpu.c~cpu_control_file drivers/base/cpu.c
@@ -75,7 +75,7 @@ int __init register_cpu(struct cpu *cpu,
 		error = sysfs_create_link(&root->sysdev.kobj,
 					  &cpu->sysdev.kobj,
 					  kobject_name(&cpu->sysdev.kobj));
-	if (!error)
+	if (!error && !cpu->not_removable)
 		register_cpu_control(cpu);
 	return error;
 }
arch/ppc64/kernel/sysfs.c renamed from arch/ppc64/kernel/sysfs.c~cpu_control_file +10 -0
diff -puN arch/ppc64/kernel/sysfs.c~cpu_control_file arch/ppc64/kernel/sysfs.c
@@ -325,6 +325,16 @@ static int __init topology_init(void)
 #ifdef CONFIG_NUMA
 		parent = &node_devices[cpu_to_node(cpu)];
 #endif
+		/*
+		 * For now, we just see if the system supports making
+		 * the RTAS calls for CPU hotplug.  But, there may be a
+		 * more comprehensive way to do this for an individual
+		 * CPU.  For instance, the boot cpu might never be valid
+		 * for hotplugging.
+		 */
+		if (systemcfg->platform == PLATFORM_PSERIES_LPAR)
+			cpu->not_removable=1;
+
 		register_cpu(c, cpu, parent);
 
 		register_cpu_pmc(&c->sysdev);

_

#6 lore raw
In reply to Dave Hansen
Quoted 9 lines · Ashok Raj
Quoted 7 lines · Dave Hansen

knowledge about the system from the pure layout of sysfs. Waiting until __cpu_disable() to tell the user that there was no possibility of the cpu being offlined seems a bit late in the process. Your idea about the cpuinfo file in sysfs is definitely right; it has *exactly* the information that I'm trying to present. But, the current sysfs guidelines tend to discourage single files with lots of information like those in /proc.

Quoted 7 lines

How does the attached patch look? I would try to keep away from proliferation of common->arch->platform code as little as possible. What i have done is send a hint for suppressing the control file creation based on what was set in the struct cpu, before calling register_cpu() by the arch specific topology_init() functions. No new __arch/__platform functions.

here is the untested patch for PPC64, does this seem to do what you need?

I like that patch a lot. It certainly removes any argument about function names :)

Can we maybe change the name of the new field a bit?

-- Dave

arch/ppc64/kernel/sysfs.c +10 -0
diff -urp linux-2.6.7-rc2-mm2-clean/arch/ppc64/kernel/sysfs.c linux-2.6.7-rc2-mm2-cpuonline2/arch/ppc64/kernel/sysfs.c
@@ -325,6 +325,16 @@ static int __init topology_init(void)
 #ifdef CONFIG_NUMA
 		parent = &node_devices[cpu_to_node(cpu)];
 #endif
+		/*
+		 * For now, we just see if the system supports making
+		 * the RTAS calls for CPU hotplug.  But, there may be a
+		 * more comprehensive way to do this for an individual
+		 * CPU.  For instance, the boot cpu might never be valid
+		 * for hotplugging.
+		 */
+		if (systemcfg->platform == PLATFORM_PSERIES_LPAR)
+			cpu->can_control = 1;
+
 		register_cpu(c, cpu, parent);
 
 		register_cpu_pmc(&c->sysdev);
drivers/base/cpu.c +1 -1
diff -urp linux-2.6.7-rc2-mm2-clean/drivers/base/cpu.c linux-2.6.7-rc2-mm2-cpuonline2/drivers/base/cpu.c
@@ -75,7 +75,7 @@ int __init register_cpu(struct cpu *cpu,
 		error = sysfs_create_link(&root->sysdev.kobj,
 					  &cpu->sysdev.kobj,
 					  kobject_name(&cpu->sysdev.kobj));
-	if (!error)
+	if (!error && !cpu->can_control)
 		register_cpu_control(cpu);
 	return error;
 }
include/linux/cpu.h +1 -0
diff -urp linux-2.6.7-rc2-mm2-clean/include/linux/cpu.h linux-2.6.7-rc2-mm2-cpuonline2/include/linux/cpu.h
@@ -27,6 +27,7 @@
 
 struct cpu {
 	int node_id;		/* The node which contains the CPU */
+	int can_control;	/* Should the sysfs control file be created? */
 	struct sys_device sysdev;
 };
 
#7 lore raw
In reply to Dave Hansen

drivers/base/cpu.c int __init register_cpu(struct cpu *cpu, · line 78

Quoted 9 lines · Dave Hansen

diff -urp linux-2.6.7-rc2-mm2-clean/drivers/base/cpu.c linux-2.6.7-rc2-mm2-cpuonline2/drivers/base/cpu.c

drivers/base/cpu.c +1 -1
@@ -75,7 +75,7 @@ int __init register_cpu(struct cpu *cpu,
 		error = sysfs_create_link(&root->sysdev.kobj,
 					  &cpu->sysdev.kobj,
 					  kobject_name(&cpu->sysdev.kobj));
-	if (!error)
+	if (!error && !cpu->can_control)

Should be:
+ if (!error && cpu->can_control)

Right?

include/linux/cpu.h line 30

Quoted 8 lines

diff -urp linux-2.6.7-rc2-mm2-clean/include/linux/cpu.h linux-2.6.7-rc2-mm2-cpuonline2/include/linux/cpu.h

include/linux/cpu.h +1 -0
@@ -27,6 +27,7 @@
 
 struct cpu {
 	int node_id;		/* The node which contains the CPU */
+	int can_control;	/* Should the sysfs control file be created? */

Minor nit -- could we change this comment to "Could this cpu ever be hotpluggable?" Or just name the field "hotpluggable"? That would better document the intent here, wouldn't it?

Nathan

#8 lore raw
In reply to Dave Hansen
Quoted 4 lines · Dave Hansen

I like that patch a lot. It certainly removes any argument about function names :)

Can we maybe change the name of the new field a bit?

I strategically (?) changed the name to not_removable, so the field name can indicate the purpose as well clearly. Oh well, i changed the field name to no_control, to indicate "not to create" a control file. the "can_remove" when i read it in isolation, seems to indicate "this cpu is removable" and for correcness i think we would change the normal case to set as 1 instead.

picky picky picky :-)

i added a note in the function doc as well for clarity.

D: This file provides ability for caller of register_cpu() to either create
D: a control file, or not. This can be handy if a particular platform decides
D: that certain CPU's are not removable. Hence would like to not create
D: a control file.

---

 linux-2.6.7-rc2-root/arch/ppc64/kernel/sysfs.c |   10 ++++++++++
 linux-2.6.7-rc2-root/drivers/base/cpu.c        |    4 +++-
 linux-2.6.7-rc2-root/include/linux/cpu.h       |    1 +
 3 files changed, 14 insertions(+), 1 deletion(-)
include/linux/cpu.h renamed from include/linux/cpu.h~cpu_control_file +1 -0
diff -puN include/linux/cpu.h~cpu_control_file include/linux/cpu.h
@@ -27,6 +27,7 @@
 
 struct cpu {
 	int node_id;		/* The node which contains the CPU */
+	int no_control;		/* Should the sysfs control file be created? */
 	struct sys_device sysdev;
 };
 
drivers/base/cpu.c renamed from drivers/base/cpu.c~cpu_control_file +3 -1
diff -puN drivers/base/cpu.c~cpu_control_file drivers/base/cpu.c
@@ -58,6 +58,8 @@ static inline void register_cpu_control(
 
 /*
  * register_cpu - Setup a driverfs device for a CPU.
+ * @cpu - Callers can set the cpu->no_control field to 1, to indicate not to
+ *		  generate a control file in sysfs for this CPU.
  * @num - CPU number to use when creating the device.
  *
  * Initialize and register the CPU device.
@@ -75,7 +77,7 @@ int __init register_cpu(struct cpu *cpu,
 		error = sysfs_create_link(&root->sysdev.kobj,
 					  &cpu->sysdev.kobj,
 					  kobject_name(&cpu->sysdev.kobj));
-	if (!error)
+	if (!error && !cpu->no_control)
 		register_cpu_control(cpu);
 	return error;
 }
arch/ppc64/kernel/sysfs.c renamed from arch/ppc64/kernel/sysfs.c~cpu_control_file +10 -0
diff -puN arch/ppc64/kernel/sysfs.c~cpu_control_file arch/ppc64/kernel/sysfs.c
@@ -325,6 +325,16 @@ static int __init topology_init(void)
 #ifdef CONFIG_NUMA
 		parent = &node_devices[cpu_to_node(cpu)];
 #endif
+		/*
+		 * For now, we just see if the system supports making
+		 * the RTAS calls for CPU hotplug.  But, there may be a
+		 * more comprehensive way to do this for an individual
+		 * CPU.  For instance, the boot cpu might never be valid
+		 * for hotplugging.
+		 */
+		if (systemcfg->platform = PLATFORM_PSERIES_LPAR)
+			cpu->no_control=1;
+
 		register_cpu(c, cpu, parent);
 
 		register_cpu_pmc(&c->sysdev);

_

#9 lore raw
In reply to Dave Hansen

Review

Quoted 7 lines · Nathan Lynch

Review

Quoted 2 lines · Dave Hansen
(quoted diff) +1 -1
-	if (!error)
+	if (!error && !cpu->can_control)

Should be:

(quoted diff) +1 -0
+	if (!error && cpu->can_control)

Glad someone else also read it the same way as i did

the name is now fixed in the new patch posted.... you caught me just few mins before.

Cheers,
ashok

#10 lore raw
In reply to Dave Hansen

On Mon, 2004-06-07 at 07:08, Ashok Raj wrote:plugging.

Review

Quoted 2 lines
(quoted diff) +2 -0
+		if (systemcfg->platform = PLATFORM_PSERIES_LPAR)
+			cpu->no_control=1;

That condition is also inverted. Should read:

if (systemcfg->platform != PLATFORM_PSERIES_LPAR)

	cpu->no_control = 1;

-- Dave

#11 lore raw
In reply to Dave Hansen
Quoted 8 lines · Dave Hansen

On Mon, 2004-06-07 at 07:08, Ashok Raj wrote:plugging.

Review

Quoted 2 lines
(quoted diff) +2 -0
+		if (systemcfg->platform == PLATFORM_PSERIES_LPAR)
+			cpu->no_control=1;

That condition is also inverted. Should read:

if (systemcfg->platform != PLATFORM_PSERIES_LPAR)

	cpu->no_control = 1;

Good catch...I knew i mentioned untested :-)

fixed patch attached...

Cheers,
ashok

D: This file provides ability for caller of register_cpu() to either create
D: a control file, or not. This can be handy if a particular platform decides
D: that certain CPU's are not removable. Hence would like to not create
D: a control file.

---

 linux-2.6.7-rc2-root/arch/ppc64/kernel/sysfs.c |   10 ++++++++++
 linux-2.6.7-rc2-root/drivers/base/cpu.c        |    4 +++-
 linux-2.6.7-rc2-root/include/linux/cpu.h       |    1 +
 3 files changed, 14 insertions(+), 1 deletion(-)
include/linux/cpu.h renamed from include/linux/cpu.h~cpu_control_file +1 -0
diff -puN include/linux/cpu.h~cpu_control_file include/linux/cpu.h
@@ -27,6 +27,7 @@
 
 struct cpu {
 	int node_id;		/* The node which contains the CPU */
+	int no_control;		/* Should the sysfs control file be created? */
 	struct sys_device sysdev;
 };
 
drivers/base/cpu.c renamed from drivers/base/cpu.c~cpu_control_file +3 -1
diff -puN drivers/base/cpu.c~cpu_control_file drivers/base/cpu.c
@@ -58,6 +58,8 @@ static inline void register_cpu_control(
 
 /*
  * register_cpu - Setup a driverfs device for a CPU.
+ * @cpu - Callers can set the cpu->no_control field to 1, to indicate not to
+ *		  generate a control file in sysfs for this CPU.
  * @num - CPU number to use when creating the device.
  *
  * Initialize and register the CPU device.
@@ -75,7 +77,7 @@ int __init register_cpu(struct cpu *cpu,
 		error = sysfs_create_link(&root->sysdev.kobj,
 					  &cpu->sysdev.kobj,
 					  kobject_name(&cpu->sysdev.kobj));
-	if (!error)
+	if (!error && !cpu->no_control)
 		register_cpu_control(cpu);
 	return error;
 }
arch/ppc64/kernel/sysfs.c renamed from arch/ppc64/kernel/sysfs.c~cpu_control_file +10 -0
diff -puN arch/ppc64/kernel/sysfs.c~cpu_control_file arch/ppc64/kernel/sysfs.c
@@ -325,6 +325,16 @@ static int __init topology_init(void)
 #ifdef CONFIG_NUMA
 		parent = &node_devices[cpu_to_node(cpu)];
 #endif
+		/*
+		 * For now, we just see if the system supports making
+		 * the RTAS calls for CPU hotplug.  But, there may be a
+		 * more comprehensive way to do this for an individual
+		 * CPU.  For instance, the boot cpu might never be valid
+		 * for hotplugging.
+		 */
+		if (systemcfg->platform != PLATFORM_PSERIES_LPAR)
+			cpu->no_control=1;
+
 		register_cpu(c, cpu, parent);
 
 		register_cpu_pmc(&c->sysdev);

_

#12 lore raw
In reply to Dave Hansen
Quoted 7 lines · Ashok Raj
Quoted 6 lines · Dave Hansen

On Mon, 2004-06-07 at 07:08, Ashok Raj wrote:plugging.

Review

Quoted 2 lines
(quoted diff) +2 -0
+		if (systemcfg->platform == PLATFORM_PSERIES_LPAR)
+			cpu->no_control=1;

That condition is also inverted. Should read:

Quoted 6 lines
Quoted 2 lines

if (systemcfg->platform != PLATFORM_PSERIES_LPAR)

	cpu->no_control = 1;

Good catch...I knew i mentioned untested :-)

fixed patch attached...

The smallest of nitpicks:

	cpu->no_control=1;

needs to be

	cpu->no_control = 1;

Would you like to submit this now?

-- Dave

D: This file provides ability for caller of register_cpu() to either create
D: a control file, or not. This can be handy if a particular platform decides
D: that certain CPU's are not removable. Hence would like to not create
D: a control file.

---

 linux-2.6.7-rc2-root/arch/ppc64/kernel/sysfs.c |   10 ++++++++++
 linux-2.6.7-rc2-root/drivers/base/cpu.c        |    4 +++-
 linux-2.6.7-rc2-root/include/linux/cpu.h       |    1 +
 3 files changed, 14 insertions(+), 1 deletion(-)
include/linux/cpu.h renamed from include/linux/cpu.h~cpu_control_file +1 -0
diff -puN include/linux/cpu.h~cpu_control_file include/linux/cpu.h
@@ -27,6 +27,7 @@
 
 struct cpu {
 	int node_id;		/* The node which contains the CPU */
+	int no_control;		/* Should the sysfs control file be created? */
 	struct sys_device sysdev;
 };
 
drivers/base/cpu.c renamed from drivers/base/cpu.c~cpu_control_file +3 -1
diff -puN drivers/base/cpu.c~cpu_control_file drivers/base/cpu.c
@@ -58,6 +58,8 @@ static inline void register_cpu_control(
 
 /*
  * register_cpu - Setup a driverfs device for a CPU.
+ * @cpu - Callers can set the cpu->no_control field to 1, to indicate not to
+ *		  generate a control file in sysfs for this CPU.
  * @num - CPU number to use when creating the device.
  *
  * Initialize and register the CPU device.
@@ -75,7 +77,7 @@ int __init register_cpu(struct cpu *cpu,
 		error = sysfs_create_link(&root->sysdev.kobj,
 					  &cpu->sysdev.kobj,
 					  kobject_name(&cpu->sysdev.kobj));
-	if (!error)
+	if (!error && !cpu->no_control)
 		register_cpu_control(cpu);
 	return error;
 }
arch/ppc64/kernel/sysfs.c renamed from arch/ppc64/kernel/sysfs.c~cpu_control_file +10 -0
diff -puN arch/ppc64/kernel/sysfs.c~cpu_control_file arch/ppc64/kernel/sysfs.c
@@ -325,6 +325,16 @@ static int __init topology_init(void)
 #ifdef CONFIG_NUMA
 		parent = &node_devices[cpu_to_node(cpu)];
 #endif
+		/*
+		 * For now, we just see if the system supports making
+		 * the RTAS calls for CPU hotplug.  But, there may be a
+		 * more comprehensive way to do this for an individual
+		 * CPU.  For instance, the boot cpu might never be valid
+		 * for hotplugging.
+		 */
+		if (systemcfg->platform != PLATFORM_PSERIES_LPAR)
+			cpu->no_control = 1;
+
 		register_cpu(c, cpu, parent);
 
 		register_cpu_pmc(&c->sysdev);

_

#14 lore raw
In reply to Dave Hansen
Quoted 34 lines · Ashok Raj
Quoted 8 lines · Dave Hansen

On Mon, 2004-06-07 at 07:08, Ashok Raj wrote:plugging.

Review

Quoted 2 lines
(quoted diff) +2 -0
+		if (systemcfg->platform = PLATFORM_PSERIES_LPAR)
+			cpu->no_control=1;

That condition is also inverted. Should read:

if (systemcfg->platform != PLATFORM_PSERIES_LPAR)

	cpu->no_control = 1;

Good catch...I knew i mentioned untested :-)

fixed patch attached...

...
--- linux-2.6.7-rc2/arch/ppc64/kernel/sysfs.c~cpu_control_file 2004-06-06 13:12:06.467033408 -0700
+++ linux-2.6.7-rc2-root/arch/ppc64/kernel/sysfs.c 2004-06-07 10:12:45.999901454 -0700
@@ -325,6 +325,16 @@ static int __init topology_init(void)
#ifdef CONFIG_NUMA
parent = &node_devices[cpu_to_node(cpu)];
#endif
+ /*
+ * For now, we just see if the system supports making
+ * the RTAS calls for CPU hotplug. But, there may be a
+ * more comprehensive way to do this for an individual
+ * CPU. For instance, the boot cpu might never be valid
+ * for hotplugging.
+ */
+ if (systemcfg->platform != PLATFORM_PSERIES_LPAR)
+ cpu->no_control=1;
+
register_cpu(c, cpu, parent);

Quoted 2 lines
  		register_cpu_pmc(&c->sysdev);

The ppc64 part doesn't compile - `cpu' is an integer.

#15 lore raw
In reply to Dave Hansen
Quoted 8 lines · Andrew Morton
Quoted 6 lines · Ashok Raj
Quoted 4 lines · Dave Hansen

On Mon, 2004-06-07 at 07:08, Ashok Raj wrote:plugging.

Review

Quoted 2 lines
(quoted diff) +2 -0
+		if (systemcfg->platform = PLATFORM_PSERIES_LPAR)
+			cpu->no_control=1;

The ppc64 part doesn't compile - `cpu' is an integer.

Sorry about that... I dont have a PPC64 platform....

ashokr

D: This file provides ability for caller of register_cpu() to either create
D: a control file, or not. This can be handy if a particular platform decides
D: that certain CPU's are not removable. Hence would like to not create
D: a control file.

---

 linux-2.6.7-rc2-root/arch/ppc64/kernel/sysfs.c |   10 ++++++++++
 linux-2.6.7-rc2-root/drivers/base/cpu.c        |    4 +++-
 linux-2.6.7-rc2-root/include/linux/cpu.h       |    1 +
 3 files changed, 14 insertions(+), 1 deletion(-)
include/linux/cpu.h renamed from include/linux/cpu.h~cpu_control_file +1 -0
diff -puN include/linux/cpu.h~cpu_control_file include/linux/cpu.h
@@ -27,6 +27,7 @@
 
 struct cpu {
 	int node_id;		/* The node which contains the CPU */
+	int no_control;		/* Should the sysfs control file be created? */
 	struct sys_device sysdev;
 };
 
drivers/base/cpu.c renamed from drivers/base/cpu.c~cpu_control_file +3 -1
diff -puN drivers/base/cpu.c~cpu_control_file drivers/base/cpu.c
@@ -58,6 +58,8 @@ static inline void register_cpu_control(
 
 /*
  * register_cpu - Setup a driverfs device for a CPU.
+ * @cpu - Callers can set the cpu->no_control field to 1, to indicate not to
+ *		  generate a control file in sysfs for this CPU.
  * @num - CPU number to use when creating the device.
  *
  * Initialize and register the CPU device.
@@ -75,7 +77,7 @@ int __init register_cpu(struct cpu *cpu,
 		error = sysfs_create_link(&root->sysdev.kobj,
 					  &cpu->sysdev.kobj,
 					  kobject_name(&cpu->sysdev.kobj));
-	if (!error)
+	if (!error && !cpu->no_control)
 		register_cpu_control(cpu);
 	return error;
 }
arch/ppc64/kernel/sysfs.c renamed from arch/ppc64/kernel/sysfs.c~cpu_control_file +10 -0
diff -puN arch/ppc64/kernel/sysfs.c~cpu_control_file arch/ppc64/kernel/sysfs.c
@@ -325,6 +325,16 @@ static int __init topology_init(void)
 #ifdef CONFIG_NUMA
 		parent = &node_devices[cpu_to_node(cpu)];
 #endif
+		/*
+		 * For now, we just see if the system supports making
+		 * the RTAS calls for CPU hotplug.  But, there may be a
+		 * more comprehensive way to do this for an individual
+		 * CPU.  For instance, the boot cpu might never be valid
+		 * for hotplugging.
+		 */
+		if (systemcfg->platform != PLATFORM_PSERIES_LPAR)
+			c->no_control = 1;
+
 		register_cpu(c, cpu, parent);
 
 		register_cpu_pmc(&c->sysdev);

_