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,
muchun.song@linux.dev, osalvador@suse.de,
roman.gushchin@linux.dev, nao.horiguchi@gmail.com
Subject: Re: [PATCH 4/7] mm/hugetlb: Clean up map/global resv accounting when allocate
Date: Mon, 06 Jan 2025 14:48:12 +0000 [thread overview]
Message-ID: <diqz7c78rob7.fsf@ackerleytng-ctop.c.googlers.com> (raw)
In-Reply-To: <Z3gSXYQaDhcCOIcJ@x1n> (message from Peter Xu on Fri, 3 Jan 2025 11:37:49 -0500)
Peter Xu <peterx@redhat.com> writes:
> On Sat, Dec 28, 2024 at 12:06:34AM +0000, Ackerley Tng wrote:
>> >
>> > - /* If this allocation is not consuming a reservation, charge it now.
>> > + /*
>> > + * If this allocation is not consuming a per-vma reservation,
>> > + * charge the hugetlb cgroup now.
>> > */
>> > - deferred_reserve = map_chg || cow_from_owner;
>> > - if (deferred_reserve) {
>> > + if (map_chg) {
>> > ret = hugetlb_cgroup_charge_cgroup_rsvd(
>> > idx, pages_per_huge_page(h), &h_cg);
>>
>> Should hugetlb_cgroup_charge_cgroup_rsvd() be called when map_chg == MAP_CHG_ENFORCED?
>
> This looks like a pretty niche use case, though I would say yes.
>
> I don't think I take a lot of consideration here when drafting the patch,
> as the change here should have kept the old behavior: map_chg grows into
> the tristate so that we can drop deferred_reserve, OTOH nothing should
> change from such behavior of cgroup charging.
>
> When it happens, it means the owner process CoWed a private hugetlb folio
> which will enforce bypassing the vma reservation. Here bypassing the vma
> check makes sense to me, because the new to-be-cowed folio X will replace
> another folio Y, which should have consumed the private vma resv at this
> specific index. So there's no way the to-be-cowed folio X can have anything
> to do with the vma reservation..
>
> Besides the vma reservation, I don't see why this folio allocation needs to
> be any more special. IOW, it should still go through all rest checks and
> fail the process properly if the check fails, that should include any form
> of cgroups (either hugetlb or memcg), IMHO.
>
> Do you have any specific thought on this path?
I re-read the code, and I hope this understanding is right:
When a user sets "rsvd.max_usage_in_bytes" to X, the user is saying that
within this cgroup, the maximum memory that can be reserved in the vma
reservation is X.
Hence even when this CoW is performed, this should count towards the
cgroup's "rsvd.max_usage_in_bytes" and so yes, it should be charged.
I think I misunderstood the context on cgroup charging earlier and hence
I thought it shouldn't be charged, but I agree with you after
re-reading.
>
> Thanks,
next prev parent reply other threads:[~2025-01-06 14:48 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
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 [this message]
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=diqz7c78rob7.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 \
/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