@@ -6289,7 +6289,7 @@ static void mem_cgroup_attach(struct cgroup_taskset *tset)
return;
task_lock(task);
- if (task->mm && task->mm->owner == task)
+ if (task->mm && READ_ONCE(task->mm->owner) == task)
lru_gen_migrate_mm(task->mm);
task_unlock(task);
}
@@ -3270,15 +3270,17 @@ void lru_gen_del_mm(struct mm_struct *mm)
void lru_gen_migrate_mm(struct mm_struct *mm)
{
struct mem_cgroup *memcg;
+ struct task_struct *task = rcu_dereference_protected(mm->owner, true);
- lockdep_assert_held(&mm->owner->alloc_lock);
+ VM_WARN_ON_ONCE(task->mm != mm);
+ lockdep_assert_held(&task->alloc_lock);
/* for mm_update_next_owner() */
if (mem_cgroup_disabled())
return;
rcu_read_lock();
- memcg = mem_cgroup_from_task(rcu_dereference(mm->owner));
+ memcg = mem_cgroup_from_task(task);
rcu_read_unlock();
if (memcg == mm->lru_gen.memcg)
return;
Link: https://lore.kernel.org/r/CAOUHufY8+O_MwkrPzgfBKSFwLJ1v6LPDox1yGV0tjX4ozjh2Dw@mail.gmail.com/ Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Yu Zhao <yuzhao@google.com> --- mm/memcontrol.c | 2 +- mm/vmscan.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-)