The patch titled Subject: mm-kmem-add-direct-objcg-pointer-to-task_struct-v4 has been added to the -mm mm-unstable branch. Its filename is mm-kmem-add-direct-objcg-pointer-to-task_struct-v4.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-kmem-add-direct-objcg-pointer-to-task_struct-v4.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Roman Gushchin <roman.gushchin@xxxxxxxxx> Subject: mm-kmem-add-direct-objcg-pointer-to-task_struct-v4 Date: Wed, 18 Oct 2023 11:08:20 -0700 add comment, s/0/CURRENT_OBJCG_UPDATE_BIT/ Link: https://lkml.kernel.org/r/ZTAfFOsvlbqPI0Uk@xxxxxxxxxxxxxxxxxxxxxxxxx Signed-off-by: Roman Gushchin (Cruise) <roman.gushchin@xxxxxxxxx> Tested-by: Naresh Kamboju <naresh.kamboju@xxxxxxxxxx> Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: David Rientjes <rientjes@xxxxxxxxxx> Cc: Dennis Zhou <dennis@xxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxxxx> Cc: Muchun Song <muchun.song@xxxxxxxxx> Cc: Shakeel Butt <shakeelb@xxxxxxxxxx> Cc: Vlastimil Babka <vbabka@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memcontrol.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/mm/memcontrol.c~mm-kmem-add-direct-objcg-pointer-to-task_struct-v4 +++ a/mm/memcontrol.c @@ -249,7 +249,8 @@ struct mem_cgroup *vmpressure_to_memcg(s return container_of(vmpr, struct mem_cgroup, vmpressure); } -#define CURRENT_OBJCG_UPDATE_FLAG 0x1UL +#define CURRENT_OBJCG_UPDATE_BIT 0 +#define CURRENT_OBJCG_UPDATE_FLAG (1UL << CURRENT_OBJCG_UPDATE_BIT) #ifdef CONFIG_MEMCG_KMEM static DEFINE_SPINLOCK(objcg_lock); @@ -3126,6 +3127,13 @@ static struct obj_cgroup *current_objcg_ old = NULL; } + /* + * Release the objcg pointer from the previous iteration, + * if try_cmpxcg() below fails. + */ + if (unlikely(objcg)) + obj_cgroup_put(objcg); + /* Obtain the new objcg pointer. */ rcu_read_lock(); memcg = mem_cgroup_from_task(current); @@ -6598,7 +6606,7 @@ static void mem_cgroup_kmem_attach(struc cgroup_taskset_for_each(task, css, tset) { /* atomically set the update bit */ - set_bit(0, (unsigned long *)&task->objcg); + set_bit(CURRENT_OBJCG_UPDATE_BIT, (unsigned long *)&task->objcg); } } #else _ Patches currently in -mm which might be from roman.gushchin@xxxxxxxxx are mm-kmem-optimize-get_obj_cgroup_from_current.patch mm-kmem-add-direct-objcg-pointer-to-task_struct.patch mm-kmem-add-direct-objcg-pointer-to-task_struct-v4.patch mm-kmem-make-memcg-keep-a-reference-to-the-original-objcg.patch mm-kmem-scoped-objcg-protection.patch percpu-scoped-objcg-protection.patch