kernel: Update MGLRU patchset
[openwrt/staging/dedeckeh.git] / target / linux / generic / backport-5.15 / 020-v6.1-15-mm-multi-gen-LRU-move-lru_gen_add_mm-out-of-IRQ-off-.patch
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 diff --git a/fs/exec.c b/fs/exec.c
33 index 1afa15a07d26..718c58947be1 100644
34 --- a/fs/exec.c
35 +++ b/fs/exec.c
36 @@ -1013,7 +1013,6 @@ static int exec_mmap(struct mm_struct *mm)
37 active_mm = tsk->active_mm;
38 tsk->active_mm = mm;
39 tsk->mm = mm;
40 - lru_gen_add_mm(mm);
41 /*
42 * This prevents preemption while active_mm is being loaded and
43 * it and mm are being updated, which could cause problems for
44 @@ -1028,6 +1027,7 @@ static int exec_mmap(struct mm_struct *mm)
45 local_irq_enable();
46 tsk->mm->vmacache_seqnum = 0;
47 vmacache_flush(tsk);
48 + lru_gen_add_mm(mm);
49 task_unlock(tsk);
50 lru_gen_use_mm(mm);
51 if (old_mm) {
52 --
53 2.40.0
54