提交 78b132e9 编写于 作者: W Wei Yang 提交者: Linus Torvalds

mm/mempolicy: remove or narrow the lock on current

It is not necessary to hold the lock of current when setting nodemask of
a new policy.
Signed-off-by: NWei Yang <richard.weiyang@linux.alibaba.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Reviewed-by: NAndrew Morton <akpm@linux-foundation.org>
Link: https://lkml.kernel.org/r/20200921040416.86185-1-richard.weiyang@linux.alibaba.comSigned-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 11002620
...@@ -875,13 +875,12 @@ static long do_set_mempolicy(unsigned short mode, unsigned short flags, ...@@ -875,13 +875,12 @@ static long do_set_mempolicy(unsigned short mode, unsigned short flags,
goto out; goto out;
} }
task_lock(current);
ret = mpol_set_nodemask(new, nodes, scratch); ret = mpol_set_nodemask(new, nodes, scratch);
if (ret) { if (ret) {
task_unlock(current);
mpol_put(new); mpol_put(new);
goto out; goto out;
} }
task_lock(current);
old = current->mempolicy; old = current->mempolicy;
current->mempolicy = new; current->mempolicy = new;
if (new && new->mode == MPOL_INTERLEAVE) if (new && new->mode == MPOL_INTERLEAVE)
...@@ -1324,9 +1323,7 @@ static long do_mbind(unsigned long start, unsigned long len, ...@@ -1324,9 +1323,7 @@ static long do_mbind(unsigned long start, unsigned long len,
NODEMASK_SCRATCH(scratch); NODEMASK_SCRATCH(scratch);
if (scratch) { if (scratch) {
mmap_write_lock(mm); mmap_write_lock(mm);
task_lock(current);
err = mpol_set_nodemask(new, nmask, scratch); err = mpol_set_nodemask(new, nmask, scratch);
task_unlock(current);
if (err) if (err)
mmap_write_unlock(mm); mmap_write_unlock(mm);
} else } else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册