linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpuset: fix regression when failed to generate sched domains
@ 2008-11-18  6:02 Li Zefan
  2008-11-18  7:45 ` Ingo Molnar
  2008-11-19  1:24 ` Max Krasnyansky
  0 siblings, 2 replies; 3+ messages in thread
From: Li Zefan @ 2008-11-18  6:02 UTC (permalink / raw)
  To: Ingo Molnar, Andrew Morton
  Cc: Max Krasnyansky, Vaidyanathan Srinivasan, Paul Menage, LKML

When cpuset failed to generate sched domains due to kmalloc()
failure, the scheduler should fallback to the single partition
'fallback_doms' and rebuild sched domains, but now it only
destroys but not rebuilds sched domains.

The regression is introduced by:

commit dfb512ec4834116124da61d6c1ee10fd0aa32bd6
Author: Max Krasnyansky <maxk@qualcomm.com>
Date:   Fri Aug 29 13:11:41 2008 -0700

    sched: arch_reinit_sched_domains() must destroy domains to force rebuild

After the above commit, partition_sched_domains(0, NULL, NULL) will
only destroy sched domains and partition_sched_domains(1, NULL, NULL)
will create the default sched domain.

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

Should I also CC stable for 2.6.27.xx ?

---
 kernel/cpuset.c |   12 ++++++++----
 kernel/sched.c  |   13 +++++++------
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 3e00526..81fc679 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -587,7 +587,6 @@ static int generate_sched_domains(cpumask_t **domains,
 	int ndoms;		/* number of sched domains in result */
 	int nslot;		/* next empty doms[] cpumask_t slot */
 
-	ndoms = 0;
 	doms = NULL;
 	dattr = NULL;
 	csa = NULL;
@@ -674,10 +673,8 @@ restart:
 	 * Convert <csn, csa> to <ndoms, doms> and populate cpu masks.
 	 */
 	doms = kmalloc(ndoms * sizeof(cpumask_t), GFP_KERNEL);
-	if (!doms) {
-		ndoms = 0;
+	if (!doms)
 		goto done;
-	}
 
 	/*
 	 * The rest of the code, including the scheduler, can deal with
@@ -732,6 +729,13 @@ restart:
 done:
 	kfree(csa);
 
+	/*
+	 * Fallback to the default domain if kmalloc() failed.
+	 * See comments in partition_sched_domains().
+	 */
+	if (doms == NULL)
+		ndoms = 1;
+
 	*domains    = doms;
 	*attributes = dattr;
 	return ndoms;
diff --git a/kernel/sched.c b/kernel/sched.c
index c94baf2..9b1e793 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -7789,13 +7789,14 @@ static int dattrs_equal(struct sched_domain_attr *cur, int idx_cur,
  *
  * The passed in 'doms_new' should be kmalloc'd. This routine takes
  * ownership of it and will kfree it when done with it. If the caller
- * failed the kmalloc call, then it can pass in doms_new == NULL,
- * and partition_sched_domains() will fallback to the single partition
- * 'fallback_doms', it also forces the domains to be rebuilt.
+ * failed the kmalloc call, then it can pass in doms_new == NULL &&
+ * ndoms_new == 1, and partition_sched_domains() will fallback to
+ * the single partition 'fallback_doms', it also forces the domains
+ * to be rebuilt.
  *
- * If doms_new==NULL it will be replaced with cpu_online_map.
- * ndoms_new==0 is a special case for destroying existing domains.
- * It will not create the default domain.
+ * If doms_new == NULL it will be replaced with cpu_online_map.
+ * ndoms_new == 0 is a special case for destroying existing domains,
+ * and it will not create the default domain.
  *
  * Call with hotplug lock held
  */
-- 
1.5.4.rc3

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

* Re: [PATCH] cpuset: fix regression when failed to generate sched domains
  2008-11-18  6:02 [PATCH] cpuset: fix regression when failed to generate sched domains Li Zefan
@ 2008-11-18  7:45 ` Ingo Molnar
  2008-11-19  1:24 ` Max Krasnyansky
  1 sibling, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2008-11-18  7:45 UTC (permalink / raw)
  To: Li Zefan
  Cc: Andrew Morton, Max Krasnyansky, Vaidyanathan Srinivasan,
	Paul Menage, LKML


* Li Zefan <lizf@cn.fujitsu.com> wrote:

> When cpuset failed to generate sched domains due to kmalloc()
> failure, the scheduler should fallback to the single partition
> 'fallback_doms' and rebuild sched domains, but now it only
> destroys but not rebuilds sched domains.
> 
> The regression is introduced by:
> 
> commit dfb512ec4834116124da61d6c1ee10fd0aa32bd6
> Author: Max Krasnyansky <maxk@qualcomm.com>
> Date:   Fri Aug 29 13:11:41 2008 -0700
> 
>     sched: arch_reinit_sched_domains() must destroy domains to force rebuild
> 
> After the above commit, partition_sched_domains(0, NULL, NULL) will
> only destroy sched domains and partition_sched_domains(1, NULL, NULL)
> will create the default sched domain.
> 
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>

applied to tip/sched/urgent, thanks!

> Should I also CC stable for 2.6.27.xx ?

i've added a Cc: stable to the commit - that will trigger a -stable 
backport.

	Ingo

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

* Re: [PATCH] cpuset: fix regression when failed to generate sched domains
  2008-11-18  6:02 [PATCH] cpuset: fix regression when failed to generate sched domains Li Zefan
  2008-11-18  7:45 ` Ingo Molnar
@ 2008-11-19  1:24 ` Max Krasnyansky
  1 sibling, 0 replies; 3+ messages in thread
From: Max Krasnyansky @ 2008-11-19  1:24 UTC (permalink / raw)
  To: Li Zefan
  Cc: Ingo Molnar, Andrew Morton, Vaidyanathan Srinivasan, Paul Menage,
	LKML

Li Zefan wrote:
> When cpuset failed to generate sched domains due to kmalloc()
> failure, the scheduler should fallback to the single partition
> 'fallback_doms' and rebuild sched domains, but now it only
> destroys but not rebuilds sched domains.
> 
> The regression is introduced by:
> 
> commit dfb512ec4834116124da61d6c1ee10fd0aa32bd6
> Author: Max Krasnyansky <maxk@qualcomm.com>
> Date:   Fri Aug 29 13:11:41 2008 -0700
> 
>     sched: arch_reinit_sched_domains() must destroy domains to force rebuild
> 
> After the above commit, partition_sched_domains(0, NULL, NULL) will
> only destroy sched domains and partition_sched_domains(1, NULL, NULL)
> will create the default sched domain.
> 
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>

Looks good to me. Thanx for the fix.

Max



> ---
> 
> Should I also CC stable for 2.6.27.xx ?
> 
> ---
>  kernel/cpuset.c |   12 ++++++++----
>  kernel/sched.c  |   13 +++++++------
>  2 files changed, 15 insertions(+), 10 deletions(-)
> 
> diff --git a/kernel/cpuset.c b/kernel/cpuset.c
> index 3e00526..81fc679 100644
> --- a/kernel/cpuset.c
> +++ b/kernel/cpuset.c
> @@ -587,7 +587,6 @@ static int generate_sched_domains(cpumask_t **domains,
>  	int ndoms;		/* number of sched domains in result */
>  	int nslot;		/* next empty doms[] cpumask_t slot */
>  
> -	ndoms = 0;
>  	doms = NULL;
>  	dattr = NULL;
>  	csa = NULL;
> @@ -674,10 +673,8 @@ restart:
>  	 * Convert <csn, csa> to <ndoms, doms> and populate cpu masks.
>  	 */
>  	doms = kmalloc(ndoms * sizeof(cpumask_t), GFP_KERNEL);
> -	if (!doms) {
> -		ndoms = 0;
> +	if (!doms)
>  		goto done;
> -	}
>  
>  	/*
>  	 * The rest of the code, including the scheduler, can deal with
> @@ -732,6 +729,13 @@ restart:
>  done:
>  	kfree(csa);
>  
> +	/*
> +	 * Fallback to the default domain if kmalloc() failed.
> +	 * See comments in partition_sched_domains().
> +	 */
> +	if (doms == NULL)
> +		ndoms = 1;
> +
>  	*domains    = doms;
>  	*attributes = dattr;
>  	return ndoms;
> diff --git a/kernel/sched.c b/kernel/sched.c
> index c94baf2..9b1e793 100644
> --- a/kernel/sched.c
> +++ b/kernel/sched.c
> @@ -7789,13 +7789,14 @@ static int dattrs_equal(struct sched_domain_attr *cur, int idx_cur,
>   *
>   * The passed in 'doms_new' should be kmalloc'd. This routine takes
>   * ownership of it and will kfree it when done with it. If the caller
> - * failed the kmalloc call, then it can pass in doms_new == NULL,
> - * and partition_sched_domains() will fallback to the single partition
> - * 'fallback_doms', it also forces the domains to be rebuilt.
> + * failed the kmalloc call, then it can pass in doms_new == NULL &&
> + * ndoms_new == 1, and partition_sched_domains() will fallback to
> + * the single partition 'fallback_doms', it also forces the domains
> + * to be rebuilt.
>   *
> - * If doms_new==NULL it will be replaced with cpu_online_map.
> - * ndoms_new==0 is a special case for destroying existing domains.
> - * It will not create the default domain.
> + * If doms_new == NULL it will be replaced with cpu_online_map.
> + * ndoms_new == 0 is a special case for destroying existing domains,
> + * and it will not create the default domain.
>   *
>   * Call with hotplug lock held
>   */


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

end of thread, other threads:[~2008-11-19  1:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-18  6:02 [PATCH] cpuset: fix regression when failed to generate sched domains Li Zefan
2008-11-18  7:45 ` Ingo Molnar
2008-11-19  1:24 ` Max Krasnyansky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).