From: "Liam R. Howlett" <Liam.Howlett@Oracle.com>
To: "John Hsu (許永翰)" <John.Hsu@mediatek.com>
Cc: "Andrew Yang (楊智強)" <Andrew.Yang@mediatek.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Qun-wei Lin (林群崴)" <Qun-wei.Lin@mediatek.com>,
"surenb@google.com" <surenb@google.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"Chinwen Chang (張錦文)" <chinwen.chang@mediatek.com>,
"Kuan-Ying Lee (李冠穎)" <Kuan-Ying.Lee@mediatek.com>,
"Casper Li (李中榮)" <casper.li@mediatek.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"yuzhao@google.com" <yuzhao@google.com>,
"maple-tree@lists.infradead.org" <maple-tree@lists.infradead.org>
Subject: Re: [BUG] trigger BUG_ON in mas_store_prealloc when low memory
Date: Tue, 8 Aug 2023 16:00:57 -0400 [thread overview]
Message-ID: <20230808200057.p3pqwkumghqbdvbi@revolver> (raw)
In-Reply-To: <981aac92a51c4e2cfd2ca83d11742e5741e60285.camel@mediatek.com>
* John Hsu (許永翰) <John.Hsu@mediatek.com> [230807 05:55]:
> On Wed, 2023-07-19 at 14:51 -0400, Liam R. Howlett wrote:
...
> > > As I know, following is rb_tree flow in 5.15.186:
> > >
> > > ...
> > > mmap_write_lock_killable(mm)
> > > ...
> > > do_mmap()
> > > ...
> > > mmap_region()
> > > ...
> > > vm_area_alloc(mm)
> > > ...
> > > mmap_write_unlock(mm)
> > >
> > > vm_area_alloc is in the mmap_lock hoding period.
> > > It seems that the flow would sleep here in rb_tree flow.
> > > If I miss anything, please tell me, thanks!
> >
> > Before the mmap_write_unlock(mm) in the above sequence, the
> > i_mmap_lock_write(), anon_vma_lock_write(), and/or the
> > flush_dcache_mmap_lock() may be taken. Check __vma_adjust().
> >
> > The insertion into the tree needs to hold some subset of these locks.
> > The rb-tree insert did not allocate within these locks, but the maple
> > tree would need to allocate within these locks to insert into the
> > tree.
> > This is why the preallocation exists and why it is necessary.
> >
>
> Yap, preallocation is necessary. anon_vma_lock_write() and
> flush_dcache_mmap_lock() hold the lock and manipulate rb_tree. I think
> that there is no maple tree manipulations during the lock holding
> period. Is there any future work in this section?
__vma_adjust() does modify the maple tree during the lock holding
section through vma_mas_store() in 6.1. Prior to 6.1, there is no maple
tree.
...
> > There are also config options to debug the tree operations, but they
> > do
> > not detect the redundant write issues. Perhaps I can look at adding
> > support for detecting redundant writes, but that will not be
> > backported
> > to a stable kernel.
> >
>
> The sufficient test cases of maple tree ensure the function work well.
> But the redundant operations (alloc node, free node, tree
> manipulations) of maple_tree are not easy to detect (e.g. the case
> reported this time and mas_preallocate() allocates redundant nodes with
> the worst case).
>
> The detecting redundant writes mechanism may help the developers to
> find out the problems easier. Hope it can be establised successfully!!
When I went to add this, I had found I already added it here [1].
This operation was not caught by MA_STATE_PREALLOC because there are two
writes before a mas_destroy(), so there may be nodes left which avoid
the warning. I'll look at improving this situation.
Thanks,
Liam
[1] https://lore.kernel.org/linux-mm/20220722160546.1478722-2-Liam.Howlett@oracle.com/
prev parent reply other threads:[~2023-08-08 20:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-09 8:37 John Hsu (許永翰)
2023-06-13 14:11 ` Liam R. Howlett
2023-06-14 7:06 ` John Hsu (許永翰)
2023-06-14 15:58 ` Liam R. Howlett
2023-06-16 9:18 ` John Hsu (許永翰)
2023-07-06 18:54 ` Liam R. Howlett
2023-07-10 12:49 ` John Hsu (許永翰)
2023-07-10 14:24 ` Liam R. Howlett
2023-07-13 3:25 ` John Hsu (許永翰)
2023-07-13 3:29 ` John Hsu (許永翰)
2023-07-19 18:51 ` Liam R. Howlett
2023-07-19 19:22 ` Liam R. Howlett
2023-08-07 9:54 ` John Hsu (許永翰)
2023-08-08 20:00 ` Liam R. Howlett [this message]
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=20230808200057.p3pqwkumghqbdvbi@revolver \
--to=liam.howlett@oracle.com \
--cc=Andrew.Yang@mediatek.com \
--cc=John.Hsu@mediatek.com \
--cc=Kuan-Ying.Lee@mediatek.com \
--cc=Qun-wei.Lin@mediatek.com \
--cc=akpm@linux-foundation.org \
--cc=casper.li@mediatek.com \
--cc=chinwen.chang@mediatek.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maple-tree@lists.infradead.org \
--cc=surenb@google.com \
--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