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-next>] [day] [month] [year] [list]
Message-ID: <20241106221434.2029328-1-joshua.hahnjy@gmail.com>
Date: Wed,  6 Nov 2024 14:14:32 -0800
From: Joshua Hahn <joshua.hahnjy@...il.com>
To: shakeel.butt@...ux.dev
Cc: hannes@...xchg.org,
	mhocko@...nel.org,
	roman.gushchin@...ux.dev,
	muchun.song@...ux.dev,
	akpm@...ux-foundation.org,
	cgroups@...r.kernel.org,
	linux-mm@...ck.org,
	linux-kernel@...r.kernel.org,
	kernel-team@...a.com
Subject: [PATCH 0/2] memcg/hugetlb: Rework memcg hugetlb charging

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@...ux.dev>
Signed-off-by: Joshua Hahn <joshua.hahnjy@...il.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