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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Link: https://lore.kernel.org/r/CAOUHufY8+O_MwkrPzgfBKSFwLJ1v6LPDox1yGV0tjX4ozjh2Dw@xxxxxxxxxxxxxx/
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Signed-off-by: Yu Zhao <yuzhao@xxxxxxxxxx>
---
 mm/memcontrol.c | 2 +-
 mm/vmscan.c     | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

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;
-- 
2.37.3.968.ga6b4b080e4-goog





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux