linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Yin Fengwei <fengwei.yin@intel.com>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Naoya Horiguchi <naoya.horiguchi@linux.dev>,
	Axel Rasmussen <axelrasmussen@google.com>,
	Mina Almasry <almasrymina@google.com>,
	Michal Hocko <mhocko@suse.com>, Peter Xu <peterx@redhat.com>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Shuah Khan <shuah@kernel.org>, Mike Rapoport <rppt@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v3 1/3] mm: enable MADV_DONTNEED for hugetlb mappings
Date: Thu, 17 Feb 2022 09:58:26 +0100	[thread overview]
Message-ID: <fad42051-6816-08cf-1430-ad4da5dbc951@redhat.com> (raw)
In-Reply-To: <57fa170a-253b-932f-0261-b4905881d888@intel.com>

On 17.02.22 09:32, Yin Fengwei wrote:
> 
> 
> On 2022/2/15 08:23, Mike Kravetz wrote:
>> MADV_DONTNEED is currently disabled for hugetlb mappings.  This
>> certainly makes sense in shared file mappings as the pagecache maintains
>> a reference to the page and it will never be freed.  However, it could
>> be useful to unmap and free pages in private mappings.  In addition,
>> userfaultfd minor fault users may be able to simplify code by using
>> MADV_DONTNEED.
>>
>> The primary thing preventing MADV_DONTNEED from working on hugetlb
>> mappings is a check in can_madv_lru_vma().  To allow support for hugetlb
>> mappings create and use a new routine madvise_dontneed_free_valid_vma()
>> that allows hugetlb mappings in this specific case.
>>
>> For normal mappings, madvise requires the start address be PAGE aligned
>> and rounds up length to the next multiple of PAGE_SIZE.  Do similarly
> 
> In man page of mmap, NOTE for "Huge page (Huge TLB) mappings":
> 
> "For munmap(), addr, and length must both be a multiple of the 
> underlying huge page size."
> 
> Should we apply same rule to MADV_DONTNEED? Thanks.

madvise() already has different rules than mmap() for ordinary pages, so
we'd much rather try staying consistent with madvise() rules.

-- 
Thanks,

David / dhildenb



  reply	other threads:[~2022-02-17  8:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-15  0:23 [PATCH v3 0/3] Add hugetlb MADV_DONTNEED support Mike Kravetz
2022-02-15  0:23 ` [PATCH v3 1/3] mm: enable MADV_DONTNEED for hugetlb mappings Mike Kravetz
2022-02-17  8:32   ` Yin Fengwei
2022-02-17  8:58     ` David Hildenbrand [this message]
2022-02-18  0:39       ` Yin Fengwei
2022-02-15  0:23 ` [PATCH v3 2/3] selftests/vm: add hugetlb madvise MADV_DONTNEED MADV_REMOVE test Mike Kravetz
2022-02-15  0:23 ` [PATCH v3 3/3] userfaultfd/selftests: enable hugetlb remap and remove event testing Mike Kravetz

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=fad42051-6816-08cf-1430-ad4da5dbc951@redhat.com \
    --to=david@redhat.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=almasrymina@google.com \
    --cc=axelrasmussen@google.com \
    --cc=fengwei.yin@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=mike.kravetz@oracle.com \
    --cc=naoya.horiguchi@linux.dev \
    --cc=peterx@redhat.com \
    --cc=rppt@kernel.org \
    --cc=shuah@kernel.org \
    /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