linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>
To: Ryan Roberts <ryan.roberts@arm.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	maple-tree@lists.infradead.org
Subject: Re: [PATCH v4 18/49] mlock: Convert mlock to vma iterator
Date: Tue, 11 Jul 2023 11:27:34 -0400	[thread overview]
Message-ID: <20230711152734.hith252qxjbnz4bt@revolver> (raw)
In-Reply-To: <50341ca1-d582-b33a-e3d0-acb08a65166f@arm.com>

* Ryan Roberts <ryan.roberts@arm.com> [230711 10:09]:
> On 20/01/2023 16:26, Liam R. Howlett wrote:
> > From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>
> > 
> > Use the vma iterator so that the iterator can be invalidated or updated
> > to avoid each caller doing so.
> 
> Hi,


Hello!

> 
> I've bisected 2 mm selftest regressions back to this patch, so hoping someone can help debug and fix? The failures are reproducible on x86_64 and arm64.

Thanks!  That is a big help.  Where did you start your bisection?  I
assume 6.4?

> 
> 
> mlock-random-test:
> 
> $ ./run_kselftest.sh -t mm:mlock-random-test
> TAP version 13
> 1..1
> # selftests: mm: mlock-random-test
> mlock() failure at |0xaaaaaaab52d0(131072)| mlock:|0xaaaaaaacc65d(26551)|
> not ok 1 selftests: mm: mlock-random-test # exit=255
> 
> This mallocs a buffer then loops 100 times, trying to mlock random parts of it. After this patch, the test fails after a variable number of iterations; mlock() returns ENOMEM. If I explicitly munlock at the end of each loop, it works.
> 
> 
> mlock2-tests:
> 
> $ ./run_kselftest.sh -t mm:mlock2-tests
> TAP version 13
> 1..1
> # selftests: mm: mlock2-tests
> munlock(): Cannot allocate memory
> munlock(): Cannot allocate memory
> not ok 1 selftests: mm: mlock2-tests # exit=2
> 
> Here, a 3 page buffer is mlock2()ed, then the middle page is munlocked. Finally the whole 3 page range is munlocked, and after this patch it fails with ENOMEM. If I modify the test to split the final munlock into 2, one for the first page and one for the last, the test passes.
> 
> 
> Immediately prior to this patch (2286a6914c77 "mm: change mprotect_fixup to vma iterator"), both tests pass.
> 
> From a quick scan of the man page, I don't think it explicitly says that its ok to call mlock/munlock on already locked/unlocked pages, but it's certainly a change of behavior and the tests notice, so I'm guessing this wasn't intentional?
> 
> I'm not familiar with this code so it's not obvious to me exactly what the problem is, but I'm hoping someone can help debug?

I think I see the issue and I'm working on a fix. I appreciate the
analysis and report, it really helps narrow things down.

Regards,
Liam

  reply	other threads:[~2023-07-11 15:28 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-20 16:26 [PATCH v4 00/49] VMA tree type safety and remove __vma_adjust() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 01/49] maple_tree: Add mas_init() function Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 02/49] maple_tree: Fix potential rcu issue Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 03/49] maple_tree: Reduce user error potential Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 04/49] test_maple_tree: Test modifications while iterating Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 05/49] maple_tree: Fix handle of invalidated state in mas_wr_store_setup() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 06/49] maple_tree: Fix mas_prev() and mas_find() state handling Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 07/49] mm: Expand vma iterator interface Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 08/49] mm/mmap: convert brk to use vma iterator Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 09/49] kernel/fork: Convert forking to using the vmi iterator Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 10/49] mmap: Convert vma_link() vma iterator Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 11/49] mm/mmap: Remove preallocation from do_mas_align_munmap() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 12/49] mmap: Change do_mas_munmap and do_mas_aligned_munmap() to use vma iterator Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 13/49] mmap: Convert vma_expand() " Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 14/49] mm: Add temporary vma iterator versions of vma_merge(), split_vma(), and __split_vma() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 15/49] ipc/shm: Use the vma iterator for munmap calls Liam R. Howlett
2023-01-25 11:00   ` Sven Schnelle
2023-01-25 13:53     ` Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 16/49] userfaultfd: Use vma iterator Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 17/49] mm: Change mprotect_fixup to " Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 18/49] mlock: Convert mlock " Liam R. Howlett
2023-07-11 14:08   ` Ryan Roberts
2023-07-11 15:27     ` Liam R. Howlett [this message]
2023-07-11 15:30       ` Ryan Roberts
2023-07-11 17:57         ` Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 19/49] coredump: Convert " Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 20/49] mempolicy: " Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 21/49] task_mmu: " Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 22/49] sched: " Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 23/49] madvise: Use vmi iterator for __split_vma() and vma_merge() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 24/49] mmap: Pass through vmi iterator to __split_vma() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 25/49] mmap: Use vmi version of vma_merge() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 26/49] mm/mremap: " Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 27/49] nommu: Convert nommu to using the vma iterator Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 28/49] nommu: Pass through vma iterator to shrink_vma() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 29/49] mm: Switch vma_merge(), split_vma(), and __split_vma to vma iterator Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 30/49] mm/damon/vaddr-test.h: Stop using vma_mas_store() for maple tree store Liam R. Howlett
2023-01-20 17:32   ` SeongJae Park
2023-01-20 16:26 ` [PATCH v4 31/49] mmap: Convert __vma_adjust() to use vma iterator Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 32/49] mm: Pass through vma iterator to __vma_adjust() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 33/49] madvise: Use split_vma() instead of __split_vma() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 34/49] mm: Remove unnecessary write to vma iterator in __vma_adjust() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 35/49] mm: Pass vma iterator through to __vma_adjust() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 36/49] mm: Add vma iterator to vma_adjust() arguments Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 37/49] mmap: Clean up mmap_region() unrolling Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 38/49] mm: Change munmap splitting order and move_vma() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 39/49] mm/mmap: move anon_vma setting in __vma_adjust() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 40/49] mm/mmap: Refactor locking out of __vma_adjust() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 41/49] mm/mmap: Use vma_prepare() and vma_complete() in vma_expand() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 42/49] mm/mmap: Introduce init_vma_prep() and init_multi_vma_prep() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 43/49] mm: Don't use __vma_adjust() in __split_vma() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 44/49] mm/mremap: Convert vma_adjust() to vma_expand() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 45/49] mm/mmap: Don't use __vma_adjust() in shift_arg_pages() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 46/49] mm/mmap: Introduce dup_vma_anon() helper Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 47/49] mm/mmap: Convert do_brk_flags() to use vma_prepare() and vma_complete() Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 48/49] mm/mmap: Remove __vma_adjust() Liam R. Howlett
2023-02-22 16:17   ` Vlastimil Babka
2023-02-23  2:12     ` Liam R. Howlett
2023-01-20 16:26 ` [PATCH v4 49/49] vma_merge: Set vma iterator to correct position Liam R. Howlett

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=20230711152734.hith252qxjbnz4bt@revolver \
    --to=liam.howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=maple-tree@lists.infradead.org \
    --cc=ryan.roberts@arm.com \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).