From: Ackerley Tng <ackerleytng@google.com>
To: Peter Xu <peterx@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
riel@surriel.com, leitao@debian.org, akpm@linux-foundation.org,
peterx@redhat.com, muchun.song@linux.dev, osalvador@suse.de,
roman.gushchin@linux.dev, nao.horiguchi@gmail.com,
stable@vger.kernel.org
Subject: Re: [PATCH 1/7] mm/hugetlb: Fix avoid_reserve to allow taking folio from subpool
Date: Wed, 18 Dec 2024 14:33:43 +0000 [thread overview]
Message-ID: <diqzwmfxrrg8.fsf@ackerleytng-ctop.c.googlers.com> (raw)
In-Reply-To: <20241201212240.533824-2-peterx@redhat.com> (message from Peter Xu on Sun, 1 Dec 2024 16:22:34 -0500)
Peter Xu <peterx@redhat.com> writes:
> Since commit 04f2cbe35699 ("hugetlb: guarantee that COW faults for a
> process that called mmap(MAP_PRIVATE) on hugetlbfs will succeed"),
> avoid_reserve was introduced for a special case of CoW on hugetlb private
> mappings, and only if the owner VMA is trying to allocate yet another
> hugetlb folio that is not reserved within the private vma reserved map.
>
> Later on, in commit d85f69b0b533 ("mm/hugetlb: alloc_huge_page handle areas
> hole punched by fallocate"), alloc_huge_page() enforced to not consume any
> global reservation as long as avoid_reserve=true. This operation doesn't
> look correct, because even if it will enforce the allocation to not use
> global reservation at all, it will still try to take one reservation from
> the spool (if the subpool existed). Then since the spool reserved pages
> take from global reservation, it'll also take one reservation globally.
>
> Logically it can cause global reservation to go wrong.
>
> I wrote a reproducer below
Thank you so much for looking into this!
> <snip>
I was able to reproduce this using your
reproducer. /sys/kernel/mm/hugepages/hugepages-2048kB/resv_hugepages
is not decremented even after the reproducer exits.
# sysctl vm.nr_hugepages=16
vm.nr_hugepages = 16
# mkdir ./hugetlb-pool
# mount -t hugetlbfs -o min_size=8M,pagesize=2M none ./hugetlb-pool
# for i in $(seq 16); do ./a.out hugetlb-pool/test; cat /sys/kernel/mm/hugepages/hugepages-2048kB/resv_hugepages; done
5
6
7
8
9
10
11
12
13
14
15
16
16
16
16
16
#
I'll go over the rest of your patches and dig into the meaning of `avoid_reserve`.
next prev parent reply other threads:[~2024-12-18 14:33 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-01 21:22 [PATCH 0/7] mm/hugetlb: Refactor hugetlb allocation resv accounting Peter Xu
2024-12-01 21:22 ` [PATCH 1/7] mm/hugetlb: Fix avoid_reserve to allow taking folio from subpool Peter Xu
2024-12-18 14:33 ` Ackerley Tng [this message]
2024-12-27 23:15 ` Ackerley Tng
2025-01-03 16:26 ` Peter Xu
2024-12-01 21:22 ` [PATCH 2/7] mm/hugetlb: Stop using avoid_reserve flag in fork() Peter Xu
2024-12-01 21:22 ` [PATCH 3/7] mm/hugetlb: Rename avoid_reserve to cow_from_owner Peter Xu
2024-12-01 21:22 ` [PATCH 4/7] mm/hugetlb: Clean up map/global resv accounting when allocate Peter Xu
2024-12-28 0:06 ` Ackerley Tng
2025-01-03 16:37 ` Peter Xu
2025-01-06 14:48 ` Ackerley Tng
2025-01-06 20:55 ` Peter Xu
2024-12-01 21:22 ` [PATCH 5/7] mm/hugetlb: Simplify vma_has_reserves() Peter Xu
2024-12-01 21:22 ` [PATCH 6/7] mm/hugetlb: Drop vma_has_reserves() Peter Xu
2024-12-01 21:22 ` [PATCH 7/7] mm/hugetlb: Unify restore reserve accounting for new allocations Peter Xu
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=diqzwmfxrrg8.fsf@ackerleytng-ctop.c.googlers.com \
--to=ackerleytng@google.com \
--cc=akpm@linux-foundation.org \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=nao.horiguchi@gmail.com \
--cc=osalvador@suse.de \
--cc=peterx@redhat.com \
--cc=riel@surriel.com \
--cc=roman.gushchin@linux.dev \
--cc=stable@vger.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