public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Allow cpusets to be configured/built on non-SMP systems
@ 2009-03-03  1:36 Paul Menage
  2009-03-03  2:01 ` Li Zefan
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Paul Menage @ 2009-03-03  1:36 UTC (permalink / raw)
  To: Li Zefan, Andrew Morton; +Cc: LKML, Linux Containers

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).

Signed-off-by: Paul Menage <menage@google.com>

---

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

diff --git a/init/Kconfig b/init/Kconfig
index 92d2c64..3f20aa2 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -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
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index a46d693..b4d12d8 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -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;


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] Allow cpusets to be configured/built on non-SMP systems
  2009-03-03  1:36 [PATCH] Allow cpusets to be configured/built on non-SMP systems Paul Menage
@ 2009-03-03  2:01 ` Li Zefan
  2009-03-03  3:17 ` Li Zefan
  2009-03-03  8:07 ` Ingo Molnar
  2 siblings, 0 replies; 10+ messages in thread
From: Li Zefan @ 2009-03-03  2:01 UTC (permalink / raw)
  To: Paul Menage; +Cc: Andrew Morton, LKML, Linux Containers

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

return 0;

> +}

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Allow cpusets to be configured/built on non-SMP systems
  2009-03-03  1:36 [PATCH] Allow cpusets to be configured/built on non-SMP systems Paul Menage
  2009-03-03  2:01 ` Li Zefan
@ 2009-03-03  3:17 ` Li Zefan
  2009-03-03  6:01   ` Paul Menage
  2009-03-03  8:07 ` Ingo Molnar
  2 siblings, 1 reply; 10+ messages in thread
From: Li Zefan @ 2009-03-03  3:17 UTC (permalink / raw)
  To: Paul Menage; +Cc: Andrew Morton, LKML, Linux Containers

Paul Menage wrote:
> 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.

Reviewed-by: Li Zefan <lizf@cn.fujitsu.com>

> Signed-off-by: Paul Menage <menage@google.com>
> 
> ---
> 
>  init/Kconfig    |    2 +-
>  kernel/cpuset.c |   14 ++++++++++++++
>  2 files changed, 15 insertions(+), 1 deletions(-)
...
> +static int generate_sched_domains(struct cpumask **domains,
> +			struct sched_domain_attr **attributes)
> +{

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

> +}

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Allow cpusets to be configured/built on non-SMP systems
  2009-03-03  3:17 ` Li Zefan
@ 2009-03-03  6:01   ` Paul Menage
  2009-03-03  6:41     ` Paul Menage
  2009-03-03  8:26     ` Paul Menage
  0 siblings, 2 replies; 10+ messages in thread
From: Paul Menage @ 2009-03-03  6:01 UTC (permalink / raw)
  To: Li Zefan; +Cc: Andrew Morton, LKML, Linux Containers

On Mon, Mar 2, 2009 at 7:17 PM, Li Zefan <lizf@cn.fujitsu.com> wrote:
>> +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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Allow cpusets to be configured/built on non-SMP systems
  2009-03-03  6:01   ` Paul Menage
@ 2009-03-03  6:41     ` Paul Menage
  2009-03-03  8:26     ` Paul Menage
  1 sibling, 0 replies; 10+ messages in thread
From: Paul Menage @ 2009-03-03  6:41 UTC (permalink / raw)
  To: Li Zefan; +Cc: Andrew Morton, LKML, Linux Containers

On Mon, Mar 2, 2009 at 10:01 PM, Paul Menage <menage@google.com> wrote:
> On Mon, Mar 2, 2009 at 7:17 PM, Li Zefan <lizf@cn.fujitsu.com> wrote:
>>> +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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Allow cpusets to be configured/built on non-SMP systems
  2009-03-03  1:36 [PATCH] Allow cpusets to be configured/built on non-SMP systems Paul Menage
  2009-03-03  2:01 ` Li Zefan
  2009-03-03  3:17 ` Li Zefan
@ 2009-03-03  8:07 ` Ingo Molnar
  2 siblings, 0 replies; 10+ messages in thread
From: Ingo Molnar @ 2009-03-03  8:07 UTC (permalink / raw)
  To: Paul Menage
  Cc: Li Zefan, Andrew Morton, LKML, Linux Containers, Peter Zijlstra


* Paul Menage <menage@google.com> wrote:

> 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).
> 
> Signed-off-by: Paul Menage <menage@google.com>
> 
> ---
> 
>  init/Kconfig    |    2 +-
>  kernel/cpuset.c |   14 ++++++++++++++
>  2 files changed, 15 insertions(+), 1 deletions(-)
> 
> diff --git a/init/Kconfig b/init/Kconfig
> index 92d2c64..3f20aa2 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -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
> diff --git a/kernel/cpuset.c b/kernel/cpuset.c
> index a46d693..b4d12d8 100644
> --- a/kernel/cpuset.c
> +++ b/kernel/cpuset.c
>
> @@ -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

