From da7988723345ed5081ee978a740965dc6f87bada Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Wed, 26 Oct 2022 15:48:30 +0200 Subject: [PATCH] BACKPORT: mm: multi-gen LRU: move lru_gen_add_mm() out of IRQ-off region lru_gen_add_mm() has been added within an IRQ-off region in the commit mentioned below. The other invocations of lru_gen_add_mm() are not within an IRQ-off region. The invocation within IRQ-off region is problematic on PREEMPT_RT because the function is using a spin_lock_t which must not be used within IRQ-disabled regions. The other invocations of lru_gen_add_mm() occur while task_struct::alloc_lock is acquired. Move lru_gen_add_mm() after interrupts are enabled and before task_unlock(). Bug: 254441685 Link: https://lkml.kernel.org/r/20221026134830.711887-1-bigeasy@linutronix.de Fixes: bd74fdaea1460 ("mm: multi-gen LRU: support page table walks") Signed-off-by: Sebastian Andrzej Siewior Acked-by: Yu Zhao Cc: Al Viro Cc: "Eric W . Biederman" Cc: Kees Cook Cc: Thomas Gleixner Signed-off-by: Andrew Morton (cherry picked from commit dda1c41a07b4a4c3f99b5b28c1e8c485205fe860) Signed-off-by: Lee Jones Change-Id: I0ab2d5811f6c8df16a4deb58ab6aa9717eac565f [backport of the commit ad8cc978ccc17a0fd1149ebd76407b629907a727 from android13-5.15 branch] Signed-off-by: Marek Szyprowski --- fs/exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/exec.c b/fs/exec.c index 9536a61..c11f1fe 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1036,9 +1036,9 @@ static int exec_mmap(struct mm_struct *mm) membarrier_exec_mmap(mm); tsk->mm = mm; tsk->active_mm = mm; - lru_gen_add_mm(mm); activate_mm(active_mm, mm); tsk->mm->vmacache_seqnum = 0; + lru_gen_add_mm(mm); vmacache_flush(tsk); task_unlock(tsk); lru_gen_use_mm(mm); -- 2.7.4