From: Rik van Riel <riel@surriel.com>
To: Mike Kravetz <mike.kravetz@oracle.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
kernel-team@meta.com, Andrew Morton <akpm@linux-foundation.org>,
David Hildenbrand <david@redhat.com>
Subject: Re: [PATCH] mm,madvise,hugetlb: fix unexpected data loss with MADV_DONTNEED on hugetlbfs
Date: Fri, 21 Oct 2022 19:29:59 -0400 [thread overview]
Message-ID: <e0fc94ec3e6e088ad26d1b2ba7a1e9dfb4fb8079.camel@surriel.com> (raw)
In-Reply-To: <Y1MFjnDBOzpCW/9Z@monkey>
[-- Attachment #1: Type: text/plain, Size: 1828 bytes --]
On Fri, 2022-10-21 at 13:48 -0700, Mike Kravetz wrote:
> On 10/21/22 15:45, Rik van Riel wrote:
> > A common use case for hugetlbfs is for the application to create
> > memory pools backed by huge pages, which then get handed over to
> > some malloc library (eg. jemalloc) for further management.
> >
> > That malloc library may be doing MADV_DONTNEED calls on memory
> > that is no longer needed, expecting those calls to happen on
> > PAGE_SIZE boundaries.
> >
>
> Thanks Rik. I tend to agree with this direction as it is 'breaking'
> current code. David and I discussed this in this thread,
> https://lore.kernel.org/linux-mm/356a4b9a-1f56-ae06-b211-bd32fc93ecda@redhat.com/
>
> One thing to note is that there was not any documentation saying
> madvise would happen on page boundaries. The system call takes a
> length and rounds up to page size. However, the man page explicitly
> said it operates on a byte range. Certainly mm people and others
> know we only operate on pages. But, that is not what was documented.
>
> When the change was made to add hugetlb support, the decision was
> made
> to round up the range to hugetlb page boundaries in hugetlb vmas.
> This
> was to be consistent with how madvise operated on base pages. At the
> same time, madvise documentation was updated say it operates on page
> boundaries as well as the behavior for hugetlb mappings. If moving
> forward with this change we will need to update the man page.
I'll send in a patch for the man page after the patch gets
merged. I'll change the text to clarify that the system
may round up the specified length to PAGE_SIZE granularity,
which is a quantity programs can get through (IIRC) getconf.
Andrew, I split out the bit of the patch for stable.
--
All Rights Reversed.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2022-10-21 23:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-21 19:45 Rik van Riel
2022-10-21 20:48 ` Mike Kravetz
2022-10-21 23:29 ` Rik van Riel [this message]
2022-10-21 23:42 ` Mike Kravetz
2022-10-21 20:48 ` 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=e0fc94ec3e6e088ad26d1b2ba7a1e9dfb4fb8079.camel@surriel.com \
--to=riel@surriel.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.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
all inboxes | Powered by JetHome®