diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2008-11-18 01:02:03 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-11-18 02:44:51 -0500 |
commit | 700018e0a77b4113172257fcdaa1c58e27a5074f (patch) | |
tree | 60ea1cc7682b19203e1caab15ebb2285153eeee7 | |
parent | ad133ba3dc283300e5b62b5b7211d2f39fbf6ee7 (diff) |
cpuset: fix regression when failed to generate sched domains
Impact: properly rebuild sched-domains on kmalloc() failure
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 was 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>
Cc: Max Krasnyansky <maxk@qualcomm.com>
Cc: <stable@kernel.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r-- | kernel/cpuset.c | 12 | ||||
-rw-r--r-- | kernel/sched.c | 13 |
2 files changed, 15 insertions, 10 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 3e00526f52ec..81fc6791a296 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -587,7 +587,6 @@ static int generate_sched_domains(cpumask_t **domains, | |||
587 | int ndoms; /* number of sched domains in result */ | 587 | int ndoms; /* number of sched domains in result */ |
588 | int nslot; /* next empty doms[] cpumask_t slot */ | 588 | int nslot; /* next empty doms[] cpumask_t slot */ |
589 | 589 | ||
590 | ndoms = 0; | ||
591 | doms = NULL; | 590 | doms = NULL; |
592 | dattr = NULL; | 591 | dattr = NULL; |
593 | csa = NULL; | 592 | csa = NULL; |
@@ -674,10 +673,8 @@ restart: | |||
674 | * Convert <csn, csa> to <ndoms, doms> and populate cpu masks. | 673 | * Convert <csn, csa> to <ndoms, doms> and populate cpu masks. |
675 | */ | 674 | */ |
676 | doms = kmalloc(ndoms * sizeof(cpumask_t), GFP_KERNEL); | 675 | doms = kmalloc(ndoms * sizeof(cpumask_t), GFP_KERNEL); |
677 | if (!doms) { | 676 | if (!doms) |
678 | ndoms = 0; | ||
679 | goto done; | 677 | goto done; |
680 | } | ||
681 | 678 | ||
682 | /* | 679 | /* |
683 | * The rest of the code, including the scheduler, can deal with | 680 | * The rest of the code, including the scheduler, can deal with |
@@ -732,6 +729,13 @@ restart: | |||
732 | done: | 729 | done: |
733 | kfree(csa); | 730 | kfree(csa); |
734 | 731 | ||
732 | /* | ||
733 | * Fallback to the default domain if kmalloc() failed. | ||
734 | * See comments in partition_sched_domains(). | ||
735 | */ | ||
736 | if (doms == NULL) | ||
737 | ndoms = 1; | ||
738 | |||
735 | *domains = doms; | 739 | *domains = doms; |
736 | *attributes = dattr; | 740 | *attributes = dattr; |
737 | return ndoms; | 741 | return ndoms; |
diff --git a/kernel/sched.c b/kernel/sched.c index c94baf2969e7..9b1e79371c20 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, | |||
7789 | * | 7789 | * |
7790 | * The passed in 'doms_new' should be kmalloc'd. This routine takes | 7790 | * The passed in 'doms_new' should be kmalloc'd. This routine takes |
7791 | * ownership of it and will kfree it when done with it. If the caller | 7791 | * ownership of it and will kfree it when done with it. If the caller |
7792 | * failed the kmalloc call, then it can pass in doms_new == NULL, | 7792 | * failed the kmalloc call, then it can pass in doms_new == NULL && |
7793 | * and partition_sched_domains() will fallback to the single partition | 7793 | * ndoms_new == 1, and partition_sched_domains() will fallback to |
7794 | * 'fallback_doms', it also forces the domains to be rebuilt. | 7794 | * the single partition 'fallback_doms', it also forces the domains |
7795 | * to be rebuilt. | ||
7795 | * | 7796 | * |
7796 | * If doms_new==NULL it will be replaced with cpu_online_map. | 7797 | * If doms_new == NULL it will be replaced with cpu_online_map. |
7797 | * ndoms_new==0 is a special case for destroying existing domains. | 7798 | * ndoms_new == 0 is a special case for destroying existing domains, |
7798 | * It will not create the default domain. | 7799 | * and it will not create the default domain. |
7799 | * | 7800 | * |
7800 | * Call with hotplug lock held | 7801 | * Call with hotplug lock held |
7801 | */ | 7802 | */ |