From: Andrew Morton <akpm@linux-foundation.org> To: vbabka@suse.cz,efault@gmx.de,hughd@google.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org Subject: [patch 06/16] mm/munlock: add lru_add_drain() to fix memcg_stat_test Date: Fri, 01 Apr 2022 11:28:27 -0700 [thread overview] Message-ID: <20220401182828.3285DC2BBE4@smtp.kernel.org> (raw) In-Reply-To: <20220401112740.351496714b370467a92207a6@linux-foundation.org> From: Hugh Dickins <hughd@google.com> Subject: mm/munlock: add lru_add_drain() to fix memcg_stat_test Mike reports that LTP memcg_stat_test usually leads to... memcg_stat_test 3 TINFO: Test unevictable with MAP_LOCKED memcg_stat_test 3 TINFO: Running memcg_process --mmap-lock1 -s 135168 memcg_stat_test 3 TINFO: Warming up pid: 3460 memcg_stat_test 3 TINFO: Process is still here after warm up: 3460 memcg_stat_test 3 TFAIL: unevictable is 122880, 135168 expected ...but may lead to... memcg_stat_test 4 TINFO: Test unevictable with mlock memcg_stat_test 4 TINFO: Running memcg_process --mmap-lock2 -s 135168 memcg_stat_test 4 TINFO: Warming up pid: 4271 memcg_stat_test 4 TINFO: Process is still here after warm up: 4271 memcg_stat_test 4 TFAIL: unevictable is 122880, 135168 expected ...or both. A wee bit flaky. follow_page_pte() used to have an lru_add_drain() per each page mlocked, and the test came to rely on accurate stats. The pagevec to be drained is different now, but still covered by lru_add_drain(); and, never mind the test, I believe it's in everyone's interest that a bulk faulting interface like populate_vma_page_range() or faultin_vma_page_range() should drain its local pagevecs at the end, to save others sometimes needing the much more expensive lru_add_drain_all(). This does not absolutely guarantee exact stats - the mlocking task can be migrated between CPUs as it proceeds - but it's good enough and the tests pass. Link: https://lkml.kernel.org/r/47f6d39c-a075-50cb-1cfb-26dd957a48af@google.com Fixes: b67bf49ce7aa ("mm/munlock: delete FOLL_MLOCK and FOLL_POPULATE") Signed-off-by: Hugh Dickins <hughd@google.com> Reported-by: Mike Galbraith <efault@gmx.de> Cc: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- mm/gup.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/mm/gup.c~mm-munlock-add-lru_add_drain-to-fix-memcg_stat_test +++ a/mm/gup.c @@ -1404,6 +1404,7 @@ long populate_vma_page_range(struct vm_a struct mm_struct *mm = vma->vm_mm; unsigned long nr_pages = (end - start) / PAGE_SIZE; int gup_flags; + long ret; VM_BUG_ON(!PAGE_ALIGNED(start)); VM_BUG_ON(!PAGE_ALIGNED(end)); @@ -1438,8 +1439,10 @@ long populate_vma_page_range(struct vm_a * We made sure addr is within a VMA, so the following will * not result in a stack expansion that recurses back here. */ - return __get_user_pages(mm, start, nr_pages, gup_flags, + ret = __get_user_pages(mm, start, nr_pages, gup_flags, NULL, NULL, locked); + lru_add_drain(); + return ret; } /* @@ -1471,6 +1474,7 @@ long faultin_vma_page_range(struct vm_ar struct mm_struct *mm = vma->vm_mm; unsigned long nr_pages = (end - start) / PAGE_SIZE; int gup_flags; + long ret; VM_BUG_ON(!PAGE_ALIGNED(start)); VM_BUG_ON(!PAGE_ALIGNED(end)); @@ -1498,8 +1502,10 @@ long faultin_vma_page_range(struct vm_ar if (check_vma_flags(vma, gup_flags)) return -EINVAL; - return __get_user_pages(mm, start, nr_pages, gup_flags, + ret = __get_user_pages(mm, start, nr_pages, gup_flags, NULL, NULL, locked); + lru_add_drain(); + return ret; } /* _
WARNING: multiple messages have this Message-ID (diff)
From: Andrew Morton <akpm@linux-foundation.org> To: vbabka@suse.cz, efault@gmx.de, hughd@google.com, akpm@linux-foundation.org, patches@lists.linux.dev, linux-mm@kvack.org, mm-commits@vger.kernel.org, torvalds@linux-foundation.org, akpm@linux-foundation.org Subject: [patch 06/16] mm/munlock: add lru_add_drain() to fix memcg_stat_test Date: Fri, 01 Apr 2022 11:28:27 -0700 [thread overview] Message-ID: <20220401182828.3285DC2BBE4@smtp.kernel.org> (raw) In-Reply-To: <20220401112740.351496714b370467a92207a6@linux-foundation.org> From: Hugh Dickins <hughd@google.com> Subject: mm/munlock: add lru_add_drain() to fix memcg_stat_test Mike reports that LTP memcg_stat_test usually leads to... memcg_stat_test 3 TINFO: Test unevictable with MAP_LOCKED memcg_stat_test 3 TINFO: Running memcg_process --mmap-lock1 -s 135168 memcg_stat_test 3 TINFO: Warming up pid: 3460 memcg_stat_test 3 TINFO: Process is still here after warm up: 3460 memcg_stat_test 3 TFAIL: unevictable is 122880, 135168 expected ...but may lead to... memcg_stat_test 4 TINFO: Test unevictable with mlock memcg_stat_test 4 TINFO: Running memcg_process --mmap-lock2 -s 135168 memcg_stat_test 4 TINFO: Warming up pid: 4271 memcg_stat_test 4 TINFO: Process is still here after warm up: 4271 memcg_stat_test 4 TFAIL: unevictable is 122880, 135168 expected ...or both. A wee bit flaky. follow_page_pte() used to have an lru_add_drain() per each page mlocked, and the test came to rely on accurate stats. The pagevec to be drained is different now, but still covered by lru_add_drain(); and, never mind the test, I believe it's in everyone's interest that a bulk faulting interface like populate_vma_page_range() or faultin_vma_page_range() should drain its local pagevecs at the end, to save others sometimes needing the much more expensive lru_add_drain_all(). This does not absolutely guarantee exact stats - the mlocking task can be migrated between CPUs as it proceeds - but it's good enough and the tests pass. Link: https://lkml.kernel.org/r/47f6d39c-a075-50cb-1cfb-26dd957a48af@google.com Fixes: b67bf49ce7aa ("mm/munlock: delete FOLL_MLOCK and FOLL_POPULATE") Signed-off-by: Hugh Dickins <hughd@google.com> Reported-by: Mike Galbraith <efault@gmx.de> Cc: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- mm/gup.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/mm/gup.c~mm-munlock-add-lru_add_drain-to-fix-memcg_stat_test +++ a/mm/gup.c @@ -1404,6 +1404,7 @@ long populate_vma_page_range(struct vm_a struct mm_struct *mm = vma->vm_mm; unsigned long nr_pages = (end - start) / PAGE_SIZE; int gup_flags; + long ret; VM_BUG_ON(!PAGE_ALIGNED(start)); VM_BUG_ON(!PAGE_ALIGNED(end)); @@ -1438,8 +1439,10 @@ long populate_vma_page_range(struct vm_a * We made sure addr is within a VMA, so the following will * not result in a stack expansion that recurses back here. */ - return __get_user_pages(mm, start, nr_pages, gup_flags, + ret = __get_user_pages(mm, start, nr_pages, gup_flags, NULL, NULL, locked); + lru_add_drain(); + return ret; } /* @@ -1471,6 +1474,7 @@ long faultin_vma_page_range(struct vm_ar struct mm_struct *mm = vma->vm_mm; unsigned long nr_pages = (end - start) / PAGE_SIZE; int gup_flags; + long ret; VM_BUG_ON(!PAGE_ALIGNED(start)); VM_BUG_ON(!PAGE_ALIGNED(end)); @@ -1498,8 +1502,10 @@ long faultin_vma_page_range(struct vm_ar if (check_vma_flags(vma, gup_flags)) return -EINVAL; - return __get_user_pages(mm, start, nr_pages, gup_flags, + ret = __get_user_pages(mm, start, nr_pages, gup_flags, NULL, NULL, locked); + lru_add_drain(); + return ret; } /* _
next prev parent reply other threads:[~2022-04-01 18:28 UTC|newest] Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-04-01 18:27 incoming Andrew Morton 2022-04-01 18:28 ` [patch 01/16] Revert "mm: madvise: skip unmapped vma holes passed to process_madvise" Andrew Morton 2022-04-01 18:28 ` Andrew Morton 2022-04-01 18:28 ` [patch 02/16] ocfs2: fix crash when mount with quota enabled Andrew Morton 2022-04-01 18:28 ` Andrew Morton 2022-04-01 18:28 ` [patch 03/16] nilfs2: fix lockdep warnings in page operations for btree nodes Andrew Morton 2022-04-01 18:28 ` Andrew Morton 2022-04-01 18:28 ` [patch 04/16] nilfs2: fix lockdep warnings during disk space reclamation Andrew Morton 2022-04-01 18:28 ` Andrew Morton 2022-04-01 18:28 ` [patch 05/16] nilfs2: get rid of nilfs_mapping_init() Andrew Morton 2022-04-01 18:28 ` Andrew Morton 2022-04-01 18:28 ` Andrew Morton [this message] 2022-04-01 18:28 ` [patch 06/16] mm/munlock: add lru_add_drain() to fix memcg_stat_test Andrew Morton 2022-04-01 18:28 ` [patch 07/16] mm/munlock: update Documentation/vm/unevictable-lru.rst Andrew Morton 2022-04-01 18:28 ` Andrew Morton 2022-04-01 18:28 ` [patch 08/16] mm/munlock: protect the per-CPU pagevec by a local_lock_t Andrew Morton 2022-04-01 18:28 ` Andrew Morton 2022-04-01 18:28 ` [patch 09/16] mm: kfence: fix objcgs vector allocation Andrew Morton 2022-04-01 18:28 ` Andrew Morton 2022-04-01 18:28 ` [patch 10/16] mailmap: update Kirill's email Andrew Morton 2022-04-01 18:28 ` Andrew Morton 2022-04-01 18:28 ` [patch 11/16] mm,hwpoison: unmap poisoned page before invalidation Andrew Morton 2022-04-01 18:28 ` Andrew Morton 2022-04-01 18:28 ` [patch 12/16] mm, kasan: fix __GFP_BITS_SHIFT definition breaking LOCKDEP Andrew Morton 2022-04-01 18:28 ` Andrew Morton 2022-04-01 18:28 ` [patch 13/16] tools/vm/page_owner_sort.c: remove -c option Andrew Morton 2022-04-01 18:28 ` Andrew Morton 2022-04-01 18:28 ` [patch 14/16] doc/vm/page_owner.rst: remove content related to " Andrew Morton 2022-04-01 18:28 ` Andrew Morton 2022-04-01 18:28 ` [patch 15/16] mm/kmemleak: reset tag when compare object pointer Andrew Morton 2022-04-01 18:28 ` Andrew Morton 2022-04-01 18:28 ` [patch 16/16] mm/damon: prevent activated scheme from sleeping by deactivated schemes Andrew Morton 2022-04-01 18:28 ` Andrew Morton [not found] <l> 2022-04-01 18:21 ` [patch 06/16] mm/munlock: add lru_add_drain() to fix memcg_stat_test Andrew Morton 2022-04-01 18:21 ` Andrew Morton
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220401182828.3285DC2BBE4@smtp.kernel.org \ --to=akpm@linux-foundation.org \ --cc=efault@gmx.de \ --cc=hughd@google.com \ --cc=linux-mm@kvack.org \ --cc=mm-commits@vger.kernel.org \ --cc=patches@lists.linux.dev \ --cc=torvalds@linux-foundation.org \ --cc=vbabka@suse.cz \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.