| From: Roman Gushchin <roman.gushchin@linux.dev> |
| 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@P9FQF9L96D.corp.robot.car |
| Signed-off-by: Roman Gushchin (Cruise) <roman.gushchin@linux.dev> |
| Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org> |
| Acked-by: Johannes Weiner <hannes@cmpxchg.org> |
| Cc: David Rientjes <rientjes@google.com> |
| Cc: Dennis Zhou <dennis@kernel.org> |
| Cc: Michal Hocko <mhocko@kernel.org> |
| Cc: Muchun Song <muchun.song@linux.dev> |
| Cc: Shakeel Butt <shakeelb@google.com> |
| Cc: Vlastimil Babka <vbabka@suse.cz> |
| Signed-off-by: Andrew Morton <akpm@linux-foundation.org> |
| --- |
| |
| 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); |
| @@ -6596,7 +6604,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 |
| _ |