diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2017-10-11 12:04:35 +0200 |
---|---|---|
committer | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2017-10-11 12:27:01 +0200 |
commit | b2302d63e4ff0ae34732c2ea0de668eaebbce819 (patch) | |
tree | 21d4110b6144f1a15d4846a6ef7dc0d395a98e91 | |
parent | c5c5f525611e97a1aed5670c0d499070ee98163a (diff) | |
download | linux-rt-b2302d63e4ff0ae34732c2ea0de668eaebbce819.tar.gz |
[ANNOUNCE] v4.11.12-rt15v4.11.12-rt15-patches
Dear RT folks!
I'm pleased to announce the v4.11.12-rt15 patch set.
Changes since v4.11.12-rt14:
- Programmed wake ups (nanosleep, clock_nanosleep, …) by a task with
RT priority will still be carried out in the hardirq context
(nothing changes). If it is programmed by task with a normal
priority then the wake up will be carried out in the softirq
context via the ktimersoftd thread.
The advantage is that multiple wake ups of non-RT tasks won't
disturb the RT task. Reported by Gratian Crisan.
- Paul Gortmaker reported splat during boot when TSC (on x86) becomes
unstable and kernel switches to an alternative. This has been fixed
by cherry-picking a patch from upstream.
- After the hrtimer rework, certain wake ups (like those programmed in
the past using the softirq context) won't fire. Reported by Mike
Galbraith, patched by Anna-Maria Gleixner.
- After the hrtimer rework, wake ups using CLOCK_REALTIME and a
relative delay were affected by clock_settime() (they should have
not been). Reported by Mike Galbraith.
Known issues
None
The delta patch against v4.11.12-rt14 is appended below and can be found here:
https://cdn.kernel.org/pub/linux/kernel/projects/rt/4.11/incr/patch-4.11.12-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 v4.11.12-rt15
The RT patch against v4.11.12 can be found here:
https://cdn.kernel.org/pub/linux/kernel/projects/rt/4.11/older/patch-4.11.12-rt15.patch.xz
The split quilt queue is available at:
https://cdn.kernel.org/pub/linux/kernel/projects/rt/4.11/older/patches-4.11.12-rt15.tar.xz
Sebastian
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
16 files changed, 274 insertions, 42 deletions
diff --git a/patches/0040-tracing-Add-trace_event_buffer_reserve-variant-that-.patch b/patches/0040-tracing-Add-trace_event_buffer_reserve-variant-that-.patch index 18369c5b01cf..a7f603a6b87e 100644 --- a/patches/0040-tracing-Add-trace_event_buffer_reserve-variant-that-.patch +++ b/patches/0040-tracing-Add-trace_event_buffer_reserve-variant-that-.patch @@ -33,14 +33,12 @@ you can include it in your series. Link: https://lkml.kernel.org/r/20170908162756.74c6be8a@gandalf.local.home Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- - kernel/trace/ring_buffer.c | 64 ++++++++++++---------------------------------- - 1 file changed, 17 insertions(+), 47 deletions(-) + kernel/trace/ring_buffer.c | 66 ++++++++++++--------------------------------- + 1 file changed, 18 insertions(+), 48 deletions(-) -diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c -index ac34ea2b2a10..29430b81c674 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c -@@ -2581,61 +2581,29 @@ rb_wakeups(struct ring_buffer *buffer, struct ring_buffer_per_cpu *cpu_buffer) +@@ -2581,61 +2581,29 @@ rb_wakeups(struct ring_buffer *buffer, s * The lock and unlock are done within a preempt disable section. * The current_context per_cpu variable can only be modified * by the current task between lock and unlock. But it can @@ -56,11 +54,7 @@ index ac34ea2b2a10..29430b81c674 100644 - * bit 1 = IRQ context - * bit 2 = SoftIRQ context - * bit 3 = normal context. -+ * Normal context. -+ * SoftIRQ context -+ * IRQ context -+ * NMI context - * +- * - * This works because this is the order of contexts that can - * preempt other contexts. A SoftIRQ never preempts an IRQ - * context. @@ -82,6 +76,11 @@ index ac34ea2b2a10..29430b81c674 100644 - * The least significant bit can be cleared this way, and it - * just so happens that it is the same bit corresponding to - * the current context. ++ * Normal context. ++ * SoftIRQ context ++ * IRQ context ++ * NMI context ++ * + * If for some reason the ring buffer starts to recurse, we + * only allow that to happen at most 4 times (one for each + * context). If it happens 5 times, then we consider this a @@ -116,7 +115,7 @@ index ac34ea2b2a10..29430b81c674 100644 return 0; } -@@ -2643,7 +2611,9 @@ trace_recursive_lock(struct ring_buffer_per_cpu *cpu_buffer) +@@ -2643,7 +2611,9 @@ trace_recursive_lock(struct ring_buffer_ static __always_inline void trace_recursive_unlock(struct ring_buffer_per_cpu *cpu_buffer) { @@ -127,6 +126,3 @@ index ac34ea2b2a10..29430b81c674 100644 } /** --- -2.14.1 - diff --git a/patches/cpu_chill-Add-a-UNINTERRUPTIBLE-hrtimer_nanosleep.patch b/patches/cpu_chill-Add-a-UNINTERRUPTIBLE-hrtimer_nanosleep.patch index 0924cf5672fc..d3c5dfd0a55c 100644 --- a/patches/cpu_chill-Add-a-UNINTERRUPTIBLE-hrtimer_nanosleep.patch +++ b/patches/cpu_chill-Add-a-UNINTERRUPTIBLE-hrtimer_nanosleep.patch @@ -33,7 +33,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c -@@ -1664,10 +1664,11 @@ EXPORT_SYMBOL_GPL(hrtimer_init_sleeper_o +@@ -1687,10 +1687,11 @@ EXPORT_SYMBOL_GPL(hrtimer_init_sleeper_o #endif @@ -47,7 +47,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> hrtimer_start_expires(&t->timer, mode); if (likely(t->task)) -@@ -1709,7 +1710,8 @@ long __sched hrtimer_nanosleep_restart(s +@@ -1732,7 +1733,8 @@ long __sched hrtimer_nanosleep_restart(s HRTIMER_MODE_ABS, current); hrtimer_set_expires_tv64(&t.timer, restart->nanosleep.expires); @@ -57,7 +57,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> goto out; rmtp = restart->nanosleep.rmtp; -@@ -1726,8 +1728,10 @@ long __sched hrtimer_nanosleep_restart(s +@@ -1749,8 +1751,10 @@ long __sched hrtimer_nanosleep_restart(s return ret; } @@ -70,7 +70,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> { struct restart_block *restart; struct hrtimer_sleeper t; -@@ -1741,7 +1745,7 @@ long hrtimer_nanosleep(struct timespec * +@@ -1764,7 +1768,7 @@ long hrtimer_nanosleep(struct timespec * hrtimer_init_sleeper_on_stack(&t, clockid, mode, current); hrtimer_set_expires_range_ns(&t.timer, timespec_to_ktime(*rqtp), slack); @@ -79,7 +79,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> goto out; /* Absolute timers do not update the rmtp value and restart: */ -@@ -1768,6 +1772,12 @@ long hrtimer_nanosleep(struct timespec * +@@ -1791,6 +1795,12 @@ long hrtimer_nanosleep(struct timespec * return ret; } @@ -92,7 +92,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> SYSCALL_DEFINE2(nanosleep, struct timespec __user *, rqtp, struct timespec __user *, rmtp) { -@@ -1794,7 +1804,8 @@ void cpu_chill(void) +@@ -1817,7 +1827,8 @@ void cpu_chill(void) unsigned int freeze_flag = current->flags & PF_NOFREEZE; current->flags |= PF_NOFREEZE; diff --git a/patches/ftrace-Fix-trace-header-alignment.patch b/patches/ftrace-Fix-trace-header-alignment.patch index c209ce46a496..ba263bd43182 100644 --- a/patches/ftrace-Fix-trace-header-alignment.patch +++ b/patches/ftrace-Fix-trace-header-alignment.patch @@ -14,7 +14,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c -@@ -3144,17 +3144,17 @@ get_total_entries(struct trace_buffer *b +@@ -3121,17 +3121,17 @@ get_total_entries(struct trace_buffer *b static void print_lat_help_header(struct seq_file *m) { @@ -43,7 +43,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> } static void print_event_info(struct trace_buffer *buf, struct seq_file *m) -@@ -3183,11 +3183,11 @@ static void print_func_help_header_irq(s +@@ -3160,11 +3160,11 @@ static void print_func_help_header_irq(s "# |/ _-----=> need-resched_lazy\n" "# || / _---=> hardirq/softirq\n" "# ||| / _--=> preempt-depth\n" diff --git a/patches/ftrace-migrate-disable-tracing.patch b/patches/ftrace-migrate-disable-tracing.patch index c59aa3e75d62..dd2ebfb8e4bc 100644 --- a/patches/ftrace-migrate-disable-tracing.patch +++ b/patches/ftrace-migrate-disable-tracing.patch @@ -23,7 +23,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de> #define TRACE_EVENT_TYPE_MAX \ --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c -@@ -1955,6 +1955,8 @@ tracing_generic_entry_update(struct trac +@@ -1954,6 +1954,8 @@ tracing_generic_entry_update(struct trac ((pc & SOFTIRQ_OFFSET) ? TRACE_FLAG_SOFTIRQ : 0) | (tif_need_resched() ? TRACE_FLAG_NEED_RESCHED : 0) | (test_preempt_need_resched() ? TRACE_FLAG_PREEMPT_RESCHED : 0); @@ -32,7 +32,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de> } EXPORT_SYMBOL_GPL(tracing_generic_entry_update); -@@ -3145,9 +3147,10 @@ static void print_lat_help_header(struct +@@ -3122,9 +3124,10 @@ static void print_lat_help_header(struct "# | / _----=> need-resched \n" "# || / _---=> hardirq/softirq \n" "# ||| / _--=> preempt-depth \n" diff --git a/patches/hrtimer-Move-schedule_work-call-to-helper-thread.patch b/patches/hrtimer-Move-schedule_work-call-to-helper-thread.patch index 5071e0d4e1fc..bff567d7dbf8 100644 --- a/patches/hrtimer-Move-schedule_work-call-to-helper-thread.patch +++ b/patches/hrtimer-Move-schedule_work-call-to-helper-thread.patch @@ -51,7 +51,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c -@@ -685,6 +685,29 @@ static void hrtimer_switch_to_hres(void) +@@ -691,6 +691,29 @@ static void hrtimer_switch_to_hres(void) retrigger_next_event(NULL); } @@ -81,7 +81,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> static void clock_was_set_work(struct work_struct *work) { clock_was_set(); -@@ -700,6 +723,7 @@ void clock_was_set_delayed(void) +@@ -706,6 +729,7 @@ void clock_was_set_delayed(void) { schedule_work(&hrtimer_work); } diff --git a/patches/hrtimer-by-timers-by-default-into-the-softirq-context.patch b/patches/hrtimer-by-timers-by-default-into-the-softirq-context.patch index 75914c661e07..7891c2323360 100644 --- a/patches/hrtimer-by-timers-by-default-into-the-softirq-context.patch +++ b/patches/hrtimer-by-timers-by-default-into-the-softirq-context.patch @@ -148,7 +148,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> }; /* -@@ -1194,7 +1206,11 @@ static inline int hrtimer_clockid_to_bas +@@ -1200,7 +1212,11 @@ static inline int hrtimer_clockid_to_bas return base; } WARN(1, "Invalid clockid %d. Using MONOTONIC\n", clock_id); @@ -160,7 +160,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> } static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id, -@@ -1587,6 +1603,10 @@ static void __hrtimer_init_sleeper(struc +@@ -1593,6 +1609,10 @@ static void __hrtimer_init_sleeper(struc enum hrtimer_mode mode, struct task_struct *task) { diff --git a/patches/hrtimer-consolidate-hrtimer_init-hrtimer_init_sleepe.patch b/patches/hrtimer-consolidate-hrtimer_init-hrtimer_init_sleepe.patch index 4ba25565b78e..6d5fd53f1b32 100644 --- a/patches/hrtimer-consolidate-hrtimer_init-hrtimer_init_sleepe.patch +++ b/patches/hrtimer-consolidate-hrtimer_init-hrtimer_init_sleepe.patch @@ -135,7 +135,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> } --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c -@@ -1554,17 +1554,46 @@ static enum hrtimer_restart hrtimer_wake +@@ -1560,17 +1560,46 @@ static enum hrtimer_restart hrtimer_wake return HRTIMER_NORESTART; } @@ -185,7 +185,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> do { set_current_state(TASK_INTERRUPTIBLE); hrtimer_start_expires(&t->timer, mode); -@@ -1604,8 +1633,8 @@ long __sched hrtimer_nanosleep_restart(s +@@ -1610,8 +1639,8 @@ long __sched hrtimer_nanosleep_restart(s struct timespec __user *rmtp; int ret = 0; @@ -196,7 +196,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> hrtimer_set_expires_tv64(&t.timer, restart->nanosleep.expires); if (do_nanosleep(&t, HRTIMER_MODE_ABS)) -@@ -1637,8 +1666,9 @@ long hrtimer_nanosleep(struct timespec * +@@ -1643,8 +1672,9 @@ long hrtimer_nanosleep(struct timespec * if (dl_task(current) || rt_task(current)) slack = 0; @@ -207,7 +207,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> if (do_nanosleep(&t, mode)) goto out; -@@ -1816,10 +1846,9 @@ schedule_hrtimeout_range_clock(ktime_t * +@@ -1822,10 +1852,9 @@ schedule_hrtimeout_range_clock(ktime_t * return -EINTR; } diff --git a/patches/hrtimer-soft-bases-timekeeping.patch b/patches/hrtimer-soft-bases-timekeeping.patch new file mode 100644 index 000000000000..1280fe4977a4 --- /dev/null +++ b/patches/hrtimer-soft-bases-timekeeping.patch @@ -0,0 +1,31 @@ +Subject: hrtimer: Update offset for soft bases +From: Anna-Maria Gleixner <anna-maria@linutronix.de> +Date: Fri, 06 Oct 2017 11:28:38 +0200 + +The offset of the clock bases is done via timekeeping mechanisms. The +offsets of the soft bases has to be considered as well. + +Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de> +Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> +--- + kernel/time/hrtimer.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +--- a/kernel/time/hrtimer.c ++++ b/kernel/time/hrtimer.c +@@ -550,8 +550,14 @@ static inline ktime_t hrtimer_update_bas + ktime_t *offs_boot = &base->clock_base[HRTIMER_BASE_BOOTTIME].offset; + ktime_t *offs_tai = &base->clock_base[HRTIMER_BASE_TAI].offset; + +- return ktime_get_update_offsets_now(&base->clock_was_set_seq, ++ ktime_t now = ktime_get_update_offsets_now(&base->clock_was_set_seq, + offs_real, offs_boot, offs_tai); ++ ++ base->clock_base[HRTIMER_BASE_REALTIME_SOFT].offset = *offs_real; ++ base->clock_base[HRTIMER_BASE_BOOTTIME_SOFT].offset = *offs_boot; ++ base->clock_base[HRTIMER_BASE_TAI_SOFT].offset = *offs_tai; ++ ++ return now; + } + + /* diff --git a/patches/hrtimers-prepare-full-preemption.patch b/patches/hrtimers-prepare-full-preemption.patch index 91b349cf8210..f4716c78e81c 100644 --- a/patches/hrtimers-prepare-full-preemption.patch +++ b/patches/hrtimers-prepare-full-preemption.patch @@ -60,7 +60,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de> } --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c -@@ -862,6 +862,33 @@ u64 hrtimer_forward(struct hrtimer *time +@@ -868,6 +868,33 @@ u64 hrtimer_forward(struct hrtimer *time } EXPORT_SYMBOL_GPL(hrtimer_forward); @@ -94,7 +94,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de> /* * enqueue_hrtimer - internal function to (re)start a timer * -@@ -1109,7 +1136,7 @@ int hrtimer_cancel(struct hrtimer *timer +@@ -1115,7 +1142,7 @@ int hrtimer_cancel(struct hrtimer *timer if (ret >= 0) return ret; @@ -103,7 +103,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de> } } EXPORT_SYMBOL_GPL(hrtimer_cancel); -@@ -1385,6 +1412,7 @@ static __latent_entropy void hrtimer_run +@@ -1391,6 +1418,7 @@ static __latent_entropy void hrtimer_run hrtimer_update_softirq_timer(cpu_base, true); raw_spin_unlock_irq(&cpu_base->lock); @@ -111,7 +111,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de> } #ifdef CONFIG_HIGH_RES_TIMERS -@@ -1727,6 +1755,9 @@ int hrtimers_prepare_cpu(unsigned int cp +@@ -1733,6 +1761,9 @@ int hrtimers_prepare_cpu(unsigned int cp cpu_base->hres_active = 0; cpu_base->expires_next = KTIME_MAX; cpu_base->softirq_expires_next = KTIME_MAX; diff --git a/patches/localversion.patch b/patches/localversion.patch index e1f3b8d87864..340816c8febc 100644 --- a/patches/localversion.patch +++ b/patches/localversion.patch @@ -10,4 +10,4 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de> --- /dev/null +++ b/localversion-rt @@ -0,0 +1 @@ -+-rt14 ++-rt15 diff --git a/patches/preempt-lazy-support.patch b/patches/preempt-lazy-support.patch index 89124728466b..e98d84bc008d 100644 --- a/patches/preempt-lazy-support.patch +++ b/patches/preempt-lazy-support.patch @@ -492,7 +492,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de> --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c -@@ -1943,6 +1943,7 @@ tracing_generic_entry_update(struct trac +@@ -1942,6 +1942,7 @@ tracing_generic_entry_update(struct trac struct task_struct *tsk = current; entry->preempt_count = pc & 0xff; @@ -500,7 +500,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de> entry->pid = (tsk) ? tsk->pid : 0; entry->flags = #ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT -@@ -1953,7 +1954,8 @@ tracing_generic_entry_update(struct trac +@@ -1952,7 +1953,8 @@ tracing_generic_entry_update(struct trac ((pc & NMI_MASK ) ? TRACE_FLAG_NMI : 0) | ((pc & HARDIRQ_MASK) ? TRACE_FLAG_HARDIRQ : 0) | ((pc & SOFTIRQ_OFFSET) ? TRACE_FLAG_SOFTIRQ : 0) | @@ -510,7 +510,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de> (test_preempt_need_resched() ? TRACE_FLAG_PREEMPT_RESCHED : 0); entry->migrate_disable = (tsk) ? __migrate_disabled(tsk) & 0xFF : 0; -@@ -3142,15 +3144,17 @@ get_total_entries(struct trace_buffer *b +@@ -3119,15 +3121,17 @@ get_total_entries(struct trace_buffer *b static void print_lat_help_header(struct seq_file *m) { @@ -537,7 +537,7 @@ Signed-off-by: Thomas Gleixner <tglx@linutronix.de> } static void print_event_info(struct trace_buffer *buf, struct seq_file *m) -@@ -3176,11 +3180,14 @@ static void print_func_help_header_irq(s +@@ -3153,11 +3157,14 @@ static void print_func_help_header_irq(s print_event_info(buf, m); seq_puts(m, "# _-----=> irqs-off\n" "# / _----=> need-resched\n" diff --git a/patches/rt-introduce-cpu-chill.patch b/patches/rt-introduce-cpu-chill.patch index b99bb40083f7..47e01a46017c 100644 --- a/patches/rt-introduce-cpu-chill.patch +++ b/patches/rt-introduce-cpu-chill.patch @@ -100,7 +100,7 @@ Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> #endif /* defined(_LINUX_DELAY_H) */ --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c -@@ -1782,6 +1782,25 @@ SYSCALL_DEFINE2(nanosleep, struct timesp +@@ -1805,6 +1805,25 @@ SYSCALL_DEFINE2(nanosleep, struct timesp return hrtimer_nanosleep(&tu, rmtp, HRTIMER_MODE_REL, CLOCK_MONOTONIC); } diff --git a/patches/sched-clock-Initialize-all-per-CPU-state-before-swit.patch b/patches/sched-clock-Initialize-all-per-CPU-state-before-swit.patch new file mode 100644 index 000000000000..1ac686c4f189 --- /dev/null +++ b/patches/sched-clock-Initialize-all-per-CPU-state-before-swit.patch @@ -0,0 +1,118 @@ +From: Peter Zijlstra <peterz@infradead.org> +Date: Fri, 21 Apr 2017 12:11:53 +0200 +Subject: [PATCH] sched/clock: Initialize all per-CPU state before switching + (back) to unstable + +In preparation for not keeping the sched_clock_tick() active for +stable TSC, we need to explicitly initialize all per-CPU state +before switching back to unstable. + +Note: this patch looses the __gtod_offset calculation; it will be +restored in the next one. + +Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> +Cc: Linus Torvalds <torvalds@linux-foundation.org> +Cc: Mike Galbraith <efault@gmx.de> +Cc: Peter Zijlstra <peterz@infradead.org> +Cc: Thomas Gleixner <tglx@linutronix.de> +Cc: linux-kernel@vger.kernel.org +Signed-off-by: Ingo Molnar <mingo@kernel.org> +Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> +--- + kernel/sched/clock.c | 60 +++++++++++++++++++++++++++++++++------------------ + 1 file changed, 39 insertions(+), 21 deletions(-) + +--- a/kernel/sched/clock.c ++++ b/kernel/sched/clock.c +@@ -124,6 +124,12 @@ int sched_clock_stable(void) + return static_branch_likely(&__sched_clock_stable); + } + ++static void __scd_stamp(struct sched_clock_data *scd) ++{ ++ scd->tick_gtod = ktime_get_ns(); ++ scd->tick_raw = sched_clock(); ++} ++ + static void __set_sched_clock_stable(void) + { + struct sched_clock_data *scd = this_scd(); +@@ -141,8 +147,37 @@ static void __set_sched_clock_stable(voi + tick_dep_clear(TICK_DEP_BIT_CLOCK_UNSTABLE); + } + ++/* ++ * If we ever get here, we're screwed, because we found out -- typically after ++ * the fact -- that TSC wasn't good. This means all our clocksources (including ++ * ktime) could have reported wrong values. ++ * ++ * What we do here is an attempt to fix up and continue sort of where we left ++ * off in a coherent manner. ++ * ++ * The only way to fully avoid random clock jumps is to boot with: ++ * "tsc=unstable". ++ */ + static void __sched_clock_work(struct work_struct *work) + { ++ struct sched_clock_data *scd; ++ int cpu; ++ ++ /* take a current timestamp and set 'now' */ ++ preempt_disable(); ++ scd = this_scd(); ++ __scd_stamp(scd); ++ scd->clock = scd->tick_gtod + __gtod_offset; ++ preempt_enable(); ++ ++ /* clone to all CPUs */ ++ for_each_possible_cpu(cpu) ++ per_cpu(sched_clock_data, cpu) = *scd; ++ ++ printk(KERN_INFO "sched_clock: Marking unstable (%lld, %lld)<-(%lld, %lld)\n", ++ scd->tick_gtod, __gtod_offset, ++ scd->tick_raw, __sched_clock_offset); ++ + static_branch_disable(&__sched_clock_stable); + } + +@@ -150,27 +185,11 @@ static DECLARE_WORK(sched_clock_work, __ + + static void __clear_sched_clock_stable(void) + { +- struct sched_clock_data *scd = this_scd(); +- +- /* +- * Attempt to make the stable->unstable transition continuous. +- * +- * Trouble is, this is typically called from the TSC watchdog +- * timer, which is late per definition. This means the tick +- * values can already be screwy. +- * +- * Still do what we can. +- */ +- __gtod_offset = (scd->tick_raw + __sched_clock_offset) - (scd->tick_gtod); +- +- printk(KERN_INFO "sched_clock: Marking unstable (%lld, %lld)<-(%lld, %lld)\n", +- scd->tick_gtod, __gtod_offset, +- scd->tick_raw, __sched_clock_offset); ++ if (!sched_clock_stable()) ++ return; + + tick_dep_set(TICK_DEP_BIT_CLOCK_UNSTABLE); +- +- if (sched_clock_stable()) +- schedule_work(&sched_clock_work); ++ schedule_work(&sched_clock_work); + } + + void clear_sched_clock_stable(void) +@@ -357,8 +376,7 @@ void sched_clock_tick(void) + * XXX arguably we can skip this if we expose tsc_clocksource_reliable + */ + scd = this_scd(); +- scd->tick_raw = sched_clock(); +- scd->tick_gtod = ktime_get_ns(); ++ __scd_stamp(scd); + + if (!sched_clock_stable() && likely(sched_clock_running)) + sched_clock_local(scd); diff --git a/patches/series b/patches/series index 32bfb07ec7d9..d6f4af4c0253 100644 --- a/patches/series +++ b/patches/series @@ -5,6 +5,7 @@ ############################################################ # UPSTREAM changes queued ############################################################ +sched-clock-Initialize-all-per-CPU-state-before-swit.patch ############################################################ # UPSTREAM FIXES, patches pending @@ -140,6 +141,8 @@ hrtimer-Remove-hrtimer_peek_ahead_timers-leftovers.patch 0016-hrtimer-Allow-function-reuse-for-softirq-based-hrtim.patch 0017-hrtimer-Implementation-of-softirq-hrtimer-handling.patch 0018-hrtimer-Enable-soft-and-hard-hrtimer.patch +hrtimer-soft-bases-timekeeping.patch +time-hrtimer-use-a-MONOTIC-clock-for-relative-REALTI.patch 0019-can-bcm-Replace-hrtimer_tasklet-with-softirq-based-h.patch 0020-mac80211_hwsim-Replace-hrtimer-tasklet-with-softirq-.patch 0021-xfrm-Replace-hrtimer-tasklet-with-softirq-hrtimer.patch @@ -430,6 +433,7 @@ x86-kvm-require-const-tsc-for-rt.patch hrtimer-consolidate-hrtimer_init-hrtimer_init_sleepe.patch hrtimers-prepare-full-preemption.patch hrtimer-by-timers-by-default-into-the-softirq-context.patch +time-hrtimer-Use-softirq-based-wakeups-for-non-RT-th.patch timer-fd-avoid-live-lock.patch # POSIX-CPU-TIMERS diff --git a/patches/time-hrtimer-Use-softirq-based-wakeups-for-non-RT-th.patch b/patches/time-hrtimer-Use-softirq-based-wakeups-for-non-RT-th.patch new file mode 100644 index 000000000000..4493e1b8ad5d --- /dev/null +++ b/patches/time-hrtimer-Use-softirq-based-wakeups-for-non-RT-th.patch @@ -0,0 +1,52 @@ +From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> +Date: Wed, 4 Oct 2017 16:47:19 +0200 +Subject: [PATCH RT] time/hrtimer: Use softirq based wakeups for non-RT threads + +Normal wake ups (like clock_nanosleep()) which are performed by normal +users can easily lead to 2ms latency spikes if (enough) hrtimer wakeups +are synchronized. +This patch moves all hrtimers wakeups to the softirq queue unless the +caller has a RT priority. + +Reported-by: Gratian Crisan <gratian.crisan@ni.com> +Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> +--- + kernel/time/hrtimer.c | 21 +++++++++++++++++++-- + 1 file changed, 19 insertions(+), 2 deletions(-) + +--- a/kernel/time/hrtimer.c ++++ b/kernel/time/hrtimer.c +@@ -1604,14 +1604,31 @@ static enum hrtimer_restart hrtimer_wake + return HRTIMER_NORESTART; + } + ++#ifdef CONFIG_PREEMPT_RT_FULL ++static bool task_is_elevated(struct task_struct *tsk) ++{ ++ int policy = tsk->policy; ++ ++ if (policy == SCHED_FIFO || policy == SCHED_RR) ++ return true; ++ if (policy == SCHED_DEADLINE) ++ return true; ++ return false; ++} ++#endif ++ + static void __hrtimer_init_sleeper(struct hrtimer_sleeper *sl, + clockid_t clock_id, + enum hrtimer_mode mode, + struct task_struct *task) + { + #ifdef CONFIG_PREEMPT_RT_FULL +- if (!(clock_id & HRTIMER_BASE_SOFT_MASK)) +- clock_id |= HRTIMER_BASE_HARD_MASK; ++ if (!(clock_id & (HRTIMER_BASE_HARD_MASK | HRTIMER_BASE_SOFT_MASK))) { ++ if (task_is_elevated(current) || system_state != SYSTEM_RUNNING) ++ clock_id |= HRTIMER_BASE_HARD_MASK; ++ else ++ clock_id |= HRTIMER_BASE_SOFT_MASK; ++ } + #endif + __hrtimer_init(&sl->timer, clock_id, mode); + sl->timer.function = hrtimer_wakeup; diff --git a/patches/time-hrtimer-use-a-MONOTIC-clock-for-relative-REALTI.patch b/patches/time-hrtimer-use-a-MONOTIC-clock-for-relative-REALTI.patch new file mode 100644 index 000000000000..c7da128a48de --- /dev/null +++ b/patches/time-hrtimer-use-a-MONOTIC-clock-for-relative-REALTI.patch @@ -0,0 +1,31 @@ +From: Sebastian Andrzej Siewior <bigeasy@linutronix.de> +Date: Wed, 11 Oct 2017 10:23:00 +0200 +Subject: [PATCH] time/hrtimer: use a MONOTIC clock for "relative" REALTIME + sleep + +clock_nanosleep(CLOCK_REALTIME, ) with a relative delay/time should not +be effected by clock_settime(CLOCK_REALTIME,) thus we need to use +CLOCK_MONOTONIC instead. This is already done for the clock itself and +for the SOFT-irq based clock but was forgotten for the HARD-irq clock. + +Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> +--- + kernel/time/hrtimer.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c +index cdd7cd35da11..b7c2ea23a320 100644 +--- a/kernel/time/hrtimer.c ++++ b/kernel/time/hrtimer.c +@@ -1258,6 +1258,8 @@ static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id, + clock_id = CLOCK_MONOTONIC; + else if (clock_id == CLOCK_REALTIME_SOFT) + clock_id = CLOCK_MONOTONIC_SOFT; ++ else if (clock_id == CLOCK_REALTIME_HARD) ++ clock_id = CLOCK_MONOTONIC_HARD; + } + + base = hrtimer_clockid_to_base(clock_id); +-- +2.14.2 + |