diff mbox series

[v14-fix,04/11] mm: multi-gen LRU: fix warning from __rcu

Message ID 20220918204755.3135720-4-yuzhao@google.com (mailing list archive)
State New
Headers show
Series [v14-fix,01/11] mm: multi-gen LRU: update admin guide | expand

Commit Message

Yu Zhao Sept. 18, 2022, 8:47 p.m. UTC
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(-)
diff mbox series

Patch

diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 8086edbdd39b..ac6440daf208 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -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);
 }
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 629518813b59..8291808ec535 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -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;