5b1d378504a8002f3cc881a8f1a366b4dd281f06
[openwrt/staging/stintel.git] /
1 From 255bb0ac393f1c2818cd75af45a9226300ab3daf Mon Sep 17 00:00:00 2001
2 From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
3 Date: Wed, 26 Oct 2022 15:48:30 +0200
4 Subject: [PATCH 15/29] mm: multi-gen LRU: move lru_gen_add_mm() out of IRQ-off
5 region
6
7 lru_gen_add_mm() has been added within an IRQ-off region in the commit
8 mentioned below. The other invocations of lru_gen_add_mm() are not within
9 an IRQ-off region.
10
11 The invocation within IRQ-off region is problematic on PREEMPT_RT because
12 the function is using a spin_lock_t which must not be used within
13 IRQ-disabled regions.
14
15 The other invocations of lru_gen_add_mm() occur while
16 task_struct::alloc_lock is acquired. Move lru_gen_add_mm() after
17 interrupts are enabled and before task_unlock().
18
19 Link: https://lkml.kernel.org/r/20221026134830.711887-1-bigeasy@linutronix.de
20 Fixes: bd74fdaea1460 ("mm: multi-gen LRU: support page table walks")
21 Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
22 Acked-by: Yu Zhao <yuzhao@google.com>
23 Cc: Al Viro <viro@zeniv.linux.org.uk>
24 Cc: "Eric W . Biederman" <ebiederm@xmission.com>
25 Cc: Kees Cook <keescook@chromium.org>
26 Cc: Thomas Gleixner <tglx@linutronix.de>
27 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
28 ---
29 fs/exec.c | 2 +-
30 1 file changed, 1 insertion(+), 1 deletion(-)
31
32 --- a/fs/exec.c
33 +++ b/fs/exec.c
34 @@ -1013,7 +1013,6 @@ static int exec_mmap(struct mm_struct *m
35 active_mm = tsk->active_mm;
36 tsk->active_mm = mm;
37 tsk->mm = mm;
38 - lru_gen_add_mm(mm);
39 /*
40 * This prevents preemption while active_mm is being loaded and
41 * it and mm are being updated, which could cause problems for
42 @@ -1028,6 +1027,7 @@ static int exec_mmap(struct mm_struct *m
43 local_irq_enable();
44 tsk->mm->vmacache_seqnum = 0;
45 vmacache_flush(tsk);
46 + lru_gen_add_mm(mm);
47 task_unlock(tsk);
48 lru_gen_use_mm(mm);
49 if (old_mm) {