Skip to contentSkip to conversation

Allow cpusets to be configured/built on non-SMP systems

PATCH In review Paul Menage 6 participants 16 messages Mar 3, 2009 4 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow cpusets to be configured/built on non-SMP systems

Allow cpusets to be configured/built on non-SMP systems

Currently it's impossible to build cpusets under UML on x86-64, since cpusets depends on SMP and x86-64 UML doesn't support SMP.

There's code in cpusets that doesn't depend on SMP. This patch surrounds the minimum amount of cpusets code with #ifdef CONFIG_SMP in order to allow cpusets to build/run on UP systems (for testing purposes under UML).

---

 init/Kconfig    |    2 +-
 kernel/cpuset.c |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletions(-)
init/Kconfig +1 -1
index 92d2c64..3f20aa2 100644
@@ -477,7 +477,7 @@ config CGROUP_DEVICE
 
 config CPUSETS
 	bool "Cpuset support"
-	depends on SMP && CGROUPS
+	depends on CGROUPS
 	help
 	  This option will let you create and manage CPUSETs which
 	  allow dynamically partitioning a system into sets of CPUs and
kernel/cpuset.c +14 -0
index a46d693..b4d12d8 100644
@@ -517,6 +517,8 @@ static int validate_change(const struct cpuset *cur, const struct cpuset *trial)
 	return 0;
 }
 
+#ifdef CONFIG_SMP
+
 /*
  * Helper routine for generate_sched_domains().
  * Do cpusets a, b have overlapping cpus_allowed masks?
@@ -811,6 +813,16 @@ static void do_rebuild_sched_domains(struct work_struct *unused)
 
 	put_online_cpus();
 }
+#else
+static void do_rebuild_sched_domains(struct work_struct *unused)
+{
+}
+
+static int generate_sched_domains(struct cpumask **domains,
+			struct sched_domain_attr **attributes)
+{
+}
+#endif // CONFIG_SMP
 
 static DECLARE_WORK(rebuild_sched_domains_work, do_rebuild_sched_domains);
 
@@ -1164,8 +1176,10 @@ int current_cpuset_is_being_rebound(void)
 
 static int update_relax_domain_level(struct cpuset *cs, s64 val)
 {
+#ifdef CONFIG_SMP
 	if (val < -1 || val >= SD_LV_MAX)
 		return -EINVAL;
+#endif
 
 	if (val != cs->relax_domain_level) {
 		cs->relax_domain_level = val;
#1 lore raw

kernel/cpuset.c static void do_rebuild_sched_domains(struct work_struct *unused) · line 823

Quoted 3 lines
kernel/cpuset.c +3 -0
+static int generate_sched_domains(struct cpumask **domains,
+			struct sched_domain_attr **attributes)
+{

return 0;

Quoted 1 line

+}

A message that is not in the archive (sent off-list or not yet received): 20090303013432.11211.18662.stgit-B63HFAS8fGlSzHKm+aFRNNkmqwFzkYv6@public.gmane.org

#3 lore raw

kernel/cpuset.c static void do_rebuild_sched_domains(struct work_struct *unused) · line 823

Quoted 3 lines
kernel/cpuset.c +3 -0
+static int generate_sched_domains(struct cpumask **domains,
+			struct sched_domain_attr **attributes)
+{

return 0;

Quoted 1 line

+}

Reviewed-by
#4 lore raw
In reply to a message not in the archive
Quoted 10 lines · Paul Menage

Allow cpusets to be configured/built on non-SMP systems

Currently it's impossible to build cpusets under UML on x86-64, since cpusets depends on SMP and x86-64 UML doesn't support SMP.

There's code in cpusets that doesn't depend on SMP. This patch surrounds the minimum amount of cpusets code with #ifdef CONFIG_SMP in order to allow cpusets to build/run on UP systems (for testing purposes under UML).

The patch is ok for this purpose.

Quoted 7 lines

---

 init/Kconfig    |    2 +-
 kernel/cpuset.c |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletions(-)

...

kernel/cpuset.c static void do_rebuild_sched_domains(struct work_struct *unused) · line 823

Quoted 3 lines
kernel/cpuset.c +3 -0
+static int generate_sched_domains(struct cpumask **domains,
+			struct sched_domain_attr **attributes)
+{

Except here should "return 0;", otherwise emit a compile warining.

Quoted 1 line

+}

#5 lore raw
In reply to a message not in the archive
Quoted 46 lines · Paul Menage

Allow cpusets to be configured/built on non-SMP systems

Currently it's impossible to build cpusets under UML on x86-64, since cpusets depends on SMP and x86-64 UML doesn't support SMP.

There's code in cpusets that doesn't depend on SMP. This patch surrounds the minimum amount of cpusets code with #ifdef CONFIG_SMP in order to allow cpusets to build/run on UP systems (for testing purposes under UML).

---

 init/Kconfig    |    2 +-
 kernel/cpuset.c |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletions(-)
init/Kconfig +1 -1
index 92d2c64..3f20aa2 100644
@@ -477,7 +477,7 @@ config CGROUP_DEVICE
 
 config CPUSETS
 	bool "Cpuset support"
-	depends on SMP && CGROUPS
+	depends on CGROUPS
 	help
 	  This option will let you create and manage CPUSETs which
 	  allow dynamically partitioning a system into sets of CPUs and
kernel/cpuset.c +2 -0
index a46d693..b4d12d8 100644
@@ -517,6 +517,8 @@ static int validate_change(const struct cpuset *cur, const struct cpuset *trial)
 	return 0;
 }
 
+#ifdef CONFIG_SMP
+
 /*
  * Helper routine for generate_sched_domains().
  * Do cpusets a, b have overlapping cpus_allowed masks?

kernel/cpuset.c static void do_rebuild_sched_domains(struct work_struct *unused) · line 816

Quoted 4 lines
kernel/cpuset.c +1 -0
@@ -811,6 +813,16 @@ static void do_rebuild_sched_domains(struct work_struct *unused)
 
 	put_online_cpus();
 }
+#else

Please use:

kernel/cpuset.c static void do_rebuild_sched_domains(struct work_struct *unused) · line 817

Quoted 1 line
kernel/cpuset.c +1 -0
+#else /* !CONFIG_SMP: */

