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