From: Johannes Weiner <hannes@cmpxchg.org>
To: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Rik van Riel <riel@surriel.com>, Chris Mason <clm@meta.com>,
David Hildenbrand <david@redhat.com>,
Axel Rasmussen <axelrasmussen@google.com>,
Peter Xu <peterx@redhat.com>,
James Houghton <jthoughton@google.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com, Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [BUG] hugetlbfs_no_page vs MADV_DONTNEED race leading to SIGBUS
Date: Thu, 27 Oct 2022 11:07:56 -0400 [thread overview]
Message-ID: <Y1qezB09SaZy9pRS@cmpxchg.org> (raw)
In-Reply-To: <Y1mMw2mt0my0qVqP@monkey>
On Wed, Oct 26, 2022 at 12:38:43PM -0700, Mike Kravetz wrote:
> On 10/25/22 16:37, Rik van Riel wrote:
> > What are the reasonable alternatives here?
> >
> > Should we see if anybody can come up with a simple solution
> > to the problem, or would it be better to just disable
> > MADV_DONTNEED on hugetlbfs for now?
>
> Here is one thought (perhaps crazy). Do not allow MADV_DONTNEED on
> hugetlb mappings. This would help with the library code passed hugetlb
> mapping. For the use cases where MADV_DONTNEED on hugetlb is desirable,
> create ?MADV_DONTNEED_HUGETLB? that only operates on hugetlb mappings.
> In this way the caller must be aware they are operating on a hugetlb
> mapping.
What could also work is implementing mlock() for hugetlb, and having
MADV_DONTNEED respect it.
That would allow libraries/general-purpose allocators to continue
using MADV_DONTNEED without being aware of the underlying memory
situation. Whoever is responsible for setting up the memory pool could
just mlock() - or not, if hugetlb overcommit is enabled - and the GP
allocator would do the right thing in both scenarios.
[ Our setup code is actually already calling mlock() on the hugetlb
ranges. We never wanted DONTNEED to free hugetlb pages - it just
happened to work so far because DONTNEED wasn't implemented for
them. If both DONTNEED and mlock() were implemented, we'd be good. ]
Johannes
prev parent reply other threads:[~2022-10-27 15:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-25 20:37 Rik van Riel
2022-10-26 3:07 ` Mike Kravetz
2022-10-26 4:13 ` Mike Kravetz
2022-10-26 19:38 ` Mike Kravetz
2022-10-27 15:07 ` Johannes Weiner [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=Y1qezB09SaZy9pRS@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=clm@meta.com \
--cc=david@redhat.com \
--cc=jthoughton@google.com \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=peterx@redhat.com \
--cc=riel@surriel.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