Message ID | 20220409073846.22286-2-linmiaohe@huawei.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | A few cleanup and fixup patches for migration | expand |
On Sat, Apr 09, 2022 at 03:38:43PM +0800, Miaohe Lin wrote: > rcu_read_lock is required by grabbing the task refcount but it's not > needed for ptrace_may_access. So we could release the rcu lock after > task refcount is successfully grabbed to reduce the rcu holding time. > > Reviewed-by: Muchun Song <songmuchun@bytedance.com> > Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> Looks good: Reviewed-by: Christoph Hellwig <hch@lst.de>
On Sat, 2022-04-09 at 15:38 +0800, Miaohe Lin wrote: > rcu_read_lock is required by grabbing the task refcount but it's not > needed for ptrace_may_access. So we could release the rcu lock after > task refcount is successfully grabbed to reduce the rcu holding time. > > Reviewed-by: Muchun Song <songmuchun@bytedance.com> > Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> > --- > mm/migrate.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/mm/migrate.c b/mm/migrate.c > index a3d8c2be2631..d8aae6c75990 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -1907,17 +1907,16 @@ static struct mm_struct *find_mm_struct(pid_t pid, nodemask_t *mem_nodes) > return ERR_PTR(-ESRCH); > } > get_task_struct(task); > + rcu_read_unlock(); > > > /* > * Check if this process has the right to modify the specified > * process. Use the regular "ptrace_may_access()" checks. > */ > if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS)) { > - rcu_read_unlock(); > mm = ERR_PTR(-EPERM); > goto out; > } > - rcu_read_unlock(); > > > mm = ERR_PTR(security_task_movememory(task)); > if (IS_ERR(mm)) Why do you ignore our discussion for the previous version? https://lore.kernel.org/linux-mm/8735ju7as9.fsf@yhuang6-desk2.ccr.corp.intel.com/ Best Regards, Huang, Ying
On 2022/4/12 10:07, ying.huang@intel.com wrote: > On Sat, 2022-04-09 at 15:38 +0800, Miaohe Lin wrote: >> rcu_read_lock is required by grabbing the task refcount but it's not >> needed for ptrace_may_access. So we could release the rcu lock after >> task refcount is successfully grabbed to reduce the rcu holding time. >> >> Reviewed-by: Muchun Song <songmuchun@bytedance.com> >> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> >> --- >> mm/migrate.c | 3 +-- >> 1 file changed, 1 insertion(+), 2 deletions(-) >> >> diff --git a/mm/migrate.c b/mm/migrate.c >> index a3d8c2be2631..d8aae6c75990 100644 >> --- a/mm/migrate.c >> +++ b/mm/migrate.c >> @@ -1907,17 +1907,16 @@ static struct mm_struct *find_mm_struct(pid_t pid, nodemask_t *mem_nodes) >> return ERR_PTR(-ESRCH); >> } >> get_task_struct(task); >> + rcu_read_unlock(); >> >> >> /* >> * Check if this process has the right to modify the specified >> * process. Use the regular "ptrace_may_access()" checks. >> */ >> if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS)) { >> - rcu_read_unlock(); >> mm = ERR_PTR(-EPERM); >> goto out; >> } >> - rcu_read_unlock(); >> >> >> mm = ERR_PTR(security_task_movememory(task)); >> if (IS_ERR(mm)) > > Why do you ignore our discussion for the previous version? > > https://lore.kernel.org/linux-mm/8735ju7as9.fsf@yhuang6-desk2.ccr.corp.intel.com/ > Sorry for confusing. I remember this patch is pending for verify. The reason I post this series is that I want to move the other patches in this series forward while this patch is still pending for verify. Thanks. > Best Regards, > Huang, Ying > > > . >
diff --git a/mm/migrate.c b/mm/migrate.c index a3d8c2be2631..d8aae6c75990 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1907,17 +1907,16 @@ static struct mm_struct *find_mm_struct(pid_t pid, nodemask_t *mem_nodes) return ERR_PTR(-ESRCH); } get_task_struct(task); + rcu_read_unlock(); /* * Check if this process has the right to modify the specified * process. Use the regular "ptrace_may_access()" checks. */ if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS)) { - rcu_read_unlock(); mm = ERR_PTR(-EPERM); goto out; } - rcu_read_unlock(); mm = ERR_PTR(security_task_movememory(task)); if (IS_ERR(mm))