[ANNOUNCE] v5.2.21-rt15
Dear RT folks!
I'm pleased to announce the v5.2.21-rt15 patch set.
Changes since v5.2.21-rt14:
- Since the migrate_disable() rework, the kernel did not build on UP
or without RT enabled. Patch by Daniel Wagner.
- Since the migrate_disable() rework, with heave changing of the
task's affinity mask the kernel could issue a warning in
migrate_enable() and crash later.
Known issues
- None
The delta patch against v5.2.21-rt14 is appended below and can be found here:
https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.2/incr/patch-5.2.21-rt14-rt15.patch.xz
You can get this release via the git tree at:
git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git v5.2.21-rt15
The RT patch against v5.2.21 can be found here:
https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patch-5.2.21-rt15.patch.xz
The split quilt queue is available at:
https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.2/older/patches-5.2.21-rt15.tar.xz
Sebastian
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
diff --git a/patches/0011-printk_safe-remove-printk-safe-code.patch b/patches/0011-printk_safe-remove-printk-safe-code.patch
index 02ed10d..baedc97 100644
--- a/patches/0011-printk_safe-remove-printk-safe-code.patch
+++ b/patches/0011-printk_safe-remove-printk-safe-code.patch
@@ -130,7 +130,7 @@
call_function_init();
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
-@@ -970,7 +970,6 @@ void crash_kexec(struct pt_regs *regs)
+@@ -972,7 +972,6 @@ void crash_kexec(struct pt_regs *regs)
old_cpu = atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, this_cpu);
if (old_cpu == PANIC_CPU_INVALID) {
/* This is the 1st CPU which comes here, so go ahead. */
diff --git a/patches/arm-disable-NEON-in-kernel-mode.patch b/patches/arm-disable-NEON-in-kernel-mode.patch
index f2d3e50..e0354b8 100644
--- a/patches/arm-disable-NEON-in-kernel-mode.patch
+++ b/patches/arm-disable-NEON-in-kernel-mode.patch
@@ -19,7 +19,7 @@
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
-@@ -2135,7 +2135,7 @@ config NEON
+@@ -2136,7 +2136,7 @@ config NEON
config KERNEL_MODE_NEON
bool "Support for NEON in kernel mode"
diff --git a/patches/lib-smp_processor_id-Adjust-check_preemption_disable.patch b/patches/lib-smp_processor_id-Adjust-check_preemption_disable.patch
new file mode 100644
index 0000000..c9c5761
--- /dev/null
+++ b/patches/lib-smp_processor_id-Adjust-check_preemption_disable.patch
@@ -0,0 +1,30 @@
+From: Daniel Wagner <dwagner@suse.de>
+Date: Mon, 16 Dec 2019 16:15:57 +0100
+Subject: [PATCH] lib/smp_processor_id: Adjust check_preemption_disabled()
+
+The current->migrate_disable counter is not always defined leading to
+build failures with DEBUG_PREEMPT && !PREEMPT_RT_BASE.
+
+Restrict the access to ->migrate_disable to same set where
+->migrate_disable is modified.
+
+Signed-off-by: Daniel Wagner <dwagner@suse.de>
+[bigeasy: adjust condition + description]
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ lib/smp_processor_id.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/lib/smp_processor_id.c
++++ b/lib/smp_processor_id.c
+@@ -23,8 +23,10 @@ unsigned int check_preemption_disabled(c
+ * Kernel threads bound to a single CPU can safely use
+ * smp_processor_id():
+ */
++#if defined(CONFIG_PREEMPT_RT_BASE) && (defined(CONFIG_SMP) || defined(CONFIG_SCHED_DEBUG))
+ if (current->migrate_disable)
+ goto out;
++#endif
+
+ if (current->nr_cpus_allowed == 1)
+ goto out;
diff --git a/patches/localversion.patch b/patches/localversion.patch
index e1f3b8d..340816c 100644
--- a/patches/localversion.patch
+++ b/patches/localversion.patch
@@ -10,4 +10,4 @@
--- /dev/null
+++ b/localversion-rt
@@ -0,0 +1 @@
-+-rt14
++-rt15
diff --git a/patches/locking-Make-spinlock_t-and-rwlock_t-a-RCU-section-o.patch b/patches/locking-Make-spinlock_t-and-rwlock_t-a-RCU-section-o.patch
index 901a79a..5e03f5b 100644
--- a/patches/locking-Make-spinlock_t-and-rwlock_t-a-RCU-section-o.patch
+++ b/patches/locking-Make-spinlock_t-and-rwlock_t-a-RCU-section-o.patch
@@ -10,15 +10,13 @@
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
- kernel/locking/rtmutex.c | 6 ++++++
- kernel/locking/rwlock-rt.c | 6 ++++++
+ kernel/locking/rtmutex.c | 6 ++++++
+ kernel/locking/rwlock-rt.c | 6 ++++++
2 files changed, 12 insertions(+)
-diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
-index cf09f8e7ed0f4..602eb7821a1b1 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
-@@ -1141,6 +1141,7 @@ void __sched rt_spin_lock_slowunlock(struct rt_mutex *lock)
+@@ -1143,6 +1143,7 @@ void __sched rt_spin_lock_slowunlock(str
void __lockfunc rt_spin_lock(spinlock_t *lock)
{
sleeping_lock_inc();
@@ -26,7 +24,7 @@
migrate_disable();
spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
rt_spin_lock_fastlock(&lock->lock, rt_spin_lock_slowlock);
-@@ -1156,6 +1157,7 @@ void __lockfunc __rt_spin_lock(struct rt_mutex *lock)
+@@ -1158,6 +1159,7 @@ void __lockfunc __rt_spin_lock(struct rt
void __lockfunc rt_spin_lock_nested(spinlock_t *lock, int subclass)
{
sleeping_lock_inc();
@@ -34,7 +32,7 @@
migrate_disable();
spin_acquire(&lock->dep_map, subclass, 0, _RET_IP_);
rt_spin_lock_fastlock(&lock->lock, rt_spin_lock_slowlock);
-@@ -1169,6 +1171,7 @@ void __lockfunc rt_spin_unlock(spinlock_t *lock)
+@@ -1171,6 +1173,7 @@ void __lockfunc rt_spin_unlock(spinlock_
spin_release(&lock->dep_map, 1, _RET_IP_);
rt_spin_lock_fastunlock(&lock->lock, rt_spin_lock_slowunlock);
migrate_enable();
@@ -42,7 +40,7 @@
sleeping_lock_dec();
}
EXPORT_SYMBOL(rt_spin_unlock);
-@@ -1200,6 +1203,7 @@ int __lockfunc rt_spin_trylock(spinlock_t *lock)
+@@ -1202,6 +1205,7 @@ int __lockfunc rt_spin_trylock(spinlock_
ret = __rt_mutex_trylock(&lock->lock);
if (ret) {
spin_acquire(&lock->dep_map, 0, 1, _RET_IP_);
@@ -50,7 +48,7 @@
} else {
migrate_enable();
sleeping_lock_dec();
-@@ -1216,6 +1220,7 @@ int __lockfunc rt_spin_trylock_bh(spinlock_t *lock)
+@@ -1218,6 +1222,7 @@ int __lockfunc rt_spin_trylock_bh(spinlo
ret = __rt_mutex_trylock(&lock->lock);
if (ret) {
sleeping_lock_inc();
@@ -58,7 +56,7 @@
migrate_disable();
spin_acquire(&lock->dep_map, 0, 1, _RET_IP_);
} else
-@@ -1232,6 +1237,7 @@ int __lockfunc rt_spin_trylock_irqsave(spinlock_t *lock, unsigned long *flags)
+@@ -1234,6 +1239,7 @@ int __lockfunc rt_spin_trylock_irqsave(s
ret = __rt_mutex_trylock(&lock->lock);
if (ret) {
sleeping_lock_inc();
@@ -66,11 +64,9 @@
migrate_disable();
spin_acquire(&lock->dep_map, 0, 1, _RET_IP_);
}
-diff --git a/kernel/locking/rwlock-rt.c b/kernel/locking/rwlock-rt.c
-index c3b91205161cc..0ae8c62ea8320 100644
--- a/kernel/locking/rwlock-rt.c
+++ b/kernel/locking/rwlock-rt.c
-@@ -310,6 +310,7 @@ int __lockfunc rt_read_trylock(rwlock_t *rwlock)
+@@ -310,6 +310,7 @@ int __lockfunc rt_read_trylock(rwlock_t
ret = do_read_rt_trylock(rwlock);
if (ret) {
rwlock_acquire_read(&rwlock->dep_map, 0, 1, _RET_IP_);
@@ -78,7 +74,7 @@
} else {
migrate_enable();
sleeping_lock_dec();
-@@ -327,6 +328,7 @@ int __lockfunc rt_write_trylock(rwlock_t *rwlock)
+@@ -327,6 +328,7 @@ int __lockfunc rt_write_trylock(rwlock_t
ret = do_write_rt_trylock(rwlock);
if (ret) {
rwlock_acquire(&rwlock->dep_map, 0, 1, _RET_IP_);
@@ -102,7 +98,7 @@
migrate_disable();
rwlock_acquire(&rwlock->dep_map, 0, 0, _RET_IP_);
do_write_rt_lock(rwlock);
-@@ -358,6 +362,7 @@ void __lockfunc rt_read_unlock(rwlock_t *rwlock)
+@@ -358,6 +362,7 @@ void __lockfunc rt_read_unlock(rwlock_t
rwlock_release(&rwlock->dep_map, 1, _RET_IP_);
do_read_rt_unlock(rwlock);
migrate_enable();
@@ -110,7 +106,7 @@
sleeping_lock_dec();
}
EXPORT_SYMBOL(rt_read_unlock);
-@@ -367,6 +372,7 @@ void __lockfunc rt_write_unlock(rwlock_t *rwlock)
+@@ -367,6 +372,7 @@ void __lockfunc rt_write_unlock(rwlock_t
rwlock_release(&rwlock->dep_map, 1, _RET_IP_);
do_write_rt_unlock(rwlock);
migrate_enable();
@@ -118,6 +114,3 @@
sleeping_lock_dec();
}
EXPORT_SYMBOL(rt_write_unlock);
---
-2.24.0
-
diff --git a/patches/powerpc-Fixup-compile-and-lazy-preempt.patch b/patches/powerpc-Fixup-compile-and-lazy-preempt.patch
index 29c4988..4465a656 100644
--- a/patches/powerpc-Fixup-compile-and-lazy-preempt.patch
+++ b/patches/powerpc-Fixup-compile-and-lazy-preempt.patch
@@ -1,4 +1,3 @@
-From 722fba3af8da86eb5ccc78fde3a82f2ff42e120f Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date: Tue, 3 Dec 2019 18:06:20 +0100
Subject: [PATCH] powerpc: Fixup compile and lazy-preempt
@@ -12,15 +11,13 @@
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
- arch/powerpc/kernel/entry_32.S | 4 ++--
- include/linux/preempt.h | 4 ++--
+ arch/powerpc/kernel/entry_32.S | 4 ++--
+ include/linux/preempt.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
-diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
-index d37b373104502..004944258387b 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
-@@ -893,10 +893,10 @@ user_exc_return: /* r10 contains MSR_KERNEL here */
+@@ -893,10 +893,10 @@ user_exc_return: /* r10 contains MSR_KE
bne restore_kuap
andi. r8,r8,_TIF_NEED_RESCHED
bne+ 1f
@@ -33,8 +30,6 @@
andi. r0,r0,_TIF_NEED_RESCHED_LAZY
beq+ restore_kuap
1:
-diff --git a/include/linux/preempt.h b/include/linux/preempt.h
-index d559e3a0379c2..7653dd58b4b21 100644
--- a/include/linux/preempt.h
+++ b/include/linux/preempt.h
@@ -100,9 +100,9 @@
@@ -49,6 +44,3 @@
#else
---
-2.24.0
-
diff --git a/patches/printk-hack-out-emergency-loglevel-usage.patch b/patches/printk-hack-out-emergency-loglevel-usage.patch
index 1ba92e2..3ca7bc8f 100644
--- a/patches/printk-hack-out-emergency-loglevel-usage.patch
+++ b/patches/printk-hack-out-emergency-loglevel-usage.patch
@@ -10,14 +10,12 @@
Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
- kernel/printk/printk.c | 13 +++----------
+ kernel/printk/printk.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
-diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
-index 9d9523431..2b4616fd4 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
-@@ -1767,15 +1767,8 @@ static void call_console_drivers(u64 seq, const char *ext_text, size_t ext_len,
+@@ -1767,15 +1767,8 @@ static void call_console_drivers(u64 seq
con->wrote_history = 1;
con->printk_seq = seq - 1;
}
@@ -34,7 +32,7 @@
if (con->printk_seq < seq)
con->printk_seq = seq;
continue;
-@@ -3161,7 +3154,7 @@ static bool console_can_emergency(int level)
+@@ -3161,7 +3154,7 @@ static bool console_can_emergency(int le
for_each_console(con) {
if (!(con->flags & CON_ENABLED))
continue;
@@ -43,7 +41,7 @@
return true;
if (con->write && (con->flags & CON_BOOT))
return true;
-@@ -3177,7 +3170,7 @@ static void call_emergency_console_drivers(int level, const char *text,
+@@ -3177,7 +3170,7 @@ static void call_emergency_console_drive
for_each_console(con) {
if (!(con->flags & CON_ENABLED))
continue;
@@ -52,6 +50,3 @@
con->write_atomic(con, text, text_len);
continue;
}
---
-2.19.0
-
diff --git a/patches/sched-Lazy-migrate_disable-processing.patch b/patches/sched-Lazy-migrate_disable-processing.patch
index 49b44a8..a0f2812 100644
--- a/patches/sched-Lazy-migrate_disable-processing.patch
+++ b/patches/sched-Lazy-migrate_disable-processing.patch
@@ -30,17 +30,15 @@
Signed-off-by: Scott Wood <swood@redhat.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
- include/linux/cpu.h | 4 -
- include/linux/sched.h | 11 +--
- init/init_task.c | 4 +
- kernel/cpu.c | 103 +++++++++--------------
- kernel/sched/core.c | 180 +++++++++++++++++------------------------
- kernel/sched/sched.h | 4 +
- lib/smp_processor_id.c | 3 +
+ include/linux/cpu.h | 4 -
+ include/linux/sched.h | 11 +-
+ init/init_task.c | 4 +
+ kernel/cpu.c | 103 ++++++++++------------------
+ kernel/sched/core.c | 180 +++++++++++++++++++------------------------------
+ kernel/sched/sched.h | 4 +
+ lib/smp_processor_id.c | 3
7 files changed, 128 insertions(+), 181 deletions(-)
-diff --git a/include/linux/cpu.h b/include/linux/cpu.h
-index f4a772c12d140..2df500fdcbc44 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -113,8 +113,6 @@ extern void cpu_hotplug_disable(void);
@@ -52,7 +50,7 @@
#else /* CONFIG_HOTPLUG_CPU */
-@@ -126,8 +124,6 @@ static inline int cpus_read_trylock(void) { return true; }
+@@ -126,8 +124,6 @@ static inline int cpus_read_trylock(voi
static inline void lockdep_assert_cpus_held(void) { }
static inline void cpu_hotplug_disable(void) { }
static inline void cpu_hotplug_enable(void) { }
@@ -61,11 +59,9 @@
#endif /* !CONFIG_HOTPLUG_CPU */
-diff --git a/include/linux/sched.h b/include/linux/sched.h
-index 7e892e727f126..c6872b38bf770 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
-@@ -229,6 +229,8 @@ extern void io_schedule_finish(int token);
+@@ -229,6 +229,8 @@ extern void io_schedule_finish(int token
extern long io_schedule_timeout(long timeout);
extern void io_schedule(void);
@@ -93,15 +89,13 @@
# endif
#endif
#ifdef CONFIG_PREEMPT_RT_FULL
-@@ -2074,4 +2073,6 @@ static inline void rseq_syscall(struct pt_regs *regs)
+@@ -2072,4 +2071,6 @@ static inline void rseq_syscall(struct p
#endif
+extern struct task_struct *takedown_cpu_task;
+
#endif
-diff --git a/init/init_task.c b/init/init_task.c
-index e402413dc47d5..c0c7618fd2fb9 100644
--- a/init/init_task.c
+++ b/init/init_task.c
@@ -81,6 +81,10 @@ struct task_struct init_task
@@ -115,11 +109,9 @@
.mm = NULL,
.active_mm = &init_mm,
.restart_block = {
-diff --git a/kernel/cpu.c b/kernel/cpu.c
-index 25afa2bb1a2cf..e1bf3c698a321 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
-@@ -76,11 +76,6 @@ static DEFINE_PER_CPU(struct cpuhp_cpu_state, cpuhp_state) = {
+@@ -76,11 +76,6 @@ static DEFINE_PER_CPU(struct cpuhp_cpu_s
.fail = CPUHP_INVALID,
};
@@ -219,7 +211,7 @@
struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu);
int err;
-@@ -941,17 +893,38 @@ static int takedown_cpu(unsigned int cpu)
+@@ -941,17 +893,38 @@ static int takedown_cpu(unsigned int cpu
*/
irq_lock_sparse();
@@ -262,7 +254,7 @@
#endif
/* CPU refused to die */
irq_unlock_sparse();
-@@ -971,8 +944,8 @@ static int takedown_cpu(unsigned int cpu)
+@@ -971,8 +944,8 @@ static int takedown_cpu(unsigned int cpu
wait_for_ap_thread(st, false);
BUG_ON(st->state != CPUHP_AP_IDLE_DEAD);
@@ -273,11 +265,9 @@
#endif
/* Interrupts are moved away from the dying cpu, reenable alloc/free */
irq_unlock_sparse();
-diff --git a/kernel/sched/core.c b/kernel/sched/core.c
-index bfd160e90797a..5cb2a519b8bf2 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
-@@ -1126,7 +1126,8 @@ static int migration_cpu_stop(void *data)
+@@ -1126,7 +1126,8 @@ static int migration_cpu_stop(void *data
void set_cpus_allowed_common(struct task_struct *p, const struct cpumask *new_mask)
{
cpumask_copy(&p->cpus_mask, new_mask);
@@ -287,7 +277,7 @@
}
#if defined(CONFIG_SMP) && defined(CONFIG_PREEMPT_RT_BASE)
-@@ -1137,8 +1138,7 @@ int __migrate_disabled(struct task_struct *p)
+@@ -1137,8 +1138,7 @@ int __migrate_disabled(struct task_struc
EXPORT_SYMBOL_GPL(__migrate_disabled);
#endif
@@ -297,7 +287,7 @@
{
struct rq *rq = task_rq(p);
bool queued, running;
-@@ -1167,20 +1167,6 @@ static void __do_set_cpus_allowed_tail(struct task_struct *p,
+@@ -1167,20 +1167,6 @@ static void __do_set_cpus_allowed_tail(s
set_curr_task(rq, p);
}
@@ -318,7 +308,7 @@
/*
* Change a given task's CPU affinity. Migrate the thread to a
* proper CPU and schedule it away if the CPU it's executing on
-@@ -1239,7 +1225,8 @@ static int __set_cpus_allowed_ptr(struct task_struct *p,
+@@ -1239,7 +1225,8 @@ static int __set_cpus_allowed_ptr(struct
}
/* Can the task run on the task's current CPU? If so, we're done */
@@ -328,7 +318,7 @@
goto out;
dest_cpu = cpumask_any_and(cpu_valid_mask, new_mask);
-@@ -3502,6 +3489,8 @@ pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
+@@ -3502,6 +3489,8 @@ pick_next_task(struct rq *rq, struct tas
BUG();
}
@@ -337,7 +327,7 @@
/*
* __schedule() is the main scheduler function.
*
-@@ -3572,6 +3561,9 @@ static void __sched notrace __schedule(bool preempt)
+@@ -3572,6 +3561,9 @@ static void __sched notrace __schedule(b
rq_lock(rq, &rf);
smp_mb__after_spinlock();
@@ -347,7 +337,7 @@
/* Promote REQ to ACT */
rq->clock_update_flags <<= 1;
update_rq_clock(rq);
-@@ -5822,6 +5814,8 @@ static void migrate_tasks(struct rq *dead_rq, struct rq_flags *rf)
+@@ -5822,6 +5814,8 @@ static void migrate_tasks(struct rq *dea
BUG_ON(!next);
put_prev_task(rq, next);
@@ -356,7 +346,7 @@
/*
* Rules for changing task_struct::cpus_mask are holding
* both pi_lock and rq->lock, such that holding either
-@@ -7317,14 +7311,9 @@ update_nr_migratory(struct task_struct *p, long delta)
+@@ -7317,14 +7311,9 @@ update_nr_migratory(struct task_struct *
static inline void
migrate_disable_update_cpus_allowed(struct task_struct *p)
{
@@ -371,7 +361,7 @@
}
static inline void
-@@ -7342,54 +7331,35 @@ migrate_enable_update_cpus_allowed(struct task_struct *p)
+@@ -7342,54 +7331,35 @@ migrate_enable_update_cpus_allowed(struc
void migrate_disable(void)
{
@@ -388,12 +378,12 @@
+ current->pinned_on_cpu = smp_processor_id();
#endif
- return;
-- }
+ }
-#ifdef CONFIG_SCHED_DEBUG
- if (unlikely(p->migrate_disable_atomic)) {
- tracing_off();
- WARN_ON_ONCE(1);
- }
+- }
-#endif
- if (p->migrate_disable) {
@@ -482,9 +472,7 @@
task_rq_unlock(rq, p, &rf);
- p->migrate_disable_update = 0;
-+ preempt_lazy_enable();
-+ preempt_enable();
-
+-
- WARN_ON(smp_processor_id() != cpu);
- if (!cpumask_test_cpu(cpu, &p->cpus_mask)) {
- struct migration_arg arg = { p };
@@ -494,7 +482,9 @@
- update_rq_clock(rq);
- arg.dest_cpu = select_fallback_rq(cpu, p);
- task_rq_unlock(rq, p, &rf);
--
++ preempt_lazy_enable();
++ preempt_enable();
+
- unpin_current_cpu();
- preempt_lazy_enable();
- preempt_enable();
@@ -574,8 +564,6 @@
+{
+}
#endif
-diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
-index 9c1bbd67e9711..2e4db417049dd 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -952,6 +952,10 @@ struct rq {
@@ -589,11 +577,9 @@
};
#ifdef CONFIG_FAIR_GROUP_SCHED
-diff --git a/lib/smp_processor_id.c b/lib/smp_processor_id.c
-index bd95716532889..5f2618d346c42 100644
--- a/lib/smp_processor_id.c
+++ b/lib/smp_processor_id.c
-@@ -23,6 +23,9 @@ unsigned int check_preemption_disabled(const char *what1, const char *what2)
+@@ -23,6 +23,9 @@ unsigned int check_preemption_disabled(c
* Kernel threads bound to a single CPU can safely use
* smp_processor_id():
*/
@@ -603,6 +589,3 @@
if (current->nr_cpus_allowed == 1)
goto out;
---
-2.23.0
-
diff --git a/patches/sched-core-migrate_enable-must-access-takedown_cpu_t.patch b/patches/sched-core-migrate_enable-must-access-takedown_cpu_t.patch
index 5279121..a92091f 100644
--- a/patches/sched-core-migrate_enable-must-access-takedown_cpu_t.patch
+++ b/patches/sched-core-migrate_enable-must-access-takedown_cpu_t.patch
@@ -11,15 +11,13 @@
Reported-by: Dick Hollenbeck <dick@softplc.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
- kernel/cpu.c | 2 ++
- kernel/sched/core.c | 2 ++
+ kernel/cpu.c | 2 ++
+ kernel/sched/core.c | 2 ++
2 files changed, 4 insertions(+)
-diff --git a/kernel/cpu.c b/kernel/cpu.c
-index 123ad9626cc7f..81a6e5068972c 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
-@@ -887,7 +887,9 @@ static int take_cpu_down(void *_param)
+@@ -877,7 +877,9 @@ static int take_cpu_down(void *_param)
return 0;
}
@@ -29,11 +27,9 @@
static int takedown_cpu(unsigned int cpu)
{
-diff --git a/kernel/sched/core.c b/kernel/sched/core.c
-index bd26257eb2358..8bea013b2baf5 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
-@@ -8212,9 +8212,11 @@ void migrate_enable(void)
+@@ -7384,9 +7384,11 @@ void migrate_enable(void)
p->migrate_disable = 0;
rq->nr_pinned--;
@@ -45,6 +41,3 @@
if (!p->migrate_disable_scheduled)
goto out;
---
-2.24.0
-
diff --git a/patches/sched-migrate_enable-Busy-loop-until-the-migration-r.patch b/patches/sched-migrate_enable-Busy-loop-until-the-migration-r.patch
new file mode 100644
index 0000000..224e7c6
--- /dev/null
+++ b/patches/sched-migrate_enable-Busy-loop-until-the-migration-r.patch
@@ -0,0 +1,47 @@
+From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+Date: Thu, 12 Dec 2019 10:53:59 +0100
+Subject: [PATCH] sched: migrate_enable: Busy loop until the migration
+ request is completed
+
+If user task changes the CPU affinity mask of a running task it will
+dispatch migration request if the current CPU is no longer allowed. This
+might happen shortly before a task enters a migrate_disable() section.
+Upon leaving the migrate_disable() section, the task will notice that
+the current CPU is no longer allowed and will will dispatch its own
+migration request to move it off the current CPU.
+While invoking __schedule() the first migration request will be
+processed and the task returns on the "new" CPU with "arg.done = 0". Its
+own migration request will be processed shortly after and will result in
+memory corruption if the stack memory, designed for request, was used
+otherwise in the meantime.
+
+Spin until the migration request has been processed if it was accepted.
+
+Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
+---
+ kernel/sched/core.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+--- a/kernel/sched/core.c
++++ b/kernel/sched/core.c
+@@ -7399,7 +7399,7 @@ void migrate_enable(void)
+
+ WARN_ON(smp_processor_id() != cpu);
+ if (!is_cpu_allowed(p, cpu)) {
+- struct migration_arg arg = { p };
++ struct migration_arg arg = { .task = p };
+ struct cpu_stop_work work;
+ struct rq_flags rf;
+
+@@ -7411,7 +7411,10 @@ void migrate_enable(void)
+ stop_one_cpu_nowait(task_cpu(p), migration_cpu_stop,
+ &arg, &work);
+ __schedule(true);
+- WARN_ON_ONCE(!arg.done && !work.disabled);
++ if (!work.disabled) {
++ while (!arg.done)
++ cpu_relax();
++ }
+ }
+
+ out:
diff --git a/patches/sched-migrate_enable-Use-select_fallback_rq.patch b/patches/sched-migrate_enable-Use-select_fallback_rq.patch
index d26f7a4..0fa7ee9 100644
--- a/patches/sched-migrate_enable-Use-select_fallback_rq.patch
+++ b/patches/sched-migrate_enable-Use-select_fallback_rq.patch
@@ -10,11 +10,9 @@
Signed-off-by: Scott Wood <swood@redhat.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
- kernel/sched/core.c | 25 ++++++++++---------------
+ kernel/sched/core.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
-diff --git a/kernel/sched/core.c b/kernel/sched/core.c
-index 93b4ae1ecaff8..bfd160e90797a 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -7405,6 +7405,7 @@ void migrate_enable(void)
@@ -56,6 +54,3 @@
unpin_current_cpu();
preempt_lazy_enable();
---
-2.23.0
-
diff --git a/patches/sched-migrate_enable-Use-stop_one_cpu_nowait.patch b/patches/sched-migrate_enable-Use-stop_one_cpu_nowait.patch
index 86097c2..3966de5 100644
--- a/patches/sched-migrate_enable-Use-stop_one_cpu_nowait.patch
+++ b/patches/sched-migrate_enable-Use-stop_one_cpu_nowait.patch
@@ -11,13 +11,11 @@
Signed-off-by: Scott Wood <swood@redhat.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
- include/linux/stop_machine.h | 2 ++
- kernel/sched/core.c | 22 +++++++++++++---------
- kernel/stop_machine.c | 7 +++++--
+ include/linux/stop_machine.h | 2 ++
+ kernel/sched/core.c | 22 +++++++++++++---------
+ kernel/stop_machine.c | 7 +++++--
3 files changed, 20 insertions(+), 11 deletions(-)
-diff --git a/include/linux/stop_machine.h b/include/linux/stop_machine.h
-index 6d3635c86dbeb..82fc686ddd9eb 100644
--- a/include/linux/stop_machine.h
+++ b/include/linux/stop_machine.h
@@ -26,6 +26,8 @@ struct cpu_stop_work {
@@ -29,11 +27,9 @@
};
int stop_one_cpu(unsigned int cpu, cpu_stop_fn_t fn, void *arg);
-diff --git a/kernel/sched/core.c b/kernel/sched/core.c
-index 5cb2a519b8bf2..6383ade320f23 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
-@@ -1051,6 +1051,7 @@ static struct rq *move_queued_task(struct rq *rq, struct rq_flags *rf,
+@@ -1051,6 +1051,7 @@ static struct rq *move_queued_task(struc
struct migration_arg {
struct task_struct *task;
int dest_cpu;
@@ -41,7 +37,7 @@
};
/*
-@@ -1086,6 +1087,11 @@ static int migration_cpu_stop(void *data)
+@@ -1086,6 +1087,11 @@ static int migration_cpu_stop(void *data
struct task_struct *p = arg->task;
struct rq *rq = this_rq();
struct rq_flags rf;
@@ -53,7 +49,7 @@
/*
* The original target CPU might have gone down and we might
-@@ -1108,9 +1114,9 @@ static int migration_cpu_stop(void *data)
+@@ -1108,9 +1114,9 @@ static int migration_cpu_stop(void *data
*/
if (task_rq(p) == rq) {
if (task_on_rq_queued(p))
@@ -91,11 +87,9 @@
}
out:
-diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
-index 2b5a6754646f5..fa53a472dd443 100644
--- a/kernel/stop_machine.c
+++ b/kernel/stop_machine.c
-@@ -85,8 +85,11 @@ static bool cpu_stop_queue_work(unsigned int cpu, struct cpu_stop_work *work)
+@@ -85,8 +85,11 @@ static bool cpu_stop_queue_work(unsigned
enabled = stopper->enabled;
if (enabled)
__cpu_stop_queue_work(stopper, work, &wakeq);
@@ -109,6 +103,3 @@
raw_spin_unlock_irqrestore(&stopper->lock, flags);
wake_up_q(&wakeq);
---
-2.23.0
-
diff --git a/patches/series b/patches/series
index d80f800..aeb9507 100644
--- a/patches/series
+++ b/patches/series
@@ -422,6 +422,8 @@
sched-Lazy-migrate_disable-processing.patch
sched-migrate_enable-Use-stop_one_cpu_nowait.patch
sched-core-migrate_enable-must-access-takedown_cpu_t.patch
+sched-migrate_enable-Busy-loop-until-the-migration-r.patch
+lib-smp_processor_id-Adjust-check_preemption_disable.patch
# DRIVERS
connector-cn_proc-Protect-send_msg-with-a-local-lock.patch
diff --git a/patches/signals-allow-rt-tasks-to-cache-one-sigqueue-struct.patch b/patches/signals-allow-rt-tasks-to-cache-one-sigqueue-struct.patch
index d42483b..81399e3 100644
--- a/patches/signals-allow-rt-tasks-to-cache-one-sigqueue-struct.patch
+++ b/patches/signals-allow-rt-tasks-to-cache-one-sigqueue-struct.patch
@@ -17,7 +17,7 @@
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
-@@ -889,6 +889,8 @@ struct task_struct {
+@@ -888,6 +888,8 @@ struct task_struct {
/* Signal handlers: */
struct signal_struct *signal;
struct sighand_struct *sighand;
diff --git a/patches/x86-fpu-Don-t-cache-access-to-fpu_fpregs_owner_ctx.patch b/patches/x86-fpu-Don-t-cache-access-to-fpu_fpregs_owner_ctx.patch
index 8c1bf82..69d2ed87 100644
--- a/patches/x86-fpu-Don-t-cache-access-to-fpu_fpregs_owner_ctx.patch
+++ b/patches/x86-fpu-Don-t-cache-access-to-fpu_fpregs_owner_ctx.patch
@@ -91,14 +91,12 @@
Link: https://lkml.kernel.org/r/20191128085306.hxfa2o3knqtu4wfn@linutronix.de
Link: https://bugzilla.kernel.org/show_bug.cgi?id=205663
---
- arch/x86/include/asm/fpu/internal.h | 2 +-
+ arch/x86/include/asm/fpu/internal.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
-diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h
-index 4c95c365058aa..44c48e34d7994 100644
--- a/arch/x86/include/asm/fpu/internal.h
+++ b/arch/x86/include/asm/fpu/internal.h
-@@ -509,7 +509,7 @@ static inline void __fpu_invalidate_fpregs_state(struct fpu *fpu)
+@@ -509,7 +509,7 @@ static inline void __fpu_invalidate_fpre
static inline int fpregs_state_valid(struct fpu *fpu, unsigned int cpu)
{
@@ -107,6 +105,3 @@
}
/*
---
-2.24.0
-