Commit 909d75a3b77bdd8baa9429bad3b69a654d2954ce

Authored by Paul Jackson
Committed by Linus Torvalds
1 parent cf2a473c40

[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>

Showing 3 changed files with 33 additions and 7 deletions Side-by-side Diff

include/linux/cpuset.h
... ... @@ -18,7 +18,8 @@
18 18 extern void cpuset_init_smp(void);
19 19 extern void cpuset_fork(struct task_struct *p);
20 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 23 void cpuset_init_current_mems_allowed(void);
23 24 void cpuset_update_task_memory_state(void);
24 25 #define cpuset_nodes_subset_current_mems_allowed(nodes) \
... ... @@ -48,6 +49,11 @@
48 49 static inline cpumask_t cpuset_cpus_allowed(struct task_struct *p)
49 50 {
50 51 return cpu_possible_map;
  52 +}
  53 +
  54 +static inline nodemask_t cpuset_mems_allowed(struct task_struct *p)
  55 +{
  56 + return node_possible_map;
51 57 }
52 58  
53 59 static inline void cpuset_init_current_mems_allowed(void) {}
... ... @@ -1871,14 +1871,14 @@
1871 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 1876 cpumask_t mask;
1877 1877  
1878 1878 down(&callback_sem);
1879   - task_lock((struct task_struct *)tsk);
  1879 + task_lock(tsk);
1880 1880 guarantee_online_cpus(tsk->cpuset, &mask);
1881   - task_unlock((struct task_struct *)tsk);
  1881 + task_unlock(tsk);
1882 1882 up(&callback_sem);
1883 1883  
1884 1884 return mask;
... ... @@ -1887,6 +1887,29 @@
1887 1887 void cpuset_init_current_mems_allowed(void)
1888 1888 {
1889 1889 current->mems_allowed = NODE_MASK_ALL;
  1890 +}
  1891 +
  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;
1890 1913 }
1891 1914  
1892 1915 /**
... ... @@ -772,9 +772,6 @@
772 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 775 asmlinkage long sys_migrate_pages(pid_t pid, unsigned long maxnode,
779 776 const unsigned long __user *old_nodes,
780 777 const unsigned long __user *new_nodes)