summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorLonglong Xia <xialonglong@kylinos.cn>2026-08-31 21:35:19 +0800
committerAndrew Morton <akpm@linux-foundation.org>2026-10-06 17:39:20 -0700
commit3c2ea15046f85c1a006818ebbe8a87b0b3a18b9c (patch)
tree184764b51fa0884b771a894e7131da25a1b7437e /include/linux
parent7857e0213aad0da2b86f24d6f0698635a585dc30 (diff)
downloadlinux-3c2ea15046f85c1a006818ebbe8a87b0b3a18b9c.tar.gz
linux-3c2ea15046f85c1a006818ebbe8a87b0b3a18b9c.zip
mm/hugetlb: cap demotion at currently available free pages
Demotion must not remove free huge pages that back existing reservations. The sysfs path checks whether any page is available, but passes the entire request to demote_pool_huge_page(). For example, with two free pages and one reservation, a request for two pages removes both and leaves the reservation without a backing page. Cap the sysfs request by both global availability and the selected node's free pages. Recheck global availability in demote_pool_huge_page() before each node batch because that function drops hugetlb_lock while restoring vmemmap and reservations can change before the next batch. Testing: Tested on an x86_64 QEMU guest booted with: hugepagesz=1G hugepages=2 Reserve one 1 GiB huge page with an untouched hugetlbfs mapping: nr=2 surplus=0 free=2 resv=1 Request demotion of two pages. Before this fix, both free pages are demoted: nr=0 surplus=0 free=0 resv=1 Touching the reserved mapping then fails with SIGBUS. After this fix, the request is capped at the single available page: nr=1 surplus=0 free=1 resv=1 Touching the reserved mapping succeeds. After the process exits, the counters are: nr=1 surplus=0 free=1 resv=0 Link: https://lore.kernel.org/20260831133519.2505020-3-xialonglong2025@163.com Fixes: c0f398c3b2cf ("mm/hugetlb_vmemmap: batch HVO work when demoting") Signed-off-by: Longlong Xia <xialonglong@kylinos.cn> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Assisted-by: Codex:gpt-5.6-sol Cc: David Hildenbrand <david@kernel.org> Cc: Muchun Song <muchun.song@linux.dev> Cc: Oscar Salvador <osalvador@suse.de> Cc: Yu Zhao <yuzhao@google.com>
Diffstat (limited to 'include/linux')
0 files changed, 0 insertions, 0 deletions