From: Liam Howlett <liam.howlett@oracle.com>
To: Hugh Dickins <hughd@google.com>
Cc: David Hildenbrand <david@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Yu Zhao <yuzhao@google.com>, Matthew Wilcox <willy@infradead.org>,
"maple-tree@lists.infradead.org" <maple-tree@lists.infradead.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] maple_tree: Fix sparse reported issues
Date: Mon, 18 Jul 2022 17:47:40 +0000 [thread overview]
Message-ID: <20220718174733.dya2xjigqeud6clx@revolver> (raw)
In-Reply-To: <7db5a8c5-9084-a7fe-6e83-713e52ed8539@google.com>
...
>
> > So the only time I've even seen __vma_adjust() fail is with a fault
> > injector failing mas_preallocate() allocations. If it's safe to not
> > unwind, I'm happy to drop both unwinds but I was concerned in the path
> > of a vma_merge() calling __vma_adjust() and failing out on allocations
> > then OOM recovering, leaving a VMA with a 1/2 merged vma with anon
> > incorrectly set.. which is an even more unlikely scenario.
>
> It's not half-merged, it is correctly set up (just like if a write fault
> had occurred somewhere in that extent before the merge), so no need to
> unwind.
>
I'll drop the incorrect unwinding then.
> ...
>
> > Right, the __split_vma() never adjusts anything but one side of the
> > 'vma' VMA by inserting the 'insert' VMA. This will result in two writes
> > to the tree - but one will exactly fit in an existing range which will
> > be placed without an allocation via the mas_wr_slot_store() function in
> > the maple tree. Exact fits are nice - they are fast.
>
> I'll have to come back and think about this again later on: "Exact fits
> are nice" may answer my concern in the end, but I still have the worry
> that the first store destroys the prealloc, when it might be the second
> store which needs the prealloc.
>
> ...
>
> > > > > Do you have the patch
> > > > > "maple_tree-Fix-stale-data-copy-in-mas_wr_node_store.patch"? It sounds
> > > > > like your issue fits this fix exactly. I was seeing the same issue with
> > > > > gcc 9.3.1 20200408 and this bug doesn't happen for me now. The logs
> > > > > you sent also fit the situation. I went through the same exercise
> > > > > (exorcism?) of debugging the various additions and removals of the VMA
> > > > > only to find the issue in the tree itself. The fix also modified the
> > > > > test code to detect the issue - which was actually hit but not detected
> > > > > in the existing test cases from a live capture of VMA activities. It is
> > > > > difficult to spot in the tree dump as well. I am sure I sent this to
> > > > > Andrew as it is included in v11 and did not show up in his diff, but I
> > > > > cannot find it on lore, perhaps I forgot to CC you? I've attached it
> > > > > here for you in case you missed it.
> > > >
> > > > Thanks! No, I never received that patch, nor can I see it on lore
> > > > or marc.info; but I (still) haven't looked at v11, and don't know
> > > > about Andrew's diff. Anyway, sounds exciting, I'm eager to stop
> > > > writing this mail and get to testing with that in - but please
> > > > let me know whether it's the mas_dead_leaves() or the __vma_adjust()
> > > > mods you attached previously, which you want me to leave out.
>
> The overnight test run ended in an unexpected way, but I believe we can
> count it as a success - a big success for your stale data copy fix.
>
> (If only that fix had got through the mail system on Friday,
> my report on Sunday would have been much more optimistic.)
>
> I said before that I expected the test run to hit the swapops.h
> migration entry !PageLocked BUG, but it did not. It ran for
> nearly 7 hours, and then one of its builds terminated with
>
> {standard input}: Assembler messages:
> {standard input}: Error: open CFI at the end of file;
> missing .cfi_endproc directive
> gcc: fatal error: Killed signal terminated program cc1
> compilation terminated.
>
> which I've never seen before. Usually I'd put something like that down
> to a error in swap, or a TLB flushing error (but I include Nadav's fix
> in my kernel, and wouldn't get very far without it): neither related to
> the maple tree patchset.
>
> But on this occasion, my guess is that it's actually an example of what
> the swapops.h migration entry !PageLocked BUG is trying to alert us to.
>
> Imagine when such a "stale" migration entry is found, but the page it
> points to (now reused for something else) just happens to be PageLocked
> at that instant. Then the BUG won't fire, and we proceed to use the
> page as if it's ours, but it's not. I think that's what happened.
>
> I must get on with the day: more testing, and thinking.
I think this is the same issue seen here:
https://lore.kernel.org/linux-mm/YsQt3IHbJnAhsSWl@casper.infradead.org/
Note that on 20220616, the maple tree was in the next.
I suspect I am doing something wrong in do_brk_munmap(). I am using a
false VMA to munmap a partial vma by setting it up like the part of the
VMA that would have been split, inserted into the tree, then removed and
freed. I must be missing something necessary for this to function
correctly.
Thanks,
Liam
next prev parent reply other threads:[~2022-07-18 17:47 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-12 14:24 Liam Howlett
2022-07-12 14:54 ` Matthew Wilcox
2022-07-12 15:44 ` Liam Howlett
2022-07-13 8:34 ` David Hildenbrand
2022-07-13 13:29 ` Liam Howlett
2022-07-13 15:55 ` Hugh Dickins
2022-07-13 17:50 ` Liam Howlett
2022-07-15 19:53 ` Liam Howlett
2022-07-17 20:57 ` Hugh Dickins
2022-07-18 2:27 ` Liam Howlett
2022-07-18 4:28 ` Hugh Dickins
2022-07-18 6:47 ` Hugh Dickins
2022-07-18 12:56 ` Liam Howlett
2022-07-18 13:45 ` Liam Howlett
2022-07-18 17:30 ` Hugh Dickins
2022-07-18 17:47 ` Liam Howlett [this message]
2022-07-18 21:34 ` Hugh Dickins
2022-07-19 1:39 ` Liam 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=20220718174733.dya2xjigqeud6clx@revolver \
--to=liam.howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maple-tree@lists.infradead.org \
--cc=willy@infradead.org \
--cc=yuzhao@google.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