diff options
author | Paul Jackson <pj@sgi.com> | 2006-01-08 04:01:57 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-08 23:13:44 -0500 |
commit | 202f72d5d1b5c2c084f63ef996c736d208b447b5 (patch) | |
tree | f50551f9588f9090fee17130614e17a2dd64c656 /kernel | |
parent | 74cb21553f4bf244185b9bec4c26e4e3169ad55e (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>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/cpuset.c | 12 |
1 files changed, 11 insertions, 1 deletions
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 */ |