diff options
-rw-r--r-- | include/linux/cpuset.h | 10 | ||||
-rw-r--r-- | kernel/cpuset.c | 12 |
2 files changed, 20 insertions, 2 deletions
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h index 37d2dd7ca3e9..34081c168af5 100644 --- a/include/linux/cpuset.h +++ b/include/linux/cpuset.h | |||
@@ -14,6 +14,8 @@ | |||
14 | 14 | ||
15 | #ifdef CONFIG_CPUSETS | 15 | #ifdef CONFIG_CPUSETS |
16 | 16 | ||
17 | extern int number_of_cpusets; /* How many cpusets are defined in system? */ | ||
18 | |||
17 | extern int cpuset_init(void); | 19 | extern int cpuset_init(void); |
18 | extern void cpuset_init_smp(void); | 20 | extern void cpuset_init_smp(void); |
19 | extern void cpuset_fork(struct task_struct *p); | 21 | extern void cpuset_fork(struct task_struct *p); |
@@ -25,7 +27,13 @@ void cpuset_update_task_memory_state(void); | |||
25 | #define cpuset_nodes_subset_current_mems_allowed(nodes) \ | 27 | #define cpuset_nodes_subset_current_mems_allowed(nodes) \ |
26 | nodes_subset((nodes), current->mems_allowed) | 28 | nodes_subset((nodes), current->mems_allowed) |
27 | int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl); | 29 | int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl); |
28 | extern int cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask); | 30 | |
31 | extern int __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask); | ||
32 | static int inline cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask) | ||
33 | { | ||
34 | return number_of_cpusets <= 1 || __cpuset_zone_allowed(z, gfp_mask); | ||
35 | } | ||
36 | |||
29 | extern int cpuset_excl_nodes_overlap(const struct task_struct *p); | 37 | extern int cpuset_excl_nodes_overlap(const struct task_struct *p); |
30 | 38 | ||
31 | #define cpuset_memory_pressure_bump() \ | 39 | #define cpuset_memory_pressure_bump() \ |
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 8f764de3a9e7..6004719f26ee 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -56,6 +56,13 @@ | |||
56 | 56 | ||
57 | #define CPUSET_SUPER_MAGIC 0x27e0eb | 57 | #define CPUSET_SUPER_MAGIC 0x27e0eb |
58 | 58 | ||
59 | /* | ||
60 | * Tracks how many cpusets are currently defined in system. | ||
61 | * When there is only one cpuset (the root cpuset) we can | ||
62 | * short circuit some hooks. | ||
63 | */ | ||
64 | int number_of_cpusets; | ||
65 | |||
59 | /* See "Frequency meter" comments, below. */ | 66 | /* See "Frequency meter" comments, below. */ |
60 | 67 | ||
61 | struct fmeter { | 68 | struct fmeter { |
@@ -1664,6 +1671,7 @@ static long cpuset_create(struct cpuset *parent, const char *name, int mode) | |||
1664 | 1671 | ||
1665 | down(&callback_sem); | 1672 | down(&callback_sem); |
1666 | list_add(&cs->sibling, &cs->parent->children); | 1673 | list_add(&cs->sibling, &cs->parent->children); |
1674 | number_of_cpusets++; | ||
1667 | up(&callback_sem); | 1675 | up(&callback_sem); |
1668 | 1676 | ||
1669 | err = cpuset_create_dir(cs, name, mode); | 1677 | err = cpuset_create_dir(cs, name, mode); |
@@ -1726,6 +1734,7 @@ static int cpuset_rmdir(struct inode *unused_dir, struct dentry *dentry) | |||
1726 | spin_unlock(&d->d_lock); | 1734 | spin_unlock(&d->d_lock); |
1727 | cpuset_d_remove_dir(d); | 1735 | cpuset_d_remove_dir(d); |
1728 | dput(d); | 1736 | dput(d); |
1737 | number_of_cpusets--; | ||
1729 | up(&callback_sem); | 1738 | up(&callback_sem); |
1730 | if (list_empty(&parent->children)) | 1739 | if (list_empty(&parent->children)) |
1731 | check_for_release(parent, &pathbuf); | 1740 | check_for_release(parent, &pathbuf); |
@@ -1769,6 +1778,7 @@ int __init cpuset_init(void) | |||
1769 | root->d_inode->i_nlink++; | 1778 | root->d_inode->i_nlink++; |
1770 | top_cpuset.dentry = root; | 1779 | top_cpuset.dentry = root; |
1771 | root->d_inode->i_op = &cpuset_dir_inode_operations; | 1780 | root->d_inode->i_op = &cpuset_dir_inode_operations; |
1781 | number_of_cpusets = 1; | ||
1772 | err = cpuset_populate_dir(root); | 1782 | err = cpuset_populate_dir(root); |
1773 | /* memory_pressure_enabled is in root cpuset only */ | 1783 | /* memory_pressure_enabled is in root cpuset only */ |
1774 | if (err == 0) | 1784 | if (err == 0) |
@@ -1982,7 +1992,7 @@ static const struct cpuset *nearest_exclusive_ancestor(const struct cpuset *cs) | |||
1982 | * GFP_USER - only nodes in current tasks mems allowed ok. | 1992 | * GFP_USER - only nodes in current tasks mems allowed ok. |
1983 | **/ | 1993 | **/ |
1984 | 1994 | ||
1985 | int cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask) | 1995 | int __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask) |
1986 | { | 1996 | { |
1987 | int node; /* node that zone z is on */ | 1997 | int node; /* node that zone z is on */ |
1988 | const struct cpuset *cs; /* current cpuset ancestors */ | 1998 | const struct cpuset *cs; /* current cpuset ancestors */ |