Please use:

> +#else /* !CONFIG_SMP: */

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

> +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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Allow cpusets to be configured/built on non-SMP systems
  2009-03-03  6:01   ` Paul Menage
  2009-03-03  6:41     ` Paul Menage
@ 2009-03-03  8:26     ` Paul Menage
  2009-03-03  8:42       ` Li Zefan
  1 sibling, 1 reply; 10+ messages in thread
From: Paul Menage @ 2009-03-03  8:26 UTC (permalink / raw)
  To: Li Zefan, Ingo Molnar, Peter Zijlstra
  Cc: Andrew Morton, LKML, Linux Containers

On Mon, Mar 2, 2009 at 10:01 PM, Paul Menage <menage@google.com> wrote:
> On Mon, Mar 2, 2009 at 7:17 PM, Li Zefan <lizf@cn.fujitsu.com> wrote:
>>> +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.

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Allow cpusets to be configured/built on non-SMP systems
  2009-03-03  8:26     ` Paul Menage
@ 2009-03-03  8:42       ` Li Zefan
  2009-03-03  8:54         ` Li Zefan
  0 siblings, 1 reply; 10+ messages in thread
From: Li Zefan @ 2009-03-03  8:42 UTC (permalink / raw)
  To: Paul Menage
  Cc: Ingo Molnar, Peter Zijlstra, Andrew Morton, LKML,
	Linux Containers

Paul Menage wrote:
> On Mon, Mar 2, 2009 at 10:01 PM, Paul Menage <menage@google.com> wrote:
>> On Mon, Mar 2, 2009 at 7:17 PM, Li Zefan <lizf@cn.fujitsu.com> wrote:
>>>> +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.
> 
> 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;
		}
	...
	}

> 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.

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

But I agree with you. :)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Allow cpusets to be configured/built on non-SMP systems
  2009-03-03  8:42       ` Li Zefan
@ 2009-03-03  8:54         ` Li Zefan
  0 siblings, 0 replies; 10+ messages in thread
From: Li Zefan @ 2009-03-03  8:54 UTC (permalink / raw)
  To: Paul Menage
  Cc: Linux Containers, Ingo Molnar, Peter Zijlstra, Andrew Morton,
	LKML

Li Zefan wrote:
> Paul Menage wrote:
>> On Mon, Mar 2, 2009 at 10:01 PM, Paul Menage <menage@google.com> wrote:
>>> On Mon, Mar 2, 2009 at 7:17 PM, Li Zefan <lizf@cn.fujitsu.com> wrote:
>>>>> +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.
>> 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

> 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;
> }
> 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] Allow cpusets to be configured/built on non-SMP systems
@ 2009-03-03 23:52 Paul Menage
  0 siblings, 0 replies; 10+ messages in thread
From: Paul Menage @ 2009-03-03 23:52 UTC (permalink / raw)
  To: Andrew Morton, Li Zefan
  Cc: LKML, Linux Containers, Peter Zijlstra, Ingo Molnar

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).

Reviewed-by: Li Zefan <lizf@cn.fujitsu.com>
Signed-off-by: Paul Menage <menage@google.com>

---

Updated to include an (almost-certainly unused) result from
generate_sched_domains().

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

diff --git a/init/Kconfig b/init/Kconfig
index 92d2c64..3f20aa2 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -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
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index a46d693..321fbf1 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -517,6 +517,7 @@ 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 +812,18 @@ static void do_rebuild_sched_domains(struct work_struct *unused)
 
 	put_online_cpus();
 }
+#else /* !CONFIG_SMP */
+static void do_rebuild_sched_domains(struct work_struct *unused)
+{
+}
+
+static int generate_sched_domains(struct cpumask **domains,
+			struct sched_domain_attr **attributes)
+{
+	*domains = NULL;
+	return 1;
+}
+#endif /* CONFIG_SMP */
 
 static DECLARE_WORK(rebuild_sched_domains_work, do_rebuild_sched_domains);
 
@@ -1164,8 +1177,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;


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-03-03 23:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-03  1:36 [PATCH] Allow cpusets to be configured/built on non-SMP systems Paul Menage
2009-03-03  2:01 ` Li Zefan
2009-03-03  3:17 ` Li Zefan
2009-03-03  6:01   ` Paul Menage
2009-03-03  6:41     ` Paul Menage
2009-03-03  8:26     ` Paul Menage
2009-03-03  8:42       ` Li Zefan
2009-03-03  8:54         ` Li Zefan
2009-03-03  8:07 ` Ingo Molnar
  -- strict thread matches above, loose matches on Subject: below --
2009-03-03 23:52 Paul Menage

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox