Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mempolicy: unexport get_vma_policy() and remove its "task" arg

- get_vma_policy(task) is not safe if task != current, remove this
argument.

- get_vma_policy() no longer has callers outside of mempolicy.c,
make it static.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: David Rientjes <rientjes@google.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Oleg Nesterov and committed by
Linus Torvalds
dd6eecb9 2c7c3a7d

+8 -13
-2
include/linux/mempolicy.h
··· 137 137 struct mempolicy *get_task_policy(struct task_struct *p); 138 138 struct mempolicy *__get_vma_policy(struct vm_area_struct *vma, 139 139 unsigned long addr); 140 - struct mempolicy *get_vma_policy(struct task_struct *tsk, 141 - struct vm_area_struct *vma, unsigned long addr); 142 140 bool vma_policy_mof(struct vm_area_struct *vma); 143 141 144 142 extern void numa_default_policy(void);
+8 -11
mm/mempolicy.c
··· 1616 1616 } 1617 1617 1618 1618 /* 1619 - * get_vma_policy(@task, @vma, @addr) 1620 - * @task: task for fallback if vma policy == default 1619 + * get_vma_policy(@vma, @addr) 1621 1620 * @vma: virtual memory area whose policy is sought 1622 1621 * @addr: address in @vma for shared policy lookup 1623 1622 * 1624 1623 * Returns effective policy for a VMA at specified address. 1625 - * Falls back to @task or system default policy, as necessary. 1626 - * Current or other task's task mempolicy and non-shared vma policies must be 1627 - * protected by task_lock(task) by the caller. 1624 + * Falls back to current->mempolicy or system default policy, as necessary. 1628 1625 * Shared policies [those marked as MPOL_F_SHARED] require an extra reference 1629 1626 * count--added by the get_policy() vm_op, as appropriate--to protect against 1630 1627 * freeing by another task. It is the caller's responsibility to free the 1631 1628 * extra reference for shared policies. 1632 1629 */ 1633 - struct mempolicy *get_vma_policy(struct task_struct *task, 1634 - struct vm_area_struct *vma, unsigned long addr) 1630 + static struct mempolicy *get_vma_policy(struct vm_area_struct *vma, 1631 + unsigned long addr) 1635 1632 { 1636 1633 struct mempolicy *pol = __get_vma_policy(vma, addr); 1637 1634 1638 1635 if (!pol) 1639 - pol = get_task_policy(task); 1636 + pol = get_task_policy(current); 1640 1637 1641 1638 return pol; 1642 1639 } ··· 1861 1864 { 1862 1865 struct zonelist *zl; 1863 1866 1864 - *mpol = get_vma_policy(current, vma, addr); 1867 + *mpol = get_vma_policy(vma, addr); 1865 1868 *nodemask = NULL; /* assume !MPOL_BIND */ 1866 1869 1867 1870 if (unlikely((*mpol)->mode == MPOL_INTERLEAVE)) { ··· 2016 2019 unsigned int cpuset_mems_cookie; 2017 2020 2018 2021 retry_cpuset: 2019 - pol = get_vma_policy(current, vma, addr); 2022 + pol = get_vma_policy(vma, addr); 2020 2023 cpuset_mems_cookie = read_mems_allowed_begin(); 2021 2024 2022 2025 if (unlikely(pol->mode == MPOL_INTERLEAVE)) { ··· 2282 2285 2283 2286 BUG_ON(!vma); 2284 2287 2285 - pol = get_vma_policy(current, vma, addr); 2288 + pol = get_vma_policy(vma, addr); 2286 2289 if (!(pol->flags & MPOL_F_MOF)) 2287 2290 goto out; 2288 2291