linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Joshua Hahn <joshua.hahnjy@gmail.com>
To: shakeel.butt@linux.dev
Cc: hannes@cmpxchg.org, mhocko@kernel.org, roman.gushchin@linux.dev,
	muchun.song@linux.dev, akpm@linux-foundation.org,
	cgroups@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, kernel-team@meta.com
Subject: [PATCH 0/2] memcg/hugetlb: Rework memcg hugetlb charging
Date: Wed,  6 Nov 2024 14:14:32 -0800	[thread overview]
Message-ID: <20241106221434.2029328-1-joshua.hahnjy@gmail.com> (raw)

This series cleans up memcg's hugetlb charging logic by deprecating the
current memcg hugetlb try-charge + {commit, cancel} logic present in
alloc_hugetlb_folio. A single function mem_cgroup_charge_hugetlb takes
its place instead. This makes the code more maintainable by simplifying
the error path, and reduces memcg's footprint in hugetlb logic. 

This patch introduces a few changes in the allocation error path:
(a) Instead of having multiple return paths, we consolidate them into
    a single error path. Failing when memcg's limit is reached no longer
    returns -ENOMEM, but -ENOSPEC like the other errors as well. This
    makes the memory controller error behavior the same as hugeTLB's.
    With this said, no callers handle -ENOMEM separately, so no existing
    behavior is affected by this change.
(b) Previously, the memcg limit is checked before the folio is acquired,
    meaning the hugeTLB folio isn't acquired if the limit is reached.
    This patch performs the charging after the folio is reached, meaning
    if memcg's limit is reached, the acquired folio is freed right away. 

In the first patch, a check for whether memcg accounts hugetlb [1] is
introduced. In the second patch, the charging mechanism is reworked.

This patch builds on earlier work [2] which adds memcg hugeTLB counters.
The request for this rework is also part of the original thread.

Suggested-by: Shakeel Butt <shakeel.butt@linux.dev>
Signed-off-by: Joshua Hahn <joshua.hahnjy@gmail.com>

[1] https://lore.kernel.org/all/20231006184629.155543-1-nphamcs@gmail.com/
[2] https://lore.kernel.org/all/20241101204402.1885383-1-joshua.hahnjy@gmail.com/

Joshua Hahn (2):
  Introduce memcg_accounts_hugetlb
  Deprecate hugetlb memcg try-commit-cancel charging

 include/linux/memcontrol.h |  5 ++--
 mm/hugetlb.c               | 35 ++++++++++------------------
 mm/memcontrol.c            | 47 +++++++++++++++-----------------------
 3 files changed, 33 insertions(+), 54 deletions(-)


base-commit: 34d664f9c954f4bce85be506bd81024f64dd5fda
-- 
2.43.5



             reply	other threads:[~2024-11-06 22:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-06 22:14 Joshua Hahn [this message]
2024-11-06 22:14 ` [PATCH 1/2] memcg/hugetlb: Introduce memcg_accounts_hugetlb Joshua Hahn
2024-11-06 23:17   ` Shakeel Butt
2024-11-07  0:21   ` SeongJae Park
2024-11-07 15:07     ` Joshua Hahn
2024-11-06 22:14 ` [PATCH 2/2] memcg/hugetlb: Deprecate hugetlb memcg try-commit-cancel charging Joshua Hahn
2024-11-06 23:50   ` Shakeel Butt
2024-11-07 15:07     ` Joshua Hahn
2024-11-07 18:27     ` Joshua Hahn
2024-11-07 18:58       ` Shakeel Butt
2024-11-07 19:28         ` Joshua Hahn

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=20241106221434.2029328-1-joshua.hahnjy@gmail.com \
    --to=joshua.hahnjy@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeel.butt@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