From 4a0fbd63c8261b8655b9c0189b55d33da7788a40 Mon Sep 17 00:00:00 2001 From: Li Zefan Date: Tue, 18 Nov 2008 14:02:03 +0800 Subject: [PATCH] --- yaml --- r: 119151 b: refs/heads/master c: 700018e0a77b4113172257fcdaa1c58e27a5074f h: refs/heads/master i: 119149: 4a4efcdaee2927a743b134c7614affdcc58e789c 119147: d3e6bee704fdb8f6741edb5475843b5cfcedd69c 119143: 120d1859e04a93500b047c82068ee5af582fbeea 119135: 8fc27e0bda4fda15abc377e2bea04ab4fc0a8aff v: v3 --- [refs] | 2 +- trunk/kernel/cpuset.c | 12 ++++++++---- trunk/kernel/sched.c | 13 +++++++------ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/[refs] b/[refs] index d2338f56531e..7088ddcb0c27 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: ad133ba3dc283300e5b62b5b7211d2f39fbf6ee7 +refs/heads/master: 700018e0a77b4113172257fcdaa1c58e27a5074f diff --git a/trunk/kernel/cpuset.c b/trunk/kernel/cpuset.c index 3e00526f52ec..81fc6791a296 100644 --- a/trunk/kernel/cpuset.c +++ b/trunk/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 @@ static int generate_sched_domains(cpumask_t **domains, * Convert to 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 @@ static int generate_sched_domains(cpumask_t **domains, 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/trunk/kernel/sched.c b/trunk/kernel/sched.c index c94baf2969e7..9b1e79371c20 100644 --- a/trunk/kernel/sched.c +++ b/trunk/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 */