to show that it's the UP branch - even if the #ifdef itself has scrolled off from screen already.

kernel/cpuset.c static void do_rebuild_sched_domains(struct work_struct *unused) · line 825

Quoted 9 lines
kernel/cpuset.c +9 -0
+static void do_rebuild_sched_domains(struct work_struct *unused)
+{
+}
+
+static int generate_sched_domains(struct cpumask **domains,
+			struct sched_domain_attr **attributes)
+{
+}
+#endif // CONFIG_SMP

Please dont use C++ comments.

Looks good otherwise. (Btw., please try to Cc: PeterZ and me to cpusets patches in the future, especially when it affects the scheduler.)

Ingo

Reviewed-by on v1 1/1
#6 lore raw
In reply to Paul Menage
Quoted 10 lines · Paul Menage

Allow cpusets to be configured/built on non-SMP systems

Currently it's impossible to build cpusets under UML on x86-64, since cpusets depends on SMP and x86-64 UML doesn't support SMP.

There's code in cpusets that doesn't depend on SMP. This patch surrounds the minimum amount of cpusets code with #ifdef CONFIG_SMP in order to allow cpusets to build/run on UP systems (for testing purposes under UML).

The patch is ok for this purpose.

Quoted 7 lines

---

 init/Kconfig    |    2 +-
 kernel/cpuset.c |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletions(-)

...

kernel/cpuset.c static void do_rebuild_sched_domains(struct work_struct *unused) · line 823

Quoted 3 lines
kernel/cpuset.c +3 -0
+static int generate_sched_domains(struct cpumask **domains,
+			struct sched_domain_attr **attributes)
+{

Except here should "return 0;", otherwise emit a compile warining.

Quoted 1 line

+}

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw
Quoted 6 lines · Li Zefan

