diff options
author | Paul Jackson <pj@sgi.com> | 2006-01-08 04:01:55 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-08 23:13:44 -0500 |
commit | 909d75a3b77bdd8baa9429bad3b69a654d2954ce (patch) | |
tree | f9955ff697b7569fc75e5b8683d886315f34ac49 | |
parent | cf2a473c4089aa41c26f653200673f5a4cc25047 (diff) |
[PATCH] cpuset: implement cpuset_mems_allowed
Provide a cpuset_mems_allowed() method, which the sys_migrate_pages() code
needed, to obtain the mems_allowed vector of a cpuset, and replaced the
workaround in sys_migrate_pages() to call this new method.
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.h | 8 | ||||
-rw-r--r-- | kernel/cpuset.c | 29 | ||||
-rw-r--r-- | mm/mempolicy.c | 3 |
3 files changed, 33 insertions, 7 deletions
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h index 1feebf16ab08..37d2dd7ca3e9 100644 --- a/include/linux/cpuset.h +++ b/include/linux/cpuset.h | |||
@@ -18,7 +18,8 @@ extern int cpuset_init(void); | |||
18 | extern void cpuset_init_smp(void); | 18 | extern void cpuset_init_smp(void); |
19 | extern void cpuset_fork(struct task_struct *p); | 19 | extern void cpuset_fork(struct task_struct *p); |
20 | extern void cpuset_exit(struct task_struct *p); | 20 | extern void cpuset_exit(struct task_struct *p); |
21 | extern cpumask_t cpuset_cpus_allowed(const struct task_struct *p); | 21 | extern cpumask_t cpuset_cpus_allowed(struct task_struct *p); |
22 | extern nodemask_t cpuset_mems_allowed(struct task_struct *p); | ||
22 | void cpuset_init_current_mems_allowed(void); | 23 | void cpuset_init_current_mems_allowed(void); |
23 | void cpuset_update_task_memory_state(void); | 24 | void cpuset_update_task_memory_state(void); |
24 | #define cpuset_nodes_subset_current_mems_allowed(nodes) \ | 25 | #define cpuset_nodes_subset_current_mems_allowed(nodes) \ |
@@ -50,6 +51,11 @@ static inline cpumask_t cpuset_cpus_allowed(struct task_struct *p) | |||
50 | return cpu_possible_map; | 51 | return cpu_possible_map; |
51 | } | 52 | } |
52 | 53 | ||
54 | static inline nodemask_t cpuset_mems_allowed(struct task_struct *p) | ||
55 | { | ||
56 | return node_possible_map; | ||
57 | } | ||
58 | |||
53 | static inline void cpuset_init_current_mems_allowed(void) {} | 59 | static inline void cpuset_init_current_mems_allowed(void) {} |
54 | static inline void cpuset_update_task_memory_state(void) {} | 60 | static inline void cpuset_update_task_memory_state(void) {} |
55 | #define cpuset_nodes_subset_current_mems_allowed(nodes) (1) | 61 | #define cpuset_nodes_subset_current_mems_allowed(nodes) (1) |
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index e9917d71628a..0d0dbbd6560a 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -1871,14 +1871,14 @@ void cpuset_exit(struct task_struct *tsk) | |||
1871 | * tasks cpuset. | 1871 | * tasks cpuset. |
1872 | **/ | 1872 | **/ |
1873 | 1873 | ||
1874 | cpumask_t cpuset_cpus_allowed(const struct task_struct *tsk) | 1874 | cpumask_t cpuset_cpus_allowed(struct task_struct *tsk) |
1875 | { | 1875 | { |
1876 | cpumask_t mask; | 1876 | cpumask_t mask; |
1877 | 1877 | ||
1878 | down(&callback_sem); | 1878 | down(&callback_sem); |
1879 | task_lock((struct task_struct *)tsk); | 1879 | task_lock(tsk); |
1880 | guarantee_online_cpus(tsk->cpuset, &mask); | 1880 | guarantee_online_cpus(tsk->cpuset, &mask); |
1881 | task_unlock((struct task_struct *)tsk); | 1881 | task_unlock(tsk); |
1882 | up(&callback_sem); | 1882 | up(&callback_sem); |
1883 | 1883 | ||
1884 | return mask; | 1884 | return mask; |
@@ -1890,6 +1890,29 @@ void cpuset_init_current_mems_allowed(void) | |||
1890 | } | 1890 | } |
1891 | 1891 | ||
1892 | /** | 1892 | /** |
1893 | * cpuset_mems_allowed - return mems_allowed mask from a tasks cpuset. | ||
1894 | * @tsk: pointer to task_struct from which to obtain cpuset->mems_allowed. | ||
1895 | * | ||
1896 | * Description: Returns the nodemask_t mems_allowed of the cpuset | ||
1897 | * attached to the specified @tsk. Guaranteed to return some non-empty | ||
1898 | * subset of node_online_map, even if this means going outside the | ||
1899 | * tasks cpuset. | ||
1900 | **/ | ||
1901 | |||
1902 | nodemask_t cpuset_mems_allowed(struct task_struct *tsk) | ||
1903 | { | ||
1904 | nodemask_t mask; | ||
1905 | |||
1906 | down(&callback_sem); | ||
1907 | task_lock(tsk); | ||
1908 | guarantee_online_mems(tsk->cpuset, &mask); | ||
1909 | task_unlock(tsk); | ||
1910 | up(&callback_sem); | ||
1911 | |||
1912 | return mask; | ||
1913 | } | ||
1914 | |||
1915 | /** | ||
1893 | * cpuset_zonelist_valid_mems_allowed - check zonelist vs. curremt mems_allowed | 1916 | * cpuset_zonelist_valid_mems_allowed - check zonelist vs. curremt mems_allowed |
1894 | * @zl: the zonelist to be checked | 1917 | * @zl: the zonelist to be checked |
1895 | * | 1918 | * |
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 515bfeee027e..34d566ac147f 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c | |||
@@ -772,9 +772,6 @@ asmlinkage long sys_set_mempolicy(int mode, unsigned long __user *nmask, | |||
772 | return do_set_mempolicy(mode, &nodes); | 772 | return do_set_mempolicy(mode, &nodes); |
773 | } | 773 | } |
774 | 774 | ||
775 | /* Macro needed until Paul implements this function in kernel/cpusets.c */ | ||
776 | #define cpuset_mems_allowed(task) node_online_map | ||
777 | |||
778 | asmlinkage long sys_migrate_pages(pid_t pid, unsigned long maxnode, | 775 | asmlinkage long sys_migrate_pages(pid_t pid, unsigned long maxnode, |
779 | const unsigned long __user *old_nodes, | 776 | const unsigned long __user *old_nodes, |
780 | const unsigned long __user *new_nodes) | 777 | const unsigned long __user *new_nodes) |