diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 01:02:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-06 01:02:38 +0000 |
commit | 08b74a000942a380fe028845f92cd3a0dee827d5 (patch) | |
tree | aa78b4e12607c3e1fcce8d5cc42df4330792f118 /debian/patches-rt/0107-sched-Move-mmdrop-to-RCU-on-RT.patch | |
parent | Adding upstream version 4.19.249. (diff) | |
download | linux-f0b728ab30c2182dd64b73ed0c39114124b8488a.tar.xz linux-f0b728ab30c2182dd64b73ed0c39114124b8488a.zip |
Adding debian version 4.19.249-2.debian/4.19.249-2debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/patches-rt/0107-sched-Move-mmdrop-to-RCU-on-RT.patch')
-rw-r--r-- | debian/patches-rt/0107-sched-Move-mmdrop-to-RCU-on-RT.patch | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/debian/patches-rt/0107-sched-Move-mmdrop-to-RCU-on-RT.patch b/debian/patches-rt/0107-sched-Move-mmdrop-to-RCU-on-RT.patch new file mode 100644 index 000000000..9c6b2f686 --- /dev/null +++ b/debian/patches-rt/0107-sched-Move-mmdrop-to-RCU-on-RT.patch @@ -0,0 +1,115 @@ +From 977952ae9f00231e71587f8dc135949a2bed15e2 Mon Sep 17 00:00:00 2001 +From: Thomas Gleixner <tglx@linutronix.de> +Date: Mon, 6 Jun 2011 12:20:33 +0200 +Subject: [PATCH 107/347] sched: Move mmdrop to RCU on RT +Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.19/older/patches-4.19.246-rt110.tar.xz + +Takes sleeping locks and calls into the memory allocator, so nothing +we want to do in task switch and oder atomic contexts. + +Signed-off-by: Thomas Gleixner <tglx@linutronix.de> +--- + include/linux/mm_types.h | 4 ++++ + include/linux/sched/mm.h | 11 +++++++++++ + kernel/fork.c | 13 +++++++++++++ + kernel/sched/core.c | 7 ++++++- + 4 files changed, 34 insertions(+), 1 deletion(-) + +diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h +index 3a9a996af229..202b736ccbfa 100644 +--- a/include/linux/mm_types.h ++++ b/include/linux/mm_types.h +@@ -12,6 +12,7 @@ + #include <linux/completion.h> + #include <linux/cpumask.h> + #include <linux/uprobes.h> ++#include <linux/rcupdate.h> + #include <linux/page-flags-layout.h> + #include <linux/workqueue.h> + +@@ -487,6 +488,9 @@ struct mm_struct { + bool tlb_flush_batched; + #endif + struct uprobes_state uprobes_state; ++#ifdef CONFIG_PREEMPT_RT_BASE ++ struct rcu_head delayed_drop; ++#endif + #ifdef CONFIG_HUGETLB_PAGE + atomic_long_t hugetlb_usage; + #endif +diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h +index ef54f4b3f1e4..88e1a563f762 100644 +--- a/include/linux/sched/mm.h ++++ b/include/linux/sched/mm.h +@@ -49,6 +49,17 @@ static inline void mmdrop(struct mm_struct *mm) + __mmdrop(mm); + } + ++#ifdef CONFIG_PREEMPT_RT_BASE ++extern void __mmdrop_delayed(struct rcu_head *rhp); ++static inline void mmdrop_delayed(struct mm_struct *mm) ++{ ++ if (atomic_dec_and_test(&mm->mm_count)) ++ call_rcu(&mm->delayed_drop, __mmdrop_delayed); ++} ++#else ++# define mmdrop_delayed(mm) mmdrop(mm) ++#endif ++ + void mmdrop(struct mm_struct *mm); + + /* +diff --git a/kernel/fork.c b/kernel/fork.c +index f5a4c42233f0..114ff9724b02 100644 +--- a/kernel/fork.c ++++ b/kernel/fork.c +@@ -642,6 +642,19 @@ void __mmdrop(struct mm_struct *mm) + } + EXPORT_SYMBOL_GPL(__mmdrop); + ++#ifdef CONFIG_PREEMPT_RT_BASE ++/* ++ * RCU callback for delayed mm drop. Not strictly rcu, but we don't ++ * want another facility to make this work. ++ */ ++void __mmdrop_delayed(struct rcu_head *rhp) ++{ ++ struct mm_struct *mm = container_of(rhp, struct mm_struct, delayed_drop); ++ ++ __mmdrop(mm); ++} ++#endif ++ + static void mmdrop_async_fn(struct work_struct *work) + { + struct mm_struct *mm; +diff --git a/kernel/sched/core.c b/kernel/sched/core.c +index 4cc39856c4c6..676b9b213991 100644 +--- a/kernel/sched/core.c ++++ b/kernel/sched/core.c +@@ -2734,9 +2734,13 @@ static struct rq *finish_task_switch(struct task_struct *prev) + * provided by mmdrop(), + * - a sync_core for SYNC_CORE. + */ ++ /* ++ * We use mmdrop_delayed() here so we don't have to do the ++ * full __mmdrop() when we are the last user. ++ */ + if (mm) { + membarrier_mm_sync_core_before_usermode(mm); +- mmdrop(mm); ++ mmdrop_delayed(mm); + } + if (unlikely(prev_state == TASK_DEAD)) { + if (prev->sched_class->task_dead) +@@ -5603,6 +5607,7 @@ void sched_setnuma(struct task_struct *p, int nid) + #endif /* CONFIG_NUMA_BALANCING */ + + #ifdef CONFIG_HOTPLUG_CPU ++ + /* + * Ensure that the idle task is using init_mm right before its CPU goes + * offline. +-- +2.36.1 + |