kernel/cpuset.c static void do_rebuild_sched_domains(struct work_struct *unused) · line 823

Quoted 3 lines
kernel/cpuset.c +3 -0
+static int generate_sched_domains(struct cpumask **domains,
+                     struct sched_domain_attr **attributes)
+{

Except here should "return 0;", otherwise emit a compile warining.

Good catch - the weird thing is that (in my UML build) it doesn't actually generate that warning. Mysterious.

I'll resend with the extra return.

Paul

#9 lore raw
In reply to Li Zefan
Quoted 6 lines · Li Zefan

kernel/cpuset.c static void do_rebuild_sched_domains(struct work_struct *unused) · line 823

Quoted 3 lines
kernel/cpuset.c +3 -0
+static int generate_sched_domains(struct cpumask **domains,
+                     struct sched_domain_attr **attributes)
+{

Except here should "return 0;", otherwise emit a compile warining.

Good catch - the weird thing is that (in my UML build) it doesn't actually generate that warning. Mysterious.

I'll resend with the extra return.

Paul

A message that is not in the archive (sent off-list or not yet received): 6599ad830903022201s4d2296c7u225e84a77f9f7167-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#11 lore raw
Quoted 10 lines · Paul Menage
Quoted 6 lines · Li Zefan

kernel/cpuset.c static void do_rebuild_sched_domains(struct work_struct *unused) · line 823

Quoted 3 lines
kernel/cpuset.c +3 -0
+static int generate_sched_domains(struct cpumask **domains,
+                     struct sched_domain_attr **attributes)
+{

Except here should "return 0;", otherwise emit a compile warining.

Good catch - the weird thing is that (in my UML build) it doesn't actually generate that warning. Mysterious.

Hmm, my guess is that since UML doesn't have hotplug either, the only reference to generate_sched_domains doesn't actually invoke it, so gcc doesn't even bother compiling it.

Paul

#12 lore raw
In reply to a message not in the archive
Quoted 8 lines · Paul Menage
Quoted 6 lines · Li Zefan

kernel/cpuset.c static void do_rebuild_sched_domains(struct work_struct *unused) · line 823

Quoted 3 lines
kernel/cpuset.c +3 -0
+static int generate_sched_domains(struct cpumask **domains,
+                     struct sched_domain_attr **attributes)
+{

Except here should "return 0;", otherwise emit a compile warining.

Quoted 4 lines

Good catch - the weird thing is that (in my UML build) it doesn't actually generate that warning. Mysterious.

I'll resend with the extra return.

After looking at the sched domains code it's not clear to me that returning 0 is necessarily the right thing to do - partition_sched_domains() says that 0 is a special case used for destroying existing domains? Would returning 1 and setting up a single dummy domain be better?

Given that this return code only matters when CONFIG_HOTPLUG_CPU && !CONFIG_SMP it's unlikely to ever be used, but I guess it's better to get it right.

Paul

#13 lore raw
In reply to Paul Menage
Quoted 10 lines · Paul Menage
Quoted 6 lines · Li Zefan

kernel/cpuset.c static void do_rebuild_sched_domains(struct work_struct *unused) · line 823

Quoted 3 lines
kernel/cpuset.c +3 -0
+static int generate_sched_domains(struct cpumask **domains,
+                     struct sched_domain_attr **attributes)
+{

Except here should "return 0;", otherwise emit a compile warining.

Good catch - the weird thing is that (in my UML build) it doesn't actually generate that warning. Mysterious.

Hmm, my guess is that since UML doesn't have hotplug either, the only reference to generate_sched_domains doesn't actually invoke it, so gcc doesn't even bother compiling it.

Paul

#14 lore raw
In reply to Paul Menage
Quoted 8 lines · Paul Menage
Quoted 6 lines · Li Zefan

kernel/cpuset.c static void do_rebuild_sched_domains(struct work_struct *unused) · line 823

Quoted 3 lines
kernel/cpuset.c +3 -0
+static int generate_sched_domains(struct cpumask **domains,
+                     struct sched_domain_attr **attributes)
+{

Except here should "return 0;", otherwise emit a compile warining.

Quoted 4 lines

Good catch - the weird thing is that (in my UML build) it doesn't actually generate that warning. Mysterious.

I'll resend with the extra return.

After looking at the sched domains code it's not clear to me that returning 0 is necessarily the right thing to do - partition_sched_domains() says that 0 is a special case used for destroying existing domains? Would returning 1 and setting up a single dummy domain be better?

Given that this return code only matters when CONFIG_HOTPLUG_CPU && !CONFIG_SMP it's unlikely to ever be used, but I guess it's better to get it right.

Paul

#15 lore raw
Quoted 10 lines · Paul Menage
Quoted 9 lines · Paul Menage
Quoted 5 lines · Li Zefan

kernel/cpuset.c static void do_rebuild_sched_domains(struct work_struct *unused) · line 823

Quoted 3 lines
kernel/cpuset.c +3 -0
+static int generate_sched_domains(struct cpumask **domains,
+                     struct sched_domain_attr **attributes)
+{

Except here should "return 0;", otherwise emit a compile warining.

Good catch - the weird thing is that (in my UML build) it doesn't actually generate that warning. Mysterious.

Quoted 8 lines
Quoted 1 line

I'll resend with the extra return.

After looking at the sched domains code it's not clear to me that returning 0 is necessarily the right thing to do - partition_sched_domains() says that 0 is a special case used for destroying existing domains? Would returning 1 and setting up a single dummy domain be better?

Yes, return 1 seems more reasonable. And if we do this, should we also set *domains to NULL like this?

static int generate_sched_domains(struct cpumask **domains,
struct sched_domain_attr **attributes)

{
	*domains = NULL;
	return 1;
}

because otherwise partition_sched_domains() will access invalid memory:

void partition_sched_domains(int ndoms_new, struct cpumask *doms_new,
struct sched_domain_attr *dattr_new)

{
	...
	n = doms_new ? ndoms_new : 0;

	for (i = 0; i < ndoms_cur; i++) {
		for (j = 0; j < n && !new_topology; j++) {
			// *****here*****/
			if (cpumask_equal(&doms_cur[i], &doms_new[j])
			    && dattrs_equal(dattr_cur, i, dattr_new, j))
				goto match1;
		}
	...
	}
Quoted 2 lines

Given that this return code only matters when CONFIG_HOTPLUG_CPU && !CONFIG_SMP it's unlikely to ever be used

That's why I didn't comment on this.

Quoted 2 lines

but I guess it's better to get it right.

But I agree with you. :)

#16 lore raw
Quoted 11 lines · Li Zefan
Quoted 10 lines · Paul Menage
Quoted 9 lines · Paul Menage
Quoted 5 lines · Li Zefan

kernel/cpuset.c static void do_rebuild_sched_domains(struct work_struct *unused) · line 823

Quoted 3 lines
kernel/cpuset.c +3 -0
+static int generate_sched_domains(struct cpumask **domains,
+                     struct sched_domain_attr **attributes)
+{

Except here should "return 0;", otherwise emit a compile warining.

Good catch - the weird thing is that (in my UML build) it doesn't actually generate that warning. Mysterious.

Quoted 8 lines
Quoted 7 lines
Quoted 1 line

I'll resend with the extra return.

After looking at the sched domains code it's not clear to me that returning 0 is necessarily the right thing to do - partition_sched_domains() says that 0 is a special case used for destroying existing domains? Would returning 1 and setting up a single dummy domain be better?

partition_sched_domains() says (0, NULL, ...) is used for destroying existing domains, (1, NULL, ...) will fallback to the single default domain.

But partition_sched_domains() is a stub if !CONFIG_SMP

Quoted 10 lines

Yes, return 1 seems more reasonable. And if we do this, should we also set *domains to NULL like this?

static int generate_sched_domains(struct cpumask **domains,
struct sched_domain_attr **attributes)

{
	*domains = NULL;
	return 1;
}

A message that is not in the archive (sent off-list or not yet received): [email protected]

#18 lore raw
Quoted 11 lines · Li Zefan
Quoted 10 lines · Paul Menage
Quoted 9 lines · Paul Menage
Quoted 5 lines · Li Zefan

kernel/cpuset.c static void do_rebuild_sched_domains(struct work_struct *unused) · line 823

Quoted 3 lines
kernel/cpuset.c +3 -0
+static int generate_sched_domains(struct cpumask **domains,
+                     struct sched_domain_attr **attributes)
+{

Except here should "return 0;", otherwise emit a compile warining.

Good catch - the weird thing is that (in my UML build) it doesn't actually generate that warning. Mysterious.

Quoted 8 lines
Quoted 7 lines
Quoted 1 line

I'll resend with the extra return.

After looking at the sched domains code it's not clear to me that returning 0 is necessarily the right thing to do - partition_sched_domains() says that 0 is a special case used for destroying existing domains? Would returning 1 and setting up a single dummy domain be better?

partition_sched_domains() says (0, NULL, ...) is used for destroying existing domains, (1, NULL, ...) will fallback to the single default domain.

But partition_sched_domains() is a stub if !CONFIG_SMP

Quoted 10 lines

Yes, return 1 seems more reasonable. And if we do this, should we also set *domains to NULL like this?

static int generate_sched_domains(struct cpumask **domains,
struct sched_domain_attr **attributes)

{
	*domains = NULL;
	return 1;
}
#19 lore raw
In reply to Paul Menage
Quoted 46 lines · Paul Menage

Allow cpusets to be configured/built on non-SMP systems

Currently it's impossible to build cpusets under UML on x86-64, since cpusets depends on SMP and x86-64 UML doesn't support SMP.

There's code in cpusets that doesn't depend on SMP. This patch surrounds the minimum amount of cpusets code with #ifdef CONFIG_SMP in order to allow cpusets to build/run on UP systems (for testing purposes under UML).

---

 init/Kconfig    |    2 +-
 kernel/cpuset.c |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletions(-)
init/Kconfig +1 -1
index 92d2c64..3f20aa2 100644
@@ -477,7 +477,7 @@ config CGROUP_DEVICE
 
 config CPUSETS
 	bool "Cpuset support"
-	depends on SMP && CGROUPS
+	depends on CGROUPS
 	help
 	  This option will let you create and manage CPUSETs which
 	  allow dynamically partitioning a system into sets of CPUs and
kernel/cpuset.c +2 -0
index a46d693..b4d12d8 100644
@@ -517,6 +517,8 @@ static int validate_change(const struct cpuset *cur, const struct cpuset *trial)
 	return 0;
 }
 
+#ifdef CONFIG_SMP
+
 /*
  * Helper routine for generate_sched_domains().
  * Do cpusets a, b have overlapping cpus_allowed masks?

kernel/cpuset.c static void do_rebuild_sched_domains(struct work_struct *unused) · line 816

Quoted 4 lines
kernel/cpuset.c +1 -0
@@ -811,6 +813,16 @@ static void do_rebuild_sched_domains(struct work_struct *unused)
 
 	put_online_cpus();
 }
+#else

Please use:

kernel/cpuset.c static void do_rebuild_sched_domains(struct work_struct *unused) · line 817

Quoted 1 line
kernel/cpuset.c +1 -0
+#else /* !CONFIG_SMP: */

to show that it's the UP branch - even if the #ifdef itself has scrolled off from screen already.

kernel/cpuset.c static void do_rebuild_sched_domains(struct work_struct *unused) · line 825

Quoted 9 lines
kernel/cpuset.c +9 -0
+static void do_rebuild_sched_domains(struct work_struct *unused)
+{
+}
+
+static int generate_sched_domains(struct cpumask **domains,
+			struct sched_domain_attr **attributes)
+{
+}
+#endif // CONFIG_SMP

Please dont use C++ comments.

Looks good otherwise. (Btw., please try to Cc: PeterZ and me to cpusets patches in the future, especially when it affects the scheduler.)

Ingo