lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87qzvg6i3c.fsf@linux.dev>
Date: Mon, 06 Oct 2025 10:44:07 -0700
From: Roman Gushchin <roman.gushchin@...ux.dev>
To: Jan Kara <jack@...e.cz>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
  linux-kernel@...r.kernel.org,  "Matthew Wilcox (Oracle)"
 <willy@...radead.org>,  Dev Jain <dev.jain@....com>,  linux-mm@...ck.org
Subject: Re: [PATCH v2] mm: readahead: make thp readahead conditional to
 mmap_miss logic

Jan Kara <jack@...e.cz> writes:

> On Sun 05-10-25 18:54:09, Roman Gushchin wrote:
>> Commit 4687fdbb805a ("mm/filemap: Support VM_HUGEPAGE for file mappings")
>> introduced a special handling for VM_HUGEPAGE mappings: even if the
>> readahead is disabled, 1 or 2 HPAGE_PMD_ORDER pages are
>> allocated.
>> 
>> This change causes a significant regression for containers with a
>> tight memory.max limit, if VM_HUGEPAGE is widely used. Prior to this
>> commit, mmap_miss logic would eventually lead to the readahead
>> disablement, effectively reducing the memory pressure in the
>> cgroup. With this change the kernel is trying to allocate 1-2 huge
>> pages for each fault, no matter if these pages are used or not
>> before being evicted, increasing the memory pressure multi-fold.
>> 
>> To fix the regression, let's make the new VM_HUGEPAGE conditional
>> to the mmap_miss check, but keep independent from the ra->ra_pages.
>> This way the main intention of commit 4687fdbb805a ("mm/filemap:
>> Support VM_HUGEPAGE for file mappings") stays intact, but the
>> regression is resolved.
>> 
>> The logic behind this changes is simple: even if a user explicitly
>> requests using huge pages to back the file mapping (using VM_HUGEPAGE
>> flag), under a very strong memory pressure it's better to fall back
>> to ordinary pages.
>> 
>> Signed-off-by: Roman Gushchin <roman.gushchin@...ux.dev>
>> Reviewed-by: Jan Kara <jack@...e.cz>
>> Cc: Matthew Wilcox (Oracle) <willy@...radead.org>
>> Cc: Dev Jain <dev.jain@....com>
>> Cc: linux-mm@...ck.org
>> 
>> --
>> 
>> v2: fixed VM_SEQ_READ handling (by Dev Jain)
>
> OK, but now we'll do mmap_miss detection and bail-out even for VM_SEQ_READ
> | VM_HUGEPAGE vmas. And without VM_HUGEPAGE we won't do it which is really
> odd. So I think you want to make the whole mmap_miss logic conditional on
> !VM_SEQ_READ...

Yeah, agree, good point.

Thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