diff options
| author | Vlastimil Babka <[email protected]> | 2024-03-26 10:37:38 +0000 |
|---|---|---|
| committer | Andrew Morton <[email protected]> | 2024-04-26 03:56:16 +0000 |
| commit | 9f9796b413d3c417f34cae427c4e47bfdd3a7454 (patch) | |
| tree | c705ec6cc394266ee70bd4b2923dd13e760b87ea /mm/sparse.c | |
| parent | proc: rewrite stable_page_flags() (diff) | |
| download | kernel-9f9796b413d3c417f34cae427c4e47bfdd3a7454.tar.gz kernel-9f9796b413d3c417f34cae427c4e47bfdd3a7454.zip | |
mm, slab: move memcg charging to post-alloc hook
Patch series "memcg_kmem hooks refactoring", v3.
This patch (of 2):
The MEMCG_KMEM integration with slab currently relies on two hooks during
allocation. memcg_slab_pre_alloc_hook() determines the objcg and charges
it, and memcg_slab_post_alloc_hook() assigns the objcg pointer to the
allocated object(s).
As Linus pointed out, this is unnecessarily complex. Failing to charge
due to memcg limits should be rare, so we can optimistically allocate the
object(s) and do the charging together with assigning the objcg pointer in
a single post_alloc hook. In the rare case the charging fails, we can
free the object(s) back.
This simplifies the code (no need to pass around the objcg pointer) and
potentially allows to separate charging from allocation in cases where
it's common that the allocation would be immediately freed, and the memcg
handling overhead could be saved.
[[email protected]: fix call to memcg_alloc_abort_single()]
Link: https://lkml.kernel.org/r/[email protected]
[[email protected]: comment fixup]
Link: https://lkml.kernel.org/r/[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Vlastimil Babka <[email protected]>
Signed-off-by: Roman Gushchin <[email protected]>
Suggested-by: Linus Torvalds <[email protected]>
Link: https://lore.kernel.org/all/CAHk-=whYOOdM7jWy5jdrAm8LxcgCMFyk2bt8fYYvZzM4U-zAQA@mail.gmail.com/
Reviewed-by: Roman Gushchin <[email protected]>
Reviewed-by: Chengming Zhou <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Christian Brauner <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: Chuck Lever <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Hyeonggon Yoo <[email protected]>
Cc: Jan Kara <[email protected]>
Cc: Jeff Layton <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Cc: Josh Poimboeuf <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Muchun Song <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Shakeel Butt <[email protected]>
Cc: Aishwarya TCV <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Diffstat (limited to 'mm/sparse.c')
0 files changed, 0 insertions, 0 deletions
