| From: |
| Vlastimil Babka <vbabka-AT-suse.cz> |
| To: |
| Linus Torvalds <torvalds-AT-linux-foundation.org>, Josh Poimboeuf <jpoimboe-AT-kernel.org>, Jeff Layton <jlayton-AT-kernel.org>, Chuck Lever <chuck.lever-AT-oracle.com>, Kees Cook <kees-AT-kernel.org>, Christoph Lameter <cl-AT-linux.com>, Pekka Enberg <penberg-AT-kernel.org>, David Rientjes <rientjes-AT-google.com>, Joonsoo Kim <iamjoonsoo.kim-AT-lge.com>, Andrew Morton <akpm-AT-linux-foundation.org>, Roman Gushchin <roman.gushchin-AT-linux.dev>, Hyeonggon Yoo <42.hyeyoo-AT-gmail.com>, Johannes Weiner <hannes-AT-cmpxchg.org>, Michal Hocko <mhocko-AT-kernel.org>, Shakeel Butt <shakeelb-AT-google.com>, Muchun Song <muchun.song-AT-linux.dev>, Alexander Viro <viro-AT-zeniv.linux.org.uk>, Christian Brauner <brauner-AT-kernel.org>, Jan Kara <jack-AT-suse.cz> |
| Subject: |
| [PATCH RFC 0/4] memcg_kmem hooks refactoring and kmem_cache_charge() |
| Date: |
| Fri, 01 Mar 2024 18:07:07 +0100 |
| Message-ID: |
| <20240301-slab-memcg-v1-0-359328a46596@suse.cz> |
| Cc: |
| linux-mm-AT-kvack.org, linux-kernel-AT-vger.kernel.org, cgroups-AT-vger.kernel.org, linux-fsdevel-AT-vger.kernel.org, Vlastimil Babka <vbabka-AT-suse.cz> |
| Archive-link: |
| Article |
Hi,
I have tried to look into Linus's suggestions to reduce slab memcg
accounting overhead [1] [2].
The reorganized hooks are in Patch 1 and it definitely seems like nice
cleanup on its own.
In Patch 2 I have tried to move them to mm/memcontrol.c to reduce calls
to memcg code. I hoped to see better performance, but probably didn't.
Patch 3 introduces the suggested kmem_cache_charge() API and Patch 4
tries to use it for the testcase in [1] but it's unfinished due to my
lack of VFS knowledge.
I haven't done much benchmarking yet, just in a guest VM on my desktop
for the test case from [1]. Applying patches 1+2 might have improved it
slightly, but could be noise. With 3+4 the memcg overhead is gone as
expected (the charging never happens) but due to the unfinished state I
don't know yet if the separation might hurt cases where the open()
actually succeeds.
Anyway thought I would share already so others can play with it and see
if it's a good direction to pursue (with patches 3+4). I think Patch 1
should be good to apply in any case (after more testing, and review),
not yet sure about Patch 2.
[1] https://lore.kernel.org/all/CAHk-=whYOOdM7jWy5jdrAm8LxcgC...
[2] https://lore.kernel.org/all/CAHk-=whw936qzDLBQdUz-He5WK_0...
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
---
Vlastimil Babka (4):
mm, slab: move memcg charging to post-alloc hook
mm, slab: move slab_memcg hooks to mm/memcontrol.c
mm, slab: introduce kmem_cache_charge()
UNFINISHED mm, fs: use kmem_cache_charge() in path_openat()
fs/file_table.c | 9 +-
fs/internal.h | 1 +
fs/namei.c | 4 +-
include/linux/slab.h | 10 +++
mm/memcontrol.c | 90 ++++++++++++++++++++
mm/slab.h | 10 +++
mm/slub.c | 231 +++++++++++++++------------------------------------
7 files changed, 188 insertions(+), 167 deletions(-)
---
base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d
change-id: 20240229-slab-memcg-ae6b3789c924
Best regards,
--
Vlastimil Babka <vbabka@suse.cz>