diff options
Diffstat (limited to 'kernel/cpuset.c')
-rw-r--r-- | kernel/cpuset.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 3e00526f52ec..96c0ba13b8cd 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/list.h> | 36 | #include <linux/list.h> |
37 | #include <linux/mempolicy.h> | 37 | #include <linux/mempolicy.h> |
38 | #include <linux/mm.h> | 38 | #include <linux/mm.h> |
39 | #include <linux/memory.h> | ||
39 | #include <linux/module.h> | 40 | #include <linux/module.h> |
40 | #include <linux/mount.h> | 41 | #include <linux/mount.h> |
41 | #include <linux/namei.h> | 42 | #include <linux/namei.h> |
@@ -584,10 +585,9 @@ static int generate_sched_domains(cpumask_t **domains, | |||
584 | int i, j, k; /* indices for partition finding loops */ | 585 | int i, j, k; /* indices for partition finding loops */ |
585 | cpumask_t *doms; /* resulting partition; i.e. sched domains */ | 586 | cpumask_t *doms; /* resulting partition; i.e. sched domains */ |
586 | struct sched_domain_attr *dattr; /* attributes for custom domains */ | 587 | struct sched_domain_attr *dattr; /* attributes for custom domains */ |
587 | int ndoms; /* number of sched domains in result */ | 588 | int ndoms = 0; /* number of sched domains in result */ |
588 | int nslot; /* next empty doms[] cpumask_t slot */ | 589 | int nslot; /* next empty doms[] cpumask_t slot */ |
589 | 590 | ||
590 | ndoms = 0; | ||
591 | doms = NULL; | 591 | doms = NULL; |
592 | dattr = NULL; | 592 | dattr = NULL; |
593 | csa = NULL; | 593 | csa = NULL; |
@@ -674,10 +674,8 @@ restart: | |||
674 | * Convert <csn, csa> to <ndoms, doms> and populate cpu masks. | 674 | * Convert <csn, csa> to <ndoms, doms> and populate cpu masks. |
675 | */ | 675 | */ |
676 | doms = kmalloc(ndoms * sizeof(cpumask_t), GFP_KERNEL); | 676 | doms = kmalloc(ndoms * sizeof(cpumask_t), GFP_KERNEL); |
677 | if (!doms) { | 677 | if (!doms) |
678 | ndoms = 0; | ||
679 | goto done; | 678 | goto done; |
680 | } | ||
681 | 679 | ||
682 | /* | 680 | /* |
683 | * The rest of the code, including the scheduler, can deal with | 681 | * The rest of the code, including the scheduler, can deal with |
@@ -732,6 +730,13 @@ restart: | |||
732 | done: | 730 | done: |
733 | kfree(csa); | 731 | kfree(csa); |
734 | 732 | ||
733 | /* | ||
734 | * Fallback to the default domain if kmalloc() failed. | ||
735 | * See comments in partition_sched_domains(). | ||
736 | */ | ||
737 | if (doms == NULL) | ||
738 | ndoms = 1; | ||
739 | |||
735 | *domains = doms; | 740 | *domains = doms; |
736 | *attributes = dattr; | 741 | *attributes = dattr; |
737 | return ndoms; | 742 | return ndoms; |
@@ -2011,12 +2016,23 @@ static int cpuset_track_online_cpus(struct notifier_block *unused_nb, | |||
2011 | * Call this routine anytime after node_states[N_HIGH_MEMORY] changes. | 2016 | * Call this routine anytime after node_states[N_HIGH_MEMORY] changes. |
2012 | * See also the previous routine cpuset_track_online_cpus(). | 2017 | * See also the previous routine cpuset_track_online_cpus(). |
2013 | */ | 2018 | */ |
2014 | void cpuset_track_online_nodes(void) | 2019 | static int cpuset_track_online_nodes(struct notifier_block *self, |
2020 | unsigned long action, void *arg) | ||
2015 | { | 2021 | { |
2016 | cgroup_lock(); | 2022 | cgroup_lock(); |
2017 | top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY]; | 2023 | switch (action) { |
2018 | scan_for_empty_cpusets(&top_cpuset); | 2024 | case MEM_ONLINE: |
2025 | top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY]; | ||
2026 | break; | ||
2027 | case MEM_OFFLINE: | ||
2028 | top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY]; | ||
2029 | scan_for_empty_cpusets(&top_cpuset); | ||
2030 | break; | ||
2031 | default: | ||
2032 | break; | ||
2033 | } | ||
2019 | cgroup_unlock(); | 2034 | cgroup_unlock(); |
2035 | return NOTIFY_OK; | ||
2020 | } | 2036 | } |
2021 | #endif | 2037 | #endif |
2022 | 2038 | ||
@@ -2032,6 +2048,7 @@ void __init cpuset_init_smp(void) | |||
2032 | top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY]; | 2048 | top_cpuset.mems_allowed = node_states[N_HIGH_MEMORY]; |
2033 | 2049 | ||
2034 | hotcpu_notifier(cpuset_track_online_cpus, 0); | 2050 | hotcpu_notifier(cpuset_track_online_cpus, 0); |
2051 | hotplug_memory_notifier(cpuset_track_online_nodes, 10); | ||
2035 | } | 2052 | } |
2036 | 2053 | ||
2037 | /** | 2054 | /** |