The quilt patch titled Subject: mm: reduce the rcu lock duration has been removed from the -mm tree. Its filename was mm-reduce-the-rcu-lock-duration.patch This patch was dropped because it was withdrawn ------------------------------------------------------ From: Miaohe Lin <linmiaohe@xxxxxxxxxx> Subject: mm: reduce the rcu lock duration Date: Mon, 30 May 2022 19:30:13 +0800 Patch series "A few cleanup and fixup patches for migration", v4. This series contains a few patches to remove unneeded lock page and PageMovable check, reduce the rcu lock duration. Also we fix potential pte_unmap on an not mapped pte. More details can be found in the respective changelogs. This patch (of 4): Commit 3268c63eded4 ("mm: fix move/migrate_pages() race on task struct") extends the period of the rcu_read_lock until after the permissions checks are done to prevent the task pointed to from changing from under us. But the task_struct refcount is also taken at that time, the reference to task is guaranteed to be stable. So it's unnecessary to extend the period of the rcu_read_lock. Release the rcu lock after task refcount is successfully grabbed to reduce the rcu holding time. Link: https://lkml.kernel.org/r/20220530113016.16663-1-linmiaohe@xxxxxxxxxx Link: https://lkml.kernel.org/r/20220530113016.16663-2-linmiaohe@xxxxxxxxxx Signed-off-by: Miaohe Lin <linmiaohe@xxxxxxxxxx> Reviewed-by: Muchun Song <songmuchun@xxxxxxxxxxxxx> Reviewed-by: Christoph Hellwig <hch@xxxxxx> Reviewed-by: Oscar Salvador <osalvador@xxxxxxx> Reviewed-by: David Hildenbrand <david@xxxxxxxxxx> Cc: Huang Ying <ying.huang@xxxxxxxxx> Cc: David Howells <dhowells@xxxxxxxxxx> Cc: Christoph Lameter <cl@xxxxxxxxx> Cc: Peter Xu <peterx@xxxxxxxxxx> Cc: Alistair Popple <apopple@xxxxxxxxxx> Cc: Mike Kravetz <mike.kravetz@xxxxxxxxxx> Cc: David Howells <dhowells@xxxxxxxxxx> Cc: kernel test robot <lkp@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/mempolicy.c | 3 +-- mm/migrate.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) --- a/mm/mempolicy.c~mm-reduce-the-rcu-lock-duration +++ a/mm/mempolicy.c @@ -1617,6 +1617,7 @@ static int kernel_migrate_pages(pid_t pi goto out; } get_task_struct(task); + rcu_read_unlock(); err = -EINVAL; @@ -1625,11 +1626,9 @@ static int kernel_migrate_pages(pid_t pi * Use the regular "ptrace_may_access()" checks. */ if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS)) { - rcu_read_unlock(); err = -EPERM; goto out_put; } - rcu_read_unlock(); task_nodes = cpuset_mems_allowed(task); /* Is the user allowed to access the target nodes? */ --- a/mm/migrate.c~mm-reduce-the-rcu-lock-duration +++ a/mm/migrate.c @@ -1902,17 +1902,16 @@ static struct mm_struct *find_mm_struct( 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)) _ Patches currently in -mm which might be from linmiaohe@xxxxxxxxxx are mm-migration-remove-unneeded-lock-page-and-pagemovable-check.patch mm-migration-return-errno-when-isolate_huge_page-failed.patch mm-migration-fix-potential-pte_unmap-on-an-not-mapped-pte.patch mm-swapfile-make-security_vm_enough_memory_mm-work-as-expected.patch mm-swapfile-fix-possible-data-races-of-inuse_pages.patch mm-swap-remove-swap_cache_info-statistics.patch mm-vmscan-dont-try-to-reclaim-freed-folios.patch mm-page_alloc-minor-clean-up-for-memmap_init_compound.patch mm-madvise-minor-cleanup-for-swapin_walk_pmd_entry.patch