aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Jackson <pj@sgi.com>2006-01-08 04:01:57 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-08 23:13:44 -0500
commit202f72d5d1b5c2c084f63ef996c736d208b447b5 (patch)
treef50551f9588f9090fee17130614e17a2dd64c656
parent74cb21553f4bf244185b9bec4c26e4e3169ad55e (diff)
[PATCH] cpuset: number_of_cpusets optimization
Easy little optimization hack to avoid actually having to call cpuset_zone_allowed() and check mems_allowed, in the main page allocation routine, __alloc_pages(). This saves several CPU cycles per page allocation on systems not using cpusets. A counter is updated each time a cpuset is created or removed, and whenever there is only one cpuset in the system, it must be the root cpuset, which contains all CPUs and all Memory Nodes. In that case, when the counter is one, all allocations are allowed. Signed-off-by: Paul Jackson <pj@sgi.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--include/linux/cpuset.h10
-rw-r--r--kernel/cpuset.c12
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
17extern int number_of_cpusets; /* How many cpusets are defined in system? */
18
17extern int cpuset_init(void); 19extern int cpuset_init(void);
18extern void cpuset_init_smp(void); 20extern void cpuset_init_smp(void);
19extern void cpuset_fork(struct task_struct *p); 21extern 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)
27int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl); 29int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl);
28extern int cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask); 30
31extern int __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask);
32static 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
29extern int cpuset_excl_nodes_overlap(const struct task_struct *p); 37extern 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 */
64int number_of_cpusets;
65
59/* See "Frequency meter" comments, below. */ 66/* See "Frequency meter" comments, below. */
60 67
61struct fmeter { 68struct 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
1985int cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask) 1995int __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 */