diff --git a/debian/changelog b/debian/changelog index 7e6906f2a..b6d9160e9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -435,6 +435,7 @@ linux (4.16.16-1) UNRELEASED; urgency=medium [ Bastian Blank ] * hv_netvsc: Fix a network regression after ifdown/ifup + * [rt] Update to 4.16.15-rt7. [ Vagrant Cascadian ] * [arm64] Enable configuration options used in Firefly-RK3399: diff --git a/debian/config/defines b/debian/config/defines index acff62ef5..1c57528ca 100644 --- a/debian/config/defines +++ b/debian/config/defines @@ -113,7 +113,7 @@ debug-info: true signed-code: false [featureset-rt_base] -enabled: false +enabled: true [description] part-long-up: This kernel is not suitable for SMP (multi-processor, diff --git a/debian/patches/features/all/rt/0001-ARM-at91-add-TCB-registers-definitions.patch b/debian/patches/features/all/rt/0001-ARM-at91-add-TCB-registers-definitions.patch index 34ba5d599..2a0bf2141 100644 --- a/debian/patches/features/all/rt/0001-ARM-at91-add-TCB-registers-definitions.patch +++ b/debian/patches/features/all/rt/0001-ARM-at91-add-TCB-registers-definitions.patch @@ -1,7 +1,6 @@ From: Alexandre Belloni Date: Wed, 18 Apr 2018 12:51:38 +0200 Subject: [PATCH 1/6] ARM: at91: add TCB registers definitions -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Add registers and bits definitions for the timer counter blocks found on Atmel ARM SoCs. diff --git a/debian/patches/features/all/rt/suspend-prevernt-might-sleep-splats.patch b/debian/patches/features/all/rt/0001-PM-suspend-Prevent-might-sleep-splats.patch similarity index 58% rename from debian/patches/features/all/rt/suspend-prevernt-might-sleep-splats.patch rename to debian/patches/features/all/rt/0001-PM-suspend-Prevent-might-sleep-splats.patch index 611f0fe94..0e410af32 100644 --- a/debian/patches/features/all/rt/suspend-prevernt-might-sleep-splats.patch +++ b/debian/patches/features/all/rt/0001-PM-suspend-Prevent-might-sleep-splats.patch @@ -1,28 +1,35 @@ From: Thomas Gleixner Date: Thu, 15 Jul 2010 10:29:00 +0200 -Subject: suspend: Prevent might sleep splats -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz +Subject: [PATCH 1/4] PM / suspend: Prevent might sleep splats -timekeeping suspend/resume calls read_persistant_clock() which takes +timekeeping suspend/resume calls read_persistent_clock() which takes rtc_lock. That results in might sleep warnings because at that point we run with interrupts disabled. We cannot convert rtc_lock to a raw spinlock as that would trigger other might sleep warnings. -As a temporary workaround we disable the might sleep warnings by -setting system_state to SYSTEM_SUSPEND before calling sysdev_suspend() -and restoring it to SYSTEM_RUNNING afer sysdev_resume(). +As a workaround we disable the might sleep warnings by setting +system_state to SYSTEM_SUSPEND before calling sysdev_suspend() and +restoring it to SYSTEM_RUNNING afer sysdev_resume(). There is no lock +contention because hibernate / suspend to RAM is single-CPU at this +point. -Needs to be revisited. +In s2idle's case the system_state is set to SYSTEM_SUSPEND before +timekeeping_suspend() which is invoked by the last CPU. In the resume +case it set back to SYSTEM_RUNNING after timekeeping_resume() which is +invoked by the first CPU in the resume case. The other CPUs will block +on tick_freeze_lock. Signed-off-by: Thomas Gleixner - +[bigeasy: cover s2idle] +Signed-off-by: Sebastian Andrzej Siewior --- - include/linux/kernel.h | 1 + - kernel/power/hibernate.c | 7 +++++++ - kernel/power/suspend.c | 4 ++++ - 3 files changed, 12 insertions(+) + include/linux/kernel.h | 1 + + kernel/power/hibernate.c | 7 +++++++ + kernel/power/suspend.c | 4 ++++ + kernel/time/tick-common.c | 2 ++ + 4 files changed, 14 insertions(+) --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -105,3 +112,21 @@ Signed-off-by: Thomas Gleixner arch_suspend_enable_irqs(); BUG_ON(irqs_disabled()); +--- a/kernel/time/tick-common.c ++++ b/kernel/time/tick-common.c +@@ -490,6 +490,7 @@ void tick_freeze(void) + if (tick_freeze_depth == num_online_cpus()) { + trace_suspend_resume(TPS("timekeeping_freeze"), + smp_processor_id(), true); ++ system_state = SYSTEM_SUSPEND; + timekeeping_suspend(); + } else { + tick_suspend_local(); +@@ -513,6 +514,7 @@ void tick_unfreeze(void) + + if (tick_freeze_depth == num_online_cpus()) { + timekeeping_resume(); ++ system_state = SYSTEM_RUNNING; + trace_suspend_resume(TPS("timekeeping_freeze"), + smp_processor_id(), false); + } else { diff --git a/debian/patches/features/all/rt/0001-bdi-use-refcount_t-for-reference-counting-instead-at.patch b/debian/patches/features/all/rt/0001-bdi-use-refcount_t-for-reference-counting-instead-at.patch index 474acb82d..bf52cabe6 100644 --- a/debian/patches/features/all/rt/0001-bdi-use-refcount_t-for-reference-counting-instead-at.patch +++ b/debian/patches/features/all/rt/0001-bdi-use-refcount_t-for-reference-counting-instead-at.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Mon, 7 May 2018 16:51:09 +0200 Subject: [PATCH] bdi: use refcount_t for reference counting instead atomic_t -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz refcount_t type and corresponding API should be used instead of atomic_t when the variable is used as a reference counter. This allows to avoid accidental @@ -54,7 +53,7 @@ Signed-off-by: Sebastian Andrzej Siewior --- a/mm/backing-dev.c +++ b/mm/backing-dev.c -@@ -460,10 +460,10 @@ wb_congested_get_create(struct backing_d +@@ -461,10 +461,10 @@ wb_congested_get_create(struct backing_d if (new_congested) { /* !found and storage for new one already allocated, insert */ congested = new_congested; @@ -67,7 +66,7 @@ Signed-off-by: Sebastian Andrzej Siewior } spin_unlock_irqrestore(&cgwb_lock, flags); -@@ -473,13 +473,13 @@ wb_congested_get_create(struct backing_d +@@ -474,13 +474,13 @@ wb_congested_get_create(struct backing_d if (!new_congested) return NULL; @@ -83,7 +82,7 @@ Signed-off-by: Sebastian Andrzej Siewior spin_unlock_irqrestore(&cgwb_lock, flags); kfree(new_congested); return congested; -@@ -496,7 +496,7 @@ void wb_congested_put(struct bdi_writeba +@@ -497,7 +497,7 @@ void wb_congested_put(struct bdi_writeba unsigned long flags; local_irq_save(flags); @@ -92,7 +91,7 @@ Signed-off-by: Sebastian Andrzej Siewior local_irq_restore(flags); return; } -@@ -806,7 +806,7 @@ static int cgwb_bdi_init(struct backing_ +@@ -807,7 +807,7 @@ static int cgwb_bdi_init(struct backing_ if (!bdi->wb_congested) return -ENOMEM; diff --git a/debian/patches/features/all/rt/0001-get-rid-of-trylock-loop-in-locking-dentries-on-shrin.patch b/debian/patches/features/all/rt/0001-get-rid-of-trylock-loop-in-locking-dentries-on-shrin.patch index 1a3ab9890..74f230a99 100644 --- a/debian/patches/features/all/rt/0001-get-rid-of-trylock-loop-in-locking-dentries-on-shrin.patch +++ b/debian/patches/features/all/rt/0001-get-rid-of-trylock-loop-in-locking-dentries-on-shrin.patch @@ -2,7 +2,6 @@ From: Al Viro Date: Fri, 23 Feb 2018 21:54:18 -0500 Subject: [PATCH 01/17] get rid of trylock loop in locking dentries on shrink list -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 3b3f09f48ba78c0634e929849860a6447d057eed diff --git a/debian/patches/features/all/rt/0001-iommu-amd-Use-raw-locks-on-atomic-context-paths.patch b/debian/patches/features/all/rt/0001-iommu-amd-Use-raw-locks-on-atomic-context-paths.patch index e7e7d725b..c3673536c 100644 --- a/debian/patches/features/all/rt/0001-iommu-amd-Use-raw-locks-on-atomic-context-paths.patch +++ b/debian/patches/features/all/rt/0001-iommu-amd-Use-raw-locks-on-atomic-context-paths.patch @@ -1,7 +1,6 @@ From: Scott Wood Date: Sun, 21 Jan 2018 03:28:54 -0600 Subject: [PATCH 1/3] iommu/amd: Use raw locks on atomic context paths -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 27790398c2aed917828dc3c6f81240d57f1584c9 diff --git a/debian/patches/features/all/rt/0001-spinlock-atomic_dec_and_lock-Add-an-irqsave-variant.patch b/debian/patches/features/all/rt/0001-spinlock-atomic_dec_and_lock-Add-an-irqsave-variant.patch new file mode 100644 index 000000000..9f34a6e1e --- /dev/null +++ b/debian/patches/features/all/rt/0001-spinlock-atomic_dec_and_lock-Add-an-irqsave-variant.patch @@ -0,0 +1,57 @@ +From: Anna-Maria Gleixner +Date: Fri, 4 May 2018 17:45:29 +0200 +Subject: [PATCH 1/3] spinlock: atomic_dec_and_lock: Add an irqsave variant + +There are in-tree users of atomic_dec_and_lock() which must acquire the +spin lock with interrupts disabled. To workaround the lack of an irqsave +variant of atomic_dec_and_lock() they use local_irq_save() at the call +site. This causes extra code and creates in some places unneeded long +interrupt disabled times. These places need also extra treatment for +PREEMPT_RT due to the disconnect of the irq disabling and the lock +function. + +Implement the missing irqsave variant of the function. + +Signed-off-by: Anna-Maria Gleixner +Signed-off-by: Sebastian Andrzej Siewior +--- + include/linux/spinlock.h | 5 +++++ + lib/dec_and_lock.c | 16 ++++++++++++++++ + 2 files changed, 21 insertions(+) + +--- a/include/linux/spinlock.h ++++ b/include/linux/spinlock.h +@@ -409,6 +409,11 @@ extern int _atomic_dec_and_lock(atomic_t + #define atomic_dec_and_lock(atomic, lock) \ + __cond_lock(lock, _atomic_dec_and_lock(atomic, lock)) + ++extern int _atomic_dec_and_lock_irqsave(atomic_t *atomic, spinlock_t *lock, ++ unsigned long *flags); ++#define atomic_dec_and_lock_irqsave(atomic, lock, flags) \ ++ __cond_lock(lock, _atomic_dec_and_lock_irqsave(atomic, lock, &(flags))) ++ + int alloc_bucket_spinlocks(spinlock_t **locks, unsigned int *lock_mask, + size_t max_size, unsigned int cpu_mult, + gfp_t gfp); +--- a/lib/dec_and_lock.c ++++ b/lib/dec_and_lock.c +@@ -33,3 +33,19 @@ int _atomic_dec_and_lock(atomic_t *atomi + } + + EXPORT_SYMBOL(_atomic_dec_and_lock); ++ ++int _atomic_dec_and_lock_irqsave(atomic_t *atomic, spinlock_t *lock, ++ unsigned long *flags) ++{ ++ /* Subtract 1 from counter unless that drops it to 0 (ie. it was 1) */ ++ if (atomic_add_unless(atomic, -1, 1)) ++ return 0; ++ ++ /* Otherwise do it the slow way */ ++ spin_lock_irqsave(lock, *flags); ++ if (atomic_dec_and_test(atomic)) ++ return 1; ++ spin_unlock_irqrestore(lock, *flags); ++ return 0; ++} ++EXPORT_SYMBOL(_atomic_dec_and_lock_irqsave); diff --git a/debian/patches/features/all/rt/0001-timers-Use-static-keys-for-migrate_enable-nohz_activ.patch b/debian/patches/features/all/rt/0001-timers-Use-static-keys-for-migrate_enable-nohz_activ.patch deleted file mode 100644 index ac9755bcc..000000000 --- a/debian/patches/features/all/rt/0001-timers-Use-static-keys-for-migrate_enable-nohz_activ.patch +++ /dev/null @@ -1,273 +0,0 @@ -From: Thomas Gleixner -Date: Wed, 20 Dec 2017 17:12:50 +0100 -Subject: [PATCH 01/29] timers: Use static keys for migrate_enable/nohz_active -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The members migrate_enable and nohz_active in the timer/hrtimer per CPU -bases have been introduced to avoid accessing global variables for these -decisions. - -Still that results in a (cache hot) load and conditional branch, which can -be avoided by using static keys. - -Implement it with static keys and optimize for the most critical case of -high performance networking which tends to disable the timer migration -functionality. - -Signed-off-by: Thomas Gleixner -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - include/linux/hrtimer.h | 4 -- - kernel/time/hrtimer.c | 17 ++------- - kernel/time/tick-internal.h | 19 ++++++---- - kernel/time/tick-sched.c | 2 - - kernel/time/timer.c | 83 ++++++++++++++++++++++---------------------- - 5 files changed, 61 insertions(+), 64 deletions(-) - ---- a/include/linux/hrtimer.h -+++ b/include/linux/hrtimer.h -@@ -153,8 +153,6 @@ enum hrtimer_base_type { - * @cpu: cpu number - * @active_bases: Bitfield to mark bases with active timers - * @clock_was_set_seq: Sequence counter of clock was set events -- * @migration_enabled: The migration of hrtimers to other cpus is enabled -- * @nohz_active: The nohz functionality is enabled - * @expires_next: absolute time of the next event which was scheduled - * via clock_set_next_event() - * @next_timer: Pointer to the first expiring timer -@@ -178,8 +176,6 @@ struct hrtimer_cpu_base { - unsigned int cpu; - unsigned int active_bases; - unsigned int clock_was_set_seq; -- bool migration_enabled; -- bool nohz_active; - #ifdef CONFIG_HIGH_RES_TIMERS - unsigned int in_hrtirq : 1, - hres_active : 1, ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -178,23 +178,16 @@ hrtimer_check_target(struct hrtimer *tim - #endif - } - --#ifdef CONFIG_NO_HZ_COMMON --static inline --struct hrtimer_cpu_base *get_target_base(struct hrtimer_cpu_base *base, -- int pinned) --{ -- if (pinned || !base->migration_enabled) -- return base; -- return &per_cpu(hrtimer_bases, get_nohz_timer_target()); --} --#else - static inline - struct hrtimer_cpu_base *get_target_base(struct hrtimer_cpu_base *base, - int pinned) - { -+#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) -+ if (static_branch_unlikely(&timers_migration_enabled) && !pinned) -+ return &per_cpu(hrtimer_bases, get_nohz_timer_target()); -+#endif - return base; - } --#endif - - /* - * We switch the timer base to a power-optimized selected CPU target, -@@ -971,7 +964,7 @@ void hrtimer_start_range_ns(struct hrtim - * Kick to reschedule the next tick to handle the new timer - * on dynticks target. - */ -- if (new_base->cpu_base->nohz_active) -+ if (is_timers_nohz_active()) - wake_up_nohz_cpu(new_base->cpu_base->cpu); - } else { - hrtimer_reprogram(timer, new_base); ---- a/kernel/time/tick-internal.h -+++ b/kernel/time/tick-internal.h -@@ -150,14 +150,19 @@ static inline void tick_nohz_init(void) - - #ifdef CONFIG_NO_HZ_COMMON - extern unsigned long tick_nohz_active; --#else -+extern void timers_update_nohz(void); -+extern struct static_key_false timers_nohz_active; -+static inline bool is_timers_nohz_active(void) -+{ -+ return static_branch_unlikely(&timers_nohz_active); -+} -+# ifdef CONFIG_SMP -+extern struct static_key_false timers_migration_enabled; -+# endif -+#else /* CONFIG_NO_HZ_COMMON */ -+static inline void timers_update_nohz(void) { } - #define tick_nohz_active (0) --#endif -- --#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) --extern void timers_update_migration(bool update_nohz); --#else --static inline void timers_update_migration(bool update_nohz) { } -+static inline bool is_timers_nohz_active(void) { return false; } - #endif - - DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases); ---- a/kernel/time/tick-sched.c -+++ b/kernel/time/tick-sched.c -@@ -1131,7 +1131,7 @@ static inline void tick_nohz_activate(st - ts->nohz_mode = mode; - /* One update is enough */ - if (!test_and_set_bit(0, &tick_nohz_active)) -- timers_update_migration(true); -+ timers_update_nohz(); - } - - /** ---- a/kernel/time/timer.c -+++ b/kernel/time/timer.c -@@ -200,8 +200,6 @@ struct timer_base { - unsigned long clk; - unsigned long next_expiry; - unsigned int cpu; -- bool migration_enabled; -- bool nohz_active; - bool is_idle; - bool must_forward_clk; - DECLARE_BITMAP(pending_map, WHEEL_SIZE); -@@ -210,45 +208,59 @@ struct timer_base { - - static DEFINE_PER_CPU(struct timer_base, timer_bases[NR_BASES]); - --#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) -+#ifdef CONFIG_NO_HZ_COMMON -+ -+DEFINE_STATIC_KEY_FALSE(timers_nohz_active); -+static DEFINE_MUTEX(timer_keys_mutex); -+ -+static void timer_update_keys(struct work_struct *work); -+static DECLARE_WORK(timer_update_work, timer_update_keys); -+ -+#ifdef CONFIG_SMP - unsigned int sysctl_timer_migration = 1; - --void timers_update_migration(bool update_nohz) -+DEFINE_STATIC_KEY_FALSE(timers_migration_enabled); -+ -+static void timers_update_migration(void) - { - bool on = sysctl_timer_migration && tick_nohz_active; -- unsigned int cpu; - -- /* Avoid the loop, if nothing to update */ -- if (this_cpu_read(timer_bases[BASE_STD].migration_enabled) == on) -- return; -+ if (on) -+ static_branch_enable(&timers_migration_enabled); -+ else -+ static_branch_disable(&timers_migration_enabled); -+} -+#else -+static inline void timers_update_migration(void) { } -+#endif /* !CONFIG_SMP */ - -- for_each_possible_cpu(cpu) { -- per_cpu(timer_bases[BASE_STD].migration_enabled, cpu) = on; -- per_cpu(timer_bases[BASE_DEF].migration_enabled, cpu) = on; -- per_cpu(hrtimer_bases.migration_enabled, cpu) = on; -- if (!update_nohz) -- continue; -- per_cpu(timer_bases[BASE_STD].nohz_active, cpu) = true; -- per_cpu(timer_bases[BASE_DEF].nohz_active, cpu) = true; -- per_cpu(hrtimer_bases.nohz_active, cpu) = true; -- } -+static void timer_update_keys(struct work_struct *work) -+{ -+ mutex_lock(&timer_keys_mutex); -+ timers_update_migration(); -+ static_branch_enable(&timers_nohz_active); -+ mutex_unlock(&timer_keys_mutex); -+} -+ -+void timers_update_nohz(void) -+{ -+ schedule_work(&timer_update_work); - } - - int timer_migration_handler(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, - loff_t *ppos) - { -- static DEFINE_MUTEX(mutex); - int ret; - -- mutex_lock(&mutex); -+ mutex_lock(&timer_keys_mutex); - ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); - if (!ret && write) -- timers_update_migration(false); -- mutex_unlock(&mutex); -+ timers_update_migration(); -+ mutex_unlock(&timer_keys_mutex); - return ret; - } --#endif -+#endif /* NO_HZ_COMMON */ - - static unsigned long round_jiffies_common(unsigned long j, int cpu, - bool force_up) -@@ -534,7 +546,7 @@ static void - static void - trigger_dyntick_cpu(struct timer_base *base, struct timer_list *timer) - { -- if (!IS_ENABLED(CONFIG_NO_HZ_COMMON) || !base->nohz_active) -+ if (!is_timers_nohz_active()) - return; - - /* -@@ -840,21 +852,20 @@ static inline struct timer_base *get_tim - return get_timer_cpu_base(tflags, tflags & TIMER_CPUMASK); - } - --#ifdef CONFIG_NO_HZ_COMMON - static inline struct timer_base * - get_target_base(struct timer_base *base, unsigned tflags) - { --#ifdef CONFIG_SMP -- if ((tflags & TIMER_PINNED) || !base->migration_enabled) -- return get_timer_this_cpu_base(tflags); -- return get_timer_cpu_base(tflags, get_nohz_timer_target()); --#else -- return get_timer_this_cpu_base(tflags); -+#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON) -+ if (static_branch_unlikely(&timers_migration_enabled) && -+ !(tflags & TIMER_PINNED)) -+ return get_timer_cpu_base(tflags, get_nohz_timer_target()); - #endif -+ return get_timer_this_cpu_base(tflags); - } - - static inline void forward_timer_base(struct timer_base *base) - { -+#ifdef CONFIG_NO_HZ_COMMON - unsigned long jnow; - - /* -@@ -878,16 +889,8 @@ static inline void forward_timer_base(st - base->clk = jnow; - else - base->clk = base->next_expiry; --} --#else --static inline struct timer_base * --get_target_base(struct timer_base *base, unsigned tflags) --{ -- return get_timer_this_cpu_base(tflags); --} -- --static inline void forward_timer_base(struct timer_base *base) { } - #endif -+} - - - /* diff --git a/debian/patches/features/all/rt/0001-tracing-Add-field-modifier-parsing-hist-error-for-hi.patch b/debian/patches/features/all/rt/0001-tracing-Add-field-modifier-parsing-hist-error-for-hi.patch index 21c5065ed..a475b779a 100644 --- a/debian/patches/features/all/rt/0001-tracing-Add-field-modifier-parsing-hist-error-for-hi.patch +++ b/debian/patches/features/all/rt/0001-tracing-Add-field-modifier-parsing-hist-error-for-hi.patch @@ -2,7 +2,6 @@ From: Steven Rostedt Date: Wed, 16 May 2018 09:36:43 -0400 Subject: [PATCH 1/5] tracing: Add field modifier parsing hist error for hist triggers -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz From: Tom Zanussi diff --git a/debian/patches/features/all/rt/0001-tracing-Move-hist-trigger-Documentation-to-histogram.patch b/debian/patches/features/all/rt/0001-tracing-Move-hist-trigger-Documentation-to-histogram.patch deleted file mode 100644 index d60379287..000000000 --- a/debian/patches/features/all/rt/0001-tracing-Move-hist-trigger-Documentation-to-histogram.patch +++ /dev/null @@ -1,3142 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:35 -0600 -Subject: [PATCH 01/37] tracing: Move hist trigger Documentation to - histogram.txt -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The hist trigger Documentation takes up a large part of events.txt - -since it will be getting even larger, move it to a separate file. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - Documentation/trace/events.txt | 1548 ------------------------------------- - Documentation/trace/histogram.txt | 1568 ++++++++++++++++++++++++++++++++++++++ - 2 files changed, 1569 insertions(+), 1547 deletions(-) - create mode 100644 Documentation/trace/histogram.txt - ---- a/Documentation/trace/events.txt -+++ b/Documentation/trace/events.txt -@@ -517,1550 +517,4 @@ triggers (you have to use '!' for each o - totals derived from one or more trace event format fields and/or - event counts (hitcount). - -- The format of a hist trigger is as follows: -- -- hist:keys=[:values=] -- [:sort=][:size=#entries][:pause][:continue] -- [:clear][:name=histname1] [if ] -- -- When a matching event is hit, an entry is added to a hash table -- using the key(s) and value(s) named. Keys and values correspond to -- fields in the event's format description. Values must correspond to -- numeric fields - on an event hit, the value(s) will be added to a -- sum kept for that field. The special string 'hitcount' can be used -- in place of an explicit value field - this is simply a count of -- event hits. If 'values' isn't specified, an implicit 'hitcount' -- value will be automatically created and used as the only value. -- Keys can be any field, or the special string 'stacktrace', which -- will use the event's kernel stacktrace as the key. The keywords -- 'keys' or 'key' can be used to specify keys, and the keywords -- 'values', 'vals', or 'val' can be used to specify values. Compound -- keys consisting of up to two fields can be specified by the 'keys' -- keyword. Hashing a compound key produces a unique entry in the -- table for each unique combination of component keys, and can be -- useful for providing more fine-grained summaries of event data. -- Additionally, sort keys consisting of up to two fields can be -- specified by the 'sort' keyword. If more than one field is -- specified, the result will be a 'sort within a sort': the first key -- is taken to be the primary sort key and the second the secondary -- key. If a hist trigger is given a name using the 'name' parameter, -- its histogram data will be shared with other triggers of the same -- name, and trigger hits will update this common data. Only triggers -- with 'compatible' fields can be combined in this way; triggers are -- 'compatible' if the fields named in the trigger share the same -- number and type of fields and those fields also have the same names. -- Note that any two events always share the compatible 'hitcount' and -- 'stacktrace' fields and can therefore be combined using those -- fields, however pointless that may be. -- -- 'hist' triggers add a 'hist' file to each event's subdirectory. -- Reading the 'hist' file for the event will dump the hash table in -- its entirety to stdout. If there are multiple hist triggers -- attached to an event, there will be a table for each trigger in the -- output. The table displayed for a named trigger will be the same as -- any other instance having the same name. Each printed hash table -- entry is a simple list of the keys and values comprising the entry; -- keys are printed first and are delineated by curly braces, and are -- followed by the set of value fields for the entry. By default, -- numeric fields are displayed as base-10 integers. This can be -- modified by appending any of the following modifiers to the field -- name: -- -- .hex display a number as a hex value -- .sym display an address as a symbol -- .sym-offset display an address as a symbol and offset -- .syscall display a syscall id as a system call name -- .execname display a common_pid as a program name -- -- Note that in general the semantics of a given field aren't -- interpreted when applying a modifier to it, but there are some -- restrictions to be aware of in this regard: -- -- - only the 'hex' modifier can be used for values (because values -- are essentially sums, and the other modifiers don't make sense -- in that context). -- - the 'execname' modifier can only be used on a 'common_pid'. The -- reason for this is that the execname is simply the 'comm' value -- saved for the 'current' process when an event was triggered, -- which is the same as the common_pid value saved by the event -- tracing code. Trying to apply that comm value to other pid -- values wouldn't be correct, and typically events that care save -- pid-specific comm fields in the event itself. -- -- A typical usage scenario would be the following to enable a hist -- trigger, read its current contents, and then turn it off: -- -- # echo 'hist:keys=skbaddr.hex:vals=len' > \ -- /sys/kernel/debug/tracing/events/net/netif_rx/trigger -- -- # cat /sys/kernel/debug/tracing/events/net/netif_rx/hist -- -- # echo '!hist:keys=skbaddr.hex:vals=len' > \ -- /sys/kernel/debug/tracing/events/net/netif_rx/trigger -- -- The trigger file itself can be read to show the details of the -- currently attached hist trigger. This information is also displayed -- at the top of the 'hist' file when read. -- -- By default, the size of the hash table is 2048 entries. The 'size' -- parameter can be used to specify more or fewer than that. The units -- are in terms of hashtable entries - if a run uses more entries than -- specified, the results will show the number of 'drops', the number -- of hits that were ignored. The size should be a power of 2 between -- 128 and 131072 (any non- power-of-2 number specified will be rounded -- up). -- -- The 'sort' parameter can be used to specify a value field to sort -- on. The default if unspecified is 'hitcount' and the default sort -- order is 'ascending'. To sort in the opposite direction, append -- .descending' to the sort key. -- -- The 'pause' parameter can be used to pause an existing hist trigger -- or to start a hist trigger but not log any events until told to do -- so. 'continue' or 'cont' can be used to start or restart a paused -- hist trigger. -- -- The 'clear' parameter will clear the contents of a running hist -- trigger and leave its current paused/active state. -- -- Note that the 'pause', 'cont', and 'clear' parameters should be -- applied using 'append' shell operator ('>>') if applied to an -- existing trigger, rather than via the '>' operator, which will cause -- the trigger to be removed through truncation. -- --- enable_hist/disable_hist -- -- The enable_hist and disable_hist triggers can be used to have one -- event conditionally start and stop another event's already-attached -- hist trigger. Any number of enable_hist and disable_hist triggers -- can be attached to a given event, allowing that event to kick off -- and stop aggregations on a host of other events. -- -- The format is very similar to the enable/disable_event triggers: -- -- enable_hist::[:count] -- disable_hist::[:count] -- -- Instead of enabling or disabling the tracing of the target event -- into the trace buffer as the enable/disable_event triggers do, the -- enable/disable_hist triggers enable or disable the aggregation of -- the target event into a hash table. -- -- A typical usage scenario for the enable_hist/disable_hist triggers -- would be to first set up a paused hist trigger on some event, -- followed by an enable_hist/disable_hist pair that turns the hist -- aggregation on and off when conditions of interest are hit: -- -- # echo 'hist:keys=skbaddr.hex:vals=len:pause' > \ -- /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger -- -- # echo 'enable_hist:net:netif_receive_skb if filename==/usr/bin/wget' > \ -- /sys/kernel/debug/tracing/events/sched/sched_process_exec/trigger -- -- # echo 'disable_hist:net:netif_receive_skb if comm==wget' > \ -- /sys/kernel/debug/tracing/events/sched/sched_process_exit/trigger -- -- The above sets up an initially paused hist trigger which is unpaused -- and starts aggregating events when a given program is executed, and -- which stops aggregating when the process exits and the hist trigger -- is paused again. -- -- The examples below provide a more concrete illustration of the -- concepts and typical usage patterns discussed above. -- -- --6.2 'hist' trigger examples ----------------------------- -- -- The first set of examples creates aggregations using the kmalloc -- event. The fields that can be used for the hist trigger are listed -- in the kmalloc event's format file: -- -- # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/format -- name: kmalloc -- ID: 374 -- format: -- field:unsigned short common_type; offset:0; size:2; signed:0; -- field:unsigned char common_flags; offset:2; size:1; signed:0; -- field:unsigned char common_preempt_count; offset:3; size:1; signed:0; -- field:int common_pid; offset:4; size:4; signed:1; -- -- field:unsigned long call_site; offset:8; size:8; signed:0; -- field:const void * ptr; offset:16; size:8; signed:0; -- field:size_t bytes_req; offset:24; size:8; signed:0; -- field:size_t bytes_alloc; offset:32; size:8; signed:0; -- field:gfp_t gfp_flags; offset:40; size:4; signed:0; -- -- We'll start by creating a hist trigger that generates a simple table -- that lists the total number of bytes requested for each function in -- the kernel that made one or more calls to kmalloc: -- -- # echo 'hist:key=call_site:val=bytes_req' > \ -- /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger -- -- This tells the tracing system to create a 'hist' trigger using the -- call_site field of the kmalloc event as the key for the table, which -- just means that each unique call_site address will have an entry -- created for it in the table. The 'val=bytes_req' parameter tells -- the hist trigger that for each unique entry (call_site) in the -- table, it should keep a running total of the number of bytes -- requested by that call_site. -- -- We'll let it run for awhile and then dump the contents of the 'hist' -- file in the kmalloc event's subdirectory (for readability, a number -- of entries have been omitted): -- -- # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist -- # trigger info: hist:keys=call_site:vals=bytes_req:sort=hitcount:size=2048 [active] -- -- { call_site: 18446744072106379007 } hitcount: 1 bytes_req: 176 -- { call_site: 18446744071579557049 } hitcount: 1 bytes_req: 1024 -- { call_site: 18446744071580608289 } hitcount: 1 bytes_req: 16384 -- { call_site: 18446744071581827654 } hitcount: 1 bytes_req: 24 -- { call_site: 18446744071580700980 } hitcount: 1 bytes_req: 8 -- { call_site: 18446744071579359876 } hitcount: 1 bytes_req: 152 -- { call_site: 18446744071580795365 } hitcount: 3 bytes_req: 144 -- { call_site: 18446744071581303129 } hitcount: 3 bytes_req: 144 -- { call_site: 18446744071580713234 } hitcount: 4 bytes_req: 2560 -- { call_site: 18446744071580933750 } hitcount: 4 bytes_req: 736 -- . -- . -- . -- { call_site: 18446744072106047046 } hitcount: 69 bytes_req: 5576 -- { call_site: 18446744071582116407 } hitcount: 73 bytes_req: 2336 -- { call_site: 18446744072106054684 } hitcount: 136 bytes_req: 140504 -- { call_site: 18446744072106224230 } hitcount: 136 bytes_req: 19584 -- { call_site: 18446744072106078074 } hitcount: 153 bytes_req: 2448 -- { call_site: 18446744072106062406 } hitcount: 153 bytes_req: 36720 -- { call_site: 18446744071582507929 } hitcount: 153 bytes_req: 37088 -- { call_site: 18446744072102520590 } hitcount: 273 bytes_req: 10920 -- { call_site: 18446744071582143559 } hitcount: 358 bytes_req: 716 -- { call_site: 18446744072106465852 } hitcount: 417 bytes_req: 56712 -- { call_site: 18446744072102523378 } hitcount: 485 bytes_req: 27160 -- { call_site: 18446744072099568646 } hitcount: 1676 bytes_req: 33520 -- -- Totals: -- Hits: 4610 -- Entries: 45 -- Dropped: 0 -- -- The output displays a line for each entry, beginning with the key -- specified in the trigger, followed by the value(s) also specified in -- the trigger. At the beginning of the output is a line that displays -- the trigger info, which can also be displayed by reading the -- 'trigger' file: -- -- # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger -- hist:keys=call_site:vals=bytes_req:sort=hitcount:size=2048 [active] -- -- At the end of the output are a few lines that display the overall -- totals for the run. The 'Hits' field shows the total number of -- times the event trigger was hit, the 'Entries' field shows the total -- number of used entries in the hash table, and the 'Dropped' field -- shows the number of hits that were dropped because the number of -- used entries for the run exceeded the maximum number of entries -- allowed for the table (normally 0, but if not a hint that you may -- want to increase the size of the table using the 'size' parameter). -- -- Notice in the above output that there's an extra field, 'hitcount', -- which wasn't specified in the trigger. Also notice that in the -- trigger info output, there's a parameter, 'sort=hitcount', which -- wasn't specified in the trigger either. The reason for that is that -- every trigger implicitly keeps a count of the total number of hits -- attributed to a given entry, called the 'hitcount'. That hitcount -- information is explicitly displayed in the output, and in the -- absence of a user-specified sort parameter, is used as the default -- sort field. -- -- The value 'hitcount' can be used in place of an explicit value in -- the 'values' parameter if you don't really need to have any -- particular field summed and are mainly interested in hit -- frequencies. -- -- To turn the hist trigger off, simply call up the trigger in the -- command history and re-execute it with a '!' prepended: -- -- # echo '!hist:key=call_site:val=bytes_req' > \ -- /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger -- -- Finally, notice that the call_site as displayed in the output above -- isn't really very useful. It's an address, but normally addresses -- are displayed in hex. To have a numeric field displayed as a hex -- value, simply append '.hex' to the field name in the trigger: -- -- # echo 'hist:key=call_site.hex:val=bytes_req' > \ -- /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger -- -- # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist -- # trigger info: hist:keys=call_site.hex:vals=bytes_req:sort=hitcount:size=2048 [active] -- -- { call_site: ffffffffa026b291 } hitcount: 1 bytes_req: 433 -- { call_site: ffffffffa07186ff } hitcount: 1 bytes_req: 176 -- { call_site: ffffffff811ae721 } hitcount: 1 bytes_req: 16384 -- { call_site: ffffffff811c5134 } hitcount: 1 bytes_req: 8 -- { call_site: ffffffffa04a9ebb } hitcount: 1 bytes_req: 511 -- { call_site: ffffffff8122e0a6 } hitcount: 1 bytes_req: 12 -- { call_site: ffffffff8107da84 } hitcount: 1 bytes_req: 152 -- { call_site: ffffffff812d8246 } hitcount: 1 bytes_req: 24 -- { call_site: ffffffff811dc1e5 } hitcount: 3 bytes_req: 144 -- { call_site: ffffffffa02515e8 } hitcount: 3 bytes_req: 648 -- { call_site: ffffffff81258159 } hitcount: 3 bytes_req: 144 -- { call_site: ffffffff811c80f4 } hitcount: 4 bytes_req: 544 -- . -- . -- . -- { call_site: ffffffffa06c7646 } hitcount: 106 bytes_req: 8024 -- { call_site: ffffffffa06cb246 } hitcount: 132 bytes_req: 31680 -- { call_site: ffffffffa06cef7a } hitcount: 132 bytes_req: 2112 -- { call_site: ffffffff8137e399 } hitcount: 132 bytes_req: 23232 -- { call_site: ffffffffa06c941c } hitcount: 185 bytes_req: 171360 -- { call_site: ffffffffa06f2a66 } hitcount: 185 bytes_req: 26640 -- { call_site: ffffffffa036a70e } hitcount: 265 bytes_req: 10600 -- { call_site: ffffffff81325447 } hitcount: 292 bytes_req: 584 -- { call_site: ffffffffa072da3c } hitcount: 446 bytes_req: 60656 -- { call_site: ffffffffa036b1f2 } hitcount: 526 bytes_req: 29456 -- { call_site: ffffffffa0099c06 } hitcount: 1780 bytes_req: 35600 -- -- Totals: -- Hits: 4775 -- Entries: 46 -- Dropped: 0 -- -- Even that's only marginally more useful - while hex values do look -- more like addresses, what users are typically more interested in -- when looking at text addresses are the corresponding symbols -- instead. To have an address displayed as symbolic value instead, -- simply append '.sym' or '.sym-offset' to the field name in the -- trigger: -- -- # echo 'hist:key=call_site.sym:val=bytes_req' > \ -- /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger -- -- # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist -- # trigger info: hist:keys=call_site.sym:vals=bytes_req:sort=hitcount:size=2048 [active] -- -- { call_site: [ffffffff810adcb9] syslog_print_all } hitcount: 1 bytes_req: 1024 -- { call_site: [ffffffff8154bc62] usb_control_msg } hitcount: 1 bytes_req: 8 -- { call_site: [ffffffffa00bf6fe] hidraw_send_report [hid] } hitcount: 1 bytes_req: 7 -- { call_site: [ffffffff8154acbe] usb_alloc_urb } hitcount: 1 bytes_req: 192 -- { call_site: [ffffffffa00bf1ca] hidraw_report_event [hid] } hitcount: 1 bytes_req: 7 -- { call_site: [ffffffff811e3a25] __seq_open_private } hitcount: 1 bytes_req: 40 -- { call_site: [ffffffff8109524a] alloc_fair_sched_group } hitcount: 2 bytes_req: 128 -- { call_site: [ffffffff811febd5] fsnotify_alloc_group } hitcount: 2 bytes_req: 528 -- { call_site: [ffffffff81440f58] __tty_buffer_request_room } hitcount: 2 bytes_req: 2624 -- { call_site: [ffffffff81200ba6] inotify_new_group } hitcount: 2 bytes_req: 96 -- { call_site: [ffffffffa05e19af] ieee80211_start_tx_ba_session [mac80211] } hitcount: 2 bytes_req: 464 -- { call_site: [ffffffff81672406] tcp_get_metrics } hitcount: 2 bytes_req: 304 -- { call_site: [ffffffff81097ec2] alloc_rt_sched_group } hitcount: 2 bytes_req: 128 -- { call_site: [ffffffff81089b05] sched_create_group } hitcount: 2 bytes_req: 1424 -- . -- . -- . -- { call_site: [ffffffffa04a580c] intel_crtc_page_flip [i915] } hitcount: 1185 bytes_req: 123240 -- { call_site: [ffffffffa0287592] drm_mode_page_flip_ioctl [drm] } hitcount: 1185 bytes_req: 104280 -- { call_site: [ffffffffa04c4a3c] intel_plane_duplicate_state [i915] } hitcount: 1402 bytes_req: 190672 -- { call_site: [ffffffff812891ca] ext4_find_extent } hitcount: 1518 bytes_req: 146208 -- { call_site: [ffffffffa029070e] drm_vma_node_allow [drm] } hitcount: 1746 bytes_req: 69840 -- { call_site: [ffffffffa045e7c4] i915_gem_do_execbuffer.isra.23 [i915] } hitcount: 2021 bytes_req: 792312 -- { call_site: [ffffffffa02911f2] drm_modeset_lock_crtc [drm] } hitcount: 2592 bytes_req: 145152 -- { call_site: [ffffffffa0489a66] intel_ring_begin [i915] } hitcount: 2629 bytes_req: 378576 -- { call_site: [ffffffffa046041c] i915_gem_execbuffer2 [i915] } hitcount: 2629 bytes_req: 3783248 -- { call_site: [ffffffff81325607] apparmor_file_alloc_security } hitcount: 5192 bytes_req: 10384 -- { call_site: [ffffffffa00b7c06] hid_report_raw_event [hid] } hitcount: 5529 bytes_req: 110584 -- { call_site: [ffffffff8131ebf7] aa_alloc_task_context } hitcount: 21943 bytes_req: 702176 -- { call_site: [ffffffff8125847d] ext4_htree_store_dirent } hitcount: 55759 bytes_req: 5074265 -- -- Totals: -- Hits: 109928 -- Entries: 71 -- Dropped: 0 -- -- Because the default sort key above is 'hitcount', the above shows a -- the list of call_sites by increasing hitcount, so that at the bottom -- we see the functions that made the most kmalloc calls during the -- run. If instead we we wanted to see the top kmalloc callers in -- terms of the number of bytes requested rather than the number of -- calls, and we wanted the top caller to appear at the top, we can use -- the 'sort' parameter, along with the 'descending' modifier: -- -- # echo 'hist:key=call_site.sym:val=bytes_req:sort=bytes_req.descending' > \ -- /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger -- -- # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist -- # trigger info: hist:keys=call_site.sym:vals=bytes_req:sort=bytes_req.descending:size=2048 [active] -- -- { call_site: [ffffffffa046041c] i915_gem_execbuffer2 [i915] } hitcount: 2186 bytes_req: 3397464 -- { call_site: [ffffffffa045e7c4] i915_gem_do_execbuffer.isra.23 [i915] } hitcount: 1790 bytes_req: 712176 -- { call_site: [ffffffff8125847d] ext4_htree_store_dirent } hitcount: 8132 bytes_req: 513135 -- { call_site: [ffffffff811e2a1b] seq_buf_alloc } hitcount: 106 bytes_req: 440128 -- { call_site: [ffffffffa0489a66] intel_ring_begin [i915] } hitcount: 2186 bytes_req: 314784 -- { call_site: [ffffffff812891ca] ext4_find_extent } hitcount: 2174 bytes_req: 208992 -- { call_site: [ffffffff811ae8e1] __kmalloc } hitcount: 8 bytes_req: 131072 -- { call_site: [ffffffffa04c4a3c] intel_plane_duplicate_state [i915] } hitcount: 859 bytes_req: 116824 -- { call_site: [ffffffffa02911f2] drm_modeset_lock_crtc [drm] } hitcount: 1834 bytes_req: 102704 -- { call_site: [ffffffffa04a580c] intel_crtc_page_flip [i915] } hitcount: 972 bytes_req: 101088 -- { call_site: [ffffffffa0287592] drm_mode_page_flip_ioctl [drm] } hitcount: 972 bytes_req: 85536 -- { call_site: [ffffffffa00b7c06] hid_report_raw_event [hid] } hitcount: 3333 bytes_req: 66664 -- { call_site: [ffffffff8137e559] sg_kmalloc } hitcount: 209 bytes_req: 61632 -- . -- . -- . -- { call_site: [ffffffff81095225] alloc_fair_sched_group } hitcount: 2 bytes_req: 128 -- { call_site: [ffffffff81097ec2] alloc_rt_sched_group } hitcount: 2 bytes_req: 128 -- { call_site: [ffffffff812d8406] copy_semundo } hitcount: 2 bytes_req: 48 -- { call_site: [ffffffff81200ba6] inotify_new_group } hitcount: 1 bytes_req: 48 -- { call_site: [ffffffffa027121a] drm_getmagic [drm] } hitcount: 1 bytes_req: 48 -- { call_site: [ffffffff811e3a25] __seq_open_private } hitcount: 1 bytes_req: 40 -- { call_site: [ffffffff811c52f4] bprm_change_interp } hitcount: 2 bytes_req: 16 -- { call_site: [ffffffff8154bc62] usb_control_msg } hitcount: 1 bytes_req: 8 -- { call_site: [ffffffffa00bf1ca] hidraw_report_event [hid] } hitcount: 1 bytes_req: 7 -- { call_site: [ffffffffa00bf6fe] hidraw_send_report [hid] } hitcount: 1 bytes_req: 7 -- -- Totals: -- Hits: 32133 -- Entries: 81 -- Dropped: 0 -- -- To display the offset and size information in addition to the symbol -- name, just use 'sym-offset' instead: -- -- # echo 'hist:key=call_site.sym-offset:val=bytes_req:sort=bytes_req.descending' > \ -- /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger -- -- # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist -- # trigger info: hist:keys=call_site.sym-offset:vals=bytes_req:sort=bytes_req.descending:size=2048 [active] -- -- { call_site: [ffffffffa046041c] i915_gem_execbuffer2+0x6c/0x2c0 [i915] } hitcount: 4569 bytes_req: 3163720 -- { call_site: [ffffffffa0489a66] intel_ring_begin+0xc6/0x1f0 [i915] } hitcount: 4569 bytes_req: 657936 -- { call_site: [ffffffffa045e7c4] i915_gem_do_execbuffer.isra.23+0x694/0x1020 [i915] } hitcount: 1519 bytes_req: 472936 -- { call_site: [ffffffffa045e646] i915_gem_do_execbuffer.isra.23+0x516/0x1020 [i915] } hitcount: 3050 bytes_req: 211832 -- { call_site: [ffffffff811e2a1b] seq_buf_alloc+0x1b/0x50 } hitcount: 34 bytes_req: 148384 -- { call_site: [ffffffffa04a580c] intel_crtc_page_flip+0xbc/0x870 [i915] } hitcount: 1385 bytes_req: 144040 -- { call_site: [ffffffff811ae8e1] __kmalloc+0x191/0x1b0 } hitcount: 8 bytes_req: 131072 -- { call_site: [ffffffffa0287592] drm_mode_page_flip_ioctl+0x282/0x360 [drm] } hitcount: 1385 bytes_req: 121880 -- { call_site: [ffffffffa02911f2] drm_modeset_lock_crtc+0x32/0x100 [drm] } hitcount: 1848 bytes_req: 103488 -- { call_site: [ffffffffa04c4a3c] intel_plane_duplicate_state+0x2c/0xa0 [i915] } hitcount: 461 bytes_req: 62696 -- { call_site: [ffffffffa029070e] drm_vma_node_allow+0x2e/0xd0 [drm] } hitcount: 1541 bytes_req: 61640 -- { call_site: [ffffffff815f8d7b] sk_prot_alloc+0xcb/0x1b0 } hitcount: 57 bytes_req: 57456 -- . -- . -- . -- { call_site: [ffffffff8109524a] alloc_fair_sched_group+0x5a/0x1a0 } hitcount: 2 bytes_req: 128 -- { call_site: [ffffffffa027b921] drm_vm_open_locked+0x31/0xa0 [drm] } hitcount: 3 bytes_req: 96 -- { call_site: [ffffffff8122e266] proc_self_follow_link+0x76/0xb0 } hitcount: 8 bytes_req: 96 -- { call_site: [ffffffff81213e80] load_elf_binary+0x240/0x1650 } hitcount: 3 bytes_req: 84 -- { call_site: [ffffffff8154bc62] usb_control_msg+0x42/0x110 } hitcount: 1 bytes_req: 8 -- { call_site: [ffffffffa00bf6fe] hidraw_send_report+0x7e/0x1a0 [hid] } hitcount: 1 bytes_req: 7 -- { call_site: [ffffffffa00bf1ca] hidraw_report_event+0x8a/0x120 [hid] } hitcount: 1 bytes_req: 7 -- -- Totals: -- Hits: 26098 -- Entries: 64 -- Dropped: 0 -- -- We can also add multiple fields to the 'values' parameter. For -- example, we might want to see the total number of bytes allocated -- alongside bytes requested, and display the result sorted by bytes -- allocated in a descending order: -- -- # echo 'hist:keys=call_site.sym:values=bytes_req,bytes_alloc:sort=bytes_alloc.descending' > \ -- /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger -- -- # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist -- # trigger info: hist:keys=call_site.sym:vals=bytes_req,bytes_alloc:sort=bytes_alloc.descending:size=2048 [active] -- -- { call_site: [ffffffffa046041c] i915_gem_execbuffer2 [i915] } hitcount: 7403 bytes_req: 4084360 bytes_alloc: 5958016 -- { call_site: [ffffffff811e2a1b] seq_buf_alloc } hitcount: 541 bytes_req: 2213968 bytes_alloc: 2228224 -- { call_site: [ffffffffa0489a66] intel_ring_begin [i915] } hitcount: 7404 bytes_req: 1066176 bytes_alloc: 1421568 -- { call_site: [ffffffffa045e7c4] i915_gem_do_execbuffer.isra.23 [i915] } hitcount: 1565 bytes_req: 557368 bytes_alloc: 1037760 -- { call_site: [ffffffff8125847d] ext4_htree_store_dirent } hitcount: 9557 bytes_req: 595778 bytes_alloc: 695744 -- { call_site: [ffffffffa045e646] i915_gem_do_execbuffer.isra.23 [i915] } hitcount: 5839 bytes_req: 430680 bytes_alloc: 470400 -- { call_site: [ffffffffa04c4a3c] intel_plane_duplicate_state [i915] } hitcount: 2388 bytes_req: 324768 bytes_alloc: 458496 -- { call_site: [ffffffffa02911f2] drm_modeset_lock_crtc [drm] } hitcount: 3911 bytes_req: 219016 bytes_alloc: 250304 -- { call_site: [ffffffff815f8d7b] sk_prot_alloc } hitcount: 235 bytes_req: 236880 bytes_alloc: 240640 -- { call_site: [ffffffff8137e559] sg_kmalloc } hitcount: 557 bytes_req: 169024 bytes_alloc: 221760 -- { call_site: [ffffffffa00b7c06] hid_report_raw_event [hid] } hitcount: 9378 bytes_req: 187548 bytes_alloc: 206312 -- { call_site: [ffffffffa04a580c] intel_crtc_page_flip [i915] } hitcount: 1519 bytes_req: 157976 bytes_alloc: 194432 -- . -- . -- . -- { call_site: [ffffffff8109bd3b] sched_autogroup_create_attach } hitcount: 2 bytes_req: 144 bytes_alloc: 192 -- { call_site: [ffffffff81097ee8] alloc_rt_sched_group } hitcount: 2 bytes_req: 128 bytes_alloc: 128 -- { call_site: [ffffffff8109524a] alloc_fair_sched_group } hitcount: 2 bytes_req: 128 bytes_alloc: 128 -- { call_site: [ffffffff81095225] alloc_fair_sched_group } hitcount: 2 bytes_req: 128 bytes_alloc: 128 -- { call_site: [ffffffff81097ec2] alloc_rt_sched_group } hitcount: 2 bytes_req: 128 bytes_alloc: 128 -- { call_site: [ffffffff81213e80] load_elf_binary } hitcount: 3 bytes_req: 84 bytes_alloc: 96 -- { call_site: [ffffffff81079a2e] kthread_create_on_node } hitcount: 1 bytes_req: 56 bytes_alloc: 64 -- { call_site: [ffffffffa00bf6fe] hidraw_send_report [hid] } hitcount: 1 bytes_req: 7 bytes_alloc: 8 -- { call_site: [ffffffff8154bc62] usb_control_msg } hitcount: 1 bytes_req: 8 bytes_alloc: 8 -- { call_site: [ffffffffa00bf1ca] hidraw_report_event [hid] } hitcount: 1 bytes_req: 7 bytes_alloc: 8 -- -- Totals: -- Hits: 66598 -- Entries: 65 -- Dropped: 0 -- -- Finally, to finish off our kmalloc example, instead of simply having -- the hist trigger display symbolic call_sites, we can have the hist -- trigger additionally display the complete set of kernel stack traces -- that led to each call_site. To do that, we simply use the special -- value 'stacktrace' for the key parameter: -- -- # echo 'hist:keys=stacktrace:values=bytes_req,bytes_alloc:sort=bytes_alloc' > \ -- /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger -- -- The above trigger will use the kernel stack trace in effect when an -- event is triggered as the key for the hash table. This allows the -- enumeration of every kernel callpath that led up to a particular -- event, along with a running total of any of the event fields for -- that event. Here we tally bytes requested and bytes allocated for -- every callpath in the system that led up to a kmalloc (in this case -- every callpath to a kmalloc for a kernel compile): -- -- # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist -- # trigger info: hist:keys=stacktrace:vals=bytes_req,bytes_alloc:sort=bytes_alloc:size=2048 [active] -- -- { stacktrace: -- __kmalloc_track_caller+0x10b/0x1a0 -- kmemdup+0x20/0x50 -- hidraw_report_event+0x8a/0x120 [hid] -- hid_report_raw_event+0x3ea/0x440 [hid] -- hid_input_report+0x112/0x190 [hid] -- hid_irq_in+0xc2/0x260 [usbhid] -- __usb_hcd_giveback_urb+0x72/0x120 -- usb_giveback_urb_bh+0x9e/0xe0 -- tasklet_hi_action+0xf8/0x100 -- __do_softirq+0x114/0x2c0 -- irq_exit+0xa5/0xb0 -- do_IRQ+0x5a/0xf0 -- ret_from_intr+0x0/0x30 -- cpuidle_enter+0x17/0x20 -- cpu_startup_entry+0x315/0x3e0 -- rest_init+0x7c/0x80 -- } hitcount: 3 bytes_req: 21 bytes_alloc: 24 -- { stacktrace: -- __kmalloc_track_caller+0x10b/0x1a0 -- kmemdup+0x20/0x50 -- hidraw_report_event+0x8a/0x120 [hid] -- hid_report_raw_event+0x3ea/0x440 [hid] -- hid_input_report+0x112/0x190 [hid] -- hid_irq_in+0xc2/0x260 [usbhid] -- __usb_hcd_giveback_urb+0x72/0x120 -- usb_giveback_urb_bh+0x9e/0xe0 -- tasklet_hi_action+0xf8/0x100 -- __do_softirq+0x114/0x2c0 -- irq_exit+0xa5/0xb0 -- do_IRQ+0x5a/0xf0 -- ret_from_intr+0x0/0x30 -- } hitcount: 3 bytes_req: 21 bytes_alloc: 24 -- { stacktrace: -- kmem_cache_alloc_trace+0xeb/0x150 -- aa_alloc_task_context+0x27/0x40 -- apparmor_cred_prepare+0x1f/0x50 -- security_prepare_creds+0x16/0x20 -- prepare_creds+0xdf/0x1a0 -- SyS_capset+0xb5/0x200 -- system_call_fastpath+0x12/0x6a -- } hitcount: 1 bytes_req: 32 bytes_alloc: 32 -- . -- . -- . -- { stacktrace: -- __kmalloc+0x11b/0x1b0 -- i915_gem_execbuffer2+0x6c/0x2c0 [i915] -- drm_ioctl+0x349/0x670 [drm] -- do_vfs_ioctl+0x2f0/0x4f0 -- SyS_ioctl+0x81/0xa0 -- system_call_fastpath+0x12/0x6a -- } hitcount: 17726 bytes_req: 13944120 bytes_alloc: 19593808 -- { stacktrace: -- __kmalloc+0x11b/0x1b0 -- load_elf_phdrs+0x76/0xa0 -- load_elf_binary+0x102/0x1650 -- search_binary_handler+0x97/0x1d0 -- do_execveat_common.isra.34+0x551/0x6e0 -- SyS_execve+0x3a/0x50 -- return_from_execve+0x0/0x23 -- } hitcount: 33348 bytes_req: 17152128 bytes_alloc: 20226048 -- { stacktrace: -- kmem_cache_alloc_trace+0xeb/0x150 -- apparmor_file_alloc_security+0x27/0x40 -- security_file_alloc+0x16/0x20 -- get_empty_filp+0x93/0x1c0 -- path_openat+0x31/0x5f0 -- do_filp_open+0x3a/0x90 -- do_sys_open+0x128/0x220 -- SyS_open+0x1e/0x20 -- system_call_fastpath+0x12/0x6a -- } hitcount: 4766422 bytes_req: 9532844 bytes_alloc: 38131376 -- { stacktrace: -- __kmalloc+0x11b/0x1b0 -- seq_buf_alloc+0x1b/0x50 -- seq_read+0x2cc/0x370 -- proc_reg_read+0x3d/0x80 -- __vfs_read+0x28/0xe0 -- vfs_read+0x86/0x140 -- SyS_read+0x46/0xb0 -- system_call_fastpath+0x12/0x6a -- } hitcount: 19133 bytes_req: 78368768 bytes_alloc: 78368768 -- -- Totals: -- Hits: 6085872 -- Entries: 253 -- Dropped: 0 -- -- If you key a hist trigger on common_pid, in order for example to -- gather and display sorted totals for each process, you can use the -- special .execname modifier to display the executable names for the -- processes in the table rather than raw pids. The example below -- keeps a per-process sum of total bytes read: -- -- # echo 'hist:key=common_pid.execname:val=count:sort=count.descending' > \ -- /sys/kernel/debug/tracing/events/syscalls/sys_enter_read/trigger -- -- # cat /sys/kernel/debug/tracing/events/syscalls/sys_enter_read/hist -- # trigger info: hist:keys=common_pid.execname:vals=count:sort=count.descending:size=2048 [active] -- -- { common_pid: gnome-terminal [ 3196] } hitcount: 280 count: 1093512 -- { common_pid: Xorg [ 1309] } hitcount: 525 count: 256640 -- { common_pid: compiz [ 2889] } hitcount: 59 count: 254400 -- { common_pid: bash [ 8710] } hitcount: 3 count: 66369 -- { common_pid: dbus-daemon-lau [ 8703] } hitcount: 49 count: 47739 -- { common_pid: irqbalance [ 1252] } hitcount: 27 count: 27648 -- { common_pid: 01ifupdown [ 8705] } hitcount: 3 count: 17216 -- { common_pid: dbus-daemon [ 772] } hitcount: 10 count: 12396 -- { common_pid: Socket Thread [ 8342] } hitcount: 11 count: 11264 -- { common_pid: nm-dhcp-client. [ 8701] } hitcount: 6 count: 7424 -- { common_pid: gmain [ 1315] } hitcount: 18 count: 6336 -- . -- . -- . -- { common_pid: postgres [ 1892] } hitcount: 2 count: 32 -- { common_pid: postgres [ 1891] } hitcount: 2 count: 32 -- { common_pid: gmain [ 8704] } hitcount: 2 count: 32 -- { common_pid: upstart-dbus-br [ 2740] } hitcount: 21 count: 21 -- { common_pid: nm-dispatcher.a [ 8696] } hitcount: 1 count: 16 -- { common_pid: indicator-datet [ 2904] } hitcount: 1 count: 16 -- { common_pid: gdbus [ 2998] } hitcount: 1 count: 16 -- { common_pid: rtkit-daemon [ 2052] } hitcount: 1 count: 8 -- { common_pid: init [ 1] } hitcount: 2 count: 2 -- -- Totals: -- Hits: 2116 -- Entries: 51 -- Dropped: 0 -- -- Similarly, if you key a hist trigger on syscall id, for example to -- gather and display a list of systemwide syscall hits, you can use -- the special .syscall modifier to display the syscall names rather -- than raw ids. The example below keeps a running total of syscall -- counts for the system during the run: -- -- # echo 'hist:key=id.syscall:val=hitcount' > \ -- /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/trigger -- -- # cat /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/hist -- # trigger info: hist:keys=id.syscall:vals=hitcount:sort=hitcount:size=2048 [active] -- -- { id: sys_fsync [ 74] } hitcount: 1 -- { id: sys_newuname [ 63] } hitcount: 1 -- { id: sys_prctl [157] } hitcount: 1 -- { id: sys_statfs [137] } hitcount: 1 -- { id: sys_symlink [ 88] } hitcount: 1 -- { id: sys_sendmmsg [307] } hitcount: 1 -- { id: sys_semctl [ 66] } hitcount: 1 -- { id: sys_readlink [ 89] } hitcount: 3 -- { id: sys_bind [ 49] } hitcount: 3 -- { id: sys_getsockname [ 51] } hitcount: 3 -- { id: sys_unlink [ 87] } hitcount: 3 -- { id: sys_rename [ 82] } hitcount: 4 -- { id: unknown_syscall [ 58] } hitcount: 4 -- { id: sys_connect [ 42] } hitcount: 4 -- { id: sys_getpid [ 39] } hitcount: 4 -- . -- . -- . -- { id: sys_rt_sigprocmask [ 14] } hitcount: 952 -- { id: sys_futex [202] } hitcount: 1534 -- { id: sys_write [ 1] } hitcount: 2689 -- { id: sys_setitimer [ 38] } hitcount: 2797 -- { id: sys_read [ 0] } hitcount: 3202 -- { id: sys_select [ 23] } hitcount: 3773 -- { id: sys_writev [ 20] } hitcount: 4531 -- { id: sys_poll [ 7] } hitcount: 8314 -- { id: sys_recvmsg [ 47] } hitcount: 13738 -- { id: sys_ioctl [ 16] } hitcount: 21843 -- -- Totals: -- Hits: 67612 -- Entries: 72 -- Dropped: 0 -- -- The syscall counts above provide a rough overall picture of system -- call activity on the system; we can see for example that the most -- popular system call on this system was the 'sys_ioctl' system call. -- -- We can use 'compound' keys to refine that number and provide some -- further insight as to which processes exactly contribute to the -- overall ioctl count. -- -- The command below keeps a hitcount for every unique combination of -- system call id and pid - the end result is essentially a table -- that keeps a per-pid sum of system call hits. The results are -- sorted using the system call id as the primary key, and the -- hitcount sum as the secondary key: -- -- # echo 'hist:key=id.syscall,common_pid.execname:val=hitcount:sort=id,hitcount' > \ -- /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/trigger -- -- # cat /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/hist -- # trigger info: hist:keys=id.syscall,common_pid.execname:vals=hitcount:sort=id.syscall,hitcount:size=2048 [active] -- -- { id: sys_read [ 0], common_pid: rtkit-daemon [ 1877] } hitcount: 1 -- { id: sys_read [ 0], common_pid: gdbus [ 2976] } hitcount: 1 -- { id: sys_read [ 0], common_pid: console-kit-dae [ 3400] } hitcount: 1 -- { id: sys_read [ 0], common_pid: postgres [ 1865] } hitcount: 1 -- { id: sys_read [ 0], common_pid: deja-dup-monito [ 3543] } hitcount: 2 -- { id: sys_read [ 0], common_pid: NetworkManager [ 890] } hitcount: 2 -- { id: sys_read [ 0], common_pid: evolution-calen [ 3048] } hitcount: 2 -- { id: sys_read [ 0], common_pid: postgres [ 1864] } hitcount: 2 -- { id: sys_read [ 0], common_pid: nm-applet [ 3022] } hitcount: 2 -- { id: sys_read [ 0], common_pid: whoopsie [ 1212] } hitcount: 2 -- . -- . -- . -- { id: sys_ioctl [ 16], common_pid: bash [ 8479] } hitcount: 1 -- { id: sys_ioctl [ 16], common_pid: bash [ 3472] } hitcount: 12 -- { id: sys_ioctl [ 16], common_pid: gnome-terminal [ 3199] } hitcount: 16 -- { id: sys_ioctl [ 16], common_pid: Xorg [ 1267] } hitcount: 1808 -- { id: sys_ioctl [ 16], common_pid: compiz [ 2994] } hitcount: 5580 -- . -- . -- . -- { id: sys_waitid [247], common_pid: upstart-dbus-br [ 2690] } hitcount: 3 -- { id: sys_waitid [247], common_pid: upstart-dbus-br [ 2688] } hitcount: 16 -- { id: sys_inotify_add_watch [254], common_pid: gmain [ 975] } hitcount: 2 -- { id: sys_inotify_add_watch [254], common_pid: gmain [ 3204] } hitcount: 4 -- { id: sys_inotify_add_watch [254], common_pid: gmain [ 2888] } hitcount: 4 -- { id: sys_inotify_add_watch [254], common_pid: gmain [ 3003] } hitcount: 4 -- { id: sys_inotify_add_watch [254], common_pid: gmain [ 2873] } hitcount: 4 -- { id: sys_inotify_add_watch [254], common_pid: gmain [ 3196] } hitcount: 6 -- { id: sys_openat [257], common_pid: java [ 2623] } hitcount: 2 -- { id: sys_eventfd2 [290], common_pid: ibus-ui-gtk3 [ 2760] } hitcount: 4 -- { id: sys_eventfd2 [290], common_pid: compiz [ 2994] } hitcount: 6 -- -- Totals: -- Hits: 31536 -- Entries: 323 -- Dropped: 0 -- -- The above list does give us a breakdown of the ioctl syscall by -- pid, but it also gives us quite a bit more than that, which we -- don't really care about at the moment. Since we know the syscall -- id for sys_ioctl (16, displayed next to the sys_ioctl name), we -- can use that to filter out all the other syscalls: -- -- # echo 'hist:key=id.syscall,common_pid.execname:val=hitcount:sort=id,hitcount if id == 16' > \ -- /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/trigger -- -- # cat /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/hist -- # trigger info: hist:keys=id.syscall,common_pid.execname:vals=hitcount:sort=id.syscall,hitcount:size=2048 if id == 16 [active] -- -- { id: sys_ioctl [ 16], common_pid: gmain [ 2769] } hitcount: 1 -- { id: sys_ioctl [ 16], common_pid: evolution-addre [ 8571] } hitcount: 1 -- { id: sys_ioctl [ 16], common_pid: gmain [ 3003] } hitcount: 1 -- { id: sys_ioctl [ 16], common_pid: gmain [ 2781] } hitcount: 1 -- { id: sys_ioctl [ 16], common_pid: gmain [ 2829] } hitcount: 1 -- { id: sys_ioctl [ 16], common_pid: bash [ 8726] } hitcount: 1 -- { id: sys_ioctl [ 16], common_pid: bash [ 8508] } hitcount: 1 -- { id: sys_ioctl [ 16], common_pid: gmain [ 2970] } hitcount: 1 -- { id: sys_ioctl [ 16], common_pid: gmain [ 2768] } hitcount: 1 -- . -- . -- . -- { id: sys_ioctl [ 16], common_pid: pool [ 8559] } hitcount: 45 -- { id: sys_ioctl [ 16], common_pid: pool [ 8555] } hitcount: 48 -- { id: sys_ioctl [ 16], common_pid: pool [ 8551] } hitcount: 48 -- { id: sys_ioctl [ 16], common_pid: avahi-daemon [ 896] } hitcount: 66 -- { id: sys_ioctl [ 16], common_pid: Xorg [ 1267] } hitcount: 26674 -- { id: sys_ioctl [ 16], common_pid: compiz [ 2994] } hitcount: 73443 -- -- Totals: -- Hits: 101162 -- Entries: 103 -- Dropped: 0 -- -- The above output shows that 'compiz' and 'Xorg' are far and away -- the heaviest ioctl callers (which might lead to questions about -- whether they really need to be making all those calls and to -- possible avenues for further investigation.) -- -- The compound key examples used a key and a sum value (hitcount) to -- sort the output, but we can just as easily use two keys instead. -- Here's an example where we use a compound key composed of the the -- common_pid and size event fields. Sorting with pid as the primary -- key and 'size' as the secondary key allows us to display an -- ordered summary of the recvfrom sizes, with counts, received by -- each process: -- -- # echo 'hist:key=common_pid.execname,size:val=hitcount:sort=common_pid,size' > \ -- /sys/kernel/debug/tracing/events/syscalls/sys_enter_recvfrom/trigger -- -- # cat /sys/kernel/debug/tracing/events/syscalls/sys_enter_recvfrom/hist -- # trigger info: hist:keys=common_pid.execname,size:vals=hitcount:sort=common_pid.execname,size:size=2048 [active] -- -- { common_pid: smbd [ 784], size: 4 } hitcount: 1 -- { common_pid: dnsmasq [ 1412], size: 4096 } hitcount: 672 -- { common_pid: postgres [ 1796], size: 1000 } hitcount: 6 -- { common_pid: postgres [ 1867], size: 1000 } hitcount: 10 -- { common_pid: bamfdaemon [ 2787], size: 28 } hitcount: 2 -- { common_pid: bamfdaemon [ 2787], size: 14360 } hitcount: 1 -- { common_pid: compiz [ 2994], size: 8 } hitcount: 1 -- { common_pid: compiz [ 2994], size: 20 } hitcount: 11 -- { common_pid: gnome-terminal [ 3199], size: 4 } hitcount: 2 -- { common_pid: firefox [ 8817], size: 4 } hitcount: 1 -- { common_pid: firefox [ 8817], size: 8 } hitcount: 5 -- { common_pid: firefox [ 8817], size: 588 } hitcount: 2 -- { common_pid: firefox [ 8817], size: 628 } hitcount: 1 -- { common_pid: firefox [ 8817], size: 6944 } hitcount: 1 -- { common_pid: firefox [ 8817], size: 408880 } hitcount: 2 -- { common_pid: firefox [ 8822], size: 8 } hitcount: 2 -- { common_pid: firefox [ 8822], size: 160 } hitcount: 2 -- { common_pid: firefox [ 8822], size: 320 } hitcount: 2 -- { common_pid: firefox [ 8822], size: 352 } hitcount: 1 -- . -- . -- . -- { common_pid: pool [ 8923], size: 1960 } hitcount: 10 -- { common_pid: pool [ 8923], size: 2048 } hitcount: 10 -- { common_pid: pool [ 8924], size: 1960 } hitcount: 10 -- { common_pid: pool [ 8924], size: 2048 } hitcount: 10 -- { common_pid: pool [ 8928], size: 1964 } hitcount: 4 -- { common_pid: pool [ 8928], size: 1965 } hitcount: 2 -- { common_pid: pool [ 8928], size: 2048 } hitcount: 6 -- { common_pid: pool [ 8929], size: 1982 } hitcount: 1 -- { common_pid: pool [ 8929], size: 2048 } hitcount: 1 -- -- Totals: -- Hits: 2016 -- Entries: 224 -- Dropped: 0 -- -- The above example also illustrates the fact that although a compound -- key is treated as a single entity for hashing purposes, the sub-keys -- it's composed of can be accessed independently. -- -- The next example uses a string field as the hash key and -- demonstrates how you can manually pause and continue a hist trigger. -- In this example, we'll aggregate fork counts and don't expect a -- large number of entries in the hash table, so we'll drop it to a -- much smaller number, say 256: -- -- # echo 'hist:key=child_comm:val=hitcount:size=256' > \ -- /sys/kernel/debug/tracing/events/sched/sched_process_fork/trigger -- -- # cat /sys/kernel/debug/tracing/events/sched/sched_process_fork/hist -- # trigger info: hist:keys=child_comm:vals=hitcount:sort=hitcount:size=256 [active] -- -- { child_comm: dconf worker } hitcount: 1 -- { child_comm: ibus-daemon } hitcount: 1 -- { child_comm: whoopsie } hitcount: 1 -- { child_comm: smbd } hitcount: 1 -- { child_comm: gdbus } hitcount: 1 -- { child_comm: kthreadd } hitcount: 1 -- { child_comm: dconf worker } hitcount: 1 -- { child_comm: evolution-alarm } hitcount: 2 -- { child_comm: Socket Thread } hitcount: 2 -- { child_comm: postgres } hitcount: 2 -- { child_comm: bash } hitcount: 3 -- { child_comm: compiz } hitcount: 3 -- { child_comm: evolution-sourc } hitcount: 4 -- { child_comm: dhclient } hitcount: 4 -- { child_comm: pool } hitcount: 5 -- { child_comm: nm-dispatcher.a } hitcount: 8 -- { child_comm: firefox } hitcount: 8 -- { child_comm: dbus-daemon } hitcount: 8 -- { child_comm: glib-pacrunner } hitcount: 10 -- { child_comm: evolution } hitcount: 23 -- -- Totals: -- Hits: 89 -- Entries: 20 -- Dropped: 0 -- -- If we want to pause the hist trigger, we can simply append :pause to -- the command that started the trigger. Notice that the trigger info -- displays as [paused]: -- -- # echo 'hist:key=child_comm:val=hitcount:size=256:pause' >> \ -- /sys/kernel/debug/tracing/events/sched/sched_process_fork/trigger -- -- # cat /sys/kernel/debug/tracing/events/sched/sched_process_fork/hist -- # trigger info: hist:keys=child_comm:vals=hitcount:sort=hitcount:size=256 [paused] -- -- { child_comm: dconf worker } hitcount: 1 -- { child_comm: kthreadd } hitcount: 1 -- { child_comm: dconf worker } hitcount: 1 -- { child_comm: gdbus } hitcount: 1 -- { child_comm: ibus-daemon } hitcount: 1 -- { child_comm: Socket Thread } hitcount: 2 -- { child_comm: evolution-alarm } hitcount: 2 -- { child_comm: smbd } hitcount: 2 -- { child_comm: bash } hitcount: 3 -- { child_comm: whoopsie } hitcount: 3 -- { child_comm: compiz } hitcount: 3 -- { child_comm: evolution-sourc } hitcount: 4 -- { child_comm: pool } hitcount: 5 -- { child_comm: postgres } hitcount: 6 -- { child_comm: firefox } hitcount: 8 -- { child_comm: dhclient } hitcount: 10 -- { child_comm: emacs } hitcount: 12 -- { child_comm: dbus-daemon } hitcount: 20 -- { child_comm: nm-dispatcher.a } hitcount: 20 -- { child_comm: evolution } hitcount: 35 -- { child_comm: glib-pacrunner } hitcount: 59 -- -- Totals: -- Hits: 199 -- Entries: 21 -- Dropped: 0 -- -- To manually continue having the trigger aggregate events, append -- :cont instead. Notice that the trigger info displays as [active] -- again, and the data has changed: -- -- # echo 'hist:key=child_comm:val=hitcount:size=256:cont' >> \ -- /sys/kernel/debug/tracing/events/sched/sched_process_fork/trigger -- -- # cat /sys/kernel/debug/tracing/events/sched/sched_process_fork/hist -- # trigger info: hist:keys=child_comm:vals=hitcount:sort=hitcount:size=256 [active] -- -- { child_comm: dconf worker } hitcount: 1 -- { child_comm: dconf worker } hitcount: 1 -- { child_comm: kthreadd } hitcount: 1 -- { child_comm: gdbus } hitcount: 1 -- { child_comm: ibus-daemon } hitcount: 1 -- { child_comm: Socket Thread } hitcount: 2 -- { child_comm: evolution-alarm } hitcount: 2 -- { child_comm: smbd } hitcount: 2 -- { child_comm: whoopsie } hitcount: 3 -- { child_comm: compiz } hitcount: 3 -- { child_comm: evolution-sourc } hitcount: 4 -- { child_comm: bash } hitcount: 5 -- { child_comm: pool } hitcount: 5 -- { child_comm: postgres } hitcount: 6 -- { child_comm: firefox } hitcount: 8 -- { child_comm: dhclient } hitcount: 11 -- { child_comm: emacs } hitcount: 12 -- { child_comm: dbus-daemon } hitcount: 22 -- { child_comm: nm-dispatcher.a } hitcount: 22 -- { child_comm: evolution } hitcount: 35 -- { child_comm: glib-pacrunner } hitcount: 59 -- -- Totals: -- Hits: 206 -- Entries: 21 -- Dropped: 0 -- -- The previous example showed how to start and stop a hist trigger by -- appending 'pause' and 'continue' to the hist trigger command. A -- hist trigger can also be started in a paused state by initially -- starting the trigger with ':pause' appended. This allows you to -- start the trigger only when you're ready to start collecting data -- and not before. For example, you could start the trigger in a -- paused state, then unpause it and do something you want to measure, -- then pause the trigger again when done. -- -- Of course, doing this manually can be difficult and error-prone, but -- it is possible to automatically start and stop a hist trigger based -- on some condition, via the enable_hist and disable_hist triggers. -- -- For example, suppose we wanted to take a look at the relative -- weights in terms of skb length for each callpath that leads to a -- netif_receieve_skb event when downloading a decent-sized file using -- wget. -- -- First we set up an initially paused stacktrace trigger on the -- netif_receive_skb event: -- -- # echo 'hist:key=stacktrace:vals=len:pause' > \ -- /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger -- -- Next, we set up an 'enable_hist' trigger on the sched_process_exec -- event, with an 'if filename==/usr/bin/wget' filter. The effect of -- this new trigger is that it will 'unpause' the hist trigger we just -- set up on netif_receive_skb if and only if it sees a -- sched_process_exec event with a filename of '/usr/bin/wget'. When -- that happens, all netif_receive_skb events are aggregated into a -- hash table keyed on stacktrace: -- -- # echo 'enable_hist:net:netif_receive_skb if filename==/usr/bin/wget' > \ -- /sys/kernel/debug/tracing/events/sched/sched_process_exec/trigger -- -- The aggregation continues until the netif_receive_skb is paused -- again, which is what the following disable_hist event does by -- creating a similar setup on the sched_process_exit event, using the -- filter 'comm==wget': -- -- # echo 'disable_hist:net:netif_receive_skb if comm==wget' > \ -- /sys/kernel/debug/tracing/events/sched/sched_process_exit/trigger -- -- Whenever a process exits and the comm field of the disable_hist -- trigger filter matches 'comm==wget', the netif_receive_skb hist -- trigger is disabled. -- -- The overall effect is that netif_receive_skb events are aggregated -- into the hash table for only the duration of the wget. Executing a -- wget command and then listing the 'hist' file will display the -- output generated by the wget command: -- -- $ wget https://www.kernel.org/pub/linux/kernel/v3.x/patch-3.19.xz -- -- # cat /sys/kernel/debug/tracing/events/net/netif_receive_skb/hist -- # trigger info: hist:keys=stacktrace:vals=len:sort=hitcount:size=2048 [paused] -- -- { stacktrace: -- __netif_receive_skb_core+0x46d/0x990 -- __netif_receive_skb+0x18/0x60 -- netif_receive_skb_internal+0x23/0x90 -- napi_gro_receive+0xc8/0x100 -- ieee80211_deliver_skb+0xd6/0x270 [mac80211] -- ieee80211_rx_handlers+0xccf/0x22f0 [mac80211] -- ieee80211_prepare_and_rx_handle+0x4e7/0xc40 [mac80211] -- ieee80211_rx+0x31d/0x900 [mac80211] -- iwlagn_rx_reply_rx+0x3db/0x6f0 [iwldvm] -- iwl_rx_dispatch+0x8e/0xf0 [iwldvm] -- iwl_pcie_irq_handler+0xe3c/0x12f0 [iwlwifi] -- irq_thread_fn+0x20/0x50 -- irq_thread+0x11f/0x150 -- kthread+0xd2/0xf0 -- ret_from_fork+0x42/0x70 -- } hitcount: 85 len: 28884 -- { stacktrace: -- __netif_receive_skb_core+0x46d/0x990 -- __netif_receive_skb+0x18/0x60 -- netif_receive_skb_internal+0x23/0x90 -- napi_gro_complete+0xa4/0xe0 -- dev_gro_receive+0x23a/0x360 -- napi_gro_receive+0x30/0x100 -- ieee80211_deliver_skb+0xd6/0x270 [mac80211] -- ieee80211_rx_handlers+0xccf/0x22f0 [mac80211] -- ieee80211_prepare_and_rx_handle+0x4e7/0xc40 [mac80211] -- ieee80211_rx+0x31d/0x900 [mac80211] -- iwlagn_rx_reply_rx+0x3db/0x6f0 [iwldvm] -- iwl_rx_dispatch+0x8e/0xf0 [iwldvm] -- iwl_pcie_irq_handler+0xe3c/0x12f0 [iwlwifi] -- irq_thread_fn+0x20/0x50 -- irq_thread+0x11f/0x150 -- kthread+0xd2/0xf0 -- } hitcount: 98 len: 664329 -- { stacktrace: -- __netif_receive_skb_core+0x46d/0x990 -- __netif_receive_skb+0x18/0x60 -- process_backlog+0xa8/0x150 -- net_rx_action+0x15d/0x340 -- __do_softirq+0x114/0x2c0 -- do_softirq_own_stack+0x1c/0x30 -- do_softirq+0x65/0x70 -- __local_bh_enable_ip+0xb5/0xc0 -- ip_finish_output+0x1f4/0x840 -- ip_output+0x6b/0xc0 -- ip_local_out_sk+0x31/0x40 -- ip_send_skb+0x1a/0x50 -- udp_send_skb+0x173/0x2a0 -- udp_sendmsg+0x2bf/0x9f0 -- inet_sendmsg+0x64/0xa0 -- sock_sendmsg+0x3d/0x50 -- } hitcount: 115 len: 13030 -- { stacktrace: -- __netif_receive_skb_core+0x46d/0x990 -- __netif_receive_skb+0x18/0x60 -- netif_receive_skb_internal+0x23/0x90 -- napi_gro_complete+0xa4/0xe0 -- napi_gro_flush+0x6d/0x90 -- iwl_pcie_irq_handler+0x92a/0x12f0 [iwlwifi] -- irq_thread_fn+0x20/0x50 -- irq_thread+0x11f/0x150 -- kthread+0xd2/0xf0 -- ret_from_fork+0x42/0x70 -- } hitcount: 934 len: 5512212 -- -- Totals: -- Hits: 1232 -- Entries: 4 -- Dropped: 0 -- -- The above shows all the netif_receive_skb callpaths and their total -- lengths for the duration of the wget command. -- -- The 'clear' hist trigger param can be used to clear the hash table. -- Suppose we wanted to try another run of the previous example but -- this time also wanted to see the complete list of events that went -- into the histogram. In order to avoid having to set everything up -- again, we can just clear the histogram first: -- -- # echo 'hist:key=stacktrace:vals=len:clear' >> \ -- /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger -- -- Just to verify that it is in fact cleared, here's what we now see in -- the hist file: -- -- # cat /sys/kernel/debug/tracing/events/net/netif_receive_skb/hist -- # trigger info: hist:keys=stacktrace:vals=len:sort=hitcount:size=2048 [paused] -- -- Totals: -- Hits: 0 -- Entries: 0 -- Dropped: 0 -- -- Since we want to see the detailed list of every netif_receive_skb -- event occurring during the new run, which are in fact the same -- events being aggregated into the hash table, we add some additional -- 'enable_event' events to the triggering sched_process_exec and -- sched_process_exit events as such: -- -- # echo 'enable_event:net:netif_receive_skb if filename==/usr/bin/wget' > \ -- /sys/kernel/debug/tracing/events/sched/sched_process_exec/trigger -- -- # echo 'disable_event:net:netif_receive_skb if comm==wget' > \ -- /sys/kernel/debug/tracing/events/sched/sched_process_exit/trigger -- -- If you read the trigger files for the sched_process_exec and -- sched_process_exit triggers, you should see two triggers for each: -- one enabling/disabling the hist aggregation and the other -- enabling/disabling the logging of events: -- -- # cat /sys/kernel/debug/tracing/events/sched/sched_process_exec/trigger -- enable_event:net:netif_receive_skb:unlimited if filename==/usr/bin/wget -- enable_hist:net:netif_receive_skb:unlimited if filename==/usr/bin/wget -- -- # cat /sys/kernel/debug/tracing/events/sched/sched_process_exit/trigger -- enable_event:net:netif_receive_skb:unlimited if comm==wget -- disable_hist:net:netif_receive_skb:unlimited if comm==wget -- -- In other words, whenever either of the sched_process_exec or -- sched_process_exit events is hit and matches 'wget', it enables or -- disables both the histogram and the event log, and what you end up -- with is a hash table and set of events just covering the specified -- duration. Run the wget command again: -- -- $ wget https://www.kernel.org/pub/linux/kernel/v3.x/patch-3.19.xz -- -- Displaying the 'hist' file should show something similar to what you -- saw in the last run, but this time you should also see the -- individual events in the trace file: -- -- # cat /sys/kernel/debug/tracing/trace -- -- # tracer: nop -- # -- # entries-in-buffer/entries-written: 183/1426 #P:4 -- # -- # _-----=> irqs-off -- # / _----=> need-resched -- # | / _---=> hardirq/softirq -- # || / _--=> preempt-depth -- # ||| / delay -- # TASK-PID CPU# |||| TIMESTAMP FUNCTION -- # | | | |||| | | -- wget-15108 [000] ..s1 31769.606929: netif_receive_skb: dev=lo skbaddr=ffff88009c353100 len=60 -- wget-15108 [000] ..s1 31769.606999: netif_receive_skb: dev=lo skbaddr=ffff88009c353200 len=60 -- dnsmasq-1382 [000] ..s1 31769.677652: netif_receive_skb: dev=lo skbaddr=ffff88009c352b00 len=130 -- dnsmasq-1382 [000] ..s1 31769.685917: netif_receive_skb: dev=lo skbaddr=ffff88009c352200 len=138 -- ##### CPU 2 buffer started #### -- irq/29-iwlwifi-559 [002] ..s. 31772.031529: netif_receive_skb: dev=wlan0 skbaddr=ffff88009d433d00 len=2948 -- irq/29-iwlwifi-559 [002] ..s. 31772.031572: netif_receive_skb: dev=wlan0 skbaddr=ffff88009d432200 len=1500 -- irq/29-iwlwifi-559 [002] ..s. 31772.032196: netif_receive_skb: dev=wlan0 skbaddr=ffff88009d433100 len=2948 -- irq/29-iwlwifi-559 [002] ..s. 31772.032761: netif_receive_skb: dev=wlan0 skbaddr=ffff88009d433000 len=2948 -- irq/29-iwlwifi-559 [002] ..s. 31772.033220: netif_receive_skb: dev=wlan0 skbaddr=ffff88009d432e00 len=1500 -- . -- . -- . -- -- The following example demonstrates how multiple hist triggers can be -- attached to a given event. This capability can be useful for -- creating a set of different summaries derived from the same set of -- events, or for comparing the effects of different filters, among -- other things. -- -- # echo 'hist:keys=skbaddr.hex:vals=len if len < 0' >> \ -- /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger -- # echo 'hist:keys=skbaddr.hex:vals=len if len > 4096' >> \ -- /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger -- # echo 'hist:keys=skbaddr.hex:vals=len if len == 256' >> \ -- /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger -- # echo 'hist:keys=skbaddr.hex:vals=len' >> \ -- /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger -- # echo 'hist:keys=len:vals=common_preempt_count' >> \ -- /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger -- -- The above set of commands create four triggers differing only in -- their filters, along with a completely different though fairly -- nonsensical trigger. Note that in order to append multiple hist -- triggers to the same file, you should use the '>>' operator to -- append them ('>' will also add the new hist trigger, but will remove -- any existing hist triggers beforehand). -- -- Displaying the contents of the 'hist' file for the event shows the -- contents of all five histograms: -- -- # cat /sys/kernel/debug/tracing/events/net/netif_receive_skb/hist -- -- # event histogram -- # -- # trigger info: hist:keys=len:vals=hitcount,common_preempt_count:sort=hitcount:size=2048 [active] -- # -- -- { len: 176 } hitcount: 1 common_preempt_count: 0 -- { len: 223 } hitcount: 1 common_preempt_count: 0 -- { len: 4854 } hitcount: 1 common_preempt_count: 0 -- { len: 395 } hitcount: 1 common_preempt_count: 0 -- { len: 177 } hitcount: 1 common_preempt_count: 0 -- { len: 446 } hitcount: 1 common_preempt_count: 0 -- { len: 1601 } hitcount: 1 common_preempt_count: 0 -- . -- . -- . -- { len: 1280 } hitcount: 66 common_preempt_count: 0 -- { len: 116 } hitcount: 81 common_preempt_count: 40 -- { len: 708 } hitcount: 112 common_preempt_count: 0 -- { len: 46 } hitcount: 221 common_preempt_count: 0 -- { len: 1264 } hitcount: 458 common_preempt_count: 0 -- -- Totals: -- Hits: 1428 -- Entries: 147 -- Dropped: 0 -- -- -- # event histogram -- # -- # trigger info: hist:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 [active] -- # -- -- { skbaddr: ffff8800baee5e00 } hitcount: 1 len: 130 -- { skbaddr: ffff88005f3d5600 } hitcount: 1 len: 1280 -- { skbaddr: ffff88005f3d4900 } hitcount: 1 len: 1280 -- { skbaddr: ffff88009fed6300 } hitcount: 1 len: 115 -- { skbaddr: ffff88009fe0ad00 } hitcount: 1 len: 115 -- { skbaddr: ffff88008cdb1900 } hitcount: 1 len: 46 -- { skbaddr: ffff880064b5ef00 } hitcount: 1 len: 118 -- { skbaddr: ffff880044e3c700 } hitcount: 1 len: 60 -- { skbaddr: ffff880100065900 } hitcount: 1 len: 46 -- { skbaddr: ffff8800d46bd500 } hitcount: 1 len: 116 -- { skbaddr: ffff88005f3d5f00 } hitcount: 1 len: 1280 -- { skbaddr: ffff880100064700 } hitcount: 1 len: 365 -- { skbaddr: ffff8800badb6f00 } hitcount: 1 len: 60 -- . -- . -- . -- { skbaddr: ffff88009fe0be00 } hitcount: 27 len: 24677 -- { skbaddr: ffff88009fe0a400 } hitcount: 27 len: 23052 -- { skbaddr: ffff88009fe0b700 } hitcount: 31 len: 25589 -- { skbaddr: ffff88009fe0b600 } hitcount: 32 len: 27326 -- { skbaddr: ffff88006a462800 } hitcount: 68 len: 71678 -- { skbaddr: ffff88006a463700 } hitcount: 70 len: 72678 -- { skbaddr: ffff88006a462b00 } hitcount: 71 len: 77589 -- { skbaddr: ffff88006a463600 } hitcount: 73 len: 71307 -- { skbaddr: ffff88006a462200 } hitcount: 81 len: 81032 -- -- Totals: -- Hits: 1451 -- Entries: 318 -- Dropped: 0 -- -- -- # event histogram -- # -- # trigger info: hist:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 if len == 256 [active] -- # -- -- -- Totals: -- Hits: 0 -- Entries: 0 -- Dropped: 0 -- -- -- # event histogram -- # -- # trigger info: hist:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 if len > 4096 [active] -- # -- -- { skbaddr: ffff88009fd2c300 } hitcount: 1 len: 7212 -- { skbaddr: ffff8800d2bcce00 } hitcount: 1 len: 7212 -- { skbaddr: ffff8800d2bcd700 } hitcount: 1 len: 7212 -- { skbaddr: ffff8800d2bcda00 } hitcount: 1 len: 21492 -- { skbaddr: ffff8800ae2e2d00 } hitcount: 1 len: 7212 -- { skbaddr: ffff8800d2bcdb00 } hitcount: 1 len: 7212 -- { skbaddr: ffff88006a4df500 } hitcount: 1 len: 4854 -- { skbaddr: ffff88008ce47b00 } hitcount: 1 len: 18636 -- { skbaddr: ffff8800ae2e2200 } hitcount: 1 len: 12924 -- { skbaddr: ffff88005f3e1000 } hitcount: 1 len: 4356 -- { skbaddr: ffff8800d2bcdc00 } hitcount: 2 len: 24420 -- { skbaddr: ffff8800d2bcc200 } hitcount: 2 len: 12996 -- -- Totals: -- Hits: 14 -- Entries: 12 -- Dropped: 0 -- -- -- # event histogram -- # -- # trigger info: hist:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 if len < 0 [active] -- # -- -- -- Totals: -- Hits: 0 -- Entries: 0 -- Dropped: 0 -- -- Named triggers can be used to have triggers share a common set of -- histogram data. This capability is mostly useful for combining the -- output of events generated by tracepoints contained inside inline -- functions, but names can be used in a hist trigger on any event. -- For example, these two triggers when hit will update the same 'len' -- field in the shared 'foo' histogram data: -- -- # echo 'hist:name=foo:keys=skbaddr.hex:vals=len' > \ -- /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger -- # echo 'hist:name=foo:keys=skbaddr.hex:vals=len' > \ -- /sys/kernel/debug/tracing/events/net/netif_rx/trigger -- -- You can see that they're updating common histogram data by reading -- each event's hist files at the same time: -- -- # cat /sys/kernel/debug/tracing/events/net/netif_receive_skb/hist; -- cat /sys/kernel/debug/tracing/events/net/netif_rx/hist -- -- # event histogram -- # -- # trigger info: hist:name=foo:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 [active] -- # -- -- { skbaddr: ffff88000ad53500 } hitcount: 1 len: 46 -- { skbaddr: ffff8800af5a1500 } hitcount: 1 len: 76 -- { skbaddr: ffff8800d62a1900 } hitcount: 1 len: 46 -- { skbaddr: ffff8800d2bccb00 } hitcount: 1 len: 468 -- { skbaddr: ffff8800d3c69900 } hitcount: 1 len: 46 -- { skbaddr: ffff88009ff09100 } hitcount: 1 len: 52 -- { skbaddr: ffff88010f13ab00 } hitcount: 1 len: 168 -- { skbaddr: ffff88006a54f400 } hitcount: 1 len: 46 -- { skbaddr: ffff8800d2bcc500 } hitcount: 1 len: 260 -- { skbaddr: ffff880064505000 } hitcount: 1 len: 46 -- { skbaddr: ffff8800baf24e00 } hitcount: 1 len: 32 -- { skbaddr: ffff88009fe0ad00 } hitcount: 1 len: 46 -- { skbaddr: ffff8800d3edff00 } hitcount: 1 len: 44 -- { skbaddr: ffff88009fe0b400 } hitcount: 1 len: 168 -- { skbaddr: ffff8800a1c55a00 } hitcount: 1 len: 40 -- { skbaddr: ffff8800d2bcd100 } hitcount: 1 len: 40 -- { skbaddr: ffff880064505f00 } hitcount: 1 len: 174 -- { skbaddr: ffff8800a8bff200 } hitcount: 1 len: 160 -- { skbaddr: ffff880044e3cc00 } hitcount: 1 len: 76 -- { skbaddr: ffff8800a8bfe700 } hitcount: 1 len: 46 -- { skbaddr: ffff8800d2bcdc00 } hitcount: 1 len: 32 -- { skbaddr: ffff8800a1f64800 } hitcount: 1 len: 46 -- { skbaddr: ffff8800d2bcde00 } hitcount: 1 len: 988 -- { skbaddr: ffff88006a5dea00 } hitcount: 1 len: 46 -- { skbaddr: ffff88002e37a200 } hitcount: 1 len: 44 -- { skbaddr: ffff8800a1f32c00 } hitcount: 2 len: 676 -- { skbaddr: ffff88000ad52600 } hitcount: 2 len: 107 -- { skbaddr: ffff8800a1f91e00 } hitcount: 2 len: 92 -- { skbaddr: ffff8800af5a0200 } hitcount: 2 len: 142 -- { skbaddr: ffff8800d2bcc600 } hitcount: 2 len: 220 -- { skbaddr: ffff8800ba36f500 } hitcount: 2 len: 92 -- { skbaddr: ffff8800d021f800 } hitcount: 2 len: 92 -- { skbaddr: ffff8800a1f33600 } hitcount: 2 len: 675 -- { skbaddr: ffff8800a8bfff00 } hitcount: 3 len: 138 -- { skbaddr: ffff8800d62a1300 } hitcount: 3 len: 138 -- { skbaddr: ffff88002e37a100 } hitcount: 4 len: 184 -- { skbaddr: ffff880064504400 } hitcount: 4 len: 184 -- { skbaddr: ffff8800a8bfec00 } hitcount: 4 len: 184 -- { skbaddr: ffff88000ad53700 } hitcount: 5 len: 230 -- { skbaddr: ffff8800d2bcdb00 } hitcount: 5 len: 196 -- { skbaddr: ffff8800a1f90000 } hitcount: 6 len: 276 -- { skbaddr: ffff88006a54f900 } hitcount: 6 len: 276 -- -- Totals: -- Hits: 81 -- Entries: 42 -- Dropped: 0 -- # event histogram -- # -- # trigger info: hist:name=foo:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 [active] -- # -- -- { skbaddr: ffff88000ad53500 } hitcount: 1 len: 46 -- { skbaddr: ffff8800af5a1500 } hitcount: 1 len: 76 -- { skbaddr: ffff8800d62a1900 } hitcount: 1 len: 46 -- { skbaddr: ffff8800d2bccb00 } hitcount: 1 len: 468 -- { skbaddr: ffff8800d3c69900 } hitcount: 1 len: 46 -- { skbaddr: ffff88009ff09100 } hitcount: 1 len: 52 -- { skbaddr: ffff88010f13ab00 } hitcount: 1 len: 168 -- { skbaddr: ffff88006a54f400 } hitcount: 1 len: 46 -- { skbaddr: ffff8800d2bcc500 } hitcount: 1 len: 260 -- { skbaddr: ffff880064505000 } hitcount: 1 len: 46 -- { skbaddr: ffff8800baf24e00 } hitcount: 1 len: 32 -- { skbaddr: ffff88009fe0ad00 } hitcount: 1 len: 46 -- { skbaddr: ffff8800d3edff00 } hitcount: 1 len: 44 -- { skbaddr: ffff88009fe0b400 } hitcount: 1 len: 168 -- { skbaddr: ffff8800a1c55a00 } hitcount: 1 len: 40 -- { skbaddr: ffff8800d2bcd100 } hitcount: 1 len: 40 -- { skbaddr: ffff880064505f00 } hitcount: 1 len: 174 -- { skbaddr: ffff8800a8bff200 } hitcount: 1 len: 160 -- { skbaddr: ffff880044e3cc00 } hitcount: 1 len: 76 -- { skbaddr: ffff8800a8bfe700 } hitcount: 1 len: 46 -- { skbaddr: ffff8800d2bcdc00 } hitcount: 1 len: 32 -- { skbaddr: ffff8800a1f64800 } hitcount: 1 len: 46 -- { skbaddr: ffff8800d2bcde00 } hitcount: 1 len: 988 -- { skbaddr: ffff88006a5dea00 } hitcount: 1 len: 46 -- { skbaddr: ffff88002e37a200 } hitcount: 1 len: 44 -- { skbaddr: ffff8800a1f32c00 } hitcount: 2 len: 676 -- { skbaddr: ffff88000ad52600 } hitcount: 2 len: 107 -- { skbaddr: ffff8800a1f91e00 } hitcount: 2 len: 92 -- { skbaddr: ffff8800af5a0200 } hitcount: 2 len: 142 -- { skbaddr: ffff8800d2bcc600 } hitcount: 2 len: 220 -- { skbaddr: ffff8800ba36f500 } hitcount: 2 len: 92 -- { skbaddr: ffff8800d021f800 } hitcount: 2 len: 92 -- { skbaddr: ffff8800a1f33600 } hitcount: 2 len: 675 -- { skbaddr: ffff8800a8bfff00 } hitcount: 3 len: 138 -- { skbaddr: ffff8800d62a1300 } hitcount: 3 len: 138 -- { skbaddr: ffff88002e37a100 } hitcount: 4 len: 184 -- { skbaddr: ffff880064504400 } hitcount: 4 len: 184 -- { skbaddr: ffff8800a8bfec00 } hitcount: 4 len: 184 -- { skbaddr: ffff88000ad53700 } hitcount: 5 len: 230 -- { skbaddr: ffff8800d2bcdb00 } hitcount: 5 len: 196 -- { skbaddr: ffff8800a1f90000 } hitcount: 6 len: 276 -- { skbaddr: ffff88006a54f900 } hitcount: 6 len: 276 -- -- Totals: -- Hits: 81 -- Entries: 42 -- Dropped: 0 -- -- And here's an example that shows how to combine histogram data from -- any two events even if they don't share any 'compatible' fields -- other than 'hitcount' and 'stacktrace'. These commands create a -- couple of triggers named 'bar' using those fields: -- -- # echo 'hist:name=bar:key=stacktrace:val=hitcount' > \ -- /sys/kernel/debug/tracing/events/sched/sched_process_fork/trigger -- # echo 'hist:name=bar:key=stacktrace:val=hitcount' > \ -- /sys/kernel/debug/tracing/events/net/netif_rx/trigger -- -- And displaying the output of either shows some interesting if -- somewhat confusing output: -- -- # cat /sys/kernel/debug/tracing/events/sched/sched_process_fork/hist -- # cat /sys/kernel/debug/tracing/events/net/netif_rx/hist -- -- # event histogram -- # -- # trigger info: hist:name=bar:keys=stacktrace:vals=hitcount:sort=hitcount:size=2048 [active] -- # -- -- { stacktrace: -- _do_fork+0x18e/0x330 -- kernel_thread+0x29/0x30 -- kthreadd+0x154/0x1b0 -- ret_from_fork+0x3f/0x70 -- } hitcount: 1 -- { stacktrace: -- netif_rx_internal+0xb2/0xd0 -- netif_rx_ni+0x20/0x70 -- dev_loopback_xmit+0xaa/0xd0 -- ip_mc_output+0x126/0x240 -- ip_local_out_sk+0x31/0x40 -- igmp_send_report+0x1e9/0x230 -- igmp_timer_expire+0xe9/0x120 -- call_timer_fn+0x39/0xf0 -- run_timer_softirq+0x1e1/0x290 -- __do_softirq+0xfd/0x290 -- irq_exit+0x98/0xb0 -- smp_apic_timer_interrupt+0x4a/0x60 -- apic_timer_interrupt+0x6d/0x80 -- cpuidle_enter+0x17/0x20 -- call_cpuidle+0x3b/0x60 -- cpu_startup_entry+0x22d/0x310 -- } hitcount: 1 -- { stacktrace: -- netif_rx_internal+0xb2/0xd0 -- netif_rx_ni+0x20/0x70 -- dev_loopback_xmit+0xaa/0xd0 -- ip_mc_output+0x17f/0x240 -- ip_local_out_sk+0x31/0x40 -- ip_send_skb+0x1a/0x50 -- udp_send_skb+0x13e/0x270 -- udp_sendmsg+0x2bf/0x980 -- inet_sendmsg+0x67/0xa0 -- sock_sendmsg+0x38/0x50 -- SYSC_sendto+0xef/0x170 -- SyS_sendto+0xe/0x10 -- entry_SYSCALL_64_fastpath+0x12/0x6a -- } hitcount: 2 -- { stacktrace: -- netif_rx_internal+0xb2/0xd0 -- netif_rx+0x1c/0x60 -- loopback_xmit+0x6c/0xb0 -- dev_hard_start_xmit+0x219/0x3a0 -- __dev_queue_xmit+0x415/0x4f0 -- dev_queue_xmit_sk+0x13/0x20 -- ip_finish_output2+0x237/0x340 -- ip_finish_output+0x113/0x1d0 -- ip_output+0x66/0xc0 -- ip_local_out_sk+0x31/0x40 -- ip_send_skb+0x1a/0x50 -- udp_send_skb+0x16d/0x270 -- udp_sendmsg+0x2bf/0x980 -- inet_sendmsg+0x67/0xa0 -- sock_sendmsg+0x38/0x50 -- ___sys_sendmsg+0x14e/0x270 -- } hitcount: 76 -- { stacktrace: -- netif_rx_internal+0xb2/0xd0 -- netif_rx+0x1c/0x60 -- loopback_xmit+0x6c/0xb0 -- dev_hard_start_xmit+0x219/0x3a0 -- __dev_queue_xmit+0x415/0x4f0 -- dev_queue_xmit_sk+0x13/0x20 -- ip_finish_output2+0x237/0x340 -- ip_finish_output+0x113/0x1d0 -- ip_output+0x66/0xc0 -- ip_local_out_sk+0x31/0x40 -- ip_send_skb+0x1a/0x50 -- udp_send_skb+0x16d/0x270 -- udp_sendmsg+0x2bf/0x980 -- inet_sendmsg+0x67/0xa0 -- sock_sendmsg+0x38/0x50 -- ___sys_sendmsg+0x269/0x270 -- } hitcount: 77 -- { stacktrace: -- netif_rx_internal+0xb2/0xd0 -- netif_rx+0x1c/0x60 -- loopback_xmit+0x6c/0xb0 -- dev_hard_start_xmit+0x219/0x3a0 -- __dev_queue_xmit+0x415/0x4f0 -- dev_queue_xmit_sk+0x13/0x20 -- ip_finish_output2+0x237/0x340 -- ip_finish_output+0x113/0x1d0 -- ip_output+0x66/0xc0 -- ip_local_out_sk+0x31/0x40 -- ip_send_skb+0x1a/0x50 -- udp_send_skb+0x16d/0x270 -- udp_sendmsg+0x2bf/0x980 -- inet_sendmsg+0x67/0xa0 -- sock_sendmsg+0x38/0x50 -- SYSC_sendto+0xef/0x170 -- } hitcount: 88 -- { stacktrace: -- _do_fork+0x18e/0x330 -- SyS_clone+0x19/0x20 -- entry_SYSCALL_64_fastpath+0x12/0x6a -- } hitcount: 244 -- -- Totals: -- Hits: 489 -- Entries: 7 -- Dropped: 0 -+ See Documentation/trace/histogram.txt for details and examples. ---- /dev/null -+++ b/Documentation/trace/histogram.txt -@@ -0,0 +1,1568 @@ -+ Event Histograms -+ -+ Documentation written by Tom Zanussi -+ -+1. Introduction -+=============== -+ -+ Histogram triggers are special event triggers that can be used to -+ aggregate trace event data into histograms. For information on -+ trace events and event triggers, see Documentation/trace/events.txt. -+ -+ -+2. Histogram Trigger Command -+============================ -+ -+ A histogram trigger command is an event trigger command that -+ aggregates event hits into a hash table keyed on one or more trace -+ event format fields (or stacktrace) and a set of running totals -+ derived from one or more trace event format fields and/or event -+ counts (hitcount). -+ -+ The format of a hist trigger is as follows: -+ -+ hist:keys=[:values=] -+ [:sort=][:size=#entries][:pause][:continue] -+ [:clear][:name=histname1] [if ] -+ -+ When a matching event is hit, an entry is added to a hash table -+ using the key(s) and value(s) named. Keys and values correspond to -+ fields in the event's format description. Values must correspond to -+ numeric fields - on an event hit, the value(s) will be added to a -+ sum kept for that field. The special string 'hitcount' can be used -+ in place of an explicit value field - this is simply a count of -+ event hits. If 'values' isn't specified, an implicit 'hitcount' -+ value will be automatically created and used as the only value. -+ Keys can be any field, or the special string 'stacktrace', which -+ will use the event's kernel stacktrace as the key. The keywords -+ 'keys' or 'key' can be used to specify keys, and the keywords -+ 'values', 'vals', or 'val' can be used to specify values. Compound -+ keys consisting of up to two fields can be specified by the 'keys' -+ keyword. Hashing a compound key produces a unique entry in the -+ table for each unique combination of component keys, and can be -+ useful for providing more fine-grained summaries of event data. -+ Additionally, sort keys consisting of up to two fields can be -+ specified by the 'sort' keyword. If more than one field is -+ specified, the result will be a 'sort within a sort': the first key -+ is taken to be the primary sort key and the second the secondary -+ key. If a hist trigger is given a name using the 'name' parameter, -+ its histogram data will be shared with other triggers of the same -+ name, and trigger hits will update this common data. Only triggers -+ with 'compatible' fields can be combined in this way; triggers are -+ 'compatible' if the fields named in the trigger share the same -+ number and type of fields and those fields also have the same names. -+ Note that any two events always share the compatible 'hitcount' and -+ 'stacktrace' fields and can therefore be combined using those -+ fields, however pointless that may be. -+ -+ 'hist' triggers add a 'hist' file to each event's subdirectory. -+ Reading the 'hist' file for the event will dump the hash table in -+ its entirety to stdout. If there are multiple hist triggers -+ attached to an event, there will be a table for each trigger in the -+ output. The table displayed for a named trigger will be the same as -+ any other instance having the same name. Each printed hash table -+ entry is a simple list of the keys and values comprising the entry; -+ keys are printed first and are delineated by curly braces, and are -+ followed by the set of value fields for the entry. By default, -+ numeric fields are displayed as base-10 integers. This can be -+ modified by appending any of the following modifiers to the field -+ name: -+ -+ .hex display a number as a hex value -+ .sym display an address as a symbol -+ .sym-offset display an address as a symbol and offset -+ .syscall display a syscall id as a system call name -+ .execname display a common_pid as a program name -+ -+ Note that in general the semantics of a given field aren't -+ interpreted when applying a modifier to it, but there are some -+ restrictions to be aware of in this regard: -+ -+ - only the 'hex' modifier can be used for values (because values -+ are essentially sums, and the other modifiers don't make sense -+ in that context). -+ - the 'execname' modifier can only be used on a 'common_pid'. The -+ reason for this is that the execname is simply the 'comm' value -+ saved for the 'current' process when an event was triggered, -+ which is the same as the common_pid value saved by the event -+ tracing code. Trying to apply that comm value to other pid -+ values wouldn't be correct, and typically events that care save -+ pid-specific comm fields in the event itself. -+ -+ A typical usage scenario would be the following to enable a hist -+ trigger, read its current contents, and then turn it off: -+ -+ # echo 'hist:keys=skbaddr.hex:vals=len' > \ -+ /sys/kernel/debug/tracing/events/net/netif_rx/trigger -+ -+ # cat /sys/kernel/debug/tracing/events/net/netif_rx/hist -+ -+ # echo '!hist:keys=skbaddr.hex:vals=len' > \ -+ /sys/kernel/debug/tracing/events/net/netif_rx/trigger -+ -+ The trigger file itself can be read to show the details of the -+ currently attached hist trigger. This information is also displayed -+ at the top of the 'hist' file when read. -+ -+ By default, the size of the hash table is 2048 entries. The 'size' -+ parameter can be used to specify more or fewer than that. The units -+ are in terms of hashtable entries - if a run uses more entries than -+ specified, the results will show the number of 'drops', the number -+ of hits that were ignored. The size should be a power of 2 between -+ 128 and 131072 (any non- power-of-2 number specified will be rounded -+ up). -+ -+ The 'sort' parameter can be used to specify a value field to sort -+ on. The default if unspecified is 'hitcount' and the default sort -+ order is 'ascending'. To sort in the opposite direction, append -+ .descending' to the sort key. -+ -+ The 'pause' parameter can be used to pause an existing hist trigger -+ or to start a hist trigger but not log any events until told to do -+ so. 'continue' or 'cont' can be used to start or restart a paused -+ hist trigger. -+ -+ The 'clear' parameter will clear the contents of a running hist -+ trigger and leave its current paused/active state. -+ -+ Note that the 'pause', 'cont', and 'clear' parameters should be -+ applied using 'append' shell operator ('>>') if applied to an -+ existing trigger, rather than via the '>' operator, which will cause -+ the trigger to be removed through truncation. -+ -+- enable_hist/disable_hist -+ -+ The enable_hist and disable_hist triggers can be used to have one -+ event conditionally start and stop another event's already-attached -+ hist trigger. Any number of enable_hist and disable_hist triggers -+ can be attached to a given event, allowing that event to kick off -+ and stop aggregations on a host of other events. -+ -+ The format is very similar to the enable/disable_event triggers: -+ -+ enable_hist::[:count] -+ disable_hist::[:count] -+ -+ Instead of enabling or disabling the tracing of the target event -+ into the trace buffer as the enable/disable_event triggers do, the -+ enable/disable_hist triggers enable or disable the aggregation of -+ the target event into a hash table. -+ -+ A typical usage scenario for the enable_hist/disable_hist triggers -+ would be to first set up a paused hist trigger on some event, -+ followed by an enable_hist/disable_hist pair that turns the hist -+ aggregation on and off when conditions of interest are hit: -+ -+ # echo 'hist:keys=skbaddr.hex:vals=len:pause' > \ -+ /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger -+ -+ # echo 'enable_hist:net:netif_receive_skb if filename==/usr/bin/wget' > \ -+ /sys/kernel/debug/tracing/events/sched/sched_process_exec/trigger -+ -+ # echo 'disable_hist:net:netif_receive_skb if comm==wget' > \ -+ /sys/kernel/debug/tracing/events/sched/sched_process_exit/trigger -+ -+ The above sets up an initially paused hist trigger which is unpaused -+ and starts aggregating events when a given program is executed, and -+ which stops aggregating when the process exits and the hist trigger -+ is paused again. -+ -+ The examples below provide a more concrete illustration of the -+ concepts and typical usage patterns discussed above. -+ -+ -+6.2 'hist' trigger examples -+--------------------------- -+ -+ The first set of examples creates aggregations using the kmalloc -+ event. The fields that can be used for the hist trigger are listed -+ in the kmalloc event's format file: -+ -+ # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/format -+ name: kmalloc -+ ID: 374 -+ format: -+ field:unsigned short common_type; offset:0; size:2; signed:0; -+ field:unsigned char common_flags; offset:2; size:1; signed:0; -+ field:unsigned char common_preempt_count; offset:3; size:1; signed:0; -+ field:int common_pid; offset:4; size:4; signed:1; -+ -+ field:unsigned long call_site; offset:8; size:8; signed:0; -+ field:const void * ptr; offset:16; size:8; signed:0; -+ field:size_t bytes_req; offset:24; size:8; signed:0; -+ field:size_t bytes_alloc; offset:32; size:8; signed:0; -+ field:gfp_t gfp_flags; offset:40; size:4; signed:0; -+ -+ We'll start by creating a hist trigger that generates a simple table -+ that lists the total number of bytes requested for each function in -+ the kernel that made one or more calls to kmalloc: -+ -+ # echo 'hist:key=call_site:val=bytes_req' > \ -+ /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger -+ -+ This tells the tracing system to create a 'hist' trigger using the -+ call_site field of the kmalloc event as the key for the table, which -+ just means that each unique call_site address will have an entry -+ created for it in the table. The 'val=bytes_req' parameter tells -+ the hist trigger that for each unique entry (call_site) in the -+ table, it should keep a running total of the number of bytes -+ requested by that call_site. -+ -+ We'll let it run for awhile and then dump the contents of the 'hist' -+ file in the kmalloc event's subdirectory (for readability, a number -+ of entries have been omitted): -+ -+ # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist -+ # trigger info: hist:keys=call_site:vals=bytes_req:sort=hitcount:size=2048 [active] -+ -+ { call_site: 18446744072106379007 } hitcount: 1 bytes_req: 176 -+ { call_site: 18446744071579557049 } hitcount: 1 bytes_req: 1024 -+ { call_site: 18446744071580608289 } hitcount: 1 bytes_req: 16384 -+ { call_site: 18446744071581827654 } hitcount: 1 bytes_req: 24 -+ { call_site: 18446744071580700980 } hitcount: 1 bytes_req: 8 -+ { call_site: 18446744071579359876 } hitcount: 1 bytes_req: 152 -+ { call_site: 18446744071580795365 } hitcount: 3 bytes_req: 144 -+ { call_site: 18446744071581303129 } hitcount: 3 bytes_req: 144 -+ { call_site: 18446744071580713234 } hitcount: 4 bytes_req: 2560 -+ { call_site: 18446744071580933750 } hitcount: 4 bytes_req: 736 -+ . -+ . -+ . -+ { call_site: 18446744072106047046 } hitcount: 69 bytes_req: 5576 -+ { call_site: 18446744071582116407 } hitcount: 73 bytes_req: 2336 -+ { call_site: 18446744072106054684 } hitcount: 136 bytes_req: 140504 -+ { call_site: 18446744072106224230 } hitcount: 136 bytes_req: 19584 -+ { call_site: 18446744072106078074 } hitcount: 153 bytes_req: 2448 -+ { call_site: 18446744072106062406 } hitcount: 153 bytes_req: 36720 -+ { call_site: 18446744071582507929 } hitcount: 153 bytes_req: 37088 -+ { call_site: 18446744072102520590 } hitcount: 273 bytes_req: 10920 -+ { call_site: 18446744071582143559 } hitcount: 358 bytes_req: 716 -+ { call_site: 18446744072106465852 } hitcount: 417 bytes_req: 56712 -+ { call_site: 18446744072102523378 } hitcount: 485 bytes_req: 27160 -+ { call_site: 18446744072099568646 } hitcount: 1676 bytes_req: 33520 -+ -+ Totals: -+ Hits: 4610 -+ Entries: 45 -+ Dropped: 0 -+ -+ The output displays a line for each entry, beginning with the key -+ specified in the trigger, followed by the value(s) also specified in -+ the trigger. At the beginning of the output is a line that displays -+ the trigger info, which can also be displayed by reading the -+ 'trigger' file: -+ -+ # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger -+ hist:keys=call_site:vals=bytes_req:sort=hitcount:size=2048 [active] -+ -+ At the end of the output are a few lines that display the overall -+ totals for the run. The 'Hits' field shows the total number of -+ times the event trigger was hit, the 'Entries' field shows the total -+ number of used entries in the hash table, and the 'Dropped' field -+ shows the number of hits that were dropped because the number of -+ used entries for the run exceeded the maximum number of entries -+ allowed for the table (normally 0, but if not a hint that you may -+ want to increase the size of the table using the 'size' parameter). -+ -+ Notice in the above output that there's an extra field, 'hitcount', -+ which wasn't specified in the trigger. Also notice that in the -+ trigger info output, there's a parameter, 'sort=hitcount', which -+ wasn't specified in the trigger either. The reason for that is that -+ every trigger implicitly keeps a count of the total number of hits -+ attributed to a given entry, called the 'hitcount'. That hitcount -+ information is explicitly displayed in the output, and in the -+ absence of a user-specified sort parameter, is used as the default -+ sort field. -+ -+ The value 'hitcount' can be used in place of an explicit value in -+ the 'values' parameter if you don't really need to have any -+ particular field summed and are mainly interested in hit -+ frequencies. -+ -+ To turn the hist trigger off, simply call up the trigger in the -+ command history and re-execute it with a '!' prepended: -+ -+ # echo '!hist:key=call_site:val=bytes_req' > \ -+ /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger -+ -+ Finally, notice that the call_site as displayed in the output above -+ isn't really very useful. It's an address, but normally addresses -+ are displayed in hex. To have a numeric field displayed as a hex -+ value, simply append '.hex' to the field name in the trigger: -+ -+ # echo 'hist:key=call_site.hex:val=bytes_req' > \ -+ /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger -+ -+ # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist -+ # trigger info: hist:keys=call_site.hex:vals=bytes_req:sort=hitcount:size=2048 [active] -+ -+ { call_site: ffffffffa026b291 } hitcount: 1 bytes_req: 433 -+ { call_site: ffffffffa07186ff } hitcount: 1 bytes_req: 176 -+ { call_site: ffffffff811ae721 } hitcount: 1 bytes_req: 16384 -+ { call_site: ffffffff811c5134 } hitcount: 1 bytes_req: 8 -+ { call_site: ffffffffa04a9ebb } hitcount: 1 bytes_req: 511 -+ { call_site: ffffffff8122e0a6 } hitcount: 1 bytes_req: 12 -+ { call_site: ffffffff8107da84 } hitcount: 1 bytes_req: 152 -+ { call_site: ffffffff812d8246 } hitcount: 1 bytes_req: 24 -+ { call_site: ffffffff811dc1e5 } hitcount: 3 bytes_req: 144 -+ { call_site: ffffffffa02515e8 } hitcount: 3 bytes_req: 648 -+ { call_site: ffffffff81258159 } hitcount: 3 bytes_req: 144 -+ { call_site: ffffffff811c80f4 } hitcount: 4 bytes_req: 544 -+ . -+ . -+ . -+ { call_site: ffffffffa06c7646 } hitcount: 106 bytes_req: 8024 -+ { call_site: ffffffffa06cb246 } hitcount: 132 bytes_req: 31680 -+ { call_site: ffffffffa06cef7a } hitcount: 132 bytes_req: 2112 -+ { call_site: ffffffff8137e399 } hitcount: 132 bytes_req: 23232 -+ { call_site: ffffffffa06c941c } hitcount: 185 bytes_req: 171360 -+ { call_site: ffffffffa06f2a66 } hitcount: 185 bytes_req: 26640 -+ { call_site: ffffffffa036a70e } hitcount: 265 bytes_req: 10600 -+ { call_site: ffffffff81325447 } hitcount: 292 bytes_req: 584 -+ { call_site: ffffffffa072da3c } hitcount: 446 bytes_req: 60656 -+ { call_site: ffffffffa036b1f2 } hitcount: 526 bytes_req: 29456 -+ { call_site: ffffffffa0099c06 } hitcount: 1780 bytes_req: 35600 -+ -+ Totals: -+ Hits: 4775 -+ Entries: 46 -+ Dropped: 0 -+ -+ Even that's only marginally more useful - while hex values do look -+ more like addresses, what users are typically more interested in -+ when looking at text addresses are the corresponding symbols -+ instead. To have an address displayed as symbolic value instead, -+ simply append '.sym' or '.sym-offset' to the field name in the -+ trigger: -+ -+ # echo 'hist:key=call_site.sym:val=bytes_req' > \ -+ /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger -+ -+ # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist -+ # trigger info: hist:keys=call_site.sym:vals=bytes_req:sort=hitcount:size=2048 [active] -+ -+ { call_site: [ffffffff810adcb9] syslog_print_all } hitcount: 1 bytes_req: 1024 -+ { call_site: [ffffffff8154bc62] usb_control_msg } hitcount: 1 bytes_req: 8 -+ { call_site: [ffffffffa00bf6fe] hidraw_send_report [hid] } hitcount: 1 bytes_req: 7 -+ { call_site: [ffffffff8154acbe] usb_alloc_urb } hitcount: 1 bytes_req: 192 -+ { call_site: [ffffffffa00bf1ca] hidraw_report_event [hid] } hitcount: 1 bytes_req: 7 -+ { call_site: [ffffffff811e3a25] __seq_open_private } hitcount: 1 bytes_req: 40 -+ { call_site: [ffffffff8109524a] alloc_fair_sched_group } hitcount: 2 bytes_req: 128 -+ { call_site: [ffffffff811febd5] fsnotify_alloc_group } hitcount: 2 bytes_req: 528 -+ { call_site: [ffffffff81440f58] __tty_buffer_request_room } hitcount: 2 bytes_req: 2624 -+ { call_site: [ffffffff81200ba6] inotify_new_group } hitcount: 2 bytes_req: 96 -+ { call_site: [ffffffffa05e19af] ieee80211_start_tx_ba_session [mac80211] } hitcount: 2 bytes_req: 464 -+ { call_site: [ffffffff81672406] tcp_get_metrics } hitcount: 2 bytes_req: 304 -+ { call_site: [ffffffff81097ec2] alloc_rt_sched_group } hitcount: 2 bytes_req: 128 -+ { call_site: [ffffffff81089b05] sched_create_group } hitcount: 2 bytes_req: 1424 -+ . -+ . -+ . -+ { call_site: [ffffffffa04a580c] intel_crtc_page_flip [i915] } hitcount: 1185 bytes_req: 123240 -+ { call_site: [ffffffffa0287592] drm_mode_page_flip_ioctl [drm] } hitcount: 1185 bytes_req: 104280 -+ { call_site: [ffffffffa04c4a3c] intel_plane_duplicate_state [i915] } hitcount: 1402 bytes_req: 190672 -+ { call_site: [ffffffff812891ca] ext4_find_extent } hitcount: 1518 bytes_req: 146208 -+ { call_site: [ffffffffa029070e] drm_vma_node_allow [drm] } hitcount: 1746 bytes_req: 69840 -+ { call_site: [ffffffffa045e7c4] i915_gem_do_execbuffer.isra.23 [i915] } hitcount: 2021 bytes_req: 792312 -+ { call_site: [ffffffffa02911f2] drm_modeset_lock_crtc [drm] } hitcount: 2592 bytes_req: 145152 -+ { call_site: [ffffffffa0489a66] intel_ring_begin [i915] } hitcount: 2629 bytes_req: 378576 -+ { call_site: [ffffffffa046041c] i915_gem_execbuffer2 [i915] } hitcount: 2629 bytes_req: 3783248 -+ { call_site: [ffffffff81325607] apparmor_file_alloc_security } hitcount: 5192 bytes_req: 10384 -+ { call_site: [ffffffffa00b7c06] hid_report_raw_event [hid] } hitcount: 5529 bytes_req: 110584 -+ { call_site: [ffffffff8131ebf7] aa_alloc_task_context } hitcount: 21943 bytes_req: 702176 -+ { call_site: [ffffffff8125847d] ext4_htree_store_dirent } hitcount: 55759 bytes_req: 5074265 -+ -+ Totals: -+ Hits: 109928 -+ Entries: 71 -+ Dropped: 0 -+ -+ Because the default sort key above is 'hitcount', the above shows a -+ the list of call_sites by increasing hitcount, so that at the bottom -+ we see the functions that made the most kmalloc calls during the -+ run. If instead we we wanted to see the top kmalloc callers in -+ terms of the number of bytes requested rather than the number of -+ calls, and we wanted the top caller to appear at the top, we can use -+ the 'sort' parameter, along with the 'descending' modifier: -+ -+ # echo 'hist:key=call_site.sym:val=bytes_req:sort=bytes_req.descending' > \ -+ /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger -+ -+ # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist -+ # trigger info: hist:keys=call_site.sym:vals=bytes_req:sort=bytes_req.descending:size=2048 [active] -+ -+ { call_site: [ffffffffa046041c] i915_gem_execbuffer2 [i915] } hitcount: 2186 bytes_req: 3397464 -+ { call_site: [ffffffffa045e7c4] i915_gem_do_execbuffer.isra.23 [i915] } hitcount: 1790 bytes_req: 712176 -+ { call_site: [ffffffff8125847d] ext4_htree_store_dirent } hitcount: 8132 bytes_req: 513135 -+ { call_site: [ffffffff811e2a1b] seq_buf_alloc } hitcount: 106 bytes_req: 440128 -+ { call_site: [ffffffffa0489a66] intel_ring_begin [i915] } hitcount: 2186 bytes_req: 314784 -+ { call_site: [ffffffff812891ca] ext4_find_extent } hitcount: 2174 bytes_req: 208992 -+ { call_site: [ffffffff811ae8e1] __kmalloc } hitcount: 8 bytes_req: 131072 -+ { call_site: [ffffffffa04c4a3c] intel_plane_duplicate_state [i915] } hitcount: 859 bytes_req: 116824 -+ { call_site: [ffffffffa02911f2] drm_modeset_lock_crtc [drm] } hitcount: 1834 bytes_req: 102704 -+ { call_site: [ffffffffa04a580c] intel_crtc_page_flip [i915] } hitcount: 972 bytes_req: 101088 -+ { call_site: [ffffffffa0287592] drm_mode_page_flip_ioctl [drm] } hitcount: 972 bytes_req: 85536 -+ { call_site: [ffffffffa00b7c06] hid_report_raw_event [hid] } hitcount: 3333 bytes_req: 66664 -+ { call_site: [ffffffff8137e559] sg_kmalloc } hitcount: 209 bytes_req: 61632 -+ . -+ . -+ . -+ { call_site: [ffffffff81095225] alloc_fair_sched_group } hitcount: 2 bytes_req: 128 -+ { call_site: [ffffffff81097ec2] alloc_rt_sched_group } hitcount: 2 bytes_req: 128 -+ { call_site: [ffffffff812d8406] copy_semundo } hitcount: 2 bytes_req: 48 -+ { call_site: [ffffffff81200ba6] inotify_new_group } hitcount: 1 bytes_req: 48 -+ { call_site: [ffffffffa027121a] drm_getmagic [drm] } hitcount: 1 bytes_req: 48 -+ { call_site: [ffffffff811e3a25] __seq_open_private } hitcount: 1 bytes_req: 40 -+ { call_site: [ffffffff811c52f4] bprm_change_interp } hitcount: 2 bytes_req: 16 -+ { call_site: [ffffffff8154bc62] usb_control_msg } hitcount: 1 bytes_req: 8 -+ { call_site: [ffffffffa00bf1ca] hidraw_report_event [hid] } hitcount: 1 bytes_req: 7 -+ { call_site: [ffffffffa00bf6fe] hidraw_send_report [hid] } hitcount: 1 bytes_req: 7 -+ -+ Totals: -+ Hits: 32133 -+ Entries: 81 -+ Dropped: 0 -+ -+ To display the offset and size information in addition to the symbol -+ name, just use 'sym-offset' instead: -+ -+ # echo 'hist:key=call_site.sym-offset:val=bytes_req:sort=bytes_req.descending' > \ -+ /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger -+ -+ # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist -+ # trigger info: hist:keys=call_site.sym-offset:vals=bytes_req:sort=bytes_req.descending:size=2048 [active] -+ -+ { call_site: [ffffffffa046041c] i915_gem_execbuffer2+0x6c/0x2c0 [i915] } hitcount: 4569 bytes_req: 3163720 -+ { call_site: [ffffffffa0489a66] intel_ring_begin+0xc6/0x1f0 [i915] } hitcount: 4569 bytes_req: 657936 -+ { call_site: [ffffffffa045e7c4] i915_gem_do_execbuffer.isra.23+0x694/0x1020 [i915] } hitcount: 1519 bytes_req: 472936 -+ { call_site: [ffffffffa045e646] i915_gem_do_execbuffer.isra.23+0x516/0x1020 [i915] } hitcount: 3050 bytes_req: 211832 -+ { call_site: [ffffffff811e2a1b] seq_buf_alloc+0x1b/0x50 } hitcount: 34 bytes_req: 148384 -+ { call_site: [ffffffffa04a580c] intel_crtc_page_flip+0xbc/0x870 [i915] } hitcount: 1385 bytes_req: 144040 -+ { call_site: [ffffffff811ae8e1] __kmalloc+0x191/0x1b0 } hitcount: 8 bytes_req: 131072 -+ { call_site: [ffffffffa0287592] drm_mode_page_flip_ioctl+0x282/0x360 [drm] } hitcount: 1385 bytes_req: 121880 -+ { call_site: [ffffffffa02911f2] drm_modeset_lock_crtc+0x32/0x100 [drm] } hitcount: 1848 bytes_req: 103488 -+ { call_site: [ffffffffa04c4a3c] intel_plane_duplicate_state+0x2c/0xa0 [i915] } hitcount: 461 bytes_req: 62696 -+ { call_site: [ffffffffa029070e] drm_vma_node_allow+0x2e/0xd0 [drm] } hitcount: 1541 bytes_req: 61640 -+ { call_site: [ffffffff815f8d7b] sk_prot_alloc+0xcb/0x1b0 } hitcount: 57 bytes_req: 57456 -+ . -+ . -+ . -+ { call_site: [ffffffff8109524a] alloc_fair_sched_group+0x5a/0x1a0 } hitcount: 2 bytes_req: 128 -+ { call_site: [ffffffffa027b921] drm_vm_open_locked+0x31/0xa0 [drm] } hitcount: 3 bytes_req: 96 -+ { call_site: [ffffffff8122e266] proc_self_follow_link+0x76/0xb0 } hitcount: 8 bytes_req: 96 -+ { call_site: [ffffffff81213e80] load_elf_binary+0x240/0x1650 } hitcount: 3 bytes_req: 84 -+ { call_site: [ffffffff8154bc62] usb_control_msg+0x42/0x110 } hitcount: 1 bytes_req: 8 -+ { call_site: [ffffffffa00bf6fe] hidraw_send_report+0x7e/0x1a0 [hid] } hitcount: 1 bytes_req: 7 -+ { call_site: [ffffffffa00bf1ca] hidraw_report_event+0x8a/0x120 [hid] } hitcount: 1 bytes_req: 7 -+ -+ Totals: -+ Hits: 26098 -+ Entries: 64 -+ Dropped: 0 -+ -+ We can also add multiple fields to the 'values' parameter. For -+ example, we might want to see the total number of bytes allocated -+ alongside bytes requested, and display the result sorted by bytes -+ allocated in a descending order: -+ -+ # echo 'hist:keys=call_site.sym:values=bytes_req,bytes_alloc:sort=bytes_alloc.descending' > \ -+ /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger -+ -+ # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist -+ # trigger info: hist:keys=call_site.sym:vals=bytes_req,bytes_alloc:sort=bytes_alloc.descending:size=2048 [active] -+ -+ { call_site: [ffffffffa046041c] i915_gem_execbuffer2 [i915] } hitcount: 7403 bytes_req: 4084360 bytes_alloc: 5958016 -+ { call_site: [ffffffff811e2a1b] seq_buf_alloc } hitcount: 541 bytes_req: 2213968 bytes_alloc: 2228224 -+ { call_site: [ffffffffa0489a66] intel_ring_begin [i915] } hitcount: 7404 bytes_req: 1066176 bytes_alloc: 1421568 -+ { call_site: [ffffffffa045e7c4] i915_gem_do_execbuffer.isra.23 [i915] } hitcount: 1565 bytes_req: 557368 bytes_alloc: 1037760 -+ { call_site: [ffffffff8125847d] ext4_htree_store_dirent } hitcount: 9557 bytes_req: 595778 bytes_alloc: 695744 -+ { call_site: [ffffffffa045e646] i915_gem_do_execbuffer.isra.23 [i915] } hitcount: 5839 bytes_req: 430680 bytes_alloc: 470400 -+ { call_site: [ffffffffa04c4a3c] intel_plane_duplicate_state [i915] } hitcount: 2388 bytes_req: 324768 bytes_alloc: 458496 -+ { call_site: [ffffffffa02911f2] drm_modeset_lock_crtc [drm] } hitcount: 3911 bytes_req: 219016 bytes_alloc: 250304 -+ { call_site: [ffffffff815f8d7b] sk_prot_alloc } hitcount: 235 bytes_req: 236880 bytes_alloc: 240640 -+ { call_site: [ffffffff8137e559] sg_kmalloc } hitcount: 557 bytes_req: 169024 bytes_alloc: 221760 -+ { call_site: [ffffffffa00b7c06] hid_report_raw_event [hid] } hitcount: 9378 bytes_req: 187548 bytes_alloc: 206312 -+ { call_site: [ffffffffa04a580c] intel_crtc_page_flip [i915] } hitcount: 1519 bytes_req: 157976 bytes_alloc: 194432 -+ . -+ . -+ . -+ { call_site: [ffffffff8109bd3b] sched_autogroup_create_attach } hitcount: 2 bytes_req: 144 bytes_alloc: 192 -+ { call_site: [ffffffff81097ee8] alloc_rt_sched_group } hitcount: 2 bytes_req: 128 bytes_alloc: 128 -+ { call_site: [ffffffff8109524a] alloc_fair_sched_group } hitcount: 2 bytes_req: 128 bytes_alloc: 128 -+ { call_site: [ffffffff81095225] alloc_fair_sched_group } hitcount: 2 bytes_req: 128 bytes_alloc: 128 -+ { call_site: [ffffffff81097ec2] alloc_rt_sched_group } hitcount: 2 bytes_req: 128 bytes_alloc: 128 -+ { call_site: [ffffffff81213e80] load_elf_binary } hitcount: 3 bytes_req: 84 bytes_alloc: 96 -+ { call_site: [ffffffff81079a2e] kthread_create_on_node } hitcount: 1 bytes_req: 56 bytes_alloc: 64 -+ { call_site: [ffffffffa00bf6fe] hidraw_send_report [hid] } hitcount: 1 bytes_req: 7 bytes_alloc: 8 -+ { call_site: [ffffffff8154bc62] usb_control_msg } hitcount: 1 bytes_req: 8 bytes_alloc: 8 -+ { call_site: [ffffffffa00bf1ca] hidraw_report_event [hid] } hitcount: 1 bytes_req: 7 bytes_alloc: 8 -+ -+ Totals: -+ Hits: 66598 -+ Entries: 65 -+ Dropped: 0 -+ -+ Finally, to finish off our kmalloc example, instead of simply having -+ the hist trigger display symbolic call_sites, we can have the hist -+ trigger additionally display the complete set of kernel stack traces -+ that led to each call_site. To do that, we simply use the special -+ value 'stacktrace' for the key parameter: -+ -+ # echo 'hist:keys=stacktrace:values=bytes_req,bytes_alloc:sort=bytes_alloc' > \ -+ /sys/kernel/debug/tracing/events/kmem/kmalloc/trigger -+ -+ The above trigger will use the kernel stack trace in effect when an -+ event is triggered as the key for the hash table. This allows the -+ enumeration of every kernel callpath that led up to a particular -+ event, along with a running total of any of the event fields for -+ that event. Here we tally bytes requested and bytes allocated for -+ every callpath in the system that led up to a kmalloc (in this case -+ every callpath to a kmalloc for a kernel compile): -+ -+ # cat /sys/kernel/debug/tracing/events/kmem/kmalloc/hist -+ # trigger info: hist:keys=stacktrace:vals=bytes_req,bytes_alloc:sort=bytes_alloc:size=2048 [active] -+ -+ { stacktrace: -+ __kmalloc_track_caller+0x10b/0x1a0 -+ kmemdup+0x20/0x50 -+ hidraw_report_event+0x8a/0x120 [hid] -+ hid_report_raw_event+0x3ea/0x440 [hid] -+ hid_input_report+0x112/0x190 [hid] -+ hid_irq_in+0xc2/0x260 [usbhid] -+ __usb_hcd_giveback_urb+0x72/0x120 -+ usb_giveback_urb_bh+0x9e/0xe0 -+ tasklet_hi_action+0xf8/0x100 -+ __do_softirq+0x114/0x2c0 -+ irq_exit+0xa5/0xb0 -+ do_IRQ+0x5a/0xf0 -+ ret_from_intr+0x0/0x30 -+ cpuidle_enter+0x17/0x20 -+ cpu_startup_entry+0x315/0x3e0 -+ rest_init+0x7c/0x80 -+ } hitcount: 3 bytes_req: 21 bytes_alloc: 24 -+ { stacktrace: -+ __kmalloc_track_caller+0x10b/0x1a0 -+ kmemdup+0x20/0x50 -+ hidraw_report_event+0x8a/0x120 [hid] -+ hid_report_raw_event+0x3ea/0x440 [hid] -+ hid_input_report+0x112/0x190 [hid] -+ hid_irq_in+0xc2/0x260 [usbhid] -+ __usb_hcd_giveback_urb+0x72/0x120 -+ usb_giveback_urb_bh+0x9e/0xe0 -+ tasklet_hi_action+0xf8/0x100 -+ __do_softirq+0x114/0x2c0 -+ irq_exit+0xa5/0xb0 -+ do_IRQ+0x5a/0xf0 -+ ret_from_intr+0x0/0x30 -+ } hitcount: 3 bytes_req: 21 bytes_alloc: 24 -+ { stacktrace: -+ kmem_cache_alloc_trace+0xeb/0x150 -+ aa_alloc_task_context+0x27/0x40 -+ apparmor_cred_prepare+0x1f/0x50 -+ security_prepare_creds+0x16/0x20 -+ prepare_creds+0xdf/0x1a0 -+ SyS_capset+0xb5/0x200 -+ system_call_fastpath+0x12/0x6a -+ } hitcount: 1 bytes_req: 32 bytes_alloc: 32 -+ . -+ . -+ . -+ { stacktrace: -+ __kmalloc+0x11b/0x1b0 -+ i915_gem_execbuffer2+0x6c/0x2c0 [i915] -+ drm_ioctl+0x349/0x670 [drm] -+ do_vfs_ioctl+0x2f0/0x4f0 -+ SyS_ioctl+0x81/0xa0 -+ system_call_fastpath+0x12/0x6a -+ } hitcount: 17726 bytes_req: 13944120 bytes_alloc: 19593808 -+ { stacktrace: -+ __kmalloc+0x11b/0x1b0 -+ load_elf_phdrs+0x76/0xa0 -+ load_elf_binary+0x102/0x1650 -+ search_binary_handler+0x97/0x1d0 -+ do_execveat_common.isra.34+0x551/0x6e0 -+ SyS_execve+0x3a/0x50 -+ return_from_execve+0x0/0x23 -+ } hitcount: 33348 bytes_req: 17152128 bytes_alloc: 20226048 -+ { stacktrace: -+ kmem_cache_alloc_trace+0xeb/0x150 -+ apparmor_file_alloc_security+0x27/0x40 -+ security_file_alloc+0x16/0x20 -+ get_empty_filp+0x93/0x1c0 -+ path_openat+0x31/0x5f0 -+ do_filp_open+0x3a/0x90 -+ do_sys_open+0x128/0x220 -+ SyS_open+0x1e/0x20 -+ system_call_fastpath+0x12/0x6a -+ } hitcount: 4766422 bytes_req: 9532844 bytes_alloc: 38131376 -+ { stacktrace: -+ __kmalloc+0x11b/0x1b0 -+ seq_buf_alloc+0x1b/0x50 -+ seq_read+0x2cc/0x370 -+ proc_reg_read+0x3d/0x80 -+ __vfs_read+0x28/0xe0 -+ vfs_read+0x86/0x140 -+ SyS_read+0x46/0xb0 -+ system_call_fastpath+0x12/0x6a -+ } hitcount: 19133 bytes_req: 78368768 bytes_alloc: 78368768 -+ -+ Totals: -+ Hits: 6085872 -+ Entries: 253 -+ Dropped: 0 -+ -+ If you key a hist trigger on common_pid, in order for example to -+ gather and display sorted totals for each process, you can use the -+ special .execname modifier to display the executable names for the -+ processes in the table rather than raw pids. The example below -+ keeps a per-process sum of total bytes read: -+ -+ # echo 'hist:key=common_pid.execname:val=count:sort=count.descending' > \ -+ /sys/kernel/debug/tracing/events/syscalls/sys_enter_read/trigger -+ -+ # cat /sys/kernel/debug/tracing/events/syscalls/sys_enter_read/hist -+ # trigger info: hist:keys=common_pid.execname:vals=count:sort=count.descending:size=2048 [active] -+ -+ { common_pid: gnome-terminal [ 3196] } hitcount: 280 count: 1093512 -+ { common_pid: Xorg [ 1309] } hitcount: 525 count: 256640 -+ { common_pid: compiz [ 2889] } hitcount: 59 count: 254400 -+ { common_pid: bash [ 8710] } hitcount: 3 count: 66369 -+ { common_pid: dbus-daemon-lau [ 8703] } hitcount: 49 count: 47739 -+ { common_pid: irqbalance [ 1252] } hitcount: 27 count: 27648 -+ { common_pid: 01ifupdown [ 8705] } hitcount: 3 count: 17216 -+ { common_pid: dbus-daemon [ 772] } hitcount: 10 count: 12396 -+ { common_pid: Socket Thread [ 8342] } hitcount: 11 count: 11264 -+ { common_pid: nm-dhcp-client. [ 8701] } hitcount: 6 count: 7424 -+ { common_pid: gmain [ 1315] } hitcount: 18 count: 6336 -+ . -+ . -+ . -+ { common_pid: postgres [ 1892] } hitcount: 2 count: 32 -+ { common_pid: postgres [ 1891] } hitcount: 2 count: 32 -+ { common_pid: gmain [ 8704] } hitcount: 2 count: 32 -+ { common_pid: upstart-dbus-br [ 2740] } hitcount: 21 count: 21 -+ { common_pid: nm-dispatcher.a [ 8696] } hitcount: 1 count: 16 -+ { common_pid: indicator-datet [ 2904] } hitcount: 1 count: 16 -+ { common_pid: gdbus [ 2998] } hitcount: 1 count: 16 -+ { common_pid: rtkit-daemon [ 2052] } hitcount: 1 count: 8 -+ { common_pid: init [ 1] } hitcount: 2 count: 2 -+ -+ Totals: -+ Hits: 2116 -+ Entries: 51 -+ Dropped: 0 -+ -+ Similarly, if you key a hist trigger on syscall id, for example to -+ gather and display a list of systemwide syscall hits, you can use -+ the special .syscall modifier to display the syscall names rather -+ than raw ids. The example below keeps a running total of syscall -+ counts for the system during the run: -+ -+ # echo 'hist:key=id.syscall:val=hitcount' > \ -+ /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/trigger -+ -+ # cat /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/hist -+ # trigger info: hist:keys=id.syscall:vals=hitcount:sort=hitcount:size=2048 [active] -+ -+ { id: sys_fsync [ 74] } hitcount: 1 -+ { id: sys_newuname [ 63] } hitcount: 1 -+ { id: sys_prctl [157] } hitcount: 1 -+ { id: sys_statfs [137] } hitcount: 1 -+ { id: sys_symlink [ 88] } hitcount: 1 -+ { id: sys_sendmmsg [307] } hitcount: 1 -+ { id: sys_semctl [ 66] } hitcount: 1 -+ { id: sys_readlink [ 89] } hitcount: 3 -+ { id: sys_bind [ 49] } hitcount: 3 -+ { id: sys_getsockname [ 51] } hitcount: 3 -+ { id: sys_unlink [ 87] } hitcount: 3 -+ { id: sys_rename [ 82] } hitcount: 4 -+ { id: unknown_syscall [ 58] } hitcount: 4 -+ { id: sys_connect [ 42] } hitcount: 4 -+ { id: sys_getpid [ 39] } hitcount: 4 -+ . -+ . -+ . -+ { id: sys_rt_sigprocmask [ 14] } hitcount: 952 -+ { id: sys_futex [202] } hitcount: 1534 -+ { id: sys_write [ 1] } hitcount: 2689 -+ { id: sys_setitimer [ 38] } hitcount: 2797 -+ { id: sys_read [ 0] } hitcount: 3202 -+ { id: sys_select [ 23] } hitcount: 3773 -+ { id: sys_writev [ 20] } hitcount: 4531 -+ { id: sys_poll [ 7] } hitcount: 8314 -+ { id: sys_recvmsg [ 47] } hitcount: 13738 -+ { id: sys_ioctl [ 16] } hitcount: 21843 -+ -+ Totals: -+ Hits: 67612 -+ Entries: 72 -+ Dropped: 0 -+ -+ The syscall counts above provide a rough overall picture of system -+ call activity on the system; we can see for example that the most -+ popular system call on this system was the 'sys_ioctl' system call. -+ -+ We can use 'compound' keys to refine that number and provide some -+ further insight as to which processes exactly contribute to the -+ overall ioctl count. -+ -+ The command below keeps a hitcount for every unique combination of -+ system call id and pid - the end result is essentially a table -+ that keeps a per-pid sum of system call hits. The results are -+ sorted using the system call id as the primary key, and the -+ hitcount sum as the secondary key: -+ -+ # echo 'hist:key=id.syscall,common_pid.execname:val=hitcount:sort=id,hitcount' > \ -+ /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/trigger -+ -+ # cat /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/hist -+ # trigger info: hist:keys=id.syscall,common_pid.execname:vals=hitcount:sort=id.syscall,hitcount:size=2048 [active] -+ -+ { id: sys_read [ 0], common_pid: rtkit-daemon [ 1877] } hitcount: 1 -+ { id: sys_read [ 0], common_pid: gdbus [ 2976] } hitcount: 1 -+ { id: sys_read [ 0], common_pid: console-kit-dae [ 3400] } hitcount: 1 -+ { id: sys_read [ 0], common_pid: postgres [ 1865] } hitcount: 1 -+ { id: sys_read [ 0], common_pid: deja-dup-monito [ 3543] } hitcount: 2 -+ { id: sys_read [ 0], common_pid: NetworkManager [ 890] } hitcount: 2 -+ { id: sys_read [ 0], common_pid: evolution-calen [ 3048] } hitcount: 2 -+ { id: sys_read [ 0], common_pid: postgres [ 1864] } hitcount: 2 -+ { id: sys_read [ 0], common_pid: nm-applet [ 3022] } hitcount: 2 -+ { id: sys_read [ 0], common_pid: whoopsie [ 1212] } hitcount: 2 -+ . -+ . -+ . -+ { id: sys_ioctl [ 16], common_pid: bash [ 8479] } hitcount: 1 -+ { id: sys_ioctl [ 16], common_pid: bash [ 3472] } hitcount: 12 -+ { id: sys_ioctl [ 16], common_pid: gnome-terminal [ 3199] } hitcount: 16 -+ { id: sys_ioctl [ 16], common_pid: Xorg [ 1267] } hitcount: 1808 -+ { id: sys_ioctl [ 16], common_pid: compiz [ 2994] } hitcount: 5580 -+ . -+ . -+ . -+ { id: sys_waitid [247], common_pid: upstart-dbus-br [ 2690] } hitcount: 3 -+ { id: sys_waitid [247], common_pid: upstart-dbus-br [ 2688] } hitcount: 16 -+ { id: sys_inotify_add_watch [254], common_pid: gmain [ 975] } hitcount: 2 -+ { id: sys_inotify_add_watch [254], common_pid: gmain [ 3204] } hitcount: 4 -+ { id: sys_inotify_add_watch [254], common_pid: gmain [ 2888] } hitcount: 4 -+ { id: sys_inotify_add_watch [254], common_pid: gmain [ 3003] } hitcount: 4 -+ { id: sys_inotify_add_watch [254], common_pid: gmain [ 2873] } hitcount: 4 -+ { id: sys_inotify_add_watch [254], common_pid: gmain [ 3196] } hitcount: 6 -+ { id: sys_openat [257], common_pid: java [ 2623] } hitcount: 2 -+ { id: sys_eventfd2 [290], common_pid: ibus-ui-gtk3 [ 2760] } hitcount: 4 -+ { id: sys_eventfd2 [290], common_pid: compiz [ 2994] } hitcount: 6 -+ -+ Totals: -+ Hits: 31536 -+ Entries: 323 -+ Dropped: 0 -+ -+ The above list does give us a breakdown of the ioctl syscall by -+ pid, but it also gives us quite a bit more than that, which we -+ don't really care about at the moment. Since we know the syscall -+ id for sys_ioctl (16, displayed next to the sys_ioctl name), we -+ can use that to filter out all the other syscalls: -+ -+ # echo 'hist:key=id.syscall,common_pid.execname:val=hitcount:sort=id,hitcount if id == 16' > \ -+ /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/trigger -+ -+ # cat /sys/kernel/debug/tracing/events/raw_syscalls/sys_enter/hist -+ # trigger info: hist:keys=id.syscall,common_pid.execname:vals=hitcount:sort=id.syscall,hitcount:size=2048 if id == 16 [active] -+ -+ { id: sys_ioctl [ 16], common_pid: gmain [ 2769] } hitcount: 1 -+ { id: sys_ioctl [ 16], common_pid: evolution-addre [ 8571] } hitcount: 1 -+ { id: sys_ioctl [ 16], common_pid: gmain [ 3003] } hitcount: 1 -+ { id: sys_ioctl [ 16], common_pid: gmain [ 2781] } hitcount: 1 -+ { id: sys_ioctl [ 16], common_pid: gmain [ 2829] } hitcount: 1 -+ { id: sys_ioctl [ 16], common_pid: bash [ 8726] } hitcount: 1 -+ { id: sys_ioctl [ 16], common_pid: bash [ 8508] } hitcount: 1 -+ { id: sys_ioctl [ 16], common_pid: gmain [ 2970] } hitcount: 1 -+ { id: sys_ioctl [ 16], common_pid: gmain [ 2768] } hitcount: 1 -+ . -+ . -+ . -+ { id: sys_ioctl [ 16], common_pid: pool [ 8559] } hitcount: 45 -+ { id: sys_ioctl [ 16], common_pid: pool [ 8555] } hitcount: 48 -+ { id: sys_ioctl [ 16], common_pid: pool [ 8551] } hitcount: 48 -+ { id: sys_ioctl [ 16], common_pid: avahi-daemon [ 896] } hitcount: 66 -+ { id: sys_ioctl [ 16], common_pid: Xorg [ 1267] } hitcount: 26674 -+ { id: sys_ioctl [ 16], common_pid: compiz [ 2994] } hitcount: 73443 -+ -+ Totals: -+ Hits: 101162 -+ Entries: 103 -+ Dropped: 0 -+ -+ The above output shows that 'compiz' and 'Xorg' are far and away -+ the heaviest ioctl callers (which might lead to questions about -+ whether they really need to be making all those calls and to -+ possible avenues for further investigation.) -+ -+ The compound key examples used a key and a sum value (hitcount) to -+ sort the output, but we can just as easily use two keys instead. -+ Here's an example where we use a compound key composed of the the -+ common_pid and size event fields. Sorting with pid as the primary -+ key and 'size' as the secondary key allows us to display an -+ ordered summary of the recvfrom sizes, with counts, received by -+ each process: -+ -+ # echo 'hist:key=common_pid.execname,size:val=hitcount:sort=common_pid,size' > \ -+ /sys/kernel/debug/tracing/events/syscalls/sys_enter_recvfrom/trigger -+ -+ # cat /sys/kernel/debug/tracing/events/syscalls/sys_enter_recvfrom/hist -+ # trigger info: hist:keys=common_pid.execname,size:vals=hitcount:sort=common_pid.execname,size:size=2048 [active] -+ -+ { common_pid: smbd [ 784], size: 4 } hitcount: 1 -+ { common_pid: dnsmasq [ 1412], size: 4096 } hitcount: 672 -+ { common_pid: postgres [ 1796], size: 1000 } hitcount: 6 -+ { common_pid: postgres [ 1867], size: 1000 } hitcount: 10 -+ { common_pid: bamfdaemon [ 2787], size: 28 } hitcount: 2 -+ { common_pid: bamfdaemon [ 2787], size: 14360 } hitcount: 1 -+ { common_pid: compiz [ 2994], size: 8 } hitcount: 1 -+ { common_pid: compiz [ 2994], size: 20 } hitcount: 11 -+ { common_pid: gnome-terminal [ 3199], size: 4 } hitcount: 2 -+ { common_pid: firefox [ 8817], size: 4 } hitcount: 1 -+ { common_pid: firefox [ 8817], size: 8 } hitcount: 5 -+ { common_pid: firefox [ 8817], size: 588 } hitcount: 2 -+ { common_pid: firefox [ 8817], size: 628 } hitcount: 1 -+ { common_pid: firefox [ 8817], size: 6944 } hitcount: 1 -+ { common_pid: firefox [ 8817], size: 408880 } hitcount: 2 -+ { common_pid: firefox [ 8822], size: 8 } hitcount: 2 -+ { common_pid: firefox [ 8822], size: 160 } hitcount: 2 -+ { common_pid: firefox [ 8822], size: 320 } hitcount: 2 -+ { common_pid: firefox [ 8822], size: 352 } hitcount: 1 -+ . -+ . -+ . -+ { common_pid: pool [ 8923], size: 1960 } hitcount: 10 -+ { common_pid: pool [ 8923], size: 2048 } hitcount: 10 -+ { common_pid: pool [ 8924], size: 1960 } hitcount: 10 -+ { common_pid: pool [ 8924], size: 2048 } hitcount: 10 -+ { common_pid: pool [ 8928], size: 1964 } hitcount: 4 -+ { common_pid: pool [ 8928], size: 1965 } hitcount: 2 -+ { common_pid: pool [ 8928], size: 2048 } hitcount: 6 -+ { common_pid: pool [ 8929], size: 1982 } hitcount: 1 -+ { common_pid: pool [ 8929], size: 2048 } hitcount: 1 -+ -+ Totals: -+ Hits: 2016 -+ Entries: 224 -+ Dropped: 0 -+ -+ The above example also illustrates the fact that although a compound -+ key is treated as a single entity for hashing purposes, the sub-keys -+ it's composed of can be accessed independently. -+ -+ The next example uses a string field as the hash key and -+ demonstrates how you can manually pause and continue a hist trigger. -+ In this example, we'll aggregate fork counts and don't expect a -+ large number of entries in the hash table, so we'll drop it to a -+ much smaller number, say 256: -+ -+ # echo 'hist:key=child_comm:val=hitcount:size=256' > \ -+ /sys/kernel/debug/tracing/events/sched/sched_process_fork/trigger -+ -+ # cat /sys/kernel/debug/tracing/events/sched/sched_process_fork/hist -+ # trigger info: hist:keys=child_comm:vals=hitcount:sort=hitcount:size=256 [active] -+ -+ { child_comm: dconf worker } hitcount: 1 -+ { child_comm: ibus-daemon } hitcount: 1 -+ { child_comm: whoopsie } hitcount: 1 -+ { child_comm: smbd } hitcount: 1 -+ { child_comm: gdbus } hitcount: 1 -+ { child_comm: kthreadd } hitcount: 1 -+ { child_comm: dconf worker } hitcount: 1 -+ { child_comm: evolution-alarm } hitcount: 2 -+ { child_comm: Socket Thread } hitcount: 2 -+ { child_comm: postgres } hitcount: 2 -+ { child_comm: bash } hitcount: 3 -+ { child_comm: compiz } hitcount: 3 -+ { child_comm: evolution-sourc } hitcount: 4 -+ { child_comm: dhclient } hitcount: 4 -+ { child_comm: pool } hitcount: 5 -+ { child_comm: nm-dispatcher.a } hitcount: 8 -+ { child_comm: firefox } hitcount: 8 -+ { child_comm: dbus-daemon } hitcount: 8 -+ { child_comm: glib-pacrunner } hitcount: 10 -+ { child_comm: evolution } hitcount: 23 -+ -+ Totals: -+ Hits: 89 -+ Entries: 20 -+ Dropped: 0 -+ -+ If we want to pause the hist trigger, we can simply append :pause to -+ the command that started the trigger. Notice that the trigger info -+ displays as [paused]: -+ -+ # echo 'hist:key=child_comm:val=hitcount:size=256:pause' >> \ -+ /sys/kernel/debug/tracing/events/sched/sched_process_fork/trigger -+ -+ # cat /sys/kernel/debug/tracing/events/sched/sched_process_fork/hist -+ # trigger info: hist:keys=child_comm:vals=hitcount:sort=hitcount:size=256 [paused] -+ -+ { child_comm: dconf worker } hitcount: 1 -+ { child_comm: kthreadd } hitcount: 1 -+ { child_comm: dconf worker } hitcount: 1 -+ { child_comm: gdbus } hitcount: 1 -+ { child_comm: ibus-daemon } hitcount: 1 -+ { child_comm: Socket Thread } hitcount: 2 -+ { child_comm: evolution-alarm } hitcount: 2 -+ { child_comm: smbd } hitcount: 2 -+ { child_comm: bash } hitcount: 3 -+ { child_comm: whoopsie } hitcount: 3 -+ { child_comm: compiz } hitcount: 3 -+ { child_comm: evolution-sourc } hitcount: 4 -+ { child_comm: pool } hitcount: 5 -+ { child_comm: postgres } hitcount: 6 -+ { child_comm: firefox } hitcount: 8 -+ { child_comm: dhclient } hitcount: 10 -+ { child_comm: emacs } hitcount: 12 -+ { child_comm: dbus-daemon } hitcount: 20 -+ { child_comm: nm-dispatcher.a } hitcount: 20 -+ { child_comm: evolution } hitcount: 35 -+ { child_comm: glib-pacrunner } hitcount: 59 -+ -+ Totals: -+ Hits: 199 -+ Entries: 21 -+ Dropped: 0 -+ -+ To manually continue having the trigger aggregate events, append -+ :cont instead. Notice that the trigger info displays as [active] -+ again, and the data has changed: -+ -+ # echo 'hist:key=child_comm:val=hitcount:size=256:cont' >> \ -+ /sys/kernel/debug/tracing/events/sched/sched_process_fork/trigger -+ -+ # cat /sys/kernel/debug/tracing/events/sched/sched_process_fork/hist -+ # trigger info: hist:keys=child_comm:vals=hitcount:sort=hitcount:size=256 [active] -+ -+ { child_comm: dconf worker } hitcount: 1 -+ { child_comm: dconf worker } hitcount: 1 -+ { child_comm: kthreadd } hitcount: 1 -+ { child_comm: gdbus } hitcount: 1 -+ { child_comm: ibus-daemon } hitcount: 1 -+ { child_comm: Socket Thread } hitcount: 2 -+ { child_comm: evolution-alarm } hitcount: 2 -+ { child_comm: smbd } hitcount: 2 -+ { child_comm: whoopsie } hitcount: 3 -+ { child_comm: compiz } hitcount: 3 -+ { child_comm: evolution-sourc } hitcount: 4 -+ { child_comm: bash } hitcount: 5 -+ { child_comm: pool } hitcount: 5 -+ { child_comm: postgres } hitcount: 6 -+ { child_comm: firefox } hitcount: 8 -+ { child_comm: dhclient } hitcount: 11 -+ { child_comm: emacs } hitcount: 12 -+ { child_comm: dbus-daemon } hitcount: 22 -+ { child_comm: nm-dispatcher.a } hitcount: 22 -+ { child_comm: evolution } hitcount: 35 -+ { child_comm: glib-pacrunner } hitcount: 59 -+ -+ Totals: -+ Hits: 206 -+ Entries: 21 -+ Dropped: 0 -+ -+ The previous example showed how to start and stop a hist trigger by -+ appending 'pause' and 'continue' to the hist trigger command. A -+ hist trigger can also be started in a paused state by initially -+ starting the trigger with ':pause' appended. This allows you to -+ start the trigger only when you're ready to start collecting data -+ and not before. For example, you could start the trigger in a -+ paused state, then unpause it and do something you want to measure, -+ then pause the trigger again when done. -+ -+ Of course, doing this manually can be difficult and error-prone, but -+ it is possible to automatically start and stop a hist trigger based -+ on some condition, via the enable_hist and disable_hist triggers. -+ -+ For example, suppose we wanted to take a look at the relative -+ weights in terms of skb length for each callpath that leads to a -+ netif_receieve_skb event when downloading a decent-sized file using -+ wget. -+ -+ First we set up an initially paused stacktrace trigger on the -+ netif_receive_skb event: -+ -+ # echo 'hist:key=stacktrace:vals=len:pause' > \ -+ /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger -+ -+ Next, we set up an 'enable_hist' trigger on the sched_process_exec -+ event, with an 'if filename==/usr/bin/wget' filter. The effect of -+ this new trigger is that it will 'unpause' the hist trigger we just -+ set up on netif_receive_skb if and only if it sees a -+ sched_process_exec event with a filename of '/usr/bin/wget'. When -+ that happens, all netif_receive_skb events are aggregated into a -+ hash table keyed on stacktrace: -+ -+ # echo 'enable_hist:net:netif_receive_skb if filename==/usr/bin/wget' > \ -+ /sys/kernel/debug/tracing/events/sched/sched_process_exec/trigger -+ -+ The aggregation continues until the netif_receive_skb is paused -+ again, which is what the following disable_hist event does by -+ creating a similar setup on the sched_process_exit event, using the -+ filter 'comm==wget': -+ -+ # echo 'disable_hist:net:netif_receive_skb if comm==wget' > \ -+ /sys/kernel/debug/tracing/events/sched/sched_process_exit/trigger -+ -+ Whenever a process exits and the comm field of the disable_hist -+ trigger filter matches 'comm==wget', the netif_receive_skb hist -+ trigger is disabled. -+ -+ The overall effect is that netif_receive_skb events are aggregated -+ into the hash table for only the duration of the wget. Executing a -+ wget command and then listing the 'hist' file will display the -+ output generated by the wget command: -+ -+ $ wget https://www.kernel.org/pub/linux/kernel/v3.x/patch-3.19.xz -+ -+ # cat /sys/kernel/debug/tracing/events/net/netif_receive_skb/hist -+ # trigger info: hist:keys=stacktrace:vals=len:sort=hitcount:size=2048 [paused] -+ -+ { stacktrace: -+ __netif_receive_skb_core+0x46d/0x990 -+ __netif_receive_skb+0x18/0x60 -+ netif_receive_skb_internal+0x23/0x90 -+ napi_gro_receive+0xc8/0x100 -+ ieee80211_deliver_skb+0xd6/0x270 [mac80211] -+ ieee80211_rx_handlers+0xccf/0x22f0 [mac80211] -+ ieee80211_prepare_and_rx_handle+0x4e7/0xc40 [mac80211] -+ ieee80211_rx+0x31d/0x900 [mac80211] -+ iwlagn_rx_reply_rx+0x3db/0x6f0 [iwldvm] -+ iwl_rx_dispatch+0x8e/0xf0 [iwldvm] -+ iwl_pcie_irq_handler+0xe3c/0x12f0 [iwlwifi] -+ irq_thread_fn+0x20/0x50 -+ irq_thread+0x11f/0x150 -+ kthread+0xd2/0xf0 -+ ret_from_fork+0x42/0x70 -+ } hitcount: 85 len: 28884 -+ { stacktrace: -+ __netif_receive_skb_core+0x46d/0x990 -+ __netif_receive_skb+0x18/0x60 -+ netif_receive_skb_internal+0x23/0x90 -+ napi_gro_complete+0xa4/0xe0 -+ dev_gro_receive+0x23a/0x360 -+ napi_gro_receive+0x30/0x100 -+ ieee80211_deliver_skb+0xd6/0x270 [mac80211] -+ ieee80211_rx_handlers+0xccf/0x22f0 [mac80211] -+ ieee80211_prepare_and_rx_handle+0x4e7/0xc40 [mac80211] -+ ieee80211_rx+0x31d/0x900 [mac80211] -+ iwlagn_rx_reply_rx+0x3db/0x6f0 [iwldvm] -+ iwl_rx_dispatch+0x8e/0xf0 [iwldvm] -+ iwl_pcie_irq_handler+0xe3c/0x12f0 [iwlwifi] -+ irq_thread_fn+0x20/0x50 -+ irq_thread+0x11f/0x150 -+ kthread+0xd2/0xf0 -+ } hitcount: 98 len: 664329 -+ { stacktrace: -+ __netif_receive_skb_core+0x46d/0x990 -+ __netif_receive_skb+0x18/0x60 -+ process_backlog+0xa8/0x150 -+ net_rx_action+0x15d/0x340 -+ __do_softirq+0x114/0x2c0 -+ do_softirq_own_stack+0x1c/0x30 -+ do_softirq+0x65/0x70 -+ __local_bh_enable_ip+0xb5/0xc0 -+ ip_finish_output+0x1f4/0x840 -+ ip_output+0x6b/0xc0 -+ ip_local_out_sk+0x31/0x40 -+ ip_send_skb+0x1a/0x50 -+ udp_send_skb+0x173/0x2a0 -+ udp_sendmsg+0x2bf/0x9f0 -+ inet_sendmsg+0x64/0xa0 -+ sock_sendmsg+0x3d/0x50 -+ } hitcount: 115 len: 13030 -+ { stacktrace: -+ __netif_receive_skb_core+0x46d/0x990 -+ __netif_receive_skb+0x18/0x60 -+ netif_receive_skb_internal+0x23/0x90 -+ napi_gro_complete+0xa4/0xe0 -+ napi_gro_flush+0x6d/0x90 -+ iwl_pcie_irq_handler+0x92a/0x12f0 [iwlwifi] -+ irq_thread_fn+0x20/0x50 -+ irq_thread+0x11f/0x150 -+ kthread+0xd2/0xf0 -+ ret_from_fork+0x42/0x70 -+ } hitcount: 934 len: 5512212 -+ -+ Totals: -+ Hits: 1232 -+ Entries: 4 -+ Dropped: 0 -+ -+ The above shows all the netif_receive_skb callpaths and their total -+ lengths for the duration of the wget command. -+ -+ The 'clear' hist trigger param can be used to clear the hash table. -+ Suppose we wanted to try another run of the previous example but -+ this time also wanted to see the complete list of events that went -+ into the histogram. In order to avoid having to set everything up -+ again, we can just clear the histogram first: -+ -+ # echo 'hist:key=stacktrace:vals=len:clear' >> \ -+ /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger -+ -+ Just to verify that it is in fact cleared, here's what we now see in -+ the hist file: -+ -+ # cat /sys/kernel/debug/tracing/events/net/netif_receive_skb/hist -+ # trigger info: hist:keys=stacktrace:vals=len:sort=hitcount:size=2048 [paused] -+ -+ Totals: -+ Hits: 0 -+ Entries: 0 -+ Dropped: 0 -+ -+ Since we want to see the detailed list of every netif_receive_skb -+ event occurring during the new run, which are in fact the same -+ events being aggregated into the hash table, we add some additional -+ 'enable_event' events to the triggering sched_process_exec and -+ sched_process_exit events as such: -+ -+ # echo 'enable_event:net:netif_receive_skb if filename==/usr/bin/wget' > \ -+ /sys/kernel/debug/tracing/events/sched/sched_process_exec/trigger -+ -+ # echo 'disable_event:net:netif_receive_skb if comm==wget' > \ -+ /sys/kernel/debug/tracing/events/sched/sched_process_exit/trigger -+ -+ If you read the trigger files for the sched_process_exec and -+ sched_process_exit triggers, you should see two triggers for each: -+ one enabling/disabling the hist aggregation and the other -+ enabling/disabling the logging of events: -+ -+ # cat /sys/kernel/debug/tracing/events/sched/sched_process_exec/trigger -+ enable_event:net:netif_receive_skb:unlimited if filename==/usr/bin/wget -+ enable_hist:net:netif_receive_skb:unlimited if filename==/usr/bin/wget -+ -+ # cat /sys/kernel/debug/tracing/events/sched/sched_process_exit/trigger -+ enable_event:net:netif_receive_skb:unlimited if comm==wget -+ disable_hist:net:netif_receive_skb:unlimited if comm==wget -+ -+ In other words, whenever either of the sched_process_exec or -+ sched_process_exit events is hit and matches 'wget', it enables or -+ disables both the histogram and the event log, and what you end up -+ with is a hash table and set of events just covering the specified -+ duration. Run the wget command again: -+ -+ $ wget https://www.kernel.org/pub/linux/kernel/v3.x/patch-3.19.xz -+ -+ Displaying the 'hist' file should show something similar to what you -+ saw in the last run, but this time you should also see the -+ individual events in the trace file: -+ -+ # cat /sys/kernel/debug/tracing/trace -+ -+ # tracer: nop -+ # -+ # entries-in-buffer/entries-written: 183/1426 #P:4 -+ # -+ # _-----=> irqs-off -+ # / _----=> need-resched -+ # | / _---=> hardirq/softirq -+ # || / _--=> preempt-depth -+ # ||| / delay -+ # TASK-PID CPU# |||| TIMESTAMP FUNCTION -+ # | | | |||| | | -+ wget-15108 [000] ..s1 31769.606929: netif_receive_skb: dev=lo skbaddr=ffff88009c353100 len=60 -+ wget-15108 [000] ..s1 31769.606999: netif_receive_skb: dev=lo skbaddr=ffff88009c353200 len=60 -+ dnsmasq-1382 [000] ..s1 31769.677652: netif_receive_skb: dev=lo skbaddr=ffff88009c352b00 len=130 -+ dnsmasq-1382 [000] ..s1 31769.685917: netif_receive_skb: dev=lo skbaddr=ffff88009c352200 len=138 -+ ##### CPU 2 buffer started #### -+ irq/29-iwlwifi-559 [002] ..s. 31772.031529: netif_receive_skb: dev=wlan0 skbaddr=ffff88009d433d00 len=2948 -+ irq/29-iwlwifi-559 [002] ..s. 31772.031572: netif_receive_skb: dev=wlan0 skbaddr=ffff88009d432200 len=1500 -+ irq/29-iwlwifi-559 [002] ..s. 31772.032196: netif_receive_skb: dev=wlan0 skbaddr=ffff88009d433100 len=2948 -+ irq/29-iwlwifi-559 [002] ..s. 31772.032761: netif_receive_skb: dev=wlan0 skbaddr=ffff88009d433000 len=2948 -+ irq/29-iwlwifi-559 [002] ..s. 31772.033220: netif_receive_skb: dev=wlan0 skbaddr=ffff88009d432e00 len=1500 -+ . -+ . -+ . -+ -+ The following example demonstrates how multiple hist triggers can be -+ attached to a given event. This capability can be useful for -+ creating a set of different summaries derived from the same set of -+ events, or for comparing the effects of different filters, among -+ other things. -+ -+ # echo 'hist:keys=skbaddr.hex:vals=len if len < 0' >> \ -+ /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger -+ # echo 'hist:keys=skbaddr.hex:vals=len if len > 4096' >> \ -+ /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger -+ # echo 'hist:keys=skbaddr.hex:vals=len if len == 256' >> \ -+ /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger -+ # echo 'hist:keys=skbaddr.hex:vals=len' >> \ -+ /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger -+ # echo 'hist:keys=len:vals=common_preempt_count' >> \ -+ /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger -+ -+ The above set of commands create four triggers differing only in -+ their filters, along with a completely different though fairly -+ nonsensical trigger. Note that in order to append multiple hist -+ triggers to the same file, you should use the '>>' operator to -+ append them ('>' will also add the new hist trigger, but will remove -+ any existing hist triggers beforehand). -+ -+ Displaying the contents of the 'hist' file for the event shows the -+ contents of all five histograms: -+ -+ # cat /sys/kernel/debug/tracing/events/net/netif_receive_skb/hist -+ -+ # event histogram -+ # -+ # trigger info: hist:keys=len:vals=hitcount,common_preempt_count:sort=hitcount:size=2048 [active] -+ # -+ -+ { len: 176 } hitcount: 1 common_preempt_count: 0 -+ { len: 223 } hitcount: 1 common_preempt_count: 0 -+ { len: 4854 } hitcount: 1 common_preempt_count: 0 -+ { len: 395 } hitcount: 1 common_preempt_count: 0 -+ { len: 177 } hitcount: 1 common_preempt_count: 0 -+ { len: 446 } hitcount: 1 common_preempt_count: 0 -+ { len: 1601 } hitcount: 1 common_preempt_count: 0 -+ . -+ . -+ . -+ { len: 1280 } hitcount: 66 common_preempt_count: 0 -+ { len: 116 } hitcount: 81 common_preempt_count: 40 -+ { len: 708 } hitcount: 112 common_preempt_count: 0 -+ { len: 46 } hitcount: 221 common_preempt_count: 0 -+ { len: 1264 } hitcount: 458 common_preempt_count: 0 -+ -+ Totals: -+ Hits: 1428 -+ Entries: 147 -+ Dropped: 0 -+ -+ -+ # event histogram -+ # -+ # trigger info: hist:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 [active] -+ # -+ -+ { skbaddr: ffff8800baee5e00 } hitcount: 1 len: 130 -+ { skbaddr: ffff88005f3d5600 } hitcount: 1 len: 1280 -+ { skbaddr: ffff88005f3d4900 } hitcount: 1 len: 1280 -+ { skbaddr: ffff88009fed6300 } hitcount: 1 len: 115 -+ { skbaddr: ffff88009fe0ad00 } hitcount: 1 len: 115 -+ { skbaddr: ffff88008cdb1900 } hitcount: 1 len: 46 -+ { skbaddr: ffff880064b5ef00 } hitcount: 1 len: 118 -+ { skbaddr: ffff880044e3c700 } hitcount: 1 len: 60 -+ { skbaddr: ffff880100065900 } hitcount: 1 len: 46 -+ { skbaddr: ffff8800d46bd500 } hitcount: 1 len: 116 -+ { skbaddr: ffff88005f3d5f00 } hitcount: 1 len: 1280 -+ { skbaddr: ffff880100064700 } hitcount: 1 len: 365 -+ { skbaddr: ffff8800badb6f00 } hitcount: 1 len: 60 -+ . -+ . -+ . -+ { skbaddr: ffff88009fe0be00 } hitcount: 27 len: 24677 -+ { skbaddr: ffff88009fe0a400 } hitcount: 27 len: 23052 -+ { skbaddr: ffff88009fe0b700 } hitcount: 31 len: 25589 -+ { skbaddr: ffff88009fe0b600 } hitcount: 32 len: 27326 -+ { skbaddr: ffff88006a462800 } hitcount: 68 len: 71678 -+ { skbaddr: ffff88006a463700 } hitcount: 70 len: 72678 -+ { skbaddr: ffff88006a462b00 } hitcount: 71 len: 77589 -+ { skbaddr: ffff88006a463600 } hitcount: 73 len: 71307 -+ { skbaddr: ffff88006a462200 } hitcount: 81 len: 81032 -+ -+ Totals: -+ Hits: 1451 -+ Entries: 318 -+ Dropped: 0 -+ -+ -+ # event histogram -+ # -+ # trigger info: hist:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 if len == 256 [active] -+ # -+ -+ -+ Totals: -+ Hits: 0 -+ Entries: 0 -+ Dropped: 0 -+ -+ -+ # event histogram -+ # -+ # trigger info: hist:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 if len > 4096 [active] -+ # -+ -+ { skbaddr: ffff88009fd2c300 } hitcount: 1 len: 7212 -+ { skbaddr: ffff8800d2bcce00 } hitcount: 1 len: 7212 -+ { skbaddr: ffff8800d2bcd700 } hitcount: 1 len: 7212 -+ { skbaddr: ffff8800d2bcda00 } hitcount: 1 len: 21492 -+ { skbaddr: ffff8800ae2e2d00 } hitcount: 1 len: 7212 -+ { skbaddr: ffff8800d2bcdb00 } hitcount: 1 len: 7212 -+ { skbaddr: ffff88006a4df500 } hitcount: 1 len: 4854 -+ { skbaddr: ffff88008ce47b00 } hitcount: 1 len: 18636 -+ { skbaddr: ffff8800ae2e2200 } hitcount: 1 len: 12924 -+ { skbaddr: ffff88005f3e1000 } hitcount: 1 len: 4356 -+ { skbaddr: ffff8800d2bcdc00 } hitcount: 2 len: 24420 -+ { skbaddr: ffff8800d2bcc200 } hitcount: 2 len: 12996 -+ -+ Totals: -+ Hits: 14 -+ Entries: 12 -+ Dropped: 0 -+ -+ -+ # event histogram -+ # -+ # trigger info: hist:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 if len < 0 [active] -+ # -+ -+ -+ Totals: -+ Hits: 0 -+ Entries: 0 -+ Dropped: 0 -+ -+ Named triggers can be used to have triggers share a common set of -+ histogram data. This capability is mostly useful for combining the -+ output of events generated by tracepoints contained inside inline -+ functions, but names can be used in a hist trigger on any event. -+ For example, these two triggers when hit will update the same 'len' -+ field in the shared 'foo' histogram data: -+ -+ # echo 'hist:name=foo:keys=skbaddr.hex:vals=len' > \ -+ /sys/kernel/debug/tracing/events/net/netif_receive_skb/trigger -+ # echo 'hist:name=foo:keys=skbaddr.hex:vals=len' > \ -+ /sys/kernel/debug/tracing/events/net/netif_rx/trigger -+ -+ You can see that they're updating common histogram data by reading -+ each event's hist files at the same time: -+ -+ # cat /sys/kernel/debug/tracing/events/net/netif_receive_skb/hist; -+ cat /sys/kernel/debug/tracing/events/net/netif_rx/hist -+ -+ # event histogram -+ # -+ # trigger info: hist:name=foo:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 [active] -+ # -+ -+ { skbaddr: ffff88000ad53500 } hitcount: 1 len: 46 -+ { skbaddr: ffff8800af5a1500 } hitcount: 1 len: 76 -+ { skbaddr: ffff8800d62a1900 } hitcount: 1 len: 46 -+ { skbaddr: ffff8800d2bccb00 } hitcount: 1 len: 468 -+ { skbaddr: ffff8800d3c69900 } hitcount: 1 len: 46 -+ { skbaddr: ffff88009ff09100 } hitcount: 1 len: 52 -+ { skbaddr: ffff88010f13ab00 } hitcount: 1 len: 168 -+ { skbaddr: ffff88006a54f400 } hitcount: 1 len: 46 -+ { skbaddr: ffff8800d2bcc500 } hitcount: 1 len: 260 -+ { skbaddr: ffff880064505000 } hitcount: 1 len: 46 -+ { skbaddr: ffff8800baf24e00 } hitcount: 1 len: 32 -+ { skbaddr: ffff88009fe0ad00 } hitcount: 1 len: 46 -+ { skbaddr: ffff8800d3edff00 } hitcount: 1 len: 44 -+ { skbaddr: ffff88009fe0b400 } hitcount: 1 len: 168 -+ { skbaddr: ffff8800a1c55a00 } hitcount: 1 len: 40 -+ { skbaddr: ffff8800d2bcd100 } hitcount: 1 len: 40 -+ { skbaddr: ffff880064505f00 } hitcount: 1 len: 174 -+ { skbaddr: ffff8800a8bff200 } hitcount: 1 len: 160 -+ { skbaddr: ffff880044e3cc00 } hitcount: 1 len: 76 -+ { skbaddr: ffff8800a8bfe700 } hitcount: 1 len: 46 -+ { skbaddr: ffff8800d2bcdc00 } hitcount: 1 len: 32 -+ { skbaddr: ffff8800a1f64800 } hitcount: 1 len: 46 -+ { skbaddr: ffff8800d2bcde00 } hitcount: 1 len: 988 -+ { skbaddr: ffff88006a5dea00 } hitcount: 1 len: 46 -+ { skbaddr: ffff88002e37a200 } hitcount: 1 len: 44 -+ { skbaddr: ffff8800a1f32c00 } hitcount: 2 len: 676 -+ { skbaddr: ffff88000ad52600 } hitcount: 2 len: 107 -+ { skbaddr: ffff8800a1f91e00 } hitcount: 2 len: 92 -+ { skbaddr: ffff8800af5a0200 } hitcount: 2 len: 142 -+ { skbaddr: ffff8800d2bcc600 } hitcount: 2 len: 220 -+ { skbaddr: ffff8800ba36f500 } hitcount: 2 len: 92 -+ { skbaddr: ffff8800d021f800 } hitcount: 2 len: 92 -+ { skbaddr: ffff8800a1f33600 } hitcount: 2 len: 675 -+ { skbaddr: ffff8800a8bfff00 } hitcount: 3 len: 138 -+ { skbaddr: ffff8800d62a1300 } hitcount: 3 len: 138 -+ { skbaddr: ffff88002e37a100 } hitcount: 4 len: 184 -+ { skbaddr: ffff880064504400 } hitcount: 4 len: 184 -+ { skbaddr: ffff8800a8bfec00 } hitcount: 4 len: 184 -+ { skbaddr: ffff88000ad53700 } hitcount: 5 len: 230 -+ { skbaddr: ffff8800d2bcdb00 } hitcount: 5 len: 196 -+ { skbaddr: ffff8800a1f90000 } hitcount: 6 len: 276 -+ { skbaddr: ffff88006a54f900 } hitcount: 6 len: 276 -+ -+ Totals: -+ Hits: 81 -+ Entries: 42 -+ Dropped: 0 -+ # event histogram -+ # -+ # trigger info: hist:name=foo:keys=skbaddr.hex:vals=hitcount,len:sort=hitcount:size=2048 [active] -+ # -+ -+ { skbaddr: ffff88000ad53500 } hitcount: 1 len: 46 -+ { skbaddr: ffff8800af5a1500 } hitcount: 1 len: 76 -+ { skbaddr: ffff8800d62a1900 } hitcount: 1 len: 46 -+ { skbaddr: ffff8800d2bccb00 } hitcount: 1 len: 468 -+ { skbaddr: ffff8800d3c69900 } hitcount: 1 len: 46 -+ { skbaddr: ffff88009ff09100 } hitcount: 1 len: 52 -+ { skbaddr: ffff88010f13ab00 } hitcount: 1 len: 168 -+ { skbaddr: ffff88006a54f400 } hitcount: 1 len: 46 -+ { skbaddr: ffff8800d2bcc500 } hitcount: 1 len: 260 -+ { skbaddr: ffff880064505000 } hitcount: 1 len: 46 -+ { skbaddr: ffff8800baf24e00 } hitcount: 1 len: 32 -+ { skbaddr: ffff88009fe0ad00 } hitcount: 1 len: 46 -+ { skbaddr: ffff8800d3edff00 } hitcount: 1 len: 44 -+ { skbaddr: ffff88009fe0b400 } hitcount: 1 len: 168 -+ { skbaddr: ffff8800a1c55a00 } hitcount: 1 len: 40 -+ { skbaddr: ffff8800d2bcd100 } hitcount: 1 len: 40 -+ { skbaddr: ffff880064505f00 } hitcount: 1 len: 174 -+ { skbaddr: ffff8800a8bff200 } hitcount: 1 len: 160 -+ { skbaddr: ffff880044e3cc00 } hitcount: 1 len: 76 -+ { skbaddr: ffff8800a8bfe700 } hitcount: 1 len: 46 -+ { skbaddr: ffff8800d2bcdc00 } hitcount: 1 len: 32 -+ { skbaddr: ffff8800a1f64800 } hitcount: 1 len: 46 -+ { skbaddr: ffff8800d2bcde00 } hitcount: 1 len: 988 -+ { skbaddr: ffff88006a5dea00 } hitcount: 1 len: 46 -+ { skbaddr: ffff88002e37a200 } hitcount: 1 len: 44 -+ { skbaddr: ffff8800a1f32c00 } hitcount: 2 len: 676 -+ { skbaddr: ffff88000ad52600 } hitcount: 2 len: 107 -+ { skbaddr: ffff8800a1f91e00 } hitcount: 2 len: 92 -+ { skbaddr: ffff8800af5a0200 } hitcount: 2 len: 142 -+ { skbaddr: ffff8800d2bcc600 } hitcount: 2 len: 220 -+ { skbaddr: ffff8800ba36f500 } hitcount: 2 len: 92 -+ { skbaddr: ffff8800d021f800 } hitcount: 2 len: 92 -+ { skbaddr: ffff8800a1f33600 } hitcount: 2 len: 675 -+ { skbaddr: ffff8800a8bfff00 } hitcount: 3 len: 138 -+ { skbaddr: ffff8800d62a1300 } hitcount: 3 len: 138 -+ { skbaddr: ffff88002e37a100 } hitcount: 4 len: 184 -+ { skbaddr: ffff880064504400 } hitcount: 4 len: 184 -+ { skbaddr: ffff8800a8bfec00 } hitcount: 4 len: 184 -+ { skbaddr: ffff88000ad53700 } hitcount: 5 len: 230 -+ { skbaddr: ffff8800d2bcdb00 } hitcount: 5 len: 196 -+ { skbaddr: ffff8800a1f90000 } hitcount: 6 len: 276 -+ { skbaddr: ffff88006a54f900 } hitcount: 6 len: 276 -+ -+ Totals: -+ Hits: 81 -+ Entries: 42 -+ Dropped: 0 -+ -+ And here's an example that shows how to combine histogram data from -+ any two events even if they don't share any 'compatible' fields -+ other than 'hitcount' and 'stacktrace'. These commands create a -+ couple of triggers named 'bar' using those fields: -+ -+ # echo 'hist:name=bar:key=stacktrace:val=hitcount' > \ -+ /sys/kernel/debug/tracing/events/sched/sched_process_fork/trigger -+ # echo 'hist:name=bar:key=stacktrace:val=hitcount' > \ -+ /sys/kernel/debug/tracing/events/net/netif_rx/trigger -+ -+ And displaying the output of either shows some interesting if -+ somewhat confusing output: -+ -+ # cat /sys/kernel/debug/tracing/events/sched/sched_process_fork/hist -+ # cat /sys/kernel/debug/tracing/events/net/netif_rx/hist -+ -+ # event histogram -+ # -+ # trigger info: hist:name=bar:keys=stacktrace:vals=hitcount:sort=hitcount:size=2048 [active] -+ # -+ -+ { stacktrace: -+ _do_fork+0x18e/0x330 -+ kernel_thread+0x29/0x30 -+ kthreadd+0x154/0x1b0 -+ ret_from_fork+0x3f/0x70 -+ } hitcount: 1 -+ { stacktrace: -+ netif_rx_internal+0xb2/0xd0 -+ netif_rx_ni+0x20/0x70 -+ dev_loopback_xmit+0xaa/0xd0 -+ ip_mc_output+0x126/0x240 -+ ip_local_out_sk+0x31/0x40 -+ igmp_send_report+0x1e9/0x230 -+ igmp_timer_expire+0xe9/0x120 -+ call_timer_fn+0x39/0xf0 -+ run_timer_softirq+0x1e1/0x290 -+ __do_softirq+0xfd/0x290 -+ irq_exit+0x98/0xb0 -+ smp_apic_timer_interrupt+0x4a/0x60 -+ apic_timer_interrupt+0x6d/0x80 -+ cpuidle_enter+0x17/0x20 -+ call_cpuidle+0x3b/0x60 -+ cpu_startup_entry+0x22d/0x310 -+ } hitcount: 1 -+ { stacktrace: -+ netif_rx_internal+0xb2/0xd0 -+ netif_rx_ni+0x20/0x70 -+ dev_loopback_xmit+0xaa/0xd0 -+ ip_mc_output+0x17f/0x240 -+ ip_local_out_sk+0x31/0x40 -+ ip_send_skb+0x1a/0x50 -+ udp_send_skb+0x13e/0x270 -+ udp_sendmsg+0x2bf/0x980 -+ inet_sendmsg+0x67/0xa0 -+ sock_sendmsg+0x38/0x50 -+ SYSC_sendto+0xef/0x170 -+ SyS_sendto+0xe/0x10 -+ entry_SYSCALL_64_fastpath+0x12/0x6a -+ } hitcount: 2 -+ { stacktrace: -+ netif_rx_internal+0xb2/0xd0 -+ netif_rx+0x1c/0x60 -+ loopback_xmit+0x6c/0xb0 -+ dev_hard_start_xmit+0x219/0x3a0 -+ __dev_queue_xmit+0x415/0x4f0 -+ dev_queue_xmit_sk+0x13/0x20 -+ ip_finish_output2+0x237/0x340 -+ ip_finish_output+0x113/0x1d0 -+ ip_output+0x66/0xc0 -+ ip_local_out_sk+0x31/0x40 -+ ip_send_skb+0x1a/0x50 -+ udp_send_skb+0x16d/0x270 -+ udp_sendmsg+0x2bf/0x980 -+ inet_sendmsg+0x67/0xa0 -+ sock_sendmsg+0x38/0x50 -+ ___sys_sendmsg+0x14e/0x270 -+ } hitcount: 76 -+ { stacktrace: -+ netif_rx_internal+0xb2/0xd0 -+ netif_rx+0x1c/0x60 -+ loopback_xmit+0x6c/0xb0 -+ dev_hard_start_xmit+0x219/0x3a0 -+ __dev_queue_xmit+0x415/0x4f0 -+ dev_queue_xmit_sk+0x13/0x20 -+ ip_finish_output2+0x237/0x340 -+ ip_finish_output+0x113/0x1d0 -+ ip_output+0x66/0xc0 -+ ip_local_out_sk+0x31/0x40 -+ ip_send_skb+0x1a/0x50 -+ udp_send_skb+0x16d/0x270 -+ udp_sendmsg+0x2bf/0x980 -+ inet_sendmsg+0x67/0xa0 -+ sock_sendmsg+0x38/0x50 -+ ___sys_sendmsg+0x269/0x270 -+ } hitcount: 77 -+ { stacktrace: -+ netif_rx_internal+0xb2/0xd0 -+ netif_rx+0x1c/0x60 -+ loopback_xmit+0x6c/0xb0 -+ dev_hard_start_xmit+0x219/0x3a0 -+ __dev_queue_xmit+0x415/0x4f0 -+ dev_queue_xmit_sk+0x13/0x20 -+ ip_finish_output2+0x237/0x340 -+ ip_finish_output+0x113/0x1d0 -+ ip_output+0x66/0xc0 -+ ip_local_out_sk+0x31/0x40 -+ ip_send_skb+0x1a/0x50 -+ udp_send_skb+0x16d/0x270 -+ udp_sendmsg+0x2bf/0x980 -+ inet_sendmsg+0x67/0xa0 -+ sock_sendmsg+0x38/0x50 -+ SYSC_sendto+0xef/0x170 -+ } hitcount: 88 -+ { stacktrace: -+ _do_fork+0x18e/0x330 -+ SyS_clone+0x19/0x20 -+ entry_SYSCALL_64_fastpath+0x12/0x6a -+ } hitcount: 244 -+ -+ Totals: -+ Hits: 489 -+ Entries: 7 -+ Dropped: 0 diff --git a/debian/patches/features/all/rt/0001-tracing-Steve-s-unofficial-trace_recursive_lock-patc.patch b/debian/patches/features/all/rt/0001-tracing-Steve-s-unofficial-trace_recursive_lock-patc.patch deleted file mode 100644 index 82acdc732..000000000 --- a/debian/patches/features/all/rt/0001-tracing-Steve-s-unofficial-trace_recursive_lock-patc.patch +++ /dev/null @@ -1,128 +0,0 @@ -From: Steven Rostedt -Date: Fri, 22 Sep 2017 14:58:15 -0500 -Subject: [PATCH 01/42] tracing: Steve's unofficial trace_recursive_lock() - patch -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -On Tue, 5 Sep 2017 16:57:52 -0500 -Tom Zanussi wrote: - -> Synthetic event generation requires the reservation of a second event -> while the reservation of a previous event is still in progress. The -> trace_recursive_lock() check in ring_buffer_lock_reserve() prevents -> this however. -> -> This sets up a special reserve pathway for this particular case, -> leaving existing pathways untouched, other than an additional check in -> ring_buffer_lock_reserve() and trace_event_buffer_reserve(). These -> checks could be gotten rid of as well, with copies of those functions, -> but for now try to avoid that unless necessary. -> -> Signed-off-by: Tom Zanussi - -I've been planing on changing that lock, which may help you here -without having to mess around with parameters. That is to simply add a -counter. Would this patch help you. You can add a patch to increment -the count to 5 with an explanation of handling synthetic events, but -even getting to 4 is extremely unlikely. - -I'll make this into an official patch if this works for you, and then -you can include it in your series. - --- Steve - -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/ring_buffer.c | 66 ++++++++++++--------------------------------- - 1 file changed, 18 insertions(+), 48 deletions(-) - ---- a/kernel/trace/ring_buffer.c -+++ b/kernel/trace/ring_buffer.c -@@ -2542,61 +2542,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 -- * be modified more than once via an interrupt. To pass this -- * information from the lock to the unlock without having to -- * access the 'in_interrupt()' functions again (which do show -- * a bit of overhead in something as critical as function tracing, -- * we use a bitmask trick. -+ * be modified more than once via an interrupt. There are four -+ * different contexts that we need to consider. - * -- * bit 0 = NMI context -- * bit 1 = IRQ context -- * bit 2 = SoftIRQ context -- * bit 3 = normal context. -- * -- * This works because this is the order of contexts that can -- * preempt other contexts. A SoftIRQ never preempts an IRQ -- * context. -- * -- * When the context is determined, the corresponding bit is -- * checked and set (if it was set, then a recursion of that context -- * happened). -- * -- * On unlock, we need to clear this bit. To do so, just subtract -- * 1 from the current_context and AND it to itself. -- * -- * (binary) -- * 101 - 1 = 100 -- * 101 & 100 = 100 (clearing bit zero) -- * -- * 1010 - 1 = 1001 -- * 1010 & 1001 = 1000 (clearing bit 1) -- * -- * 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 -+ * recusive loop and do not let it go further. - */ - - static __always_inline int - trace_recursive_lock(struct ring_buffer_per_cpu *cpu_buffer) - { -- unsigned int val = cpu_buffer->current_context; -- int bit; -- -- if (in_interrupt()) { -- if (in_nmi()) -- bit = RB_CTX_NMI; -- else if (in_irq()) -- bit = RB_CTX_IRQ; -- else -- bit = RB_CTX_SOFTIRQ; -- } else -- bit = RB_CTX_NORMAL; -- -- if (unlikely(val & (1 << bit))) -+ if (cpu_buffer->current_context >= 4) - return 1; - -- val |= (1 << bit); -- cpu_buffer->current_context = val; -+ cpu_buffer->current_context++; -+ /* Interrupts must see this update */ -+ barrier(); - - return 0; - } -@@ -2604,7 +2572,9 @@ trace_recursive_lock(struct ring_buffer_ - static __always_inline void - trace_recursive_unlock(struct ring_buffer_per_cpu *cpu_buffer) - { -- cpu_buffer->current_context &= cpu_buffer->current_context - 1; -+ /* Don't let the dec leak out */ -+ barrier(); -+ cpu_buffer->current_context--; - } - - /** diff --git a/debian/patches/features/all/rt/0002-PM-wakeup-Make-events_lock-a-RAW_SPINLOCK.patch b/debian/patches/features/all/rt/0002-PM-wakeup-Make-events_lock-a-RAW_SPINLOCK.patch new file mode 100644 index 000000000..bf8b3e2f6 --- /dev/null +++ b/debian/patches/features/all/rt/0002-PM-wakeup-Make-events_lock-a-RAW_SPINLOCK.patch @@ -0,0 +1,82 @@ +From: Sebastian Andrzej Siewior +Date: Fri, 25 May 2018 09:57:42 +0200 +Subject: [PATCH 2/4] PM / wakeup: Make events_lock a RAW_SPINLOCK + +The `events_lock' is acquired during suspend while interrupts are +disabled even on RT. The lock is taken only for a very brief moment. +Make it a RAW lock which avoids "sleeping while atomic" warnings on RT. + +Signed-off-by: Sebastian Andrzej Siewior +--- + drivers/base/power/wakeup.c | 18 +++++++++--------- + 1 file changed, 9 insertions(+), 9 deletions(-) + +--- a/drivers/base/power/wakeup.c ++++ b/drivers/base/power/wakeup.c +@@ -57,7 +57,7 @@ static void split_counters(unsigned int + /* A preserved old value of the events counter. */ + static unsigned int saved_count; + +-static DEFINE_SPINLOCK(events_lock); ++static DEFINE_RAW_SPINLOCK(events_lock); + + static void pm_wakeup_timer_fn(struct timer_list *t); + +@@ -185,9 +185,9 @@ void wakeup_source_add(struct wakeup_sou + ws->active = false; + ws->last_time = ktime_get(); + +- spin_lock_irqsave(&events_lock, flags); ++ raw_spin_lock_irqsave(&events_lock, flags); + list_add_rcu(&ws->entry, &wakeup_sources); +- spin_unlock_irqrestore(&events_lock, flags); ++ raw_spin_unlock_irqrestore(&events_lock, flags); + } + EXPORT_SYMBOL_GPL(wakeup_source_add); + +@@ -202,9 +202,9 @@ void wakeup_source_remove(struct wakeup_ + if (WARN_ON(!ws)) + return; + +- spin_lock_irqsave(&events_lock, flags); ++ raw_spin_lock_irqsave(&events_lock, flags); + list_del_rcu(&ws->entry); +- spin_unlock_irqrestore(&events_lock, flags); ++ raw_spin_unlock_irqrestore(&events_lock, flags); + synchronize_srcu(&wakeup_srcu); + } + EXPORT_SYMBOL_GPL(wakeup_source_remove); +@@ -843,7 +843,7 @@ bool pm_wakeup_pending(void) + unsigned long flags; + bool ret = false; + +- spin_lock_irqsave(&events_lock, flags); ++ raw_spin_lock_irqsave(&events_lock, flags); + if (events_check_enabled) { + unsigned int cnt, inpr; + +@@ -851,7 +851,7 @@ bool pm_wakeup_pending(void) + ret = (cnt != saved_count || inpr > 0); + events_check_enabled = !ret; + } +- spin_unlock_irqrestore(&events_lock, flags); ++ raw_spin_unlock_irqrestore(&events_lock, flags); + + if (ret) { + pr_info("PM: Wakeup pending, aborting suspend\n"); +@@ -940,13 +940,13 @@ bool pm_save_wakeup_count(unsigned int c + unsigned long flags; + + events_check_enabled = false; +- spin_lock_irqsave(&events_lock, flags); ++ raw_spin_lock_irqsave(&events_lock, flags); + split_counters(&cnt, &inpr); + if (cnt == count && inpr == 0) { + saved_count = count; + events_check_enabled = true; + } +- spin_unlock_irqrestore(&events_lock, flags); ++ raw_spin_unlock_irqrestore(&events_lock, flags); + return events_check_enabled; + } + diff --git a/debian/patches/features/all/rt/0002-clocksource-drivers-Add-a-new-driver-for-the-Atmel-A.patch b/debian/patches/features/all/rt/0002-clocksource-drivers-Add-a-new-driver-for-the-Atmel-A.patch index dafeae764..c5f14f5ca 100644 --- a/debian/patches/features/all/rt/0002-clocksource-drivers-Add-a-new-driver-for-the-Atmel-A.patch +++ b/debian/patches/features/all/rt/0002-clocksource-drivers-Add-a-new-driver-for-the-Atmel-A.patch @@ -2,7 +2,6 @@ From: Alexandre Belloni Date: Wed, 18 Apr 2018 12:51:39 +0200 Subject: [PATCH 2/6] clocksource/drivers: Add a new driver for the Atmel ARM TC blocks -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Add a driver for the Atmel Timer Counter Blocks. This driver provides a clocksource and two clockevent devices. diff --git a/debian/patches/features/all/rt/0007-md-raid5-Use-irqsave-variant-of-refcount_dec_and_loc.patch b/debian/patches/features/all/rt/0002-drivers-md-raid5-Use-irqsave-variant-of-atomic_dec_a.patch similarity index 66% rename from debian/patches/features/all/rt/0007-md-raid5-Use-irqsave-variant-of-refcount_dec_and_loc.patch rename to debian/patches/features/all/rt/0002-drivers-md-raid5-Use-irqsave-variant-of-atomic_dec_a.patch index 1bc57a024..e95405005 100644 --- a/debian/patches/features/all/rt/0007-md-raid5-Use-irqsave-variant-of-refcount_dec_and_loc.patch +++ b/debian/patches/features/all/rt/0002-drivers-md-raid5-Use-irqsave-variant-of-atomic_dec_a.patch @@ -1,14 +1,13 @@ From: Anna-Maria Gleixner -Date: Wed, 4 Apr 2018 11:43:58 +0200 -Subject: [PATCH] md: raid5: Use irqsave variant of refcount_dec_and_lock() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz +Date: Fri, 4 May 2018 17:45:32 +0200 +Subject: [PATCH 2/3] drivers/md/raid5: Use irqsave variant of + atomic_dec_and_lock() -The irqsave variant of refcount_dec_and_lock handles irqsave/restore when +The irqsave variant of atomic_dec_and_lock handles irqsave/restore when taking/releasing the spin lock. With this variant the call of local_irq_save is no longer required. Signed-off-by: Anna-Maria Gleixner -[bigeasy: s@atomic_dec_and_lock@refcount_dec_and_lock@g ] Signed-off-by: Sebastian Andrzej Siewior --- drivers/md/raid5.c | 5 ++--- @@ -22,8 +21,8 @@ Signed-off-by: Sebastian Andrzej Siewior slow_path: - local_irq_save(flags); /* we are ok here if STRIPE_ON_RELEASE_LIST is set or not */ -- if (refcount_dec_and_lock(&sh->count, &conf->device_lock)) { -+ if (refcount_dec_and_lock_irqsave(&sh->count, &conf->device_lock, &flags)) { +- if (atomic_dec_and_lock(&sh->count, &conf->device_lock)) { ++ if (atomic_dec_and_lock_irqsave(&sh->count, &conf->device_lock, flags)) { INIT_LIST_HEAD(&list); hash = sh->hash_lock_index; do_release_stripe(conf, sh, &list); diff --git a/debian/patches/features/all/rt/0002-hrtimer-Correct-blantanly-wrong-comment.patch b/debian/patches/features/all/rt/0002-hrtimer-Correct-blantanly-wrong-comment.patch deleted file mode 100644 index a2aea8eed..000000000 --- a/debian/patches/features/all/rt/0002-hrtimer-Correct-blantanly-wrong-comment.patch +++ /dev/null @@ -1,37 +0,0 @@ -From: Thomas Gleixner -Date: Wed, 20 Dec 2017 17:12:51 +0100 -Subject: [PATCH 02/29] hrtimer: Correct blantanly wrong comment -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The protection of a hrtimer which runs its callback against migration to a -different CPU has nothing to do with hard interrupt context. - -The protection against migration of a hrtimer running the expiry callback -is the pointer in the cpu_base which holds a pointer to the currently -running timer. This pointer is evaluated in the code which potentially -switches the timer base and makes sure it's kept on the CPU on which the -callback is running. - -Reported-by: Anna-Maria Gleixner -Signed-off-by: Thomas Gleixner -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/time/hrtimer.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -1197,9 +1197,9 @@ static void __run_hrtimer(struct hrtimer - timer->is_rel = false; - - /* -- * Because we run timers from hardirq context, there is no chance -- * they get migrated to another cpu, therefore its safe to unlock -- * the timer base. -+ * The timer is marked as running in the cpu base, so it is -+ * protected against migration to a different CPU even if the lock -+ * is dropped. - */ - raw_spin_unlock(&cpu_base->lock); - trace_hrtimer_expire_entry(timer, now); diff --git a/debian/patches/features/all/rt/0002-iommu-amd-Don-t-use-dev_data-in-irte_ga_set_affinity.patch b/debian/patches/features/all/rt/0002-iommu-amd-Don-t-use-dev_data-in-irte_ga_set_affinity.patch index 201002262..9fc3d32c3 100644 --- a/debian/patches/features/all/rt/0002-iommu-amd-Don-t-use-dev_data-in-irte_ga_set_affinity.patch +++ b/debian/patches/features/all/rt/0002-iommu-amd-Don-t-use-dev_data-in-irte_ga_set_affinity.patch @@ -1,7 +1,6 @@ From: Scott Wood Date: Sun, 28 Jan 2018 14:22:19 -0600 Subject: [PATCH 2/3] iommu/amd: Don't use dev_data in irte_ga_set_affinity() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 01ee04badefd296eb7a4430497373be9b7b16783 diff --git a/debian/patches/features/all/rt/0002-iommu-amd-Turn-dev_data_list-into-a-lock-less-list.patch b/debian/patches/features/all/rt/0002-iommu-amd-Turn-dev_data_list-into-a-lock-less-list.patch index 9c60288f4..986be5fe8 100644 --- a/debian/patches/features/all/rt/0002-iommu-amd-Turn-dev_data_list-into-a-lock-less-list.patch +++ b/debian/patches/features/all/rt/0002-iommu-amd-Turn-dev_data_list-into-a-lock-less-list.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 22 Mar 2018 16:22:34 +0100 Subject: [PATCH 02/10] iommu/amd: Turn dev_data_list into a lock less list -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 779da73273fc4c4c6f41579a95e4fb7880a1720e diff --git a/debian/patches/features/all/rt/0002-nohz-Prevent-erroneous-tick-stop-invocations.patch b/debian/patches/features/all/rt/0002-nohz-Prevent-erroneous-tick-stop-invocations.patch deleted file mode 100644 index 2be6d512c..000000000 --- a/debian/patches/features/all/rt/0002-nohz-Prevent-erroneous-tick-stop-invocations.patch +++ /dev/null @@ -1,53 +0,0 @@ -From: Thomas Gleixner -Date: Fri, 22 Dec 2017 15:51:13 +0100 -Subject: [PATCH 2/4] nohz: Prevent erroneous tick stop invocations -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.8-rt9.tar.xz - -The conditions in irq_exit() to invoke tick_nohz_irq_exit() are: - - if ((idle_cpu(cpu) && !need_resched()) || tick_nohz_full_cpu(cpu)) - -This is too permissive in various aspects: - - 1) If need_resched() is set, then the tick cannot be stopped whether - the CPU is idle or in nohz full mode. - - 2) If need_resched() is not set, but softirqs are pending then this is an - indication that the softirq code punted and delegated the execution to - softirqd. need_resched() is not true because the current interrupted - task takes precedence over softirqd. - -Invoking tick_nohz_irq_exit() in these cases can cause an endless loop of -timer interrupts because the timer wheel contains an expired timer, but -softirqs are not yet executed. So it returns an immediate expiry request, -which causes the timer to fire immediately again. Lather, rinse and -repeat.... - -Prevent that by making the conditions proper and only allow invokation when -in idle or nohz full mode and neither need_resched() nor -local_softirq_pending() are set. - -Signed-off-by: Thomas Gleixner -Cc: stable@vger.kernel.org -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/softirq.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/kernel/softirq.c b/kernel/softirq.c -index 4e09821f9d9e..6d260b1229a1 100644 ---- a/kernel/softirq.c -+++ b/kernel/softirq.c -@@ -381,7 +381,8 @@ static inline void tick_irq_exit(void) - int cpu = smp_processor_id(); - - /* Make sure that timer wheel updates are propagated */ -- if ((idle_cpu(cpu) && !need_resched()) || tick_nohz_full_cpu(cpu)) { -+ if ((idle_cpu(cpu) || tick_nohz_full_cpu(cpu)) && -+ !need_resched() && !local_softirq_pending()) { - if (!in_interrupt()) - tick_nohz_irq_exit(); - } --- -2.15.1 - diff --git a/debian/patches/features/all/rt/0002-now-lock_parent-can-t-run-into-killed-dentry.patch b/debian/patches/features/all/rt/0002-now-lock_parent-can-t-run-into-killed-dentry.patch index 4d4303f77..d948f5e1b 100644 --- a/debian/patches/features/all/rt/0002-now-lock_parent-can-t-run-into-killed-dentry.patch +++ b/debian/patches/features/all/rt/0002-now-lock_parent-can-t-run-into-killed-dentry.patch @@ -1,7 +1,6 @@ From: Al Viro Date: Fri, 23 Feb 2018 22:07:35 -0500 Subject: [PATCH 02/17] now lock_parent() can't run into killed dentry -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 65d8eb5a8f5480756105173de147ef5d60163e2f diff --git a/debian/patches/features/all/rt/0002-tracing-Add-Documentation-for-log2-modifier.patch b/debian/patches/features/all/rt/0002-tracing-Add-Documentation-for-log2-modifier.patch deleted file mode 100644 index b12593ea4..000000000 --- a/debian/patches/features/all/rt/0002-tracing-Add-Documentation-for-log2-modifier.patch +++ /dev/null @@ -1,24 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:36 -0600 -Subject: [PATCH 02/37] tracing: Add Documentation for log2 modifier -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Add a line for the log2 modifier, to keep it aligned with -tracing/README. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - Documentation/trace/histogram.txt | 1 + - 1 file changed, 1 insertion(+) - ---- a/Documentation/trace/histogram.txt -+++ b/Documentation/trace/histogram.txt -@@ -73,6 +73,7 @@ - .sym-offset display an address as a symbol and offset - .syscall display a syscall id as a system call name - .execname display a common_pid as a program name -+ .log2 display log2 value rather than raw number - - Note that in general the semantics of a given field aren't - interpreted when applying a modifier to it, but there are some diff --git a/debian/patches/features/all/rt/0002-tracing-Add-field-parsing-hist-error-for-hist-trigge.patch b/debian/patches/features/all/rt/0002-tracing-Add-field-parsing-hist-error-for-hist-trigge.patch index 6bb90190f..0311b77a7 100644 --- a/debian/patches/features/all/rt/0002-tracing-Add-field-parsing-hist-error-for-hist-trigge.patch +++ b/debian/patches/features/all/rt/0002-tracing-Add-field-parsing-hist-error-for-hist-trigge.patch @@ -1,7 +1,6 @@ From: Steven Rostedt Date: Wed, 16 May 2018 09:36:44 -0400 Subject: [PATCH 2/5] tracing: Add field parsing hist error for hist triggers -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz From: Tom Zanussi diff --git a/debian/patches/features/all/rt/0002-tracing-Reverse-the-order-of-trace_types_lock-and-ev.patch b/debian/patches/features/all/rt/0002-tracing-Reverse-the-order-of-trace_types_lock-and-ev.patch deleted file mode 100644 index bb7800f95..000000000 --- a/debian/patches/features/all/rt/0002-tracing-Reverse-the-order-of-trace_types_lock-and-ev.patch +++ /dev/null @@ -1,189 +0,0 @@ -From: "Steven Rostedt (VMware)" -Date: Fri, 22 Sep 2017 14:58:16 -0500 -Subject: [PATCH 02/42] tracing: Reverse the order of trace_types_lock and - event_mutex -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -In order to make future changes where we need to call -tracing_set_clock() from within an event command, the order of -trace_types_lock and event_mutex must be reversed, as the event command -will hold event_mutex and the trace_types_lock is taken from within -tracing_set_clock(). - -Requested-by: Tom Zanussi -Signed-off-by: Steven Rostedt (VMware) -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace.c | 5 +++++ - kernel/trace/trace_events.c | 31 +++++++++++++++---------------- - 2 files changed, 20 insertions(+), 16 deletions(-) - ---- a/kernel/trace/trace.c -+++ b/kernel/trace/trace.c -@@ -7671,6 +7671,7 @@ static int instance_mkdir(const char *na - struct trace_array *tr; - int ret; - -+ mutex_lock(&event_mutex); - mutex_lock(&trace_types_lock); - - ret = -EEXIST; -@@ -7726,6 +7727,7 @@ static int instance_mkdir(const char *na - list_add(&tr->list, &ftrace_trace_arrays); - - mutex_unlock(&trace_types_lock); -+ mutex_unlock(&event_mutex); - - return 0; - -@@ -7737,6 +7739,7 @@ static int instance_mkdir(const char *na - - out_unlock: - mutex_unlock(&trace_types_lock); -+ mutex_unlock(&event_mutex); - - return ret; - -@@ -7749,6 +7752,7 @@ static int instance_rmdir(const char *na - int ret; - int i; - -+ mutex_lock(&event_mutex); - mutex_lock(&trace_types_lock); - - ret = -ENODEV; -@@ -7794,6 +7798,7 @@ static int instance_rmdir(const char *na - - out_unlock: - mutex_unlock(&trace_types_lock); -+ mutex_unlock(&event_mutex); - - return ret; - } ---- a/kernel/trace/trace_events.c -+++ b/kernel/trace/trace_events.c -@@ -1406,8 +1406,8 @@ static int subsystem_open(struct inode * - return -ENODEV; - - /* Make sure the system still exists */ -- mutex_lock(&trace_types_lock); - mutex_lock(&event_mutex); -+ mutex_lock(&trace_types_lock); - list_for_each_entry(tr, &ftrace_trace_arrays, list) { - list_for_each_entry(dir, &tr->systems, list) { - if (dir == inode->i_private) { -@@ -1421,8 +1421,8 @@ static int subsystem_open(struct inode * - } - } - exit_loop: -- mutex_unlock(&event_mutex); - mutex_unlock(&trace_types_lock); -+ mutex_unlock(&event_mutex); - - if (!system) - return -ENODEV; -@@ -2308,15 +2308,15 @@ static void __add_event_to_tracers(struc - int trace_add_event_call(struct trace_event_call *call) - { - int ret; -- mutex_lock(&trace_types_lock); - mutex_lock(&event_mutex); -+ mutex_lock(&trace_types_lock); - - ret = __register_event(call, NULL); - if (ret >= 0) - __add_event_to_tracers(call); - -- mutex_unlock(&event_mutex); - mutex_unlock(&trace_types_lock); -+ mutex_unlock(&event_mutex); - return ret; - } - -@@ -2370,13 +2370,13 @@ int trace_remove_event_call(struct trace - { - int ret; - -- mutex_lock(&trace_types_lock); - mutex_lock(&event_mutex); -+ mutex_lock(&trace_types_lock); - down_write(&trace_event_sem); - ret = probe_remove_event_call(call); - up_write(&trace_event_sem); -- mutex_unlock(&event_mutex); - mutex_unlock(&trace_types_lock); -+ mutex_unlock(&event_mutex); - - return ret; - } -@@ -2438,8 +2438,8 @@ static int trace_module_notify(struct no - { - struct module *mod = data; - -- mutex_lock(&trace_types_lock); - mutex_lock(&event_mutex); -+ mutex_lock(&trace_types_lock); - switch (val) { - case MODULE_STATE_COMING: - trace_module_add_events(mod); -@@ -2448,8 +2448,8 @@ static int trace_module_notify(struct no - trace_module_remove_events(mod); - break; - } -- mutex_unlock(&event_mutex); - mutex_unlock(&trace_types_lock); -+ mutex_unlock(&event_mutex); - - return 0; - } -@@ -2964,24 +2964,24 @@ create_event_toplevel_files(struct dentr - * creates the event hierachry in the @parent/events directory. - * - * Returns 0 on success. -+ * -+ * Must be called with event_mutex held. - */ - int event_trace_add_tracer(struct dentry *parent, struct trace_array *tr) - { - int ret; - -- mutex_lock(&event_mutex); -+ lockdep_assert_held(&event_mutex); - - ret = create_event_toplevel_files(parent, tr); - if (ret) -- goto out_unlock; -+ goto out; - - down_write(&trace_event_sem); - __trace_add_event_dirs(tr); - up_write(&trace_event_sem); - -- out_unlock: -- mutex_unlock(&event_mutex); -- -+ out: - return ret; - } - -@@ -3010,9 +3010,10 @@ early_event_add_tracer(struct dentry *pa - return ret; - } - -+/* Must be called with event_mutex held */ - int event_trace_del_tracer(struct trace_array *tr) - { -- mutex_lock(&event_mutex); -+ lockdep_assert_held(&event_mutex); - - /* Disable any event triggers and associated soft-disabled events */ - clear_event_triggers(tr); -@@ -3033,8 +3034,6 @@ int event_trace_del_tracer(struct trace_ - - tr->event_dir = NULL; - -- mutex_unlock(&event_mutex); -- - return 0; - } - diff --git a/debian/patches/features/all/rt/0002-userns-use-refcount_t-for-reference-counting-instead.patch b/debian/patches/features/all/rt/0002-userns-use-refcount_t-for-reference-counting-instead.patch index b914d03e2..938572c6c 100644 --- a/debian/patches/features/all/rt/0002-userns-use-refcount_t-for-reference-counting-instead.patch +++ b/debian/patches/features/all/rt/0002-userns-use-refcount_t-for-reference-counting-instead.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Mon, 7 May 2018 17:09:42 +0200 Subject: [PATCH] userns: use refcount_t for reference counting instead atomic_t -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz refcount_t type and corresponding API should be used instead of atomic_t when the variable is used as a reference counter. This allows to avoid accidental diff --git a/debian/patches/features/all/rt/0003-PM-s2idle-Make-s2idle_wait_head-swait-based.patch b/debian/patches/features/all/rt/0003-PM-s2idle-Make-s2idle_wait_head-swait-based.patch new file mode 100644 index 000000000..2e9a0ab4e --- /dev/null +++ b/debian/patches/features/all/rt/0003-PM-s2idle-Make-s2idle_wait_head-swait-based.patch @@ -0,0 +1,53 @@ +From: Sebastian Andrzej Siewior +Date: Fri, 25 May 2018 10:05:13 +0200 +Subject: [PATCH 3/4] PM / s2idle: Make s2idle_wait_head swait based + +s2idle_wait_head is used during s2idle with interrupts disabled even on +RT. There is no "custom" wake up function so swait could be used instead +which is also lower weight compared to the wait_queue. +Make s2idle_wait_head a swait_queue_head. + +Signed-off-by: Sebastian Andrzej Siewior +--- + kernel/power/suspend.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +--- a/kernel/power/suspend.c ++++ b/kernel/power/suspend.c +@@ -27,6 +27,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -57,7 +58,7 @@ EXPORT_SYMBOL_GPL(pm_suspend_global_flag + + static const struct platform_suspend_ops *suspend_ops; + static const struct platform_s2idle_ops *s2idle_ops; +-static DECLARE_WAIT_QUEUE_HEAD(s2idle_wait_head); ++static DECLARE_SWAIT_QUEUE_HEAD(s2idle_wait_head); + + enum s2idle_states __read_mostly s2idle_state; + static DEFINE_SPINLOCK(s2idle_lock); +@@ -91,8 +92,8 @@ static void s2idle_enter(void) + /* Push all the CPUs into the idle loop. */ + wake_up_all_idle_cpus(); + /* Make the current CPU wait so it can enter the idle loop too. */ +- wait_event(s2idle_wait_head, +- s2idle_state == S2IDLE_STATE_WAKE); ++ swait_event(s2idle_wait_head, ++ s2idle_state == S2IDLE_STATE_WAKE); + + cpuidle_pause(); + put_online_cpus(); +@@ -159,7 +160,7 @@ void s2idle_wake(void) + spin_lock_irqsave(&s2idle_lock, flags); + if (s2idle_state > S2IDLE_STATE_NONE) { + s2idle_state = S2IDLE_STATE_WAKE; +- wake_up(&s2idle_wait_head); ++ swake_up(&s2idle_wait_head); + } + spin_unlock_irqrestore(&s2idle_lock, flags); + } diff --git a/debian/patches/features/all/rt/0003-clocksource-drivers-atmel-pit-make-option-silent.patch b/debian/patches/features/all/rt/0003-clocksource-drivers-atmel-pit-make-option-silent.patch index b2a6bde46..fe6a74a3d 100644 --- a/debian/patches/features/all/rt/0003-clocksource-drivers-atmel-pit-make-option-silent.patch +++ b/debian/patches/features/all/rt/0003-clocksource-drivers-atmel-pit-make-option-silent.patch @@ -1,7 +1,6 @@ From: Alexandre Belloni Date: Wed, 18 Apr 2018 12:51:40 +0200 Subject: [PATCH 3/6] clocksource/drivers: atmel-pit: make option silent -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz To conform with the other option, make the ATMEL_PIT option silent so it can be selected from the platform diff --git a/debian/patches/features/all/rt/0008-md-raid5-Do-not-disable-irq-on-release_inactive_stri.patch b/debian/patches/features/all/rt/0003-drivers-md-raid5-Do-not-disable-irq-on-release_inact.patch similarity index 79% rename from debian/patches/features/all/rt/0008-md-raid5-Do-not-disable-irq-on-release_inactive_stri.patch rename to debian/patches/features/all/rt/0003-drivers-md-raid5-Do-not-disable-irq-on-release_inact.patch index a4e6be3bd..dff8bdff0 100644 --- a/debian/patches/features/all/rt/0008-md-raid5-Do-not-disable-irq-on-release_inactive_stri.patch +++ b/debian/patches/features/all/rt/0003-drivers-md-raid5-Do-not-disable-irq-on-release_inact.patch @@ -1,8 +1,7 @@ From: Anna-Maria Gleixner -Date: Wed, 4 Apr 2018 11:43:59 +0200 -Subject: [PATCH] md: raid5: Do not disable irq on +Date: Fri, 4 May 2018 17:45:33 +0200 +Subject: [PATCH 3/3] drivers/md/raid5: Do not disable irq on release_inactive_stripe_list() call -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz There is no need to invoke release_inactive_stripe_list() with interrupts disabled. All call sites, except raid5_release_stripe(), unlock @@ -11,7 +10,6 @@ disabled. All call sites, except raid5_release_stripe(), unlock Make it consistent. Signed-off-by: Anna-Maria Gleixner -[bigeasy: s@atomic_dec_and_lock@refcount_dec_and_lock@g ] Signed-off-by: Sebastian Andrzej Siewior --- drivers/md/raid5.c | 3 +-- diff --git a/debian/patches/features/all/rt/0003-hrtimer-Fix-kerneldoc-for-struct-hrtimer_cpu_base.patch b/debian/patches/features/all/rt/0003-hrtimer-Fix-kerneldoc-for-struct-hrtimer_cpu_base.patch deleted file mode 100644 index 03f17cba8..000000000 --- a/debian/patches/features/all/rt/0003-hrtimer-Fix-kerneldoc-for-struct-hrtimer_cpu_base.patch +++ /dev/null @@ -1,43 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:12:52 +0100 -Subject: [PATCH 03/29] hrtimer: Fix kerneldoc for struct hrtimer_cpu_base -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The sequence '/**' marks the start of a struct description. Add the -missing second asterisk. While at it adapt the ordering of the struct -members to the struct definition and document the purpose of -expires_next more precisely. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - include/linux/hrtimer.h | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - ---- a/include/linux/hrtimer.h -+++ b/include/linux/hrtimer.h -@@ -144,7 +144,7 @@ enum hrtimer_base_type { - HRTIMER_MAX_CLOCK_BASES, - }; - --/* -+/** - * struct hrtimer_cpu_base - the per cpu clock bases - * @lock: lock protecting the base and associated clock bases - * and timers -@@ -153,12 +153,12 @@ enum hrtimer_base_type { - * @cpu: cpu number - * @active_bases: Bitfield to mark bases with active timers - * @clock_was_set_seq: Sequence counter of clock was set events -- * @expires_next: absolute time of the next event which was scheduled -- * via clock_set_next_event() -- * @next_timer: Pointer to the first expiring timer - * @in_hrtirq: hrtimer_interrupt() is currently executing - * @hres_active: State of high resolution mode - * @hang_detected: The last hrtimer interrupt detected a hang -+ * @expires_next: absolute time of the next event, is required for remote -+ * hrtimer enqueue -+ * @next_timer: Pointer to the first expiring timer - * @nr_events: Total number of hrtimer interrupt events - * @nr_retries: Total number of hrtimer interrupt retries - * @nr_hangs: Total number of hrtimer interrupt hangs diff --git a/debian/patches/features/all/rt/0003-iommu-amd-Avoid-locking-get_irq_table-from-atomic-co.patch b/debian/patches/features/all/rt/0003-iommu-amd-Avoid-locking-get_irq_table-from-atomic-co.patch index 2b56c8dc2..cd4498c08 100644 --- a/debian/patches/features/all/rt/0003-iommu-amd-Avoid-locking-get_irq_table-from-atomic-co.patch +++ b/debian/patches/features/all/rt/0003-iommu-amd-Avoid-locking-get_irq_table-from-atomic-co.patch @@ -2,7 +2,6 @@ From: Scott Wood Date: Wed, 14 Feb 2018 17:36:28 -0600 Subject: [PATCH 3/3] iommu/amd: Avoid locking get_irq_table() from atomic context -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit df42a04b15f19a842393dc98a84cbc52b1f8ed49 diff --git a/debian/patches/features/all/rt/0003-iommu-amd-Split-domain-id-out-of-amd_iommu_devtable_.patch b/debian/patches/features/all/rt/0003-iommu-amd-Split-domain-id-out-of-amd_iommu_devtable_.patch index a2686d51e..279075969 100644 --- a/debian/patches/features/all/rt/0003-iommu-amd-Split-domain-id-out-of-amd_iommu_devtable_.patch +++ b/debian/patches/features/all/rt/0003-iommu-amd-Split-domain-id-out-of-amd_iommu_devtable_.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 22 Mar 2018 16:22:35 +0100 Subject: [PATCH 03/10] iommu/amd: Split domain id out of amd_iommu_devtable_lock -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 2bc00180890427dcc092b2f2b0d03c904bcade29 diff --git a/debian/patches/features/all/rt/0003-md-raid5-use-refcount_t-for-reference-counting-inste.patch b/debian/patches/features/all/rt/0003-md-raid5-use-refcount_t-for-reference-counting-inste.patch deleted file mode 100644 index a799df36b..000000000 --- a/debian/patches/features/all/rt/0003-md-raid5-use-refcount_t-for-reference-counting-inste.patch +++ /dev/null @@ -1,365 +0,0 @@ -From: Sebastian Andrzej Siewior -Date: Mon, 7 May 2018 17:42:52 +0200 -Subject: [PATCH] md: raid5: use refcount_t for reference counting instead - atomic_t -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz - -refcount_t type and corresponding API should be used instead of atomic_t when -the variable is used as a reference counter. This allows to avoid accidental -refcounter overflows that might lead to use-after-free situations. - -Most changes are 1:1 replacements except for - BUG_ON(atomic_inc_return(&sh->count) != 1); - -which has been turned into - refcount_inc(&sh->count); - BUG_ON(refcount_read(&sh->count) != 1); - -Suggested-by: Peter Zijlstra -Signed-off-by: Sebastian Andrzej Siewior ---- - drivers/md/raid5-cache.c | 8 ++--- - drivers/md/raid5-ppl.c | 2 - - drivers/md/raid5.c | 67 +++++++++++++++++++++++------------------------ - drivers/md/raid5.h | 4 +- - 4 files changed, 41 insertions(+), 40 deletions(-) - ---- a/drivers/md/raid5-cache.c -+++ b/drivers/md/raid5-cache.c -@@ -1049,7 +1049,7 @@ int r5l_write_stripe(struct r5l_log *log - * don't delay. - */ - clear_bit(STRIPE_DELAYED, &sh->state); -- atomic_inc(&sh->count); -+ refcount_inc(&sh->count); - - mutex_lock(&log->io_mutex); - /* meta + data */ -@@ -1388,7 +1388,7 @@ static void r5c_flush_stripe(struct r5co - lockdep_assert_held(&conf->device_lock); - - list_del_init(&sh->lru); -- atomic_inc(&sh->count); -+ refcount_inc(&sh->count); - - set_bit(STRIPE_HANDLE, &sh->state); - atomic_inc(&conf->active_stripes); -@@ -1491,7 +1491,7 @@ static void r5c_do_reclaim(struct r5conf - */ - if (!list_empty(&sh->lru) && - !test_bit(STRIPE_HANDLE, &sh->state) && -- atomic_read(&sh->count) == 0) { -+ refcount_read(&sh->count) == 0) { - r5c_flush_stripe(conf, sh); - if (count++ >= R5C_RECLAIM_STRIPE_GROUP) - break; -@@ -2912,7 +2912,7 @@ int r5c_cache_data(struct r5l_log *log, - * don't delay. - */ - clear_bit(STRIPE_DELAYED, &sh->state); -- atomic_inc(&sh->count); -+ refcount_inc(&sh->count); - - mutex_lock(&log->io_mutex); - /* meta + data */ ---- a/drivers/md/raid5-ppl.c -+++ b/drivers/md/raid5-ppl.c -@@ -388,7 +388,7 @@ int ppl_write_stripe(struct r5conf *conf - - set_bit(STRIPE_LOG_TRAPPED, &sh->state); - clear_bit(STRIPE_DELAYED, &sh->state); -- atomic_inc(&sh->count); -+ refcount_inc(&sh->count); - - if (ppl_log_stripe(log, sh)) { - spin_lock_irq(&ppl_conf->no_mem_stripes_lock); ---- a/drivers/md/raid5.c -+++ b/drivers/md/raid5.c -@@ -306,7 +306,7 @@ static void do_release_stripe(struct r5c - static void __release_stripe(struct r5conf *conf, struct stripe_head *sh, - struct list_head *temp_inactive_list) - { -- if (atomic_dec_and_test(&sh->count)) -+ if (refcount_dec_and_test(&sh->count)) - do_release_stripe(conf, sh, temp_inactive_list); - } - -@@ -398,7 +398,7 @@ void raid5_release_stripe(struct stripe_ - - /* Avoid release_list until the last reference. - */ -- if (atomic_add_unless(&sh->count, -1, 1)) -+ if (refcount_dec_not_one(&sh->count)) - return; - - if (unlikely(!conf->mddev->thread) || -@@ -411,7 +411,7 @@ void raid5_release_stripe(struct stripe_ - slow_path: - local_irq_save(flags); - /* we are ok here if STRIPE_ON_RELEASE_LIST is set or not */ -- if (atomic_dec_and_lock(&sh->count, &conf->device_lock)) { -+ if (refcount_dec_and_lock(&sh->count, &conf->device_lock)) { - INIT_LIST_HEAD(&list); - hash = sh->hash_lock_index; - do_release_stripe(conf, sh, &list); -@@ -501,7 +501,7 @@ static void init_stripe(struct stripe_he - struct r5conf *conf = sh->raid_conf; - int i, seq; - -- BUG_ON(atomic_read(&sh->count) != 0); -+ BUG_ON(refcount_read(&sh->count) != 0); - BUG_ON(test_bit(STRIPE_HANDLE, &sh->state)); - BUG_ON(stripe_operations_active(sh)); - BUG_ON(sh->batch_head); -@@ -678,11 +678,11 @@ raid5_get_active_stripe(struct r5conf *c - &conf->cache_state); - } else { - init_stripe(sh, sector, previous); -- atomic_inc(&sh->count); -+ refcount_inc(&sh->count); - } -- } else if (!atomic_inc_not_zero(&sh->count)) { -+ } else if (!refcount_inc_not_zero(&sh->count)) { - spin_lock(&conf->device_lock); -- if (!atomic_read(&sh->count)) { -+ if (!refcount_read(&sh->count)) { - if (!test_bit(STRIPE_HANDLE, &sh->state)) - atomic_inc(&conf->active_stripes); - BUG_ON(list_empty(&sh->lru) && -@@ -698,7 +698,7 @@ raid5_get_active_stripe(struct r5conf *c - sh->group = NULL; - } - } -- atomic_inc(&sh->count); -+ refcount_inc(&sh->count); - spin_unlock(&conf->device_lock); - } - } while (sh == NULL); -@@ -760,9 +760,9 @@ static void stripe_add_to_batch_list(str - hash = stripe_hash_locks_hash(head_sector); - spin_lock_irq(conf->hash_locks + hash); - head = __find_stripe(conf, head_sector, conf->generation); -- if (head && !atomic_inc_not_zero(&head->count)) { -+ if (head && !refcount_inc_not_zero(&head->count)) { - spin_lock(&conf->device_lock); -- if (!atomic_read(&head->count)) { -+ if (!refcount_read(&head->count)) { - if (!test_bit(STRIPE_HANDLE, &head->state)) - atomic_inc(&conf->active_stripes); - BUG_ON(list_empty(&head->lru) && -@@ -778,7 +778,7 @@ static void stripe_add_to_batch_list(str - head->group = NULL; - } - } -- atomic_inc(&head->count); -+ refcount_inc(&head->count); - spin_unlock(&conf->device_lock); - } - spin_unlock_irq(conf->hash_locks + hash); -@@ -847,7 +847,7 @@ static void stripe_add_to_batch_list(str - sh->batch_head->bm_seq = seq; - } - -- atomic_inc(&sh->count); -+ refcount_inc(&sh->count); - unlock_out: - unlock_two_stripes(head, sh); - out: -@@ -1110,9 +1110,9 @@ static void ops_run_io(struct stripe_hea - pr_debug("%s: for %llu schedule op %d on disc %d\n", - __func__, (unsigned long long)sh->sector, - bi->bi_opf, i); -- atomic_inc(&sh->count); -+ refcount_inc(&sh->count); - if (sh != head_sh) -- atomic_inc(&head_sh->count); -+ refcount_inc(&head_sh->count); - if (use_new_offset(conf, sh)) - bi->bi_iter.bi_sector = (sh->sector - + rdev->new_data_offset); -@@ -1174,9 +1174,9 @@ static void ops_run_io(struct stripe_hea - "replacement disc %d\n", - __func__, (unsigned long long)sh->sector, - rbi->bi_opf, i); -- atomic_inc(&sh->count); -+ refcount_inc(&sh->count); - if (sh != head_sh) -- atomic_inc(&head_sh->count); -+ refcount_inc(&head_sh->count); - if (use_new_offset(conf, sh)) - rbi->bi_iter.bi_sector = (sh->sector - + rrdev->new_data_offset); -@@ -1354,7 +1354,7 @@ static void ops_run_biofill(struct strip - } - } - -- atomic_inc(&sh->count); -+ refcount_inc(&sh->count); - init_async_submit(&submit, ASYNC_TX_ACK, tx, ops_complete_biofill, sh, NULL); - async_trigger_callback(&submit); - } -@@ -1432,7 +1432,7 @@ ops_run_compute5(struct stripe_head *sh, - if (i != target) - xor_srcs[count++] = sh->dev[i].page; - -- atomic_inc(&sh->count); -+ refcount_inc(&sh->count); - - init_async_submit(&submit, ASYNC_TX_FENCE|ASYNC_TX_XOR_ZERO_DST, NULL, - ops_complete_compute, sh, to_addr_conv(sh, percpu, 0)); -@@ -1521,7 +1521,7 @@ ops_run_compute6_1(struct stripe_head *s - BUG_ON(!test_bit(R5_Wantcompute, &tgt->flags)); - dest = tgt->page; - -- atomic_inc(&sh->count); -+ refcount_inc(&sh->count); - - if (target == qd_idx) { - count = set_syndrome_sources(blocks, sh, SYNDROME_SRC_ALL); -@@ -1596,7 +1596,7 @@ ops_run_compute6_2(struct stripe_head *s - pr_debug("%s: stripe: %llu faila: %d failb: %d\n", - __func__, (unsigned long long)sh->sector, faila, failb); - -- atomic_inc(&sh->count); -+ refcount_inc(&sh->count); - - if (failb == syndrome_disks+1) { - /* Q disk is one of the missing disks */ -@@ -1867,7 +1867,7 @@ ops_run_reconstruct5(struct stripe_head - break; - } - if (i >= sh->disks) { -- atomic_inc(&sh->count); -+ refcount_inc(&sh->count); - set_bit(R5_Discard, &sh->dev[pd_idx].flags); - ops_complete_reconstruct(sh); - return; -@@ -1908,7 +1908,7 @@ ops_run_reconstruct5(struct stripe_head - flags = ASYNC_TX_ACK | - (prexor ? ASYNC_TX_XOR_DROP_DST : ASYNC_TX_XOR_ZERO_DST); - -- atomic_inc(&head_sh->count); -+ refcount_inc(&head_sh->count); - init_async_submit(&submit, flags, tx, ops_complete_reconstruct, head_sh, - to_addr_conv(sh, percpu, j)); - } else { -@@ -1950,7 +1950,7 @@ ops_run_reconstruct6(struct stripe_head - break; - } - if (i >= sh->disks) { -- atomic_inc(&sh->count); -+ refcount_inc(&sh->count); - set_bit(R5_Discard, &sh->dev[sh->pd_idx].flags); - set_bit(R5_Discard, &sh->dev[sh->qd_idx].flags); - ops_complete_reconstruct(sh); -@@ -1974,7 +1974,7 @@ ops_run_reconstruct6(struct stripe_head - struct stripe_head, batch_list) == head_sh; - - if (last_stripe) { -- atomic_inc(&head_sh->count); -+ refcount_inc(&head_sh->count); - init_async_submit(&submit, txflags, tx, ops_complete_reconstruct, - head_sh, to_addr_conv(sh, percpu, j)); - } else -@@ -2031,7 +2031,7 @@ static void ops_run_check_p(struct strip - tx = async_xor_val(xor_dest, xor_srcs, 0, count, STRIPE_SIZE, - &sh->ops.zero_sum_result, &submit); - -- atomic_inc(&sh->count); -+ refcount_inc(&sh->count); - init_async_submit(&submit, ASYNC_TX_ACK, tx, ops_complete_check, sh, NULL); - tx = async_trigger_callback(&submit); - } -@@ -2050,7 +2050,7 @@ static void ops_run_check_pq(struct stri - if (!checkp) - srcs[count] = NULL; - -- atomic_inc(&sh->count); -+ refcount_inc(&sh->count); - init_async_submit(&submit, ASYNC_TX_ACK, NULL, ops_complete_check, - sh, to_addr_conv(sh, percpu, 0)); - async_syndrome_val(srcs, 0, count+2, STRIPE_SIZE, -@@ -2150,7 +2150,7 @@ static struct stripe_head *alloc_stripe( - INIT_LIST_HEAD(&sh->lru); - INIT_LIST_HEAD(&sh->r5c); - INIT_LIST_HEAD(&sh->log_list); -- atomic_set(&sh->count, 1); -+ refcount_set(&sh->count, 1); - sh->raid_conf = conf; - sh->log_start = MaxSector; - for (i = 0; i < disks; i++) { -@@ -2451,7 +2451,7 @@ static int drop_one_stripe(struct r5conf - spin_unlock_irq(conf->hash_locks + hash); - if (!sh) - return 0; -- BUG_ON(atomic_read(&sh->count)); -+ BUG_ON(refcount_read(&sh->count)); - shrink_buffers(sh); - free_stripe(conf->slab_cache, sh); - atomic_dec(&conf->active_stripes); -@@ -2483,7 +2483,7 @@ static void raid5_end_read_request(struc - break; - - pr_debug("end_read_request %llu/%d, count: %d, error %d.\n", -- (unsigned long long)sh->sector, i, atomic_read(&sh->count), -+ (unsigned long long)sh->sector, i, refcount_read(&sh->count), - bi->bi_status); - if (i == disks) { - bio_reset(bi); -@@ -2620,7 +2620,7 @@ static void raid5_end_write_request(stru - } - } - pr_debug("end_write_request %llu/%d, count %d, error: %d.\n", -- (unsigned long long)sh->sector, i, atomic_read(&sh->count), -+ (unsigned long long)sh->sector, i, refcount_read(&sh->count), - bi->bi_status); - if (i == disks) { - bio_reset(bi); -@@ -4687,7 +4687,7 @@ static void handle_stripe(struct stripe_ - pr_debug("handling stripe %llu, state=%#lx cnt=%d, " - "pd_idx=%d, qd_idx=%d\n, check:%d, reconstruct:%d\n", - (unsigned long long)sh->sector, sh->state, -- atomic_read(&sh->count), sh->pd_idx, sh->qd_idx, -+ refcount_read(&sh->count), sh->pd_idx, sh->qd_idx, - sh->check_state, sh->reconstruct_state); - - analyse_stripe(sh, &s); -@@ -5062,7 +5062,7 @@ static void activate_bit_delay(struct r5 - struct stripe_head *sh = list_entry(head.next, struct stripe_head, lru); - int hash; - list_del_init(&sh->lru); -- atomic_inc(&sh->count); -+ refcount_inc(&sh->count); - hash = sh->hash_lock_index; - __release_stripe(conf, sh, &temp_inactive_list[hash]); - } -@@ -5387,7 +5387,8 @@ static struct stripe_head *__get_priorit - sh->group = NULL; - } - list_del_init(&sh->lru); -- BUG_ON(atomic_inc_return(&sh->count) != 1); -+ refcount_inc(&sh->count); -+ BUG_ON(refcount_read(&sh->count) != 1); - return sh; - } - ---- a/drivers/md/raid5.h -+++ b/drivers/md/raid5.h -@@ -4,7 +4,7 @@ - - #include - #include -- -+#include - /* - * - * Each stripe contains one buffer per device. Each buffer can be in -@@ -208,7 +208,7 @@ struct stripe_head { - short ddf_layout;/* use DDF ordering to calculate Q */ - short hash_lock_index; - unsigned long state; /* state flags */ -- atomic_t count; /* nr of active thread/requests */ -+ refcount_t count; /* nr of active thread/requests */ - int bm_seq; /* sequence number for bitmap flushes */ - int disks; /* disks in stripe */ - int overwrite_disks; /* total overwrite disks in stripe, diff --git a/debian/patches/features/all/rt/0003-split-the-slow-part-of-lock_parent-off.patch b/debian/patches/features/all/rt/0003-split-the-slow-part-of-lock_parent-off.patch index 663c820bc..9a2e87ec2 100644 --- a/debian/patches/features/all/rt/0003-split-the-slow-part-of-lock_parent-off.patch +++ b/debian/patches/features/all/rt/0003-split-the-slow-part-of-lock_parent-off.patch @@ -1,7 +1,6 @@ From: Al Viro Date: Fri, 23 Feb 2018 22:11:34 -0500 Subject: [PATCH 03/17] split the slow part of lock_parent() off -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 8b987a46a1e0e93d4cb4babea06ea274e2e2b658 diff --git a/debian/patches/features/all/rt/0003-tracing-Add-support-to-detect-and-avoid-duplicates.patch b/debian/patches/features/all/rt/0003-tracing-Add-support-to-detect-and-avoid-duplicates.patch deleted file mode 100644 index 6886f161f..000000000 --- a/debian/patches/features/all/rt/0003-tracing-Add-support-to-detect-and-avoid-duplicates.patch +++ /dev/null @@ -1,115 +0,0 @@ -From: Vedang Patel -Date: Mon, 15 Jan 2018 20:51:37 -0600 -Subject: [PATCH 03/37] tracing: Add support to detect and avoid duplicates -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -A duplicate in the tracing_map hash table is when 2 different entries -have the same key and, as a result, the key_hash. This is possible due -to a race condition in the algorithm. This race condition is inherent to -the algorithm and not a bug. This was fine because, until now, we were -only interested in the sum of all the values related to a particular -key (the duplicates are dealt with in tracing_map_sort_entries()). But, -with the inclusion of variables[1], we are interested in individual -values. So, it will not be clear what value to choose when -there are duplicates. So, the duplicates need to be removed. - -The duplicates can occur in the code in the following scenarios: - -- A thread is in the process of adding a new element. It has -successfully executed cmpxchg() and inserted the key. But, it is still -not done acquiring the trace_map_elt struct, populating it and storing -the pointer to the struct in the value field of tracing_map hash table. -If another thread comes in at this time and wants to add an element with -the same key, it will not see the current element and add a new one. - -- There are multiple threads trying to execute cmpxchg at the same time, -one of the threads will succeed and the others will fail. The ones which -fail will go ahead increment 'idx' and add a new element there creating -a duplicate. - -This patch detects and avoids the first condition by asking the thread -which detects the duplicate to loop one more time. There is also a -possibility of infinite loop if the thread which is trying to insert -goes to sleep indefinitely and the one which is trying to insert a new -element detects a duplicate. Which is why, the thread loops for -map_size iterations before returning NULL. - -The second scenario is avoided by preventing the threads which failed -cmpxchg() from incrementing idx. This way, they will loop -around and check if the thread which succeeded in executing cmpxchg() -had the same key. - -[1] http://lkml.kernel.org/r/cover.1498510759.git.tom.zanussi@linux.intel.com - -Signed-off-by: Vedang Patel -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/tracing_map.c | 41 ++++++++++++++++++++++++++++++++++++----- - 1 file changed, 36 insertions(+), 5 deletions(-) - ---- a/kernel/trace/tracing_map.c -+++ b/kernel/trace/tracing_map.c -@@ -414,7 +414,9 @@ static inline struct tracing_map_elt * - __tracing_map_insert(struct tracing_map *map, void *key, bool lookup_only) - { - u32 idx, key_hash, test_key; -+ int dup_try = 0; - struct tracing_map_entry *entry; -+ struct tracing_map_elt *val; - - key_hash = jhash(key, map->key_size, 0); - if (key_hash == 0) -@@ -426,11 +428,33 @@ static inline struct tracing_map_elt * - entry = TRACING_MAP_ENTRY(map->map, idx); - test_key = entry->key; - -- if (test_key && test_key == key_hash && entry->val && -- keys_match(key, entry->val->key, map->key_size)) { -- if (!lookup_only) -- atomic64_inc(&map->hits); -- return entry->val; -+ if (test_key && test_key == key_hash) { -+ val = READ_ONCE(entry->val); -+ if (val && -+ keys_match(key, val->key, map->key_size)) { -+ if (!lookup_only) -+ atomic64_inc(&map->hits); -+ return val; -+ } else if (unlikely(!val)) { -+ /* -+ * The key is present. But, val (pointer to elt -+ * struct) is still NULL. which means some other -+ * thread is in the process of inserting an -+ * element. -+ * -+ * On top of that, it's key_hash is same as the -+ * one being inserted right now. So, it's -+ * possible that the element has the same -+ * key as well. -+ */ -+ -+ dup_try++; -+ if (dup_try > map->map_size) { -+ atomic64_inc(&map->drops); -+ break; -+ } -+ continue; -+ } - } - - if (!test_key) { -@@ -452,6 +476,13 @@ static inline struct tracing_map_elt * - atomic64_inc(&map->hits); - - return entry->val; -+ } else { -+ /* -+ * cmpxchg() failed. Loop around once -+ * more to check what key was inserted. -+ */ -+ dup_try++; -+ continue; - } - } - diff --git a/debian/patches/features/all/rt/0003-tracing-Restore-proper-field-flag-printing-when-disp.patch b/debian/patches/features/all/rt/0003-tracing-Restore-proper-field-flag-printing-when-disp.patch index 7b8602fd2..a19a63ee3 100644 --- a/debian/patches/features/all/rt/0003-tracing-Restore-proper-field-flag-printing-when-disp.patch +++ b/debian/patches/features/all/rt/0003-tracing-Restore-proper-field-flag-printing-when-disp.patch @@ -2,7 +2,6 @@ From: Steven Rostedt Date: Wed, 16 May 2018 09:36:45 -0400 Subject: [PATCH 3/5] tracing: Restore proper field flag printing when displaying triggers -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz From: Tom Zanussi diff --git a/debian/patches/features/all/rt/0004-ARM-at91-Implement-clocksource-selection.patch b/debian/patches/features/all/rt/0004-ARM-at91-Implement-clocksource-selection.patch index 2ecca7aa1..ddef46d43 100644 --- a/debian/patches/features/all/rt/0004-ARM-at91-Implement-clocksource-selection.patch +++ b/debian/patches/features/all/rt/0004-ARM-at91-Implement-clocksource-selection.patch @@ -1,7 +1,6 @@ From: Alexandre Belloni Date: Wed, 18 Apr 2018 12:51:41 +0200 Subject: [PATCH 4/6] ARM: at91: Implement clocksource selection -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Allow selecting and unselecting the PIT clocksource driver so it doesn't have to be compile when unused. diff --git a/debian/patches/features/all/rt/0004-PM-wakeup-Make-s2idle_lock-a-RAW_SPINLOCK.patch b/debian/patches/features/all/rt/0004-PM-wakeup-Make-s2idle_lock-a-RAW_SPINLOCK.patch new file mode 100644 index 000000000..d2ff68e8f --- /dev/null +++ b/debian/patches/features/all/rt/0004-PM-wakeup-Make-s2idle_lock-a-RAW_SPINLOCK.patch @@ -0,0 +1,68 @@ +From: Sebastian Andrzej Siewior +Date: Fri, 25 May 2018 10:16:05 +0200 +Subject: [PATCH 4/4] PM / wakeup: Make s2idle_lock a RAW_SPINLOCK + +The `s2idle_lock' is acquired during suspend while interrupts are +disabled even on RT. The lock is acquired for short sections only. +Make it a RAW lock which avoids "sleeping while atomic" warnings on RT. + +Signed-off-by: Sebastian Andrzej Siewior +--- + kernel/power/suspend.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +--- a/kernel/power/suspend.c ++++ b/kernel/power/suspend.c +@@ -61,7 +61,7 @@ static const struct platform_s2idle_ops + static DECLARE_SWAIT_QUEUE_HEAD(s2idle_wait_head); + + enum s2idle_states __read_mostly s2idle_state; +-static DEFINE_SPINLOCK(s2idle_lock); ++static DEFINE_RAW_SPINLOCK(s2idle_lock); + + void s2idle_set_ops(const struct platform_s2idle_ops *ops) + { +@@ -79,12 +79,12 @@ static void s2idle_enter(void) + { + trace_suspend_resume(TPS("machine_suspend"), PM_SUSPEND_TO_IDLE, true); + +- spin_lock_irq(&s2idle_lock); ++ raw_spin_lock_irq(&s2idle_lock); + if (pm_wakeup_pending()) + goto out; + + s2idle_state = S2IDLE_STATE_ENTER; +- spin_unlock_irq(&s2idle_lock); ++ raw_spin_unlock_irq(&s2idle_lock); + + get_online_cpus(); + cpuidle_resume(); +@@ -98,11 +98,11 @@ static void s2idle_enter(void) + cpuidle_pause(); + put_online_cpus(); + +- spin_lock_irq(&s2idle_lock); ++ raw_spin_lock_irq(&s2idle_lock); + + out: + s2idle_state = S2IDLE_STATE_NONE; +- spin_unlock_irq(&s2idle_lock); ++ raw_spin_unlock_irq(&s2idle_lock); + + trace_suspend_resume(TPS("machine_suspend"), PM_SUSPEND_TO_IDLE, false); + } +@@ -157,12 +157,12 @@ void s2idle_wake(void) + { + unsigned long flags; + +- spin_lock_irqsave(&s2idle_lock, flags); ++ raw_spin_lock_irqsave(&s2idle_lock, flags); + if (s2idle_state > S2IDLE_STATE_NONE) { + s2idle_state = S2IDLE_STATE_WAKE; + swake_up(&s2idle_wait_head); + } +- spin_unlock_irqrestore(&s2idle_lock, flags); ++ raw_spin_unlock_irqrestore(&s2idle_lock, flags); + } + EXPORT_SYMBOL_GPL(s2idle_wake); + diff --git a/debian/patches/features/all/rt/0004-dput-consolidate-the-do-we-need-to-retain-it-into-an.patch b/debian/patches/features/all/rt/0004-dput-consolidate-the-do-we-need-to-retain-it-into-an.patch index ff8ee949b..289d8f68d 100644 --- a/debian/patches/features/all/rt/0004-dput-consolidate-the-do-we-need-to-retain-it-into-an.patch +++ b/debian/patches/features/all/rt/0004-dput-consolidate-the-do-we-need-to-retain-it-into-an.patch @@ -2,7 +2,6 @@ From: Al Viro Date: Fri, 23 Feb 2018 21:07:24 -0500 Subject: [PATCH 04/17] dput(): consolidate the "do we need to retain it?" into an inlined helper -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit a338579f2f3d6a15c78f1dc7de4c248b4183fcea diff --git a/debian/patches/features/all/rt/0004-hrtimer-Cleanup-clock-argument-in-schedule_hrtimeout.patch b/debian/patches/features/all/rt/0004-hrtimer-Cleanup-clock-argument-in-schedule_hrtimeout.patch deleted file mode 100644 index 535c38dc7..000000000 --- a/debian/patches/features/all/rt/0004-hrtimer-Cleanup-clock-argument-in-schedule_hrtimeout.patch +++ /dev/null @@ -1,81 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:12:53 +0100 -Subject: [PATCH 04/29] hrtimer: Cleanup clock argument in - schedule_hrtimeout_range_clock() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -schedule_hrtimeout_range_clock() uses an integer for the clock id -instead of the predefined type "clockid_t". The ID of the clock is -indicated in hrtimer code as clock_id. Therefore change the name of -the variable as well to make it consistent. - -While at it, clean up the description for the function parameters clock_id -and mode. The clock modes and the clock ids are not restricted as the -comment suggests. Fix the mode description as well for the callers of -schedule_hrtimeout_range_clock(). - -No functional change. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - include/linux/hrtimer.h | 2 +- - kernel/time/hrtimer.c | 12 ++++++------ - 2 files changed, 7 insertions(+), 7 deletions(-) - ---- a/include/linux/hrtimer.h -+++ b/include/linux/hrtimer.h -@@ -462,7 +462,7 @@ extern int schedule_hrtimeout_range(ktim - extern int schedule_hrtimeout_range_clock(ktime_t *expires, - u64 delta, - const enum hrtimer_mode mode, -- int clock); -+ clockid_t clock_id); - extern int schedule_hrtimeout(ktime_t *expires, const enum hrtimer_mode mode); - - /* Soft interrupt function to run the hrtimer queues: */ ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -1664,12 +1664,12 @@ void __init hrtimers_init(void) - * schedule_hrtimeout_range_clock - sleep until timeout - * @expires: timeout value (ktime_t) - * @delta: slack in expires timeout (ktime_t) -- * @mode: timer mode, HRTIMER_MODE_ABS or HRTIMER_MODE_REL -- * @clock: timer clock, CLOCK_MONOTONIC or CLOCK_REALTIME -+ * @mode: timer mode -+ * @clock_id: timer clock to be used - */ - int __sched - schedule_hrtimeout_range_clock(ktime_t *expires, u64 delta, -- const enum hrtimer_mode mode, int clock) -+ const enum hrtimer_mode mode, clockid_t clock_id) - { - struct hrtimer_sleeper t; - -@@ -1690,7 +1690,7 @@ schedule_hrtimeout_range_clock(ktime_t * - return -EINTR; - } - -- hrtimer_init_on_stack(&t.timer, clock, mode); -+ hrtimer_init_on_stack(&t.timer, clock_id, mode); - hrtimer_set_expires_range_ns(&t.timer, *expires, delta); - - hrtimer_init_sleeper(&t, current); -@@ -1712,7 +1712,7 @@ schedule_hrtimeout_range_clock(ktime_t * - * schedule_hrtimeout_range - sleep until timeout - * @expires: timeout value (ktime_t) - * @delta: slack in expires timeout (ktime_t) -- * @mode: timer mode, HRTIMER_MODE_ABS or HRTIMER_MODE_REL -+ * @mode: timer mode - * - * Make the current task sleep until the given expiry time has - * elapsed. The routine will return immediately unless -@@ -1751,7 +1751,7 @@ EXPORT_SYMBOL_GPL(schedule_hrtimeout_ran - /** - * schedule_hrtimeout - sleep until timeout - * @expires: timeout value (ktime_t) -- * @mode: timer mode, HRTIMER_MODE_ABS or HRTIMER_MODE_REL -+ * @mode: timer mode - * - * Make the current task sleep until the given expiry time has - * elapsed. The routine will return immediately unless diff --git a/debian/patches/features/all/rt/0004-iommu-amd-Split-irq_lookup_table-out-of-the-amd_iomm.patch b/debian/patches/features/all/rt/0004-iommu-amd-Split-irq_lookup_table-out-of-the-amd_iomm.patch index 627fb25e2..4b0db7ae7 100644 --- a/debian/patches/features/all/rt/0004-iommu-amd-Split-irq_lookup_table-out-of-the-amd_iomm.patch +++ b/debian/patches/features/all/rt/0004-iommu-amd-Split-irq_lookup_table-out-of-the-amd_iomm.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 22 Mar 2018 16:22:36 +0100 Subject: [PATCH 04/10] iommu/amd: Split irq_lookup_table out of the amd_iommu_devtable_lock -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit ea6166f4b83e9cfba1c18f46a764d50045682fe5 diff --git a/debian/patches/features/all/rt/0004-locking-refcount-implement-refcount_dec_and_lock_irq.patch b/debian/patches/features/all/rt/0004-locking-refcount-implement-refcount_dec_and_lock_irq.patch index 7df9b46d1..56df14780 100644 --- a/debian/patches/features/all/rt/0004-locking-refcount-implement-refcount_dec_and_lock_irq.patch +++ b/debian/patches/features/all/rt/0004-locking-refcount-implement-refcount_dec_and_lock_irq.patch @@ -2,7 +2,6 @@ From: Anna-Maria Gleixner Date: Mon, 7 May 2018 16:44:57 +0200 Subject: [PATCH] locking/refcount: implement refcount_dec_and_lock_irqsave() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz There are in-tree users of refcount_dec_and_lock() which must acquire the spin lock with interrupts disabled. To workaround the lack of an irqsave diff --git a/debian/patches/features/all/rt/0004-timerqueue-Document-return-values-of-timerqueue_add-.patch b/debian/patches/features/all/rt/0004-timerqueue-Document-return-values-of-timerqueue_add-.patch deleted file mode 100644 index 9d7967772..000000000 --- a/debian/patches/features/all/rt/0004-timerqueue-Document-return-values-of-timerqueue_add-.patch +++ /dev/null @@ -1,45 +0,0 @@ -From: Thomas Gleixner -Date: Fri, 22 Dec 2017 15:51:15 +0100 -Subject: [PATCH 4/4] timerqueue: Document return values of - timerqueue_add/del() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.8-rt9.tar.xz - -The return values of timerqueue_add/del() are not documented in the kernel doc -comment. Add proper documentation. - -Signed-off-by: Thomas Gleixner -Cc: rt@linutronix.de -Signed-off-by: Sebastian Andrzej Siewior ---- - lib/timerqueue.c | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -diff --git a/lib/timerqueue.c b/lib/timerqueue.c -index 4a720ed4fdaf..0d54bcbc8170 100644 ---- a/lib/timerqueue.c -+++ b/lib/timerqueue.c -@@ -33,8 +33,9 @@ - * @head: head of timerqueue - * @node: timer node to be added - * -- * Adds the timer node to the timerqueue, sorted by the -- * node's expires value. -+ * Adds the timer node to the timerqueue, sorted by the node's expires -+ * value. Returns true if the newly added timer is the first expiring timer in -+ * the queue. - */ - bool timerqueue_add(struct timerqueue_head *head, struct timerqueue_node *node) - { -@@ -70,7 +71,8 @@ EXPORT_SYMBOL_GPL(timerqueue_add); - * @head: head of timerqueue - * @node: timer node to be removed - * -- * Removes the timer node from the timerqueue. -+ * Removes the timer node from the timerqueue. Returns true if the queue is -+ * not empty after the remove. - */ - bool timerqueue_del(struct timerqueue_head *head, struct timerqueue_node *node) - { --- -2.15.1 - diff --git a/debian/patches/features/all/rt/0004-tracing-Remove-code-which-merges-duplicates.patch b/debian/patches/features/all/rt/0004-tracing-Remove-code-which-merges-duplicates.patch deleted file mode 100644 index d57cc59e2..000000000 --- a/debian/patches/features/all/rt/0004-tracing-Remove-code-which-merges-duplicates.patch +++ /dev/null @@ -1,189 +0,0 @@ -From: Vedang Patel -Date: Mon, 15 Jan 2018 20:51:38 -0600 -Subject: [PATCH 04/37] tracing: Remove code which merges duplicates -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -We now have the logic to detect and remove duplicates in the -tracing_map hash table. The code which merges duplicates in the -histogram is redundant now. So, modify this code just to detect -duplicates. The duplication detection code is still kept to ensure -that any rare race condition which might cause duplicates does not go -unnoticed. - -Signed-off-by: Vedang Patel -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 11 ----- - kernel/trace/tracing_map.c | 83 ++------------------------------------- - kernel/trace/tracing_map.h | 7 --- - 3 files changed, 6 insertions(+), 95 deletions(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -340,16 +340,6 @@ static int hist_trigger_elt_comm_alloc(s - return 0; - } - --static void hist_trigger_elt_comm_copy(struct tracing_map_elt *to, -- struct tracing_map_elt *from) --{ -- char *comm_from = from->private_data; -- char *comm_to = to->private_data; -- -- if (comm_from) -- memcpy(comm_to, comm_from, TASK_COMM_LEN + 1); --} -- - static void hist_trigger_elt_comm_init(struct tracing_map_elt *elt) - { - char *comm = elt->private_data; -@@ -360,7 +350,6 @@ static void hist_trigger_elt_comm_init(s - - static const struct tracing_map_ops hist_trigger_elt_comm_ops = { - .elt_alloc = hist_trigger_elt_comm_alloc, -- .elt_copy = hist_trigger_elt_comm_copy, - .elt_free = hist_trigger_elt_comm_free, - .elt_init = hist_trigger_elt_comm_init, - }; ---- a/kernel/trace/tracing_map.c -+++ b/kernel/trace/tracing_map.c -@@ -847,67 +847,15 @@ create_sort_entry(void *key, struct trac - return sort_entry; - } - --static struct tracing_map_elt *copy_elt(struct tracing_map_elt *elt) --{ -- struct tracing_map_elt *dup_elt; -- unsigned int i; -- -- dup_elt = tracing_map_elt_alloc(elt->map); -- if (IS_ERR(dup_elt)) -- return NULL; -- -- if (elt->map->ops && elt->map->ops->elt_copy) -- elt->map->ops->elt_copy(dup_elt, elt); -- -- dup_elt->private_data = elt->private_data; -- memcpy(dup_elt->key, elt->key, elt->map->key_size); -- -- for (i = 0; i < elt->map->n_fields; i++) { -- atomic64_set(&dup_elt->fields[i].sum, -- atomic64_read(&elt->fields[i].sum)); -- dup_elt->fields[i].cmp_fn = elt->fields[i].cmp_fn; -- } -- -- return dup_elt; --} -- --static int merge_dup(struct tracing_map_sort_entry **sort_entries, -- unsigned int target, unsigned int dup) --{ -- struct tracing_map_elt *target_elt, *elt; -- bool first_dup = (target - dup) == 1; -- int i; -- -- if (first_dup) { -- elt = sort_entries[target]->elt; -- target_elt = copy_elt(elt); -- if (!target_elt) -- return -ENOMEM; -- sort_entries[target]->elt = target_elt; -- sort_entries[target]->elt_copied = true; -- } else -- target_elt = sort_entries[target]->elt; -- -- elt = sort_entries[dup]->elt; -- -- for (i = 0; i < elt->map->n_fields; i++) -- atomic64_add(atomic64_read(&elt->fields[i].sum), -- &target_elt->fields[i].sum); -- -- sort_entries[dup]->dup = true; -- -- return 0; --} -- --static int merge_dups(struct tracing_map_sort_entry **sort_entries, -+static void detect_dups(struct tracing_map_sort_entry **sort_entries, - int n_entries, unsigned int key_size) - { - unsigned int dups = 0, total_dups = 0; -- int err, i, j; -+ int i; - void *key; - - if (n_entries < 2) -- return total_dups; -+ return; - - sort(sort_entries, n_entries, sizeof(struct tracing_map_sort_entry *), - (int (*)(const void *, const void *))cmp_entries_dup, NULL); -@@ -916,30 +864,14 @@ static int merge_dups(struct tracing_map - for (i = 1; i < n_entries; i++) { - if (!memcmp(sort_entries[i]->key, key, key_size)) { - dups++; total_dups++; -- err = merge_dup(sort_entries, i - dups, i); -- if (err) -- return err; - continue; - } - key = sort_entries[i]->key; - dups = 0; - } - -- if (!total_dups) -- return total_dups; -- -- for (i = 0, j = 0; i < n_entries; i++) { -- if (!sort_entries[i]->dup) { -- sort_entries[j] = sort_entries[i]; -- if (j++ != i) -- sort_entries[i] = NULL; -- } else { -- destroy_sort_entry(sort_entries[i]); -- sort_entries[i] = NULL; -- } -- } -- -- return total_dups; -+ WARN_ONCE(total_dups > 0, -+ "Duplicates detected: %d\n", total_dups); - } - - static bool is_key(struct tracing_map *map, unsigned int field_idx) -@@ -1065,10 +997,7 @@ int tracing_map_sort_entries(struct trac - return 1; - } - -- ret = merge_dups(entries, n_entries, map->key_size); -- if (ret < 0) -- goto free; -- n_entries -= ret; -+ detect_dups(entries, n_entries, map->key_size); - - if (is_key(map, sort_keys[0].field_idx)) - cmp_entries_fn = cmp_entries_key; ---- a/kernel/trace/tracing_map.h -+++ b/kernel/trace/tracing_map.h -@@ -215,11 +215,6 @@ struct tracing_map { - * Element allocation occurs before tracing begins, when the - * tracing_map_init() call is made by client code. - * -- * @elt_copy: At certain points in the lifetime of an element, it may -- * need to be copied. The copy should include a copy of the -- * client-allocated data, which can be copied into the 'to' -- * element from the 'from' element. -- * - * @elt_free: When a tracing_map_elt is freed, this function is called - * and allows client-allocated per-element data to be freed. - * -@@ -233,8 +228,6 @@ struct tracing_map { - */ - struct tracing_map_ops { - int (*elt_alloc)(struct tracing_map_elt *elt); -- void (*elt_copy)(struct tracing_map_elt *to, -- struct tracing_map_elt *from); - void (*elt_free)(struct tracing_map_elt *elt); - void (*elt_clear)(struct tracing_map_elt *elt); - void (*elt_init)(struct tracing_map_elt *elt); diff --git a/debian/patches/features/all/rt/0004-tracing-Remove-lookups-from-tracing_map-hitcount.patch b/debian/patches/features/all/rt/0004-tracing-Remove-lookups-from-tracing_map-hitcount.patch deleted file mode 100644 index 2cb5843e1..000000000 --- a/debian/patches/features/all/rt/0004-tracing-Remove-lookups-from-tracing_map-hitcount.patch +++ /dev/null @@ -1,27 +0,0 @@ -From: Tom Zanussi -Date: Fri, 22 Sep 2017 14:58:18 -0500 -Subject: [PATCH 04/42] tracing: Remove lookups from tracing_map hitcount -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Lookups inflate the hitcount, making it essentially useless. Only -inserts and updates should really affect the hitcount anyway, so -explicitly filter lookups out. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/tracing_map.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - ---- a/kernel/trace/tracing_map.c -+++ b/kernel/trace/tracing_map.c -@@ -428,7 +428,8 @@ static inline struct tracing_map_elt * - - if (test_key && test_key == key_hash && entry->val && - keys_match(key, entry->val->key, map->key_size)) { -- atomic64_inc(&map->hits); -+ if (!lookup_only) -+ atomic64_inc(&map->hits); - return entry->val; - } - diff --git a/debian/patches/features/all/rt/0004-tracing-Uninitialized-variable-in-create_tracing_map.patch b/debian/patches/features/all/rt/0004-tracing-Uninitialized-variable-in-create_tracing_map.patch index dde0f3ee3..f3399f71d 100644 --- a/debian/patches/features/all/rt/0004-tracing-Uninitialized-variable-in-create_tracing_map.patch +++ b/debian/patches/features/all/rt/0004-tracing-Uninitialized-variable-in-create_tracing_map.patch @@ -2,7 +2,6 @@ From: Steven Rostedt Date: Wed, 16 May 2018 09:36:46 -0400 Subject: [PATCH 4/5] tracing: Uninitialized variable in create_tracing_map_fields() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz From: Dan Carpenter diff --git a/debian/patches/features/all/rt/0005-ARM-configs-at91-use-new-TCB-timer-driver.patch b/debian/patches/features/all/rt/0005-ARM-configs-at91-use-new-TCB-timer-driver.patch index 71c0c2703..a5b12e156 100644 --- a/debian/patches/features/all/rt/0005-ARM-configs-at91-use-new-TCB-timer-driver.patch +++ b/debian/patches/features/all/rt/0005-ARM-configs-at91-use-new-TCB-timer-driver.patch @@ -1,7 +1,6 @@ From: Alexandre Belloni Date: Wed, 18 Apr 2018 12:51:42 +0200 Subject: [PATCH 5/6] ARM: configs: at91: use new TCB timer driver -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Unselecting ATMEL_TCLIB switches the TCB timer driver from tcb_clksrc to timer-atmel-tcb. diff --git a/debian/patches/features/all/rt/0005-bdi-Use-irqsave-variant-of-refcount_dec_and_lock.patch b/debian/patches/features/all/rt/0005-bdi-Use-irqsave-variant-of-refcount_dec_and_lock.patch index 6ec169b0c..ab6944e9a 100644 --- a/debian/patches/features/all/rt/0005-bdi-Use-irqsave-variant-of-refcount_dec_and_lock.patch +++ b/debian/patches/features/all/rt/0005-bdi-Use-irqsave-variant-of-refcount_dec_and_lock.patch @@ -1,7 +1,6 @@ From: Anna-Maria Gleixner Date: Wed, 4 Apr 2018 11:43:56 +0200 Subject: [PATCH] bdi: Use irqsave variant of refcount_dec_and_lock() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The irqsave variant of refcount_dec_and_lock handles irqsave/restore when taking/releasing the spin lock. With this variant the call of @@ -16,7 +15,7 @@ Signed-off-by: Sebastian Andrzej Siewior --- a/mm/backing-dev.c +++ b/mm/backing-dev.c -@@ -495,11 +495,8 @@ void wb_congested_put(struct bdi_writeba +@@ -496,11 +496,8 @@ void wb_congested_put(struct bdi_writeba { unsigned long flags; diff --git a/debian/patches/features/all/rt/0005-handle-move-to-LRU-in-retain_dentry.patch b/debian/patches/features/all/rt/0005-handle-move-to-LRU-in-retain_dentry.patch index c3dc30c69..d1e3c8230 100644 --- a/debian/patches/features/all/rt/0005-handle-move-to-LRU-in-retain_dentry.patch +++ b/debian/patches/features/all/rt/0005-handle-move-to-LRU-in-retain_dentry.patch @@ -1,7 +1,6 @@ From: Al Viro Date: Tue, 6 Mar 2018 21:37:31 -0500 Subject: [PATCH 05/17] handle move to LRU in retain_dentry() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 62d9956cefe6ecc4b43a7fae37af78ba7adaceaa diff --git a/debian/patches/features/all/rt/0005-hrtimer-Fix-hrtimer-function-description.patch b/debian/patches/features/all/rt/0005-hrtimer-Fix-hrtimer-function-description.patch deleted file mode 100644 index 3aed49868..000000000 --- a/debian/patches/features/all/rt/0005-hrtimer-Fix-hrtimer-function-description.patch +++ /dev/null @@ -1,61 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:12:54 +0100 -Subject: [PATCH 05/29] hrtimer: Fix hrtimer function description -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The hrtimer_start[_range_ns]() starts a timer reliable on this CPU only -when HRTIMER_MODE_PINNED is set. Furthermore the HRTIMER_MODE_PINNED mode -is not considered, when a hrtimer is initialized. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - include/linux/hrtimer.h | 6 +++--- - kernel/time/hrtimer.c | 9 +++++---- - 2 files changed, 8 insertions(+), 7 deletions(-) - ---- a/include/linux/hrtimer.h -+++ b/include/linux/hrtimer.h -@@ -361,11 +361,11 @@ extern void hrtimer_start_range_ns(struc - u64 range_ns, const enum hrtimer_mode mode); - - /** -- * hrtimer_start - (re)start an hrtimer on the current CPU -+ * hrtimer_start - (re)start an hrtimer - * @timer: the timer to be added - * @tim: expiry time -- * @mode: expiry mode: absolute (HRTIMER_MODE_ABS) or -- * relative (HRTIMER_MODE_REL) -+ * @mode: timer mode: absolute (HRTIMER_MODE_ABS) or -+ * relative (HRTIMER_MODE_REL), and pinned (HRTIMER_MODE_PINNED) - */ - static inline void hrtimer_start(struct hrtimer *timer, ktime_t tim, - const enum hrtimer_mode mode) ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -926,12 +926,12 @@ static inline ktime_t hrtimer_update_low - } - - /** -- * hrtimer_start_range_ns - (re)start an hrtimer on the current CPU -+ * hrtimer_start_range_ns - (re)start an hrtimer - * @timer: the timer to be added - * @tim: expiry time - * @delta_ns: "slack" range for the timer -- * @mode: expiry mode: absolute (HRTIMER_MODE_ABS) or -- * relative (HRTIMER_MODE_REL) -+ * @mode: timer mode: absolute (HRTIMER_MODE_ABS) or -+ * relative (HRTIMER_MODE_REL), and pinned (HRTIMER_MODE_PINNED) - */ - void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, - u64 delta_ns, const enum hrtimer_mode mode) -@@ -1109,7 +1109,8 @@ static void __hrtimer_init(struct hrtime - * hrtimer_init - initialize a timer to the given clock - * @timer: the timer to be initialized - * @clock_id: the clock to be used -- * @mode: timer mode abs/rel -+ * @mode: timer mode: absolute (HRTIMER_MODE_ABS) or -+ * relative (HRTIMER_MODE_REL); pinned is not considered here! - */ - void hrtimer_init(struct hrtimer *timer, clockid_t clock_id, - enum hrtimer_mode mode) diff --git a/debian/patches/features/all/rt/0005-iommu-amd-Remove-the-special-case-from-alloc_irq_tab.patch b/debian/patches/features/all/rt/0005-iommu-amd-Remove-the-special-case-from-alloc_irq_tab.patch index 9a16ec5d4..597965cbb 100644 --- a/debian/patches/features/all/rt/0005-iommu-amd-Remove-the-special-case-from-alloc_irq_tab.patch +++ b/debian/patches/features/all/rt/0005-iommu-amd-Remove-the-special-case-from-alloc_irq_tab.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 22 Mar 2018 16:22:37 +0100 Subject: [PATCH 05/10] iommu/amd: Remove the special case from alloc_irq_table() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit fde65dd3d3096e8f6ecc7bbe544eb91f4220772c diff --git a/debian/patches/features/all/rt/0005-ring-buffer-Add-interface-for-setting-absolute-time-.patch b/debian/patches/features/all/rt/0005-ring-buffer-Add-interface-for-setting-absolute-time-.patch deleted file mode 100644 index 90777bf28..000000000 --- a/debian/patches/features/all/rt/0005-ring-buffer-Add-interface-for-setting-absolute-time-.patch +++ /dev/null @@ -1,129 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:39 -0600 -Subject: [PATCH 05/37] ring-buffer: Add interface for setting absolute time - stamps -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Define a new function, tracing_set_time_stamp_abs(), which can be used -to enable or disable the use of absolute timestamps rather than time -deltas for a trace array. - -Only the interface is added here; a subsequent patch will add the -underlying implementation. - -Signed-off-by: Tom Zanussi -Signed-off-by: Baohong Liu -Signed-off-by: Sebastian Andrzej Siewior ---- - include/linux/ring_buffer.h | 2 ++ - kernel/trace/ring_buffer.c | 11 +++++++++++ - kernel/trace/trace.c | 33 ++++++++++++++++++++++++++++++++- - kernel/trace/trace.h | 3 +++ - 4 files changed, 48 insertions(+), 1 deletion(-) - ---- a/include/linux/ring_buffer.h -+++ b/include/linux/ring_buffer.h -@@ -181,6 +181,8 @@ void ring_buffer_normalize_time_stamp(st - int cpu, u64 *ts); - void ring_buffer_set_clock(struct ring_buffer *buffer, - u64 (*clock)(void)); -+void ring_buffer_set_time_stamp_abs(struct ring_buffer *buffer, bool abs); -+bool ring_buffer_time_stamp_abs(struct ring_buffer *buffer); - - size_t ring_buffer_page_len(void *page); - ---- a/kernel/trace/ring_buffer.c -+++ b/kernel/trace/ring_buffer.c -@@ -489,6 +489,7 @@ struct ring_buffer { - u64 (*clock)(void); - - struct rb_irq_work irq_work; -+ bool time_stamp_abs; - }; - - struct ring_buffer_iter { -@@ -1383,6 +1384,16 @@ void ring_buffer_set_clock(struct ring_b - buffer->clock = clock; - } - -+void ring_buffer_set_time_stamp_abs(struct ring_buffer *buffer, bool abs) -+{ -+ buffer->time_stamp_abs = abs; -+} -+ -+bool ring_buffer_time_stamp_abs(struct ring_buffer *buffer) -+{ -+ return buffer->time_stamp_abs; -+} -+ - static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer); - - static inline unsigned long rb_page_entries(struct buffer_page *bpage) ---- a/kernel/trace/trace.c -+++ b/kernel/trace/trace.c -@@ -2269,7 +2269,7 @@ trace_event_buffer_lock_reserve(struct r - - *current_rb = trace_file->tr->trace_buffer.buffer; - -- if ((trace_file->flags & -+ if (!ring_buffer_time_stamp_abs(*current_rb) && (trace_file->flags & - (EVENT_FILE_FL_SOFT_DISABLED | EVENT_FILE_FL_FILTERED)) && - (entry = this_cpu_read(trace_buffered_event))) { - /* Try to use the per cpu buffer first */ -@@ -6286,6 +6286,37 @@ static int tracing_clock_open(struct ino - - return ret; - } -+ -+int tracing_set_time_stamp_abs(struct trace_array *tr, bool abs) -+{ -+ int ret = 0; -+ -+ mutex_lock(&trace_types_lock); -+ -+ if (abs && tr->time_stamp_abs_ref++) -+ goto out; -+ -+ if (!abs) { -+ if (WARN_ON_ONCE(!tr->time_stamp_abs_ref)) { -+ ret = -EINVAL; -+ goto out; -+ } -+ -+ if (--tr->time_stamp_abs_ref) -+ goto out; -+ } -+ -+ ring_buffer_set_time_stamp_abs(tr->trace_buffer.buffer, abs); -+ -+#ifdef CONFIG_TRACER_MAX_TRACE -+ if (tr->max_buffer.buffer) -+ ring_buffer_set_time_stamp_abs(tr->max_buffer.buffer, abs); -+#endif -+ out: -+ mutex_unlock(&trace_types_lock); -+ -+ return ret; -+} - - struct ftrace_buffer_info { - struct trace_iterator iter; ---- a/kernel/trace/trace.h -+++ b/kernel/trace/trace.h -@@ -273,6 +273,7 @@ struct trace_array { - /* function tracing enabled */ - int function_enabled; - #endif -+ int time_stamp_abs_ref; - }; - - enum { -@@ -286,6 +287,8 @@ extern struct mutex trace_types_lock; - extern int trace_array_get(struct trace_array *tr); - extern void trace_array_put(struct trace_array *tr); - -+extern int tracing_set_time_stamp_abs(struct trace_array *tr, bool abs); -+ - /* - * The global tracer (top) should be the first trace array added, - * but we check the flag anyway. diff --git a/debian/patches/features/all/rt/0005-tracing-Fix-a-potential-NULL-dereference.patch b/debian/patches/features/all/rt/0005-tracing-Fix-a-potential-NULL-dereference.patch index e577a68ae..29c314441 100644 --- a/debian/patches/features/all/rt/0005-tracing-Fix-a-potential-NULL-dereference.patch +++ b/debian/patches/features/all/rt/0005-tracing-Fix-a-potential-NULL-dereference.patch @@ -1,7 +1,6 @@ From: Dan Carpenter Date: Fri, 23 Mar 2018 14:37:36 +0300 Subject: [PATCH 5/5] tracing: Fix a potential NULL dereference -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz We forgot to set the error code on this path so we return ERR_PTR(0) which is NULL. It results in a NULL dereference in the caller. diff --git a/debian/patches/features/all/rt/0005-tracing-Increase-tracing-map-KEYS_MAX-size.patch b/debian/patches/features/all/rt/0005-tracing-Increase-tracing-map-KEYS_MAX-size.patch deleted file mode 100644 index ec434b1cd..000000000 --- a/debian/patches/features/all/rt/0005-tracing-Increase-tracing-map-KEYS_MAX-size.patch +++ /dev/null @@ -1,25 +0,0 @@ -From: Tom Zanussi -Date: Fri, 22 Sep 2017 14:58:19 -0500 -Subject: [PATCH 05/42] tracing: Increase tracing map KEYS_MAX size -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The current default for the number of subkeys in a compound key is 2, -which is too restrictive. Increase it to a more realistic value of 3. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/tracing_map.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/kernel/trace/tracing_map.h -+++ b/kernel/trace/tracing_map.h -@@ -6,7 +6,7 @@ - #define TRACING_MAP_BITS_MAX 17 - #define TRACING_MAP_BITS_MIN 7 - --#define TRACING_MAP_KEYS_MAX 2 -+#define TRACING_MAP_KEYS_MAX 3 - #define TRACING_MAP_VALS_MAX 3 - #define TRACING_MAP_FIELDS_MAX (TRACING_MAP_KEYS_MAX + \ - TRACING_MAP_VALS_MAX) diff --git a/debian/patches/features/all/rt/0006-ARM-configs-at91-unselect-PIT.patch b/debian/patches/features/all/rt/0006-ARM-configs-at91-unselect-PIT.patch index 487a0afe0..d3b805ffd 100644 --- a/debian/patches/features/all/rt/0006-ARM-configs-at91-unselect-PIT.patch +++ b/debian/patches/features/all/rt/0006-ARM-configs-at91-unselect-PIT.patch @@ -1,7 +1,6 @@ From: Alexandre Belloni Date: Wed, 18 Apr 2018 12:51:43 +0200 Subject: [PATCH 6/6] ARM: configs: at91: unselect PIT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The PIT is not required anymore to successfully boot and may actually harm in case preempt-rt is used because the PIT interrupt is shared. diff --git a/debian/patches/features/all/rt/0006-get-rid-of-trylock-loop-around-dentry_kill.patch b/debian/patches/features/all/rt/0006-get-rid-of-trylock-loop-around-dentry_kill.patch index 0fc00555b..6a0b764e5 100644 --- a/debian/patches/features/all/rt/0006-get-rid-of-trylock-loop-around-dentry_kill.patch +++ b/debian/patches/features/all/rt/0006-get-rid-of-trylock-loop-around-dentry_kill.patch @@ -1,7 +1,6 @@ From: Al Viro Date: Fri, 23 Feb 2018 21:25:42 -0500 Subject: [PATCH 06/17] get rid of trylock loop around dentry_kill() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit f657a666fd1b1b9fe59963943c74c245ae66f4cc diff --git a/debian/patches/features/all/rt/0006-hrtimer-Ensure-POSIX-compliance-relative-CLOCK_REALT.patch b/debian/patches/features/all/rt/0006-hrtimer-Ensure-POSIX-compliance-relative-CLOCK_REALT.patch deleted file mode 100644 index 2d1aaef6f..000000000 --- a/debian/patches/features/all/rt/0006-hrtimer-Ensure-POSIX-compliance-relative-CLOCK_REALT.patch +++ /dev/null @@ -1,41 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:12:55 +0100 -Subject: [PATCH 06/29] hrtimer: Ensure POSIX compliance (relative - CLOCK_REALTIME hrtimers) -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -POSIX specification defines, that relative CLOCK_REALTIME timers are not -affected by clock modifications. Those timers have to use CLOCK_MONOTONIC -to ensure POSIX compliance. - -The introduction of the additional mode HRTIMER_MODE_PINNED broke this -requirement for pinned timers. There is no user space visible impact -because user space timers are not using the pinned mode, but for -consistency reasons this needs to be fixed. - -Check whether the mode has the HRTIMER_MODE_REL bit set instead of -comparing with HRTIMER_MODE_ABS. - -Fixes: 597d0275736d ("timers: Framework for identifying pinned timers") -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/time/hrtimer.c | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -1097,7 +1097,12 @@ static void __hrtimer_init(struct hrtime - - cpu_base = raw_cpu_ptr(&hrtimer_bases); - -- if (clock_id == CLOCK_REALTIME && mode != HRTIMER_MODE_ABS) -+ /* -+ * Posix magic: Relative CLOCK_REALTIME timers are not affected by -+ * clock modifications, so they needs to become CLOCK_MONOTONIC to -+ * ensure Posix compliance. -+ */ -+ if (clock_id == CLOCK_REALTIME && mode & HRTIMER_MODE_REL) - clock_id = CLOCK_MONOTONIC; - - base = hrtimer_clockid_to_base(clock_id); diff --git a/debian/patches/features/all/rt/0006-iommu-amd-Use-table-instead-irt-as-variable-name-in-.patch b/debian/patches/features/all/rt/0006-iommu-amd-Use-table-instead-irt-as-variable-name-in-.patch index 7245bb071..f2cbe854c 100644 --- a/debian/patches/features/all/rt/0006-iommu-amd-Use-table-instead-irt-as-variable-name-in-.patch +++ b/debian/patches/features/all/rt/0006-iommu-amd-Use-table-instead-irt-as-variable-name-in-.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 22 Mar 2018 16:22:38 +0100 Subject: [PATCH 06/10] iommu/amd: Use `table' instead `irt' as variable name in amd_iommu_update_ga() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 4fde541c9dc114c5b448ad34b0286fe8b7c550f1 diff --git a/debian/patches/features/all/rt/0006-ring-buffer-Redefine-the-unimplemented-RINGBUF_TYPE_.patch b/debian/patches/features/all/rt/0006-ring-buffer-Redefine-the-unimplemented-RINGBUF_TYPE_.patch deleted file mode 100644 index 86bf28121..000000000 --- a/debian/patches/features/all/rt/0006-ring-buffer-Redefine-the-unimplemented-RINGBUF_TYPE_.patch +++ /dev/null @@ -1,319 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:40 -0600 -Subject: [PATCH 06/37] ring-buffer: Redefine the unimplemented - RINGBUF_TYPE_TIME_STAMP -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -RINGBUF_TYPE_TIME_STAMP is defined but not used, and from what I can -gather was reserved for something like an absolute timestamp feature -for the ring buffer, if not a complete replacement of the current -time_delta scheme. - -This code redefines RINGBUF_TYPE_TIME_STAMP to implement absolute time -stamps. Another way to look at it is that it essentially forces -extended time_deltas for all events. - -The motivation for doing this is to enable time_deltas that aren't -dependent on previous events in the ring buffer, making it feasible to -use the ring_buffer_event timetamps in a more random-access way, for -purposes other than serial event printing. - -To set/reset this mode, use tracing_set_timestamp_abs() from the -previous interface patch. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - include/linux/ring_buffer.h | 12 ++--- - kernel/trace/ring_buffer.c | 104 ++++++++++++++++++++++++++++++++------------ - 2 files changed, 83 insertions(+), 33 deletions(-) - ---- a/include/linux/ring_buffer.h -+++ b/include/linux/ring_buffer.h -@@ -37,10 +37,12 @@ struct ring_buffer_event { - * array[0] = time delta (28 .. 59) - * size = 8 bytes - * -- * @RINGBUF_TYPE_TIME_STAMP: Sync time stamp with external clock -- * array[0] = tv_nsec -- * array[1..2] = tv_sec -- * size = 16 bytes -+ * @RINGBUF_TYPE_TIME_STAMP: Absolute timestamp -+ * Same format as TIME_EXTEND except that the -+ * value is an absolute timestamp, not a delta -+ * event.time_delta contains bottom 27 bits -+ * array[0] = top (28 .. 59) bits -+ * size = 8 bytes - * - * <= @RINGBUF_TYPE_DATA_TYPE_LEN_MAX: - * Data record -@@ -57,12 +59,12 @@ enum ring_buffer_type { - RINGBUF_TYPE_DATA_TYPE_LEN_MAX = 28, - RINGBUF_TYPE_PADDING, - RINGBUF_TYPE_TIME_EXTEND, -- /* FIXME: RINGBUF_TYPE_TIME_STAMP not implemented */ - RINGBUF_TYPE_TIME_STAMP, - }; - - unsigned ring_buffer_event_length(struct ring_buffer_event *event); - void *ring_buffer_event_data(struct ring_buffer_event *event); -+u64 ring_buffer_event_time_stamp(struct ring_buffer_event *event); - - /* - * ring_buffer_discard_commit will remove an event that has not ---- a/kernel/trace/ring_buffer.c -+++ b/kernel/trace/ring_buffer.c -@@ -42,6 +42,8 @@ int ring_buffer_print_entry_header(struc - RINGBUF_TYPE_PADDING); - trace_seq_printf(s, "\ttime_extend : type == %d\n", - RINGBUF_TYPE_TIME_EXTEND); -+ trace_seq_printf(s, "\ttime_stamp : type == %d\n", -+ RINGBUF_TYPE_TIME_STAMP); - trace_seq_printf(s, "\tdata max type_len == %d\n", - RINGBUF_TYPE_DATA_TYPE_LEN_MAX); - -@@ -141,12 +143,15 @@ int ring_buffer_print_entry_header(struc - - enum { - RB_LEN_TIME_EXTEND = 8, -- RB_LEN_TIME_STAMP = 16, -+ RB_LEN_TIME_STAMP = 8, - }; - - #define skip_time_extend(event) \ - ((struct ring_buffer_event *)((char *)event + RB_LEN_TIME_EXTEND)) - -+#define extended_time(event) \ -+ (event->type_len >= RINGBUF_TYPE_TIME_EXTEND) -+ - static inline int rb_null_event(struct ring_buffer_event *event) - { - return event->type_len == RINGBUF_TYPE_PADDING && !event->time_delta; -@@ -210,7 +215,7 @@ rb_event_ts_length(struct ring_buffer_ev - { - unsigned len = 0; - -- if (event->type_len == RINGBUF_TYPE_TIME_EXTEND) { -+ if (extended_time(event)) { - /* time extends include the data event after it */ - len = RB_LEN_TIME_EXTEND; - event = skip_time_extend(event); -@@ -232,7 +237,7 @@ unsigned ring_buffer_event_length(struct - { - unsigned length; - -- if (event->type_len == RINGBUF_TYPE_TIME_EXTEND) -+ if (extended_time(event)) - event = skip_time_extend(event); - - length = rb_event_length(event); -@@ -249,7 +254,7 @@ EXPORT_SYMBOL_GPL(ring_buffer_event_leng - static __always_inline void * - rb_event_data(struct ring_buffer_event *event) - { -- if (event->type_len == RINGBUF_TYPE_TIME_EXTEND) -+ if (extended_time(event)) - event = skip_time_extend(event); - BUG_ON(event->type_len > RINGBUF_TYPE_DATA_TYPE_LEN_MAX); - /* If length is in len field, then array[0] has the data */ -@@ -276,6 +281,27 @@ EXPORT_SYMBOL_GPL(ring_buffer_event_data - #define TS_MASK ((1ULL << TS_SHIFT) - 1) - #define TS_DELTA_TEST (~TS_MASK) - -+/** -+ * ring_buffer_event_time_stamp - return the event's extended timestamp -+ * @event: the event to get the timestamp of -+ * -+ * Returns the extended timestamp associated with a data event. -+ * An extended time_stamp is a 64-bit timestamp represented -+ * internally in a special way that makes the best use of space -+ * contained within a ring buffer event. This function decodes -+ * it and maps it to a straight u64 value. -+ */ -+u64 ring_buffer_event_time_stamp(struct ring_buffer_event *event) -+{ -+ u64 ts; -+ -+ ts = event->array[0]; -+ ts <<= TS_SHIFT; -+ ts += event->time_delta; -+ -+ return ts; -+} -+ - /* Flag when events were overwritten */ - #define RB_MISSED_EVENTS (1 << 31) - /* Missed count stored at end */ -@@ -2225,12 +2251,15 @@ rb_move_tail(struct ring_buffer_per_cpu - - /* Slow path, do not inline */ - static noinline struct ring_buffer_event * --rb_add_time_stamp(struct ring_buffer_event *event, u64 delta) -+rb_add_time_stamp(struct ring_buffer_event *event, u64 delta, bool abs) - { -- event->type_len = RINGBUF_TYPE_TIME_EXTEND; -+ if (abs) -+ event->type_len = RINGBUF_TYPE_TIME_STAMP; -+ else -+ event->type_len = RINGBUF_TYPE_TIME_EXTEND; - -- /* Not the first event on the page? */ -- if (rb_event_index(event)) { -+ /* Not the first event on the page, or not delta? */ -+ if (abs || rb_event_index(event)) { - event->time_delta = delta & TS_MASK; - event->array[0] = delta >> TS_SHIFT; - } else { -@@ -2273,7 +2302,9 @@ rb_update_event(struct ring_buffer_per_c - * add it to the start of the resevered space. - */ - if (unlikely(info->add_timestamp)) { -- event = rb_add_time_stamp(event, delta); -+ bool abs = ring_buffer_time_stamp_abs(cpu_buffer->buffer); -+ -+ event = rb_add_time_stamp(event, info->delta, abs); - length -= RB_LEN_TIME_EXTEND; - delta = 0; - } -@@ -2461,7 +2492,7 @@ static __always_inline void rb_end_commi - - static inline void rb_event_discard(struct ring_buffer_event *event) - { -- if (event->type_len == RINGBUF_TYPE_TIME_EXTEND) -+ if (extended_time(event)) - event = skip_time_extend(event); - - /* array[0] holds the actual length for the discarded event */ -@@ -2505,10 +2536,11 @@ rb_update_write_stamp(struct ring_buffer - cpu_buffer->write_stamp = - cpu_buffer->commit_page->page->time_stamp; - else if (event->type_len == RINGBUF_TYPE_TIME_EXTEND) { -- delta = event->array[0]; -- delta <<= TS_SHIFT; -- delta += event->time_delta; -+ delta = ring_buffer_event_time_stamp(event); - cpu_buffer->write_stamp += delta; -+ } else if (event->type_len == RINGBUF_TYPE_TIME_STAMP) { -+ delta = ring_buffer_event_time_stamp(event); -+ cpu_buffer->write_stamp = delta; - } else - cpu_buffer->write_stamp += event->time_delta; - } -@@ -2661,7 +2693,7 @@ static struct ring_buffer_event * - * If this is the first commit on the page, then it has the same - * timestamp as the page itself. - */ -- if (!tail) -+ if (!tail && !ring_buffer_time_stamp_abs(cpu_buffer->buffer)) - info->delta = 0; - - /* See if we shot pass the end of this buffer page */ -@@ -2739,8 +2771,11 @@ rb_reserve_next_event(struct ring_buffer - /* make sure this diff is calculated here */ - barrier(); - -- /* Did the write stamp get updated already? */ -- if (likely(info.ts >= cpu_buffer->write_stamp)) { -+ if (ring_buffer_time_stamp_abs(buffer)) { -+ info.delta = info.ts; -+ rb_handle_timestamp(cpu_buffer, &info); -+ } else /* Did the write stamp get updated already? */ -+ if (likely(info.ts >= cpu_buffer->write_stamp)) { - info.delta = diff; - if (unlikely(test_time_stamp(info.delta))) - rb_handle_timestamp(cpu_buffer, &info); -@@ -3422,14 +3457,13 @@ rb_update_read_stamp(struct ring_buffer_ - return; - - case RINGBUF_TYPE_TIME_EXTEND: -- delta = event->array[0]; -- delta <<= TS_SHIFT; -- delta += event->time_delta; -+ delta = ring_buffer_event_time_stamp(event); - cpu_buffer->read_stamp += delta; - return; - - case RINGBUF_TYPE_TIME_STAMP: -- /* FIXME: not implemented */ -+ delta = ring_buffer_event_time_stamp(event); -+ cpu_buffer->read_stamp = delta; - return; - - case RINGBUF_TYPE_DATA: -@@ -3453,14 +3487,13 @@ rb_update_iter_read_stamp(struct ring_bu - return; - - case RINGBUF_TYPE_TIME_EXTEND: -- delta = event->array[0]; -- delta <<= TS_SHIFT; -- delta += event->time_delta; -+ delta = ring_buffer_event_time_stamp(event); - iter->read_stamp += delta; - return; - - case RINGBUF_TYPE_TIME_STAMP: -- /* FIXME: not implemented */ -+ delta = ring_buffer_event_time_stamp(event); -+ iter->read_stamp = delta; - return; - - case RINGBUF_TYPE_DATA: -@@ -3684,6 +3717,8 @@ rb_buffer_peek(struct ring_buffer_per_cp - struct buffer_page *reader; - int nr_loops = 0; - -+ if (ts) -+ *ts = 0; - again: - /* - * We repeat when a time extend is encountered. -@@ -3720,12 +3755,17 @@ rb_buffer_peek(struct ring_buffer_per_cp - goto again; - - case RINGBUF_TYPE_TIME_STAMP: -- /* FIXME: not implemented */ -+ if (ts) { -+ *ts = ring_buffer_event_time_stamp(event); -+ ring_buffer_normalize_time_stamp(cpu_buffer->buffer, -+ cpu_buffer->cpu, ts); -+ } -+ /* Internal data, OK to advance */ - rb_advance_reader(cpu_buffer); - goto again; - - case RINGBUF_TYPE_DATA: -- if (ts) { -+ if (ts && !(*ts)) { - *ts = cpu_buffer->read_stamp + event->time_delta; - ring_buffer_normalize_time_stamp(cpu_buffer->buffer, - cpu_buffer->cpu, ts); -@@ -3750,6 +3790,9 @@ rb_iter_peek(struct ring_buffer_iter *it - struct ring_buffer_event *event; - int nr_loops = 0; - -+ if (ts) -+ *ts = 0; -+ - cpu_buffer = iter->cpu_buffer; - buffer = cpu_buffer->buffer; - -@@ -3802,12 +3845,17 @@ rb_iter_peek(struct ring_buffer_iter *it - goto again; - - case RINGBUF_TYPE_TIME_STAMP: -- /* FIXME: not implemented */ -+ if (ts) { -+ *ts = ring_buffer_event_time_stamp(event); -+ ring_buffer_normalize_time_stamp(cpu_buffer->buffer, -+ cpu_buffer->cpu, ts); -+ } -+ /* Internal data, OK to advance */ - rb_advance_iter(iter); - goto again; - - case RINGBUF_TYPE_DATA: -- if (ts) { -+ if (ts && !(*ts)) { - *ts = iter->read_stamp + event->time_delta; - ring_buffer_normalize_time_stamp(buffer, - cpu_buffer->cpu, ts); diff --git a/debian/patches/features/all/rt/0006-tracing-Make-traceprobe-parsing-code-reusable.patch b/debian/patches/features/all/rt/0006-tracing-Make-traceprobe-parsing-code-reusable.patch deleted file mode 100644 index e5f376aa4..000000000 --- a/debian/patches/features/all/rt/0006-tracing-Make-traceprobe-parsing-code-reusable.patch +++ /dev/null @@ -1,318 +0,0 @@ -From: Tom Zanussi -Date: Fri, 22 Sep 2017 14:58:20 -0500 -Subject: [PATCH 06/42] tracing: Make traceprobe parsing code reusable -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -traceprobe_probes_write() and traceprobe_command() actually contain -nothing that ties them to kprobes - the code is generically useful for -similar types of parsing elsewhere, so separate it out and move it to -trace.c/trace.h. - -Other than moving it, the only change is in naming: -traceprobe_probes_write() becomes trace_parse_run_command() and -traceprobe_command() becomes trace_run_command(). - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace.c | 86 ++++++++++++++++++++++++++++++++++++++++++++ - kernel/trace/trace.h | 7 +++ - kernel/trace/trace_kprobe.c | 18 ++++----- - kernel/trace/trace_probe.c | 86 -------------------------------------------- - kernel/trace/trace_probe.h | 7 --- - kernel/trace/trace_uprobe.c | 2 - - 6 files changed, 103 insertions(+), 103 deletions(-) - ---- a/kernel/trace/trace.c -+++ b/kernel/trace/trace.c -@@ -8265,6 +8265,92 @@ void ftrace_dump(enum ftrace_dump_mode o - } - EXPORT_SYMBOL_GPL(ftrace_dump); - -+int trace_run_command(const char *buf, int (*createfn)(int, char **)) -+{ -+ char **argv; -+ int argc, ret; -+ -+ argc = 0; -+ ret = 0; -+ argv = argv_split(GFP_KERNEL, buf, &argc); -+ if (!argv) -+ return -ENOMEM; -+ -+ if (argc) -+ ret = createfn(argc, argv); -+ -+ argv_free(argv); -+ -+ return ret; -+} -+ -+#define WRITE_BUFSIZE 4096 -+ -+ssize_t trace_parse_run_command(struct file *file, const char __user *buffer, -+ size_t count, loff_t *ppos, -+ int (*createfn)(int, char **)) -+{ -+ char *kbuf, *buf, *tmp; -+ int ret = 0; -+ size_t done = 0; -+ size_t size; -+ -+ kbuf = kmalloc(WRITE_BUFSIZE, GFP_KERNEL); -+ if (!kbuf) -+ return -ENOMEM; -+ -+ while (done < count) { -+ size = count - done; -+ -+ if (size >= WRITE_BUFSIZE) -+ size = WRITE_BUFSIZE - 1; -+ -+ if (copy_from_user(kbuf, buffer + done, size)) { -+ ret = -EFAULT; -+ goto out; -+ } -+ kbuf[size] = '\0'; -+ buf = kbuf; -+ do { -+ tmp = strchr(buf, '\n'); -+ if (tmp) { -+ *tmp = '\0'; -+ size = tmp - buf + 1; -+ } else { -+ size = strlen(buf); -+ if (done + size < count) { -+ if (buf != kbuf) -+ break; -+ /* This can accept WRITE_BUFSIZE - 2 ('\n' + '\0') */ -+ pr_warn("Line length is too long: Should be less than %d\n", -+ WRITE_BUFSIZE - 2); -+ ret = -EINVAL; -+ goto out; -+ } -+ } -+ done += size; -+ -+ /* Remove comments */ -+ tmp = strchr(buf, '#'); -+ -+ if (tmp) -+ *tmp = '\0'; -+ -+ ret = trace_run_command(buf, createfn); -+ if (ret) -+ goto out; -+ buf += size; -+ -+ } while (done < count); -+ } -+ ret = done; -+ -+out: -+ kfree(kbuf); -+ -+ return ret; -+} -+ - __init static int tracer_alloc_buffers(void) - { - int ring_buf_size; ---- a/kernel/trace/trace.h -+++ b/kernel/trace/trace.h -@@ -1755,6 +1755,13 @@ void trace_printk_start_comm(void); - int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set); - int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled); - -+#define MAX_EVENT_NAME_LEN 64 -+ -+extern int trace_run_command(const char *buf, int (*createfn)(int, char**)); -+extern ssize_t trace_parse_run_command(struct file *file, -+ const char __user *buffer, size_t count, loff_t *ppos, -+ int (*createfn)(int, char**)); -+ - /* - * Normal trace_printk() and friends allocates special buffers - * to do the manipulation, as well as saves the print formats ---- a/kernel/trace/trace_kprobe.c -+++ b/kernel/trace/trace_kprobe.c -@@ -907,8 +907,8 @@ static int probes_open(struct inode *ino - static ssize_t probes_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) - { -- return traceprobe_probes_write(file, buffer, count, ppos, -- create_trace_kprobe); -+ return trace_parse_run_command(file, buffer, count, ppos, -+ create_trace_kprobe); - } - - static const struct file_operations kprobe_events_ops = { -@@ -1433,9 +1433,9 @@ static __init int kprobe_trace_self_test - - pr_info("Testing kprobe tracing: "); - -- ret = traceprobe_command("p:testprobe kprobe_trace_selftest_target " -- "$stack $stack0 +0($stack)", -- create_trace_kprobe); -+ ret = trace_run_command("p:testprobe kprobe_trace_selftest_target " -+ "$stack $stack0 +0($stack)", -+ create_trace_kprobe); - if (WARN_ON_ONCE(ret)) { - pr_warn("error on probing function entry.\n"); - warn++; -@@ -1455,8 +1455,8 @@ static __init int kprobe_trace_self_test - } - } - -- ret = traceprobe_command("r:testprobe2 kprobe_trace_selftest_target " -- "$retval", create_trace_kprobe); -+ ret = trace_run_command("r:testprobe2 kprobe_trace_selftest_target " -+ "$retval", create_trace_kprobe); - if (WARN_ON_ONCE(ret)) { - pr_warn("error on probing function return.\n"); - warn++; -@@ -1526,13 +1526,13 @@ static __init int kprobe_trace_self_test - disable_trace_kprobe(tk, file); - } - -- ret = traceprobe_command("-:testprobe", create_trace_kprobe); -+ ret = trace_run_command("-:testprobe", create_trace_kprobe); - if (WARN_ON_ONCE(ret)) { - pr_warn("error on deleting a probe.\n"); - warn++; - } - -- ret = traceprobe_command("-:testprobe2", create_trace_kprobe); -+ ret = trace_run_command("-:testprobe2", create_trace_kprobe); - if (WARN_ON_ONCE(ret)) { - pr_warn("error on deleting a probe.\n"); - warn++; ---- a/kernel/trace/trace_probe.c -+++ b/kernel/trace/trace_probe.c -@@ -623,92 +623,6 @@ void traceprobe_free_probe_arg(struct pr - kfree(arg->comm); - } - --int traceprobe_command(const char *buf, int (*createfn)(int, char **)) --{ -- char **argv; -- int argc, ret; -- -- argc = 0; -- ret = 0; -- argv = argv_split(GFP_KERNEL, buf, &argc); -- if (!argv) -- return -ENOMEM; -- -- if (argc) -- ret = createfn(argc, argv); -- -- argv_free(argv); -- -- return ret; --} -- --#define WRITE_BUFSIZE 4096 -- --ssize_t traceprobe_probes_write(struct file *file, const char __user *buffer, -- size_t count, loff_t *ppos, -- int (*createfn)(int, char **)) --{ -- char *kbuf, *buf, *tmp; -- int ret = 0; -- size_t done = 0; -- size_t size; -- -- kbuf = kmalloc(WRITE_BUFSIZE, GFP_KERNEL); -- if (!kbuf) -- return -ENOMEM; -- -- while (done < count) { -- size = count - done; -- -- if (size >= WRITE_BUFSIZE) -- size = WRITE_BUFSIZE - 1; -- -- if (copy_from_user(kbuf, buffer + done, size)) { -- ret = -EFAULT; -- goto out; -- } -- kbuf[size] = '\0'; -- buf = kbuf; -- do { -- tmp = strchr(buf, '\n'); -- if (tmp) { -- *tmp = '\0'; -- size = tmp - buf + 1; -- } else { -- size = strlen(buf); -- if (done + size < count) { -- if (buf != kbuf) -- break; -- /* This can accept WRITE_BUFSIZE - 2 ('\n' + '\0') */ -- pr_warn("Line length is too long: Should be less than %d\n", -- WRITE_BUFSIZE - 2); -- ret = -EINVAL; -- goto out; -- } -- } -- done += size; -- -- /* Remove comments */ -- tmp = strchr(buf, '#'); -- -- if (tmp) -- *tmp = '\0'; -- -- ret = traceprobe_command(buf, createfn); -- if (ret) -- goto out; -- buf += size; -- -- } while (done < count); -- } -- ret = done; -- --out: -- kfree(kbuf); -- -- return ret; --} -- - static int __set_print_fmt(struct trace_probe *tp, char *buf, int len, - bool is_return) - { ---- a/kernel/trace/trace_probe.h -+++ b/kernel/trace/trace_probe.h -@@ -42,7 +42,6 @@ - - #define MAX_TRACE_ARGS 128 - #define MAX_ARGSTR_LEN 63 --#define MAX_EVENT_NAME_LEN 64 - #define MAX_STRING_SIZE PATH_MAX - - /* Reserved field names */ -@@ -356,12 +355,6 @@ extern void traceprobe_free_probe_arg(st - - extern int traceprobe_split_symbol_offset(char *symbol, unsigned long *offset); - --extern ssize_t traceprobe_probes_write(struct file *file, -- const char __user *buffer, size_t count, loff_t *ppos, -- int (*createfn)(int, char**)); -- --extern int traceprobe_command(const char *buf, int (*createfn)(int, char**)); -- - /* Sum up total data length for dynamic arraies (strings) */ - static nokprobe_inline int - __get_data_size(struct trace_probe *tp, struct pt_regs *regs) ---- a/kernel/trace/trace_uprobe.c -+++ b/kernel/trace/trace_uprobe.c -@@ -651,7 +651,7 @@ static int probes_open(struct inode *ino - static ssize_t probes_write(struct file *file, const char __user *buffer, - size_t count, loff_t *ppos) - { -- return traceprobe_probes_write(file, buffer, count, ppos, create_trace_uprobe); -+ return trace_parse_run_command(file, buffer, count, ppos, create_trace_uprobe); - } - - static const struct file_operations uprobe_events_ops = { diff --git a/debian/patches/features/all/rt/0006-userns-Use-irqsave-variant-of-refcount_dec_and_lock.patch b/debian/patches/features/all/rt/0006-userns-Use-irqsave-variant-of-refcount_dec_and_lock.patch index ee0e2cc91..2226f31b2 100644 --- a/debian/patches/features/all/rt/0006-userns-Use-irqsave-variant-of-refcount_dec_and_lock.patch +++ b/debian/patches/features/all/rt/0006-userns-Use-irqsave-variant-of-refcount_dec_and_lock.patch @@ -1,7 +1,6 @@ From: Anna-Maria Gleixner Date: Wed, 4 Apr 2018 11:43:57 +0200 Subject: [PATCH] userns: Use irqsave variant of refcount_dec_and_lock() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The irqsave variant of refcount_dec_and_lock handles irqsave/restore when taking/releasing the spin lock. With this variant the call of diff --git a/debian/patches/features/all/rt/0007-fs-dcache-Avoid-a-try_lock-loop-in-shrink_dentry_lis.patch b/debian/patches/features/all/rt/0007-fs-dcache-Avoid-a-try_lock-loop-in-shrink_dentry_lis.patch index d555f496d..5e431aa6f 100644 --- a/debian/patches/features/all/rt/0007-fs-dcache-Avoid-a-try_lock-loop-in-shrink_dentry_lis.patch +++ b/debian/patches/features/all/rt/0007-fs-dcache-Avoid-a-try_lock-loop-in-shrink_dentry_lis.patch @@ -2,7 +2,6 @@ From: John Ogness Date: Fri, 23 Feb 2018 00:50:24 +0100 Subject: [PATCH 07/17] fs/dcache: Avoid a try_lock loop in shrink_dentry_list() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 8f04da2adbdffed8dc4b2feb00ec3b3d84683885 diff --git a/debian/patches/features/all/rt/0007-hrtimer-Cleanup-hrtimer_mode-enum.patch b/debian/patches/features/all/rt/0007-hrtimer-Cleanup-hrtimer_mode-enum.patch deleted file mode 100644 index 93f41a34c..000000000 --- a/debian/patches/features/all/rt/0007-hrtimer-Cleanup-hrtimer_mode-enum.patch +++ /dev/null @@ -1,46 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:12:56 +0100 -Subject: [PATCH 07/29] hrtimer: Cleanup hrtimer_mode enum -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -It's not obvious that the HRTIMER_MODE variants are bit combinations -because all modes are hard coded constants. - -Change it so the bit meanings are clear and use the symbols for creating -modes which combine bits. - -While at it get rid of the ugly tail comments. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - include/linux/hrtimer.h | 16 +++++++++++----- - 1 file changed, 11 insertions(+), 5 deletions(-) - ---- a/include/linux/hrtimer.h -+++ b/include/linux/hrtimer.h -@@ -28,13 +28,19 @@ struct hrtimer_cpu_base; - - /* - * Mode arguments of xxx_hrtimer functions: -+ * -+ * HRTIMER_MODE_ABS - Time value is absolute -+ * HRTIMER_MODE_REL - Time value is relative to now -+ * HRTIMER_MODE_PINNED - Timer is bound to CPU (is only considered -+ * when starting the timer) - */ - enum hrtimer_mode { -- HRTIMER_MODE_ABS = 0x0, /* Time value is absolute */ -- HRTIMER_MODE_REL = 0x1, /* Time value is relative to now */ -- HRTIMER_MODE_PINNED = 0x02, /* Timer is bound to CPU */ -- HRTIMER_MODE_ABS_PINNED = 0x02, -- HRTIMER_MODE_REL_PINNED = 0x03, -+ HRTIMER_MODE_ABS = 0x00, -+ HRTIMER_MODE_REL = 0x01, -+ HRTIMER_MODE_PINNED = 0x02, -+ -+ HRTIMER_MODE_ABS_PINNED = HRTIMER_MODE_ABS | HRTIMER_MODE_PINNED, -+ HRTIMER_MODE_REL_PINNED = HRTIMER_MODE_REL | HRTIMER_MODE_PINNED, - }; - - /* diff --git a/debian/patches/features/all/rt/0007-iommu-amd-Factor-out-setting-the-remap-table-for-a-d.patch b/debian/patches/features/all/rt/0007-iommu-amd-Factor-out-setting-the-remap-table-for-a-d.patch index 04d1bae7a..d8e81ca93 100644 --- a/debian/patches/features/all/rt/0007-iommu-amd-Factor-out-setting-the-remap-table-for-a-d.patch +++ b/debian/patches/features/all/rt/0007-iommu-amd-Factor-out-setting-the-remap-table-for-a-d.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 22 Mar 2018 16:22:39 +0100 Subject: [PATCH 07/10] iommu/amd: Factor out setting the remap table for a devid -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 2fcc1e8ac4a8514c64f946178fc36c2e30e56a41 diff --git a/debian/patches/features/all/rt/0007-tracing-Add-timestamp_mode-trace-file.patch b/debian/patches/features/all/rt/0007-tracing-Add-timestamp_mode-trace-file.patch deleted file mode 100644 index 1b62a0936..000000000 --- a/debian/patches/features/all/rt/0007-tracing-Add-timestamp_mode-trace-file.patch +++ /dev/null @@ -1,134 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:41 -0600 -Subject: [PATCH 07/37] tracing: Add timestamp_mode trace file -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Add a new option flag indicating whether or not the ring buffer is in -'absolute timestamp' mode. - -Currently this is only set/unset by hist triggers that make use of a -common_timestamp. As such, there's no reason to make this writeable -for users - its purpose is only to allow users to determine -unequivocally whether or not the ring buffer is in that mode (although -absolute timestamps can coexist with the normal delta timestamps, when -the ring buffer is in absolute mode, timestamps written while absolute -mode is in effect take up more space in the buffer, and are not as -efficient). - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - Documentation/trace/ftrace.txt | 24 ++++++++++++++++++++ - kernel/trace/trace.c | 47 +++++++++++++++++++++++++++++++++++++++++ - 2 files changed, 71 insertions(+) - ---- a/Documentation/trace/ftrace.txt -+++ b/Documentation/trace/ftrace.txt -@@ -539,6 +539,30 @@ After mounting tracefs you will have acc - - See events.txt for more information. - -+ timestamp_mode: -+ -+ Certain tracers may change the timestamp mode used when -+ logging trace events into the event buffer. Events with -+ different modes can coexist within a buffer but the mode in -+ effect when an event is logged determines which timestamp mode -+ is used for that event. The default timestamp mode is -+ 'delta'. -+ -+ Usual timestamp modes for tracing: -+ -+ # cat timestamp_mode -+ [delta] absolute -+ -+ The timestamp mode with the square brackets around it is the -+ one in effect. -+ -+ delta: Default timestamp mode - timestamp is a delta against -+ a per-buffer timestamp. -+ -+ absolute: The timestamp is a full timestamp, not a delta -+ against some other value. As such it takes up more -+ space and is less efficient. -+ - hwlat_detector: - - Directory for the Hardware Latency Detector. ---- a/kernel/trace/trace.c -+++ b/kernel/trace/trace.c -@@ -4520,6 +4520,9 @@ static const char readme_msg[] = - #ifdef CONFIG_X86_64 - " x86-tsc: TSC cycle counter\n" - #endif -+ "\n timestamp_mode\t-view the mode used to timestamp events\n" -+ " delta: Delta difference against a buffer-wide timestamp\n" -+ " absolute: Absolute (standalone) timestamp\n" - "\n trace_marker\t\t- Writes into this file writes into the kernel buffer\n" - "\n trace_marker_raw\t\t- Writes into this file writes binary data into the kernel buffer\n" - " tracing_cpumask\t- Limit which CPUs to trace\n" -@@ -6287,6 +6290,40 @@ static int tracing_clock_open(struct ino - return ret; - } - -+static int tracing_time_stamp_mode_show(struct seq_file *m, void *v) -+{ -+ struct trace_array *tr = m->private; -+ -+ mutex_lock(&trace_types_lock); -+ -+ if (ring_buffer_time_stamp_abs(tr->trace_buffer.buffer)) -+ seq_puts(m, "delta [absolute]\n"); -+ else -+ seq_puts(m, "[delta] absolute\n"); -+ -+ mutex_unlock(&trace_types_lock); -+ -+ return 0; -+} -+ -+static int tracing_time_stamp_mode_open(struct inode *inode, struct file *file) -+{ -+ struct trace_array *tr = inode->i_private; -+ int ret; -+ -+ if (tracing_disabled) -+ return -ENODEV; -+ -+ if (trace_array_get(tr)) -+ return -ENODEV; -+ -+ ret = single_open(file, tracing_time_stamp_mode_show, inode->i_private); -+ if (ret < 0) -+ trace_array_put(tr); -+ -+ return ret; -+} -+ - int tracing_set_time_stamp_abs(struct trace_array *tr, bool abs) - { - int ret = 0; -@@ -6565,6 +6602,13 @@ static const struct file_operations trac - .write = tracing_clock_write, - }; - -+static const struct file_operations trace_time_stamp_mode_fops = { -+ .open = tracing_time_stamp_mode_open, -+ .read = seq_read, -+ .llseek = seq_lseek, -+ .release = tracing_single_release_tr, -+}; -+ - #ifdef CONFIG_TRACER_SNAPSHOT - static const struct file_operations snapshot_fops = { - .open = tracing_snapshot_open, -@@ -7887,6 +7931,9 @@ init_tracer_tracefs(struct trace_array * - trace_create_file("tracing_on", 0644, d_tracer, - tr, &rb_simple_fops); - -+ trace_create_file("timestamp_mode", 0444, d_tracer, tr, -+ &trace_time_stamp_mode_fops); -+ - create_trace_options_dir(tr); - - #if defined(CONFIG_TRACER_MAX_TRACE) || defined(CONFIG_HWLAT_TRACER) diff --git a/debian/patches/features/all/rt/0007-tracing-Clean-up-hist_field_flags-enum.patch b/debian/patches/features/all/rt/0007-tracing-Clean-up-hist_field_flags-enum.patch deleted file mode 100644 index 0f1079458..000000000 --- a/debian/patches/features/all/rt/0007-tracing-Clean-up-hist_field_flags-enum.patch +++ /dev/null @@ -1,44 +0,0 @@ -From: Tom Zanussi -Date: Fri, 22 Sep 2017 14:58:21 -0500 -Subject: [PATCH 07/42] tracing: Clean up hist_field_flags enum -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -As we add more flags, specifying explicit integers for the flag values -becomes more unwieldy and error-prone - switch them over to left-shift -values. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 20 ++++++++++---------- - 1 file changed, 10 insertions(+), 10 deletions(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -110,16 +110,16 @@ DEFINE_HIST_FIELD_FN(u8); - #define HIST_KEY_SIZE_MAX (MAX_FILTER_STR_VAL + HIST_STACKTRACE_SIZE) - - enum hist_field_flags { -- HIST_FIELD_FL_HITCOUNT = 1, -- HIST_FIELD_FL_KEY = 2, -- HIST_FIELD_FL_STRING = 4, -- HIST_FIELD_FL_HEX = 8, -- HIST_FIELD_FL_SYM = 16, -- HIST_FIELD_FL_SYM_OFFSET = 32, -- HIST_FIELD_FL_EXECNAME = 64, -- HIST_FIELD_FL_SYSCALL = 128, -- HIST_FIELD_FL_STACKTRACE = 256, -- HIST_FIELD_FL_LOG2 = 512, -+ HIST_FIELD_FL_HITCOUNT = 1 << 0, -+ HIST_FIELD_FL_KEY = 1 << 1, -+ HIST_FIELD_FL_STRING = 1 << 2, -+ HIST_FIELD_FL_HEX = 1 << 3, -+ HIST_FIELD_FL_SYM = 1 << 4, -+ HIST_FIELD_FL_SYM_OFFSET = 1 << 5, -+ HIST_FIELD_FL_EXECNAME = 1 << 6, -+ HIST_FIELD_FL_SYSCALL = 1 << 7, -+ HIST_FIELD_FL_STACKTRACE = 1 << 8, -+ HIST_FIELD_FL_LOG2 = 1 << 9, - }; - - struct hist_trigger_attrs { diff --git a/debian/patches/features/all/rt/0008-dcache.c-trim-includes.patch b/debian/patches/features/all/rt/0008-dcache.c-trim-includes.patch index b16122cdc..252d02dc6 100644 --- a/debian/patches/features/all/rt/0008-dcache.c-trim-includes.patch +++ b/debian/patches/features/all/rt/0008-dcache.c-trim-includes.patch @@ -1,7 +1,6 @@ From: Al Viro Date: Sun, 25 Feb 2018 02:47:29 -0500 Subject: [PATCH 08/17] dcache.c: trim includes -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 43986d63b60fd0152d9038ee3f0f9294efa8c983 diff --git a/debian/patches/features/all/rt/0008-iommu-amd-Drop-the-lock-while-allocating-new-irq-rem.patch b/debian/patches/features/all/rt/0008-iommu-amd-Drop-the-lock-while-allocating-new-irq-rem.patch index 371c06b46..1a2bca113 100644 --- a/debian/patches/features/all/rt/0008-iommu-amd-Drop-the-lock-while-allocating-new-irq-rem.patch +++ b/debian/patches/features/all/rt/0008-iommu-amd-Drop-the-lock-while-allocating-new-irq-rem.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 22 Mar 2018 16:22:40 +0100 Subject: [PATCH 08/10] iommu/amd: Drop the lock while allocating new irq remap table -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 993ca6e063a69a0c65ca42ed449b6bc1b3844151 diff --git a/debian/patches/features/all/rt/0008-tracing-Add-hist_field_name-accessor.patch b/debian/patches/features/all/rt/0008-tracing-Add-hist_field_name-accessor.patch deleted file mode 100644 index 6c0f01eae..000000000 --- a/debian/patches/features/all/rt/0008-tracing-Add-hist_field_name-accessor.patch +++ /dev/null @@ -1,175 +0,0 @@ -From: Tom Zanussi -Date: Fri, 22 Sep 2017 14:58:22 -0500 -Subject: [PATCH 08/42] tracing: Add hist_field_name() accessor -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -In preparation for hist_fields that won't be strictly based on -trace_event_fields, add a new hist_field_name() accessor to allow that -flexibility and update associated users. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 67 ++++++++++++++++++++++++++------------- - 1 file changed, 45 insertions(+), 22 deletions(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -146,6 +146,23 @@ struct hist_trigger_data { - struct tracing_map *map; - }; - -+static const char *hist_field_name(struct hist_field *field, -+ unsigned int level) -+{ -+ const char *field_name = ""; -+ -+ if (level > 1) -+ return field_name; -+ -+ if (field->field) -+ field_name = field->field->name; -+ -+ if (field_name == NULL) -+ field_name = ""; -+ -+ return field_name; -+} -+ - static hist_field_fn_t select_value_fn(int field_size, int field_is_signed) - { - hist_field_fn_t fn = NULL; -@@ -653,7 +670,6 @@ static int is_descending(const char *str - static int create_sort_keys(struct hist_trigger_data *hist_data) - { - char *fields_str = hist_data->attrs->sort_key_str; -- struct ftrace_event_field *field = NULL; - struct tracing_map_sort_key *sort_key; - int descending, ret = 0; - unsigned int i, j; -@@ -670,7 +686,9 @@ static int create_sort_keys(struct hist_ - } - - for (i = 0; i < TRACING_MAP_SORT_KEYS_MAX; i++) { -+ struct hist_field *hist_field; - char *field_str, *field_name; -+ const char *test_name; - - sort_key = &hist_data->sort_keys[i]; - -@@ -703,8 +721,10 @@ static int create_sort_keys(struct hist_ - } - - for (j = 1; j < hist_data->n_fields; j++) { -- field = hist_data->fields[j]->field; -- if (field && (strcmp(field_name, field->name) == 0)) { -+ hist_field = hist_data->fields[j]; -+ test_name = hist_field_name(hist_field, 0); -+ -+ if (strcmp(field_name, test_name) == 0) { - sort_key->field_idx = j; - descending = is_descending(field_str); - if (descending < 0) { -@@ -952,6 +972,7 @@ hist_trigger_entry_print(struct seq_file - struct hist_field *key_field; - char str[KSYM_SYMBOL_LEN]; - bool multiline = false; -+ const char *field_name; - unsigned int i; - u64 uval; - -@@ -963,26 +984,27 @@ hist_trigger_entry_print(struct seq_file - if (i > hist_data->n_vals) - seq_puts(m, ", "); - -+ field_name = hist_field_name(key_field, 0); -+ - if (key_field->flags & HIST_FIELD_FL_HEX) { - uval = *(u64 *)(key + key_field->offset); -- seq_printf(m, "%s: %llx", -- key_field->field->name, uval); -+ seq_printf(m, "%s: %llx", field_name, uval); - } else if (key_field->flags & HIST_FIELD_FL_SYM) { - uval = *(u64 *)(key + key_field->offset); - sprint_symbol_no_offset(str, uval); -- seq_printf(m, "%s: [%llx] %-45s", -- key_field->field->name, uval, str); -+ seq_printf(m, "%s: [%llx] %-45s", field_name, -+ uval, str); - } else if (key_field->flags & HIST_FIELD_FL_SYM_OFFSET) { - uval = *(u64 *)(key + key_field->offset); - sprint_symbol(str, uval); -- seq_printf(m, "%s: [%llx] %-55s", -- key_field->field->name, uval, str); -+ seq_printf(m, "%s: [%llx] %-55s", field_name, -+ uval, str); - } else if (key_field->flags & HIST_FIELD_FL_EXECNAME) { - char *comm = elt->private_data; - - uval = *(u64 *)(key + key_field->offset); -- seq_printf(m, "%s: %-16s[%10llu]", -- key_field->field->name, comm, uval); -+ seq_printf(m, "%s: %-16s[%10llu]", field_name, -+ comm, uval); - } else if (key_field->flags & HIST_FIELD_FL_SYSCALL) { - const char *syscall_name; - -@@ -991,8 +1013,8 @@ hist_trigger_entry_print(struct seq_file - if (!syscall_name) - syscall_name = "unknown_syscall"; - -- seq_printf(m, "%s: %-30s[%3llu]", -- key_field->field->name, syscall_name, uval); -+ seq_printf(m, "%s: %-30s[%3llu]", field_name, -+ syscall_name, uval); - } else if (key_field->flags & HIST_FIELD_FL_STACKTRACE) { - seq_puts(m, "stacktrace:\n"); - hist_trigger_stacktrace_print(m, -@@ -1000,15 +1022,14 @@ hist_trigger_entry_print(struct seq_file - HIST_STACKTRACE_DEPTH); - multiline = true; - } else if (key_field->flags & HIST_FIELD_FL_LOG2) { -- seq_printf(m, "%s: ~ 2^%-2llu", key_field->field->name, -+ seq_printf(m, "%s: ~ 2^%-2llu", field_name, - *(u64 *)(key + key_field->offset)); - } else if (key_field->flags & HIST_FIELD_FL_STRING) { -- seq_printf(m, "%s: %-50s", key_field->field->name, -+ seq_printf(m, "%s: %-50s", field_name, - (char *)(key + key_field->offset)); - } else { - uval = *(u64 *)(key + key_field->offset); -- seq_printf(m, "%s: %10llu", key_field->field->name, -- uval); -+ seq_printf(m, "%s: %10llu", field_name, uval); - } - } - -@@ -1021,13 +1042,13 @@ hist_trigger_entry_print(struct seq_file - tracing_map_read_sum(elt, HITCOUNT_IDX)); - - for (i = 1; i < hist_data->n_vals; i++) { -+ field_name = hist_field_name(hist_data->fields[i], 0); -+ - if (hist_data->fields[i]->flags & HIST_FIELD_FL_HEX) { -- seq_printf(m, " %s: %10llx", -- hist_data->fields[i]->field->name, -+ seq_printf(m, " %s: %10llx", field_name, - tracing_map_read_sum(elt, i)); - } else { -- seq_printf(m, " %s: %10llu", -- hist_data->fields[i]->field->name, -+ seq_printf(m, " %s: %10llu", field_name, - tracing_map_read_sum(elt, i)); - } - } -@@ -1142,7 +1163,9 @@ static const char *get_hist_field_flags( - - static void hist_field_print(struct seq_file *m, struct hist_field *hist_field) - { -- seq_printf(m, "%s", hist_field->field->name); -+ const char *field_name = hist_field_name(hist_field, 0); -+ -+ seq_printf(m, "%s", field_name); - if (hist_field->flags) { - const char *flags_str = get_hist_field_flags(hist_field); - diff --git a/debian/patches/features/all/rt/0008-tracing-Give-event-triggers-access-to-ring_buffer_ev.patch b/debian/patches/features/all/rt/0008-tracing-Give-event-triggers-access-to-ring_buffer_ev.patch deleted file mode 100644 index 55bffad67..000000000 --- a/debian/patches/features/all/rt/0008-tracing-Give-event-triggers-access-to-ring_buffer_ev.patch +++ /dev/null @@ -1,299 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:42 -0600 -Subject: [PATCH 08/37] tracing: Give event triggers access to - ring_buffer_event -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The ring_buffer event can provide a timestamp that may be useful to -various triggers - pass it into the handlers for that purpose. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - include/linux/trace_events.h | 14 ++++++---- - kernel/trace/trace.h | 9 +++--- - kernel/trace/trace_events_hist.c | 11 +++++--- - kernel/trace/trace_events_trigger.c | 47 ++++++++++++++++++++++-------------- - 4 files changed, 49 insertions(+), 32 deletions(-) - ---- a/include/linux/trace_events.h -+++ b/include/linux/trace_events.h -@@ -402,11 +402,13 @@ enum event_trigger_type { - - extern int filter_match_preds(struct event_filter *filter, void *rec); - --extern enum event_trigger_type event_triggers_call(struct trace_event_file *file, -- void *rec); --extern void event_triggers_post_call(struct trace_event_file *file, -- enum event_trigger_type tt, -- void *rec); -+extern enum event_trigger_type -+event_triggers_call(struct trace_event_file *file, void *rec, -+ struct ring_buffer_event *event); -+extern void -+event_triggers_post_call(struct trace_event_file *file, -+ enum event_trigger_type tt, -+ void *rec, struct ring_buffer_event *event); - - bool trace_event_ignore_this_pid(struct trace_event_file *trace_file); - -@@ -426,7 +428,7 @@ trace_trigger_soft_disabled(struct trace - - if (!(eflags & EVENT_FILE_FL_TRIGGER_COND)) { - if (eflags & EVENT_FILE_FL_TRIGGER_MODE) -- event_triggers_call(file, NULL); -+ event_triggers_call(file, NULL, NULL); - if (eflags & EVENT_FILE_FL_SOFT_DISABLED) - return true; - if (eflags & EVENT_FILE_FL_PID_FILTER) ---- a/kernel/trace/trace.h -+++ b/kernel/trace/trace.h -@@ -1296,7 +1296,7 @@ static inline bool - unsigned long eflags = file->flags; - - if (eflags & EVENT_FILE_FL_TRIGGER_COND) -- *tt = event_triggers_call(file, entry); -+ *tt = event_triggers_call(file, entry, event); - - if (test_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &file->flags) || - (unlikely(file->flags & EVENT_FILE_FL_FILTERED) && -@@ -1333,7 +1333,7 @@ event_trigger_unlock_commit(struct trace - trace_buffer_unlock_commit(file->tr, buffer, event, irq_flags, pc); - - if (tt) -- event_triggers_post_call(file, tt, entry); -+ event_triggers_post_call(file, tt, entry, event); - } - - /** -@@ -1366,7 +1366,7 @@ event_trigger_unlock_commit_regs(struct - irq_flags, pc, regs); - - if (tt) -- event_triggers_post_call(file, tt, entry); -+ event_triggers_post_call(file, tt, entry, event); - } - - #define FILTER_PRED_INVALID ((unsigned short)-1) -@@ -1591,7 +1591,8 @@ extern int register_trigger_hist_enable_ - */ - struct event_trigger_ops { - void (*func)(struct event_trigger_data *data, -- void *rec); -+ void *rec, -+ struct ring_buffer_event *rbe); - int (*init)(struct event_trigger_ops *ops, - struct event_trigger_data *data); - void (*free)(struct event_trigger_ops *ops, ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -909,7 +909,8 @@ static inline void add_to_key(char *comp - memcpy(compound_key + key_field->offset, key, size); - } - --static void event_hist_trigger(struct event_trigger_data *data, void *rec) -+static void event_hist_trigger(struct event_trigger_data *data, void *rec, -+ struct ring_buffer_event *event) - { - struct hist_trigger_data *hist_data = data->private_data; - bool use_compound_key = (hist_data->n_keys > 1); -@@ -1660,7 +1661,8 @@ static struct event_command trigger_hist - } - - static void --hist_enable_trigger(struct event_trigger_data *data, void *rec) -+hist_enable_trigger(struct event_trigger_data *data, void *rec, -+ struct ring_buffer_event *event) - { - struct enable_trigger_data *enable_data = data->private_data; - struct event_trigger_data *test; -@@ -1676,7 +1678,8 @@ hist_enable_trigger(struct event_trigger - } - - static void --hist_enable_count_trigger(struct event_trigger_data *data, void *rec) -+hist_enable_count_trigger(struct event_trigger_data *data, void *rec, -+ struct ring_buffer_event *event) - { - if (!data->count) - return; -@@ -1684,7 +1687,7 @@ hist_enable_count_trigger(struct event_t - if (data->count != -1) - (data->count)--; - -- hist_enable_trigger(data, rec); -+ hist_enable_trigger(data, rec, event); - } - - static struct event_trigger_ops hist_enable_trigger_ops = { ---- a/kernel/trace/trace_events_trigger.c -+++ b/kernel/trace/trace_events_trigger.c -@@ -63,7 +63,8 @@ void trigger_data_free(struct event_trig - * any trigger that should be deferred, ETT_NONE if nothing to defer. - */ - enum event_trigger_type --event_triggers_call(struct trace_event_file *file, void *rec) -+event_triggers_call(struct trace_event_file *file, void *rec, -+ struct ring_buffer_event *event) - { - struct event_trigger_data *data; - enum event_trigger_type tt = ETT_NONE; -@@ -76,7 +77,7 @@ event_triggers_call(struct trace_event_f - if (data->paused) - continue; - if (!rec) { -- data->ops->func(data, rec); -+ data->ops->func(data, rec, event); - continue; - } - filter = rcu_dereference_sched(data->filter); -@@ -86,7 +87,7 @@ event_triggers_call(struct trace_event_f - tt |= data->cmd_ops->trigger_type; - continue; - } -- data->ops->func(data, rec); -+ data->ops->func(data, rec, event); - } - return tt; - } -@@ -108,7 +109,7 @@ EXPORT_SYMBOL_GPL(event_triggers_call); - void - event_triggers_post_call(struct trace_event_file *file, - enum event_trigger_type tt, -- void *rec) -+ void *rec, struct ring_buffer_event *event) - { - struct event_trigger_data *data; - -@@ -116,7 +117,7 @@ event_triggers_post_call(struct trace_ev - if (data->paused) - continue; - if (data->cmd_ops->trigger_type & tt) -- data->ops->func(data, rec); -+ data->ops->func(data, rec, event); - } - } - EXPORT_SYMBOL_GPL(event_triggers_post_call); -@@ -909,7 +910,8 @@ void set_named_trigger_data(struct event - } - - static void --traceon_trigger(struct event_trigger_data *data, void *rec) -+traceon_trigger(struct event_trigger_data *data, void *rec, -+ struct ring_buffer_event *event) - { - if (tracing_is_on()) - return; -@@ -918,7 +920,8 @@ traceon_trigger(struct event_trigger_dat - } - - static void --traceon_count_trigger(struct event_trigger_data *data, void *rec) -+traceon_count_trigger(struct event_trigger_data *data, void *rec, -+ struct ring_buffer_event *event) - { - if (tracing_is_on()) - return; -@@ -933,7 +936,8 @@ traceon_count_trigger(struct event_trigg - } - - static void --traceoff_trigger(struct event_trigger_data *data, void *rec) -+traceoff_trigger(struct event_trigger_data *data, void *rec, -+ struct ring_buffer_event *event) - { - if (!tracing_is_on()) - return; -@@ -942,7 +946,8 @@ traceoff_trigger(struct event_trigger_da - } - - static void --traceoff_count_trigger(struct event_trigger_data *data, void *rec) -+traceoff_count_trigger(struct event_trigger_data *data, void *rec, -+ struct ring_buffer_event *event) - { - if (!tracing_is_on()) - return; -@@ -1039,13 +1044,15 @@ static struct event_command trigger_trac - - #ifdef CONFIG_TRACER_SNAPSHOT - static void --snapshot_trigger(struct event_trigger_data *data, void *rec) -+snapshot_trigger(struct event_trigger_data *data, void *rec, -+ struct ring_buffer_event *event) - { - tracing_snapshot(); - } - - static void --snapshot_count_trigger(struct event_trigger_data *data, void *rec) -+snapshot_count_trigger(struct event_trigger_data *data, void *rec, -+ struct ring_buffer_event *event) - { - if (!data->count) - return; -@@ -1053,7 +1060,7 @@ snapshot_count_trigger(struct event_trig - if (data->count != -1) - (data->count)--; - -- snapshot_trigger(data, rec); -+ snapshot_trigger(data, rec, event); - } - - static int -@@ -1132,13 +1139,15 @@ static __init int register_trigger_snaps - #define STACK_SKIP 3 - - static void --stacktrace_trigger(struct event_trigger_data *data, void *rec) -+stacktrace_trigger(struct event_trigger_data *data, void *rec, -+ struct ring_buffer_event *event) - { - trace_dump_stack(STACK_SKIP); - } - - static void --stacktrace_count_trigger(struct event_trigger_data *data, void *rec) -+stacktrace_count_trigger(struct event_trigger_data *data, void *rec, -+ struct ring_buffer_event *event) - { - if (!data->count) - return; -@@ -1146,7 +1155,7 @@ stacktrace_count_trigger(struct event_tr - if (data->count != -1) - (data->count)--; - -- stacktrace_trigger(data, rec); -+ stacktrace_trigger(data, rec, event); - } - - static int -@@ -1208,7 +1217,8 @@ static __init void unregister_trigger_tr - } - - static void --event_enable_trigger(struct event_trigger_data *data, void *rec) -+event_enable_trigger(struct event_trigger_data *data, void *rec, -+ struct ring_buffer_event *event) - { - struct enable_trigger_data *enable_data = data->private_data; - -@@ -1219,7 +1229,8 @@ event_enable_trigger(struct event_trigge - } - - static void --event_enable_count_trigger(struct event_trigger_data *data, void *rec) -+event_enable_count_trigger(struct event_trigger_data *data, void *rec, -+ struct ring_buffer_event *event) - { - struct enable_trigger_data *enable_data = data->private_data; - -@@ -1233,7 +1244,7 @@ event_enable_count_trigger(struct event_ - if (data->count != -1) - (data->count)--; - -- event_enable_trigger(data, rec); -+ event_enable_trigger(data, rec, event); - } - - int event_enable_trigger_print(struct seq_file *m, diff --git a/debian/patches/features/all/rt/0008-tracing-hrtimer-Take-all-clock-bases-and-modes-into-.patch b/debian/patches/features/all/rt/0008-tracing-hrtimer-Take-all-clock-bases-and-modes-into-.patch deleted file mode 100644 index bb40a7148..000000000 --- a/debian/patches/features/all/rt/0008-tracing-hrtimer-Take-all-clock-bases-and-modes-into-.patch +++ /dev/null @@ -1,56 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:12:57 +0100 -Subject: [PATCH 08/29] tracing/hrtimer: Take all clock bases and modes into - account -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -So far only CLOCK_MONOTONIC and CLOCK_REALTIME were taken into account as -well as HRTIMER_MODE_ABS/REL in hrtimer_init tracepoint. The query for -detecting timer mode ABS or REL is not valid, since the introduction of -HRTIMER_MODE_PINNED. - -HRTIMER_MODE_PINNED is not evaluated in hrtimer_init() call. But for the -sake of completeness print all given modes. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - include/trace/events/timer.h | 20 ++++++++++++++++---- - 1 file changed, 16 insertions(+), 4 deletions(-) - ---- a/include/trace/events/timer.h -+++ b/include/trace/events/timer.h -@@ -136,6 +136,20 @@ DEFINE_EVENT(timer_class, timer_cancel, - TP_ARGS(timer) - ); - -+#define decode_clockid(type) \ -+ __print_symbolic(type, \ -+ { CLOCK_REALTIME, "CLOCK_REALTIME" }, \ -+ { CLOCK_MONOTONIC, "CLOCK_MONOTONIC" }, \ -+ { CLOCK_BOOTTIME, "CLOCK_BOOTTIME" }, \ -+ { CLOCK_TAI, "CLOCK_TAI" }) -+ -+#define decode_hrtimer_mode(mode) \ -+ __print_symbolic(mode, \ -+ { HRTIMER_MODE_ABS, "ABS" }, \ -+ { HRTIMER_MODE_REL, "REL" }, \ -+ { HRTIMER_MODE_ABS_PINNED, "ABS|PINNED" }, \ -+ { HRTIMER_MODE_REL_PINNED, "REL|PINNED" }) -+ - /** - * hrtimer_init - called when the hrtimer is initialized - * @hrtimer: pointer to struct hrtimer -@@ -162,10 +176,8 @@ TRACE_EVENT(hrtimer_init, - ), - - TP_printk("hrtimer=%p clockid=%s mode=%s", __entry->hrtimer, -- __entry->clockid == CLOCK_REALTIME ? -- "CLOCK_REALTIME" : "CLOCK_MONOTONIC", -- __entry->mode == HRTIMER_MODE_ABS ? -- "HRTIMER_MODE_ABS" : "HRTIMER_MODE_REL") -+ decode_clockid(__entry->clockid), -+ decode_hrtimer_mode(__entry->mode)) - ); - - /** diff --git a/debian/patches/features/all/rt/0009-iommu-amd-Make-amd_iommu_devtable_lock-a-spin_lock.patch b/debian/patches/features/all/rt/0009-iommu-amd-Make-amd_iommu_devtable_lock-a-spin_lock.patch index e622ba035..0eac5e439 100644 --- a/debian/patches/features/all/rt/0009-iommu-amd-Make-amd_iommu_devtable_lock-a-spin_lock.patch +++ b/debian/patches/features/all/rt/0009-iommu-amd-Make-amd_iommu_devtable_lock-a-spin_lock.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 22 Mar 2018 16:22:41 +0100 Subject: [PATCH 09/10] iommu/amd: Make amd_iommu_devtable_lock a spin_lock -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 2cd1083d79a0a8c223af430ca97884c28a1e2fc0 diff --git a/debian/patches/features/all/rt/0009-split-d_path-and-friends-into-a-separate-file.patch b/debian/patches/features/all/rt/0009-split-d_path-and-friends-into-a-separate-file.patch index 7afdae6e9..34b9b23c2 100644 --- a/debian/patches/features/all/rt/0009-split-d_path-and-friends-into-a-separate-file.patch +++ b/debian/patches/features/all/rt/0009-split-d_path-and-friends-into-a-separate-file.patch @@ -1,7 +1,6 @@ From: Al Viro Date: Mon, 5 Mar 2018 19:15:50 -0500 Subject: [PATCH 09/17] split d_path() and friends into a separate file -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 7a5cf791a747640adb2a1b5e3838321b26953a23 diff --git a/debian/patches/features/all/rt/0009-tracing-Add-ring-buffer-event-param-to-hist-field-fu.patch b/debian/patches/features/all/rt/0009-tracing-Add-ring-buffer-event-param-to-hist-field-fu.patch deleted file mode 100644 index 5ddb47147..000000000 --- a/debian/patches/features/all/rt/0009-tracing-Add-ring-buffer-event-param-to-hist-field-fu.patch +++ /dev/null @@ -1,140 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:43 -0600 -Subject: [PATCH 09/37] tracing: Add ring buffer event param to hist field - functions -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Some events such as timestamps require access to a ring_buffer_event -struct; add a param so that hist field functions can access that. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 39 ++++++++++++++++++++++++--------------- - 1 file changed, 24 insertions(+), 15 deletions(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -26,7 +26,8 @@ - - struct hist_field; - --typedef u64 (*hist_field_fn_t) (struct hist_field *field, void *event); -+typedef u64 (*hist_field_fn_t) (struct hist_field *field, void *event, -+ struct ring_buffer_event *rbe); - - #define HIST_FIELD_OPERANDS_MAX 2 - -@@ -40,24 +41,28 @@ struct hist_field { - struct hist_field *operands[HIST_FIELD_OPERANDS_MAX]; - }; - --static u64 hist_field_none(struct hist_field *field, void *event) -+static u64 hist_field_none(struct hist_field *field, void *event, -+ struct ring_buffer_event *rbe) - { - return 0; - } - --static u64 hist_field_counter(struct hist_field *field, void *event) -+static u64 hist_field_counter(struct hist_field *field, void *event, -+ struct ring_buffer_event *rbe) - { - return 1; - } - --static u64 hist_field_string(struct hist_field *hist_field, void *event) -+static u64 hist_field_string(struct hist_field *hist_field, void *event, -+ struct ring_buffer_event *rbe) - { - char *addr = (char *)(event + hist_field->field->offset); - - return (u64)(unsigned long)addr; - } - --static u64 hist_field_dynstring(struct hist_field *hist_field, void *event) -+static u64 hist_field_dynstring(struct hist_field *hist_field, void *event, -+ struct ring_buffer_event *rbe) - { - u32 str_item = *(u32 *)(event + hist_field->field->offset); - int str_loc = str_item & 0xffff; -@@ -66,24 +71,28 @@ static u64 hist_field_dynstring(struct h - return (u64)(unsigned long)addr; - } - --static u64 hist_field_pstring(struct hist_field *hist_field, void *event) -+static u64 hist_field_pstring(struct hist_field *hist_field, void *event, -+ struct ring_buffer_event *rbe) - { - char **addr = (char **)(event + hist_field->field->offset); - - return (u64)(unsigned long)*addr; - } - --static u64 hist_field_log2(struct hist_field *hist_field, void *event) -+static u64 hist_field_log2(struct hist_field *hist_field, void *event, -+ struct ring_buffer_event *rbe) - { - struct hist_field *operand = hist_field->operands[0]; - -- u64 val = operand->fn(operand, event); -+ u64 val = operand->fn(operand, event, rbe); - - return (u64) ilog2(roundup_pow_of_two(val)); - } - - #define DEFINE_HIST_FIELD_FN(type) \ --static u64 hist_field_##type(struct hist_field *hist_field, void *event)\ -+ static u64 hist_field_##type(struct hist_field *hist_field, \ -+ void *event, \ -+ struct ring_buffer_event *rbe) \ - { \ - type *addr = (type *)(event + hist_field->field->offset); \ - \ -@@ -871,8 +880,8 @@ create_hist_data(unsigned int map_bits, - } - - static void hist_trigger_elt_update(struct hist_trigger_data *hist_data, -- struct tracing_map_elt *elt, -- void *rec) -+ struct tracing_map_elt *elt, void *rec, -+ struct ring_buffer_event *rbe) - { - struct hist_field *hist_field; - unsigned int i; -@@ -880,7 +889,7 @@ static void hist_trigger_elt_update(stru - - for_each_hist_val_field(i, hist_data) { - hist_field = hist_data->fields[i]; -- hist_val = hist_field->fn(hist_field, rec); -+ hist_val = hist_field->fn(hist_field, rec, rbe); - tracing_map_update_sum(elt, i, hist_val); - } - } -@@ -910,7 +919,7 @@ static inline void add_to_key(char *comp - } - - static void event_hist_trigger(struct event_trigger_data *data, void *rec, -- struct ring_buffer_event *event) -+ struct ring_buffer_event *rbe) - { - struct hist_trigger_data *hist_data = data->private_data; - bool use_compound_key = (hist_data->n_keys > 1); -@@ -939,7 +948,7 @@ static void event_hist_trigger(struct ev - - key = entries; - } else { -- field_contents = key_field->fn(key_field, rec); -+ field_contents = key_field->fn(key_field, rec, rbe); - if (key_field->flags & HIST_FIELD_FL_STRING) { - key = (void *)(unsigned long)field_contents; - use_compound_key = true; -@@ -956,7 +965,7 @@ static void event_hist_trigger(struct ev - - elt = tracing_map_insert(hist_data->map, key); - if (elt) -- hist_trigger_elt_update(hist_data, elt, rec); -+ hist_trigger_elt_update(hist_data, elt, rec, rbe); - } - - static void hist_trigger_stacktrace_print(struct seq_file *m, diff --git a/debian/patches/features/all/rt/0009-tracing-Move-hist-trigger-Documentation-to-histogram.patch b/debian/patches/features/all/rt/0009-tracing-Move-hist-trigger-Documentation-to-histogram.patch index 9bce3504f..115c00216 100644 --- a/debian/patches/features/all/rt/0009-tracing-Move-hist-trigger-Documentation-to-histogram.patch +++ b/debian/patches/features/all/rt/0009-tracing-Move-hist-trigger-Documentation-to-histogram.patch @@ -2,7 +2,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:35 -0600 Subject: [PATCH 09/48] tracing: Move hist trigger Documentation to histogram.txt -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The hist trigger Documentation takes up a large part of events.txt - since it will be getting even larger, move it to a separate file. diff --git a/debian/patches/features/all/rt/0009-tracing-Reimplement-log2.patch b/debian/patches/features/all/rt/0009-tracing-Reimplement-log2.patch deleted file mode 100644 index 628a9ed42..000000000 --- a/debian/patches/features/all/rt/0009-tracing-Reimplement-log2.patch +++ /dev/null @@ -1,115 +0,0 @@ -From: Tom Zanussi -Date: Fri, 22 Sep 2017 14:58:23 -0500 -Subject: [PATCH 09/42] tracing: Reimplement log2 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -log2 as currently implemented applies only to u64 trace_event_field -derived fields, and assumes that anything it's applied to is a u64 -field. - -To prepare for synthetic fields like latencies, log2 should be -applicable to those as well, so take the opportunity now to fix the -current problems as well as expand to more general uses. - -log2 should be thought of as a chaining function rather than a field -type. To enable this as well as possible future function -implementations, add a hist_field operand array into the hist_field -definition for this purpose, and make use of it to implement the log2 -'function'. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 31 +++++++++++++++++++++++++++---- - 1 file changed, 27 insertions(+), 4 deletions(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -28,12 +28,16 @@ struct hist_field; - - typedef u64 (*hist_field_fn_t) (struct hist_field *field, void *event); - -+#define HIST_FIELD_OPERANDS_MAX 2 -+ - struct hist_field { - struct ftrace_event_field *field; - unsigned long flags; - hist_field_fn_t fn; - unsigned int size; - unsigned int offset; -+ unsigned int is_signed; -+ struct hist_field *operands[HIST_FIELD_OPERANDS_MAX]; - }; - - static u64 hist_field_none(struct hist_field *field, void *event) -@@ -71,7 +75,9 @@ static u64 hist_field_pstring(struct his - - static u64 hist_field_log2(struct hist_field *hist_field, void *event) - { -- u64 val = *(u64 *)(event + hist_field->field->offset); -+ struct hist_field *operand = hist_field->operands[0]; -+ -+ u64 val = operand->fn(operand, event); - - return (u64) ilog2(roundup_pow_of_two(val)); - } -@@ -156,6 +162,8 @@ static const char *hist_field_name(struc - - if (field->field) - field_name = field->field->name; -+ else if (field->flags & HIST_FIELD_FL_LOG2) -+ field_name = hist_field_name(field->operands[0], ++level); - - if (field_name == NULL) - field_name = ""; -@@ -357,8 +365,20 @@ static const struct tracing_map_ops hist - .elt_init = hist_trigger_elt_comm_init, - }; - --static void destroy_hist_field(struct hist_field *hist_field) -+static void destroy_hist_field(struct hist_field *hist_field, -+ unsigned int level) - { -+ unsigned int i; -+ -+ if (level > 2) -+ return; -+ -+ if (!hist_field) -+ return; -+ -+ for (i = 0; i < HIST_FIELD_OPERANDS_MAX; i++) -+ destroy_hist_field(hist_field->operands[i], level + 1); -+ - kfree(hist_field); - } - -@@ -385,7 +405,10 @@ static struct hist_field *create_hist_fi - } - - if (flags & HIST_FIELD_FL_LOG2) { -+ unsigned long fl = flags & ~HIST_FIELD_FL_LOG2; - hist_field->fn = hist_field_log2; -+ hist_field->operands[0] = create_hist_field(field, fl); -+ hist_field->size = hist_field->operands[0]->size; - goto out; - } - -@@ -405,7 +428,7 @@ static struct hist_field *create_hist_fi - hist_field->fn = select_value_fn(field->size, - field->is_signed); - if (!hist_field->fn) { -- destroy_hist_field(hist_field); -+ destroy_hist_field(hist_field, 0); - return NULL; - } - } -@@ -422,7 +445,7 @@ static void destroy_hist_fields(struct h - - for (i = 0; i < TRACING_MAP_FIELDS_MAX; i++) { - if (hist_data->fields[i]) { -- destroy_hist_field(hist_data->fields[i]); -+ destroy_hist_field(hist_data->fields[i], 0); - hist_data->fields[i] = NULL; - } - } diff --git a/debian/patches/features/all/rt/0009-tracing-hrtimer-Print-hrtimer-mode-in-hrtimer_start-.patch b/debian/patches/features/all/rt/0009-tracing-hrtimer-Print-hrtimer-mode-in-hrtimer_start-.patch deleted file mode 100644 index 6baa80130..000000000 --- a/debian/patches/features/all/rt/0009-tracing-hrtimer-Print-hrtimer-mode-in-hrtimer_start-.patch +++ /dev/null @@ -1,114 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:12:58 +0100 -Subject: [PATCH 09/29] tracing/hrtimer: Print hrtimer mode in hrtimer_start - tracepoint -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The hrtimer_start tracepoint lacks the mode information. The mode is -important because consecutive starts can switch from ABS to REL or from -PINNED to non PINNED. - -Add the mode information. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - include/trace/events/timer.h | 13 ++++++++----- - kernel/time/hrtimer.c | 16 +++++++++------- - 2 files changed, 17 insertions(+), 12 deletions(-) - ---- a/include/trace/events/timer.h -+++ b/include/trace/events/timer.h -@@ -186,15 +186,16 @@ TRACE_EVENT(hrtimer_init, - */ - TRACE_EVENT(hrtimer_start, - -- TP_PROTO(struct hrtimer *hrtimer), -+ TP_PROTO(struct hrtimer *hrtimer, enum hrtimer_mode mode), - -- TP_ARGS(hrtimer), -+ TP_ARGS(hrtimer, mode), - - TP_STRUCT__entry( - __field( void *, hrtimer ) - __field( void *, function ) - __field( s64, expires ) - __field( s64, softexpires ) -+ __field( enum hrtimer_mode, mode ) - ), - - TP_fast_assign( -@@ -202,12 +203,14 @@ TRACE_EVENT(hrtimer_start, - __entry->function = hrtimer->function; - __entry->expires = hrtimer_get_expires(hrtimer); - __entry->softexpires = hrtimer_get_softexpires(hrtimer); -+ __entry->mode = mode; - ), - -- TP_printk("hrtimer=%p function=%pf expires=%llu softexpires=%llu", -- __entry->hrtimer, __entry->function, -+ TP_printk("hrtimer=%p function=%pf expires=%llu softexpires=%llu " -+ "mode=%s", __entry->hrtimer, __entry->function, - (unsigned long long) __entry->expires, -- (unsigned long long) __entry->softexpires) -+ (unsigned long long) __entry->softexpires, -+ decode_hrtimer_mode(__entry->mode)) - ); - - /** ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -435,10 +435,11 @@ debug_init(struct hrtimer *timer, clocki - trace_hrtimer_init(timer, clockid, mode); - } - --static inline void debug_activate(struct hrtimer *timer) -+static inline void debug_activate(struct hrtimer *timer, -+ enum hrtimer_mode mode) - { - debug_hrtimer_activate(timer); -- trace_hrtimer_start(timer); -+ trace_hrtimer_start(timer, mode); - } - - static inline void debug_deactivate(struct hrtimer *timer) -@@ -830,9 +831,10 @@ EXPORT_SYMBOL_GPL(hrtimer_forward); - * Returns 1 when the new timer is the leftmost timer in the tree. - */ - static int enqueue_hrtimer(struct hrtimer *timer, -- struct hrtimer_clock_base *base) -+ struct hrtimer_clock_base *base, -+ enum hrtimer_mode mode) - { -- debug_activate(timer); -+ debug_activate(timer, mode); - - base->cpu_base->active_bases |= 1 << base->index; - -@@ -955,7 +957,7 @@ void hrtimer_start_range_ns(struct hrtim - /* Switch the timer base, if necessary: */ - new_base = switch_hrtimer_base(timer, base, mode & HRTIMER_MODE_PINNED); - -- leftmost = enqueue_hrtimer(timer, new_base); -+ leftmost = enqueue_hrtimer(timer, new_base, mode); - if (!leftmost) - goto unlock; - -@@ -1224,7 +1226,7 @@ static void __run_hrtimer(struct hrtimer - */ - if (restart != HRTIMER_NORESTART && - !(timer->state & HRTIMER_STATE_ENQUEUED)) -- enqueue_hrtimer(timer, base); -+ enqueue_hrtimer(timer, base, HRTIMER_MODE_ABS); - - /* - * Separate the ->running assignment from the ->state assignment. -@@ -1623,7 +1625,7 @@ static void migrate_hrtimer_list(struct - * sort out already expired timers and reprogram the - * event device. - */ -- enqueue_hrtimer(timer, new_base); -+ enqueue_hrtimer(timer, new_base, HRTIMER_MODE_ABS); - } - } - diff --git a/debian/patches/features/all/rt/0010-hrtimer-Switch-for-loop-to-_ffs-evaluation.patch b/debian/patches/features/all/rt/0010-hrtimer-Switch-for-loop-to-_ffs-evaluation.patch deleted file mode 100644 index 06cc2f010..000000000 --- a/debian/patches/features/all/rt/0010-hrtimer-Switch-for-loop-to-_ffs-evaluation.patch +++ /dev/null @@ -1,85 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:12:59 +0100 -Subject: [PATCH 10/29] hrtimer: Switch for loop to _ffs() evaluation -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Looping over all clock bases to find active bits is suboptimal if not all -bases are active. - -Avoid this by converting it to a __ffs() evaluation. The functionallity is -outsourced into an own function and is called via a macro as suggested by -Peter Zijlstra. - -Suggested-by: Peter Zijlstra -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/time/hrtimer.c | 31 +++++++++++++++++++++---------- - 1 file changed, 21 insertions(+), 10 deletions(-) - ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -448,6 +448,23 @@ static inline void debug_deactivate(stru - trace_hrtimer_cancel(timer); - } - -+static struct hrtimer_clock_base * -+__next_base(struct hrtimer_cpu_base *cpu_base, unsigned int *active) -+{ -+ unsigned int idx; -+ -+ if (!*active) -+ return NULL; -+ -+ idx = __ffs(*active); -+ *active &= ~(1U << idx); -+ -+ return &cpu_base->clock_base[idx]; -+} -+ -+#define for_each_active_base(base, cpu_base, active) \ -+ while ((base = __next_base((cpu_base), &(active)))) -+ - #if defined(CONFIG_NO_HZ_COMMON) || defined(CONFIG_HIGH_RES_TIMERS) - static inline void hrtimer_update_next_timer(struct hrtimer_cpu_base *cpu_base, - struct hrtimer *timer) -@@ -459,18 +476,15 @@ static inline void hrtimer_update_next_t - - static ktime_t __hrtimer_get_next_event(struct hrtimer_cpu_base *cpu_base) - { -- struct hrtimer_clock_base *base = cpu_base->clock_base; -+ struct hrtimer_clock_base *base; - unsigned int active = cpu_base->active_bases; - ktime_t expires, expires_next = KTIME_MAX; - - hrtimer_update_next_timer(cpu_base, NULL); -- for (; active; base++, active >>= 1) { -+ for_each_active_base(base, cpu_base, active) { - struct timerqueue_node *next; - struct hrtimer *timer; - -- if (!(active & 0x01)) -- continue; -- - next = timerqueue_getnext(&base->active); - timer = container_of(next, struct hrtimer, node); - expires = ktime_sub(hrtimer_get_expires(timer), base->offset); -@@ -1243,16 +1257,13 @@ static void __run_hrtimer(struct hrtimer - - static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t now) - { -- struct hrtimer_clock_base *base = cpu_base->clock_base; -+ struct hrtimer_clock_base *base; - unsigned int active = cpu_base->active_bases; - -- for (; active; base++, active >>= 1) { -+ for_each_active_base(base, cpu_base, active) { - struct timerqueue_node *node; - ktime_t basenow; - -- if (!(active & 0x01)) -- continue; -- - basenow = ktime_add(now, base->offset); - - while ((node = timerqueue_getnext(&base->active))) { diff --git a/debian/patches/features/all/rt/0010-iommu-amd-Return-proper-error-code-in-irq_remapping_.patch b/debian/patches/features/all/rt/0010-iommu-amd-Return-proper-error-code-in-irq_remapping_.patch index 3545a457f..740cdf5bc 100644 --- a/debian/patches/features/all/rt/0010-iommu-amd-Return-proper-error-code-in-irq_remapping_.patch +++ b/debian/patches/features/all/rt/0010-iommu-amd-Return-proper-error-code-in-irq_remapping_.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 22 Mar 2018 16:22:42 +0100 Subject: [PATCH 10/10] iommu/amd: Return proper error code in irq_remapping_alloc() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 29d049be9438278c47253a74cf8d0ddf36bd5d68 diff --git a/debian/patches/features/all/rt/0010-take-out-orphan-externs-empty_string-slash_string.patch b/debian/patches/features/all/rt/0010-take-out-orphan-externs-empty_string-slash_string.patch index 5a80abfe5..01ddb1cac 100644 --- a/debian/patches/features/all/rt/0010-take-out-orphan-externs-empty_string-slash_string.patch +++ b/debian/patches/features/all/rt/0010-take-out-orphan-externs-empty_string-slash_string.patch @@ -1,7 +1,6 @@ From: Al Viro Date: Wed, 7 Mar 2018 12:47:04 -0500 Subject: [PATCH 10/17] take out orphan externs (empty_string/slash_string) -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 903ddaf49329076862d65f7284d825759ff67bd6 diff --git a/debian/patches/features/all/rt/0010-tracing-Add-Documentation-for-log2-modifier.patch b/debian/patches/features/all/rt/0010-tracing-Add-Documentation-for-log2-modifier.patch index 94954bf1b..a5f686cf9 100644 --- a/debian/patches/features/all/rt/0010-tracing-Add-Documentation-for-log2-modifier.patch +++ b/debian/patches/features/all/rt/0010-tracing-Add-Documentation-for-log2-modifier.patch @@ -1,7 +1,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:36 -0600 Subject: [PATCH 10/48] tracing: Add Documentation for log2 modifier -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Add a line for the log2 modifier, to keep it aligned with tracing/README. diff --git a/debian/patches/features/all/rt/0010-tracing-Break-out-hist-trigger-assignment-parsing.patch b/debian/patches/features/all/rt/0010-tracing-Break-out-hist-trigger-assignment-parsing.patch deleted file mode 100644 index 1eca58c2b..000000000 --- a/debian/patches/features/all/rt/0010-tracing-Break-out-hist-trigger-assignment-parsing.patch +++ /dev/null @@ -1,109 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:44 -0600 -Subject: [PATCH 10/37] tracing: Break out hist trigger assignment parsing -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -This will make it easier to add variables, and makes the parsing code -cleaner regardless. - -Signed-off-by: Tom Zanussi -Signed-off-by: Rajvi Jingar -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 72 +++++++++++++++++++++++++++------------ - 1 file changed, 51 insertions(+), 21 deletions(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -251,6 +251,51 @@ static void destroy_hist_trigger_attrs(s - kfree(attrs); - } - -+static int parse_assignment(char *str, struct hist_trigger_attrs *attrs) -+{ -+ int ret = 0; -+ -+ if ((strncmp(str, "key=", strlen("key=")) == 0) || -+ (strncmp(str, "keys=", strlen("keys=")) == 0)) { -+ attrs->keys_str = kstrdup(str, GFP_KERNEL); -+ if (!attrs->keys_str) { -+ ret = -ENOMEM; -+ goto out; -+ } -+ } else if ((strncmp(str, "val=", strlen("val=")) == 0) || -+ (strncmp(str, "vals=", strlen("vals=")) == 0) || -+ (strncmp(str, "values=", strlen("values=")) == 0)) { -+ attrs->vals_str = kstrdup(str, GFP_KERNEL); -+ if (!attrs->vals_str) { -+ ret = -ENOMEM; -+ goto out; -+ } -+ } else if (strncmp(str, "sort=", strlen("sort=")) == 0) { -+ attrs->sort_key_str = kstrdup(str, GFP_KERNEL); -+ if (!attrs->sort_key_str) { -+ ret = -ENOMEM; -+ goto out; -+ } -+ } else if (strncmp(str, "name=", strlen("name=")) == 0) { -+ attrs->name = kstrdup(str, GFP_KERNEL); -+ if (!attrs->name) { -+ ret = -ENOMEM; -+ goto out; -+ } -+ } else if (strncmp(str, "size=", strlen("size=")) == 0) { -+ int map_bits = parse_map_size(str); -+ -+ if (map_bits < 0) { -+ ret = map_bits; -+ goto out; -+ } -+ attrs->map_bits = map_bits; -+ } else -+ ret = -EINVAL; -+ out: -+ return ret; -+} -+ - static struct hist_trigger_attrs *parse_hist_trigger_attrs(char *trigger_str) - { - struct hist_trigger_attrs *attrs; -@@ -263,33 +308,18 @@ static struct hist_trigger_attrs *parse_ - while (trigger_str) { - char *str = strsep(&trigger_str, ":"); - -- if ((strncmp(str, "key=", strlen("key=")) == 0) || -- (strncmp(str, "keys=", strlen("keys=")) == 0)) -- attrs->keys_str = kstrdup(str, GFP_KERNEL); -- else if ((strncmp(str, "val=", strlen("val=")) == 0) || -- (strncmp(str, "vals=", strlen("vals=")) == 0) || -- (strncmp(str, "values=", strlen("values=")) == 0)) -- attrs->vals_str = kstrdup(str, GFP_KERNEL); -- else if (strncmp(str, "sort=", strlen("sort=")) == 0) -- attrs->sort_key_str = kstrdup(str, GFP_KERNEL); -- else if (strncmp(str, "name=", strlen("name=")) == 0) -- attrs->name = kstrdup(str, GFP_KERNEL); -- else if (strcmp(str, "pause") == 0) -+ if (strchr(str, '=')) { -+ ret = parse_assignment(str, attrs); -+ if (ret) -+ goto free; -+ } else if (strcmp(str, "pause") == 0) - attrs->pause = true; - else if ((strcmp(str, "cont") == 0) || - (strcmp(str, "continue") == 0)) - attrs->cont = true; - else if (strcmp(str, "clear") == 0) - attrs->clear = true; -- else if (strncmp(str, "size=", strlen("size=")) == 0) { -- int map_bits = parse_map_size(str); -- -- if (map_bits < 0) { -- ret = map_bits; -- goto free; -- } -- attrs->map_bits = map_bits; -- } else { -+ else { - ret = -EINVAL; - goto free; - } diff --git a/debian/patches/features/all/rt/0011-fold-lookup_real-into-__lookup_hash.patch b/debian/patches/features/all/rt/0011-fold-lookup_real-into-__lookup_hash.patch index e58c74df0..c0c6886ac 100644 --- a/debian/patches/features/all/rt/0011-fold-lookup_real-into-__lookup_hash.patch +++ b/debian/patches/features/all/rt/0011-fold-lookup_real-into-__lookup_hash.patch @@ -1,7 +1,6 @@ From: Al Viro Date: Thu, 8 Mar 2018 11:00:45 -0500 Subject: [PATCH 11/17] fold lookup_real() into __lookup_hash() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit a03ece5ff2bd7a9abaa0e8ddfe5f79d79e5984c8 diff --git a/debian/patches/features/all/rt/0011-hrtimer-Store-running-timer-in-hrtimer_clock_base.patch b/debian/patches/features/all/rt/0011-hrtimer-Store-running-timer-in-hrtimer_clock_base.patch deleted file mode 100644 index 1ea613c1a..000000000 --- a/debian/patches/features/all/rt/0011-hrtimer-Store-running-timer-in-hrtimer_clock_base.patch +++ /dev/null @@ -1,192 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:13:00 +0100 -Subject: [PATCH 11/29] hrtimer: Store running timer in hrtimer_clock_base -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The pointer to the currently running timer is stored in hrtimer_cpu_base -before the base lock is dropped and the callback is invoked. - -This results in two levels of indirections and the upcoming support for -softirq based hrtimer requires splitting the "running" storage into soft -and hard irq context expiry. - -Storing both in the cpu base would require conditionals in all code paths -accessing that information. - -It's possible to have a per clock base sequence count and running pointer -without changing the semantics of the related mechanisms because the timer -base pointer cannot be changed while a timer is running the callback. - -Unfortunately this makes cpu_clock base larger than 32 bytes on 32bit -kernels. Instead of having huge gaps due to alignment, remove the alignment -and let the compiler pack cpu base for 32bit. The resulting cache access -patterns are fortunately not really different from the current -behaviour. On 64bit kernels the 64byte alignment stays and the behaviour is -unchanged. This was determined by analyzing the resulting layout and -looking at the number of cache lines involved for the frequently used -clocks. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - include/linux/hrtimer.h | 20 +++++++++----------- - kernel/time/hrtimer.c | 28 +++++++++++++--------------- - 2 files changed, 22 insertions(+), 26 deletions(-) - ---- a/include/linux/hrtimer.h -+++ b/include/linux/hrtimer.h -@@ -118,9 +118,9 @@ struct hrtimer_sleeper { - }; - - #ifdef CONFIG_64BIT --# define HRTIMER_CLOCK_BASE_ALIGN 64 -+# define __hrtimer_clock_base_align ____cacheline_aligned - #else --# define HRTIMER_CLOCK_BASE_ALIGN 32 -+# define __hrtimer_clock_base_align - #endif - - /** -@@ -129,18 +129,22 @@ struct hrtimer_sleeper { - * @index: clock type index for per_cpu support when moving a - * timer to a base on another cpu. - * @clockid: clock id for per_cpu support -+ * @seq: seqcount around __run_hrtimer -+ * @running: pointer to the currently running hrtimer - * @active: red black tree root node for the active timers - * @get_time: function to retrieve the current time of the clock - * @offset: offset of this clock to the monotonic base - */ - struct hrtimer_clock_base { - struct hrtimer_cpu_base *cpu_base; -- int index; -+ unsigned int index; - clockid_t clockid; -+ seqcount_t seq; -+ struct hrtimer *running; - struct timerqueue_head active; - ktime_t (*get_time)(void); - ktime_t offset; --} __attribute__((__aligned__(HRTIMER_CLOCK_BASE_ALIGN))); -+} __hrtimer_clock_base_align; - - enum hrtimer_base_type { - HRTIMER_BASE_MONOTONIC, -@@ -154,8 +158,6 @@ enum hrtimer_base_type { - * struct hrtimer_cpu_base - the per cpu clock bases - * @lock: lock protecting the base and associated clock bases - * and timers -- * @seq: seqcount around __run_hrtimer -- * @running: pointer to the currently running hrtimer - * @cpu: cpu number - * @active_bases: Bitfield to mark bases with active timers - * @clock_was_set_seq: Sequence counter of clock was set events -@@ -177,8 +179,6 @@ enum hrtimer_base_type { - */ - struct hrtimer_cpu_base { - raw_spinlock_t lock; -- seqcount_t seq; -- struct hrtimer *running; - unsigned int cpu; - unsigned int active_bases; - unsigned int clock_was_set_seq; -@@ -198,8 +198,6 @@ struct hrtimer_cpu_base { - - static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time) - { -- BUILD_BUG_ON(sizeof(struct hrtimer_clock_base) > HRTIMER_CLOCK_BASE_ALIGN); -- - timer->node.expires = time; - timer->_softexpires = time; - } -@@ -424,7 +422,7 @@ static inline int hrtimer_is_queued(stru - */ - static inline int hrtimer_callback_running(struct hrtimer *timer) - { -- return timer->base->cpu_base->running == timer; -+ return timer->base->running == timer; - } - - /* Forward a hrtimer so it expires after now: */ ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -70,7 +70,6 @@ - DEFINE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases) = - { - .lock = __RAW_SPIN_LOCK_UNLOCKED(hrtimer_bases.lock), -- .seq = SEQCNT_ZERO(hrtimer_bases.seq), - .clock_base = - { - { -@@ -118,7 +117,6 @@ static const int hrtimer_clock_to_base_t - * timer->base->cpu_base - */ - static struct hrtimer_cpu_base migration_cpu_base = { -- .seq = SEQCNT_ZERO(migration_cpu_base), - .clock_base = { { .cpu_base = &migration_cpu_base, }, }, - }; - -@@ -1150,19 +1148,19 @@ EXPORT_SYMBOL_GPL(hrtimer_init); - */ - bool hrtimer_active(const struct hrtimer *timer) - { -- struct hrtimer_cpu_base *cpu_base; -+ struct hrtimer_clock_base *base; - unsigned int seq; - - do { -- cpu_base = READ_ONCE(timer->base->cpu_base); -- seq = raw_read_seqcount_begin(&cpu_base->seq); -+ base = READ_ONCE(timer->base); -+ seq = raw_read_seqcount_begin(&base->seq); - - if (timer->state != HRTIMER_STATE_INACTIVE || -- cpu_base->running == timer) -+ base->running == timer) - return true; - -- } while (read_seqcount_retry(&cpu_base->seq, seq) || -- cpu_base != READ_ONCE(timer->base->cpu_base)); -+ } while (read_seqcount_retry(&base->seq, seq) || -+ base != READ_ONCE(timer->base)); - - return false; - } -@@ -1196,16 +1194,16 @@ static void __run_hrtimer(struct hrtimer - lockdep_assert_held(&cpu_base->lock); - - debug_deactivate(timer); -- cpu_base->running = timer; -+ base->running = timer; - - /* - * Separate the ->running assignment from the ->state assignment. - * - * As with a regular write barrier, this ensures the read side in -- * hrtimer_active() cannot observe cpu_base->running == NULL && -+ * hrtimer_active() cannot observe base->running == NULL && - * timer->state == INACTIVE. - */ -- raw_write_seqcount_barrier(&cpu_base->seq); -+ raw_write_seqcount_barrier(&base->seq); - - __remove_hrtimer(timer, base, HRTIMER_STATE_INACTIVE, 0); - fn = timer->function; -@@ -1246,13 +1244,13 @@ static void __run_hrtimer(struct hrtimer - * Separate the ->running assignment from the ->state assignment. - * - * As with a regular write barrier, this ensures the read side in -- * hrtimer_active() cannot observe cpu_base->running == NULL && -+ * hrtimer_active() cannot observe base->running.timer == NULL && - * timer->state == INACTIVE. - */ -- raw_write_seqcount_barrier(&cpu_base->seq); -+ raw_write_seqcount_barrier(&base->seq); - -- WARN_ON_ONCE(cpu_base->running != timer); -- cpu_base->running = NULL; -+ WARN_ON_ONCE(base->running != timer); -+ base->running = NULL; - } - - static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t now) diff --git a/debian/patches/features/all/rt/0011-tracing-Add-hist-trigger-timestamp-support.patch b/debian/patches/features/all/rt/0011-tracing-Add-hist-trigger-timestamp-support.patch deleted file mode 100644 index b65dc579a..000000000 --- a/debian/patches/features/all/rt/0011-tracing-Add-hist-trigger-timestamp-support.patch +++ /dev/null @@ -1,243 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:45 -0600 -Subject: [PATCH 11/37] tracing: Add hist trigger timestamp support -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Add support for a timestamp event field. This is actually a 'pseudo-' -event field in that it behaves like it's part of the event record, but -is really part of the corresponding ring buffer event. - -To make use of the timestamp field, users can specify -"common_timestamp" as a field name for any histogram. Note that this -doesn't make much sense on its own either as either a key or value, -but needs to be supported even so, since follow-on patches will add -support for making use of this field in time deltas. The -common_timestamp 'field' is not a bona fide event field - so you won't -find it in the event description - but rather it's a synthetic field -that can be used like a real field. - -Note that the use of this field requires the ring buffer be put into -'absolute timestamp' mode, which saves the complete timestamp for each -event rather than an offset. This mode will be enabled if and only if -a histogram makes use of the "common_timestamp" field. - -Signed-off-by: Tom Zanussi -Signed-off-by: Baohong Liu -[kasan use-after-free fix] -Signed-off-by: Vedang Patel -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 94 +++++++++++++++++++++++++++++---------- - 1 file changed, 71 insertions(+), 23 deletions(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -89,6 +89,12 @@ static u64 hist_field_log2(struct hist_f - return (u64) ilog2(roundup_pow_of_two(val)); - } - -+static u64 hist_field_timestamp(struct hist_field *hist_field, void *event, -+ struct ring_buffer_event *rbe) -+{ -+ return ring_buffer_event_time_stamp(rbe); -+} -+ - #define DEFINE_HIST_FIELD_FN(type) \ - static u64 hist_field_##type(struct hist_field *hist_field, \ - void *event, \ -@@ -135,6 +141,7 @@ enum hist_field_flags { - HIST_FIELD_FL_SYSCALL = 1 << 7, - HIST_FIELD_FL_STACKTRACE = 1 << 8, - HIST_FIELD_FL_LOG2 = 1 << 9, -+ HIST_FIELD_FL_TIMESTAMP = 1 << 10, - }; - - struct hist_trigger_attrs { -@@ -159,6 +166,7 @@ struct hist_trigger_data { - struct trace_event_file *event_file; - struct hist_trigger_attrs *attrs; - struct tracing_map *map; -+ bool enable_timestamps; - }; - - static const char *hist_field_name(struct hist_field *field, -@@ -173,6 +181,8 @@ static const char *hist_field_name(struc - field_name = field->field->name; - else if (field->flags & HIST_FIELD_FL_LOG2) - field_name = hist_field_name(field->operands[0], ++level); -+ else if (field->flags & HIST_FIELD_FL_TIMESTAMP) -+ field_name = "common_timestamp"; - - if (field_name == NULL) - field_name = ""; -@@ -440,6 +450,12 @@ static struct hist_field *create_hist_fi - goto out; - } - -+ if (flags & HIST_FIELD_FL_TIMESTAMP) { -+ hist_field->fn = hist_field_timestamp; -+ hist_field->size = sizeof(u64); -+ goto out; -+ } -+ - if (WARN_ON_ONCE(!field)) - goto out; - -@@ -517,10 +533,15 @@ static int create_val_field(struct hist_ - } - } - -- field = trace_find_event_field(file->event_call, field_name); -- if (!field || !field->size) { -- ret = -EINVAL; -- goto out; -+ if (strcmp(field_name, "common_timestamp") == 0) { -+ flags |= HIST_FIELD_FL_TIMESTAMP; -+ hist_data->enable_timestamps = true; -+ } else { -+ field = trace_find_event_field(file->event_call, field_name); -+ if (!field || !field->size) { -+ ret = -EINVAL; -+ goto out; -+ } - } - - hist_data->fields[val_idx] = create_hist_field(field, flags); -@@ -615,16 +636,22 @@ static int create_key_field(struct hist_ - } - } - -- field = trace_find_event_field(file->event_call, field_name); -- if (!field || !field->size) { -- ret = -EINVAL; -- goto out; -- } -+ if (strcmp(field_name, "common_timestamp") == 0) { -+ flags |= HIST_FIELD_FL_TIMESTAMP; -+ hist_data->enable_timestamps = true; -+ key_size = sizeof(u64); -+ } else { -+ field = trace_find_event_field(file->event_call, field_name); -+ if (!field || !field->size) { -+ ret = -EINVAL; -+ goto out; -+ } - -- if (is_string_field(field)) -- key_size = MAX_FILTER_STR_VAL; -- else -- key_size = field->size; -+ if (is_string_field(field)) -+ key_size = MAX_FILTER_STR_VAL; -+ else -+ key_size = field->size; -+ } - } - - hist_data->fields[key_idx] = create_hist_field(field, flags); -@@ -820,6 +847,9 @@ static int create_tracing_map_fields(str - - if (hist_field->flags & HIST_FIELD_FL_STACKTRACE) - cmp_fn = tracing_map_cmp_none; -+ else if (!field) -+ cmp_fn = tracing_map_cmp_num(hist_field->size, -+ hist_field->is_signed); - else if (is_string_field(field)) - cmp_fn = tracing_map_cmp_string; - else -@@ -1217,7 +1247,11 @@ static void hist_field_print(struct seq_ - { - const char *field_name = hist_field_name(hist_field, 0); - -- seq_printf(m, "%s", field_name); -+ if (hist_field->flags & HIST_FIELD_FL_TIMESTAMP) -+ seq_puts(m, "common_timestamp"); -+ else if (field_name) -+ seq_printf(m, "%s", field_name); -+ - if (hist_field->flags) { - const char *flags_str = get_hist_field_flags(hist_field); - -@@ -1268,27 +1302,25 @@ static int event_hist_trigger_print(stru - - for (i = 0; i < hist_data->n_sort_keys; i++) { - struct tracing_map_sort_key *sort_key; -+ unsigned int idx; - - sort_key = &hist_data->sort_keys[i]; -+ idx = sort_key->field_idx; -+ -+ if (WARN_ON(idx >= TRACING_MAP_FIELDS_MAX)) -+ return -EINVAL; - - if (i > 0) - seq_puts(m, ","); - -- if (sort_key->field_idx == HITCOUNT_IDX) -+ if (idx == HITCOUNT_IDX) - seq_puts(m, "hitcount"); -- else { -- unsigned int idx = sort_key->field_idx; -- -- if (WARN_ON(idx >= TRACING_MAP_FIELDS_MAX)) -- return -EINVAL; -- -+ else - hist_field_print(m, hist_data->fields[idx]); -- } - - if (sort_key->descending) - seq_puts(m, ".descending"); - } -- - seq_printf(m, ":size=%u", (1 << hist_data->map->map_bits)); - - if (data->filter_str) -@@ -1456,6 +1488,10 @@ static bool hist_trigger_match(struct ev - return false; - if (key_field->offset != key_field_test->offset) - return false; -+ if (key_field->size != key_field_test->size) -+ return false; -+ if (key_field->is_signed != key_field_test->is_signed) -+ return false; - } - - for (i = 0; i < hist_data->n_sort_keys; i++) { -@@ -1538,6 +1574,9 @@ static int hist_register_trigger(char *g - - update_cond_flag(file); - -+ if (hist_data->enable_timestamps) -+ tracing_set_time_stamp_abs(file->tr, true); -+ - if (trace_event_trigger_enable_disable(file, 1) < 0) { - list_del_rcu(&data->list); - update_cond_flag(file); -@@ -1572,17 +1611,26 @@ static void hist_unregister_trigger(char - - if (unregistered && test->ops->free) - test->ops->free(test->ops, test); -+ -+ if (hist_data->enable_timestamps) { -+ if (unregistered) -+ tracing_set_time_stamp_abs(file->tr, false); -+ } - } - - static void hist_unreg_all(struct trace_event_file *file) - { - struct event_trigger_data *test, *n; -+ struct hist_trigger_data *hist_data; - - list_for_each_entry_safe(test, n, &file->triggers, list) { - if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) { -+ hist_data = test->private_data; - list_del_rcu(&test->list); - trace_event_trigger_enable_disable(file, 0); - update_cond_flag(file); -+ if (hist_data->enable_timestamps) -+ tracing_set_time_stamp_abs(file->tr, false); - if (test->ops->free) - test->ops->free(test->ops, test); - } diff --git a/debian/patches/features/all/rt/0011-tracing-Add-support-to-detect-and-avoid-duplicates.patch b/debian/patches/features/all/rt/0011-tracing-Add-support-to-detect-and-avoid-duplicates.patch index ca6e3d8db..3c34776e3 100644 --- a/debian/patches/features/all/rt/0011-tracing-Add-support-to-detect-and-avoid-duplicates.patch +++ b/debian/patches/features/all/rt/0011-tracing-Add-support-to-detect-and-avoid-duplicates.patch @@ -1,7 +1,6 @@ From: Vedang Patel Date: Mon, 15 Jan 2018 20:51:37 -0600 Subject: [PATCH 11/48] tracing: Add support to detect and avoid duplicates -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz A duplicate in the tracing_map hash table is when 2 different entries have the same key and, as a result, the key_hash. This is possible due diff --git a/debian/patches/features/all/rt/0012-debugfs_lookup-switch-to-lookup_one_len_unlocked.patch b/debian/patches/features/all/rt/0012-debugfs_lookup-switch-to-lookup_one_len_unlocked.patch index 77eff120e..542412c22 100644 --- a/debian/patches/features/all/rt/0012-debugfs_lookup-switch-to-lookup_one_len_unlocked.patch +++ b/debian/patches/features/all/rt/0012-debugfs_lookup-switch-to-lookup_one_len_unlocked.patch @@ -1,7 +1,6 @@ From: Al Viro Date: Thu, 8 Mar 2018 11:01:22 -0500 Subject: [PATCH 12/17] debugfs_lookup(): switch to lookup_one_len_unlocked() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit cd1c0c9321999737073dcfc3364e194e02604bce diff --git a/debian/patches/features/all/rt/0012-hrtimer-Make-room-in-struct-hrtimer_cpu_base.patch b/debian/patches/features/all/rt/0012-hrtimer-Make-room-in-struct-hrtimer_cpu_base.patch deleted file mode 100644 index 9775bb987..000000000 --- a/debian/patches/features/all/rt/0012-hrtimer-Make-room-in-struct-hrtimer_cpu_base.patch +++ /dev/null @@ -1,34 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:13:01 +0100 -Subject: [PATCH 12/29] hrtimer: Make room in struct hrtimer_cpu_base -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The upcoming softirq based hrtimers support requires an additional field in -the hrtimer_cpu_base struct, which would grow the struct size beyond a -cache line. - -The struct members nr_retries and nr_hangs of hrtimer_cpu_base are solely -used for diagnostic output and have no requirement to be unsigned int. - -Make them unsigned short to create room for the new struct member. No -functional change. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - include/linux/hrtimer.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/include/linux/hrtimer.h -+++ b/include/linux/hrtimer.h -@@ -189,8 +189,8 @@ struct hrtimer_cpu_base { - ktime_t expires_next; - struct hrtimer *next_timer; - unsigned int nr_events; -- unsigned int nr_retries; -- unsigned int nr_hangs; -+ unsigned short nr_retries; -+ unsigned short nr_hangs; - unsigned int max_hang_time; - #endif - struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES]; diff --git a/debian/patches/features/all/rt/0012-tracing-Add-per-element-variable-support-to-tracing_.patch b/debian/patches/features/all/rt/0012-tracing-Add-per-element-variable-support-to-tracing_.patch deleted file mode 100644 index db9a735f4..000000000 --- a/debian/patches/features/all/rt/0012-tracing-Add-per-element-variable-support-to-tracing_.patch +++ /dev/null @@ -1,221 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:46 -0600 -Subject: [PATCH 12/37] tracing: Add per-element variable support to - tracing_map -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -In order to allow information to be passed between trace events, add -support for per-element variables to tracing_map. This provides a -means for histograms to associate a value or values with an entry when -it's saved or updated, and retrieved by a subsequent event occurrences. - -Variables can be set using tracing_map_set_var() and read using -tracing_map_read_var(). tracing_map_var_set() returns true or false -depending on whether or not the variable has been set or not, which is -important for event-matching applications. - -tracing_map_read_var_once() reads the variable and resets it to the -'unset' state, implementing read-once variables, which are also -important for event-matching uses. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/tracing_map.c | 108 +++++++++++++++++++++++++++++++++++++++++++++ - kernel/trace/tracing_map.h | 11 ++++ - 2 files changed, 119 insertions(+) - ---- a/kernel/trace/tracing_map.c -+++ b/kernel/trace/tracing_map.c -@@ -66,6 +66,73 @@ u64 tracing_map_read_sum(struct tracing_ - return (u64)atomic64_read(&elt->fields[i].sum); - } - -+/** -+ * tracing_map_set_var - Assign a tracing_map_elt's variable field -+ * @elt: The tracing_map_elt -+ * @i: The index of the given variable associated with the tracing_map_elt -+ * @n: The value to assign -+ * -+ * Assign n to variable i associated with the specified tracing_map_elt -+ * instance. The index i is the index returned by the call to -+ * tracing_map_add_var() when the tracing map was set up. -+ */ -+void tracing_map_set_var(struct tracing_map_elt *elt, unsigned int i, u64 n) -+{ -+ atomic64_set(&elt->vars[i], n); -+ elt->var_set[i] = true; -+} -+ -+/** -+ * tracing_map_var_set - Return whether or not a variable has been set -+ * @elt: The tracing_map_elt -+ * @i: The index of the given variable associated with the tracing_map_elt -+ * -+ * Return true if the variable has been set, false otherwise. The -+ * index i is the index returned by the call to tracing_map_add_var() -+ * when the tracing map was set up. -+ */ -+bool tracing_map_var_set(struct tracing_map_elt *elt, unsigned int i) -+{ -+ return elt->var_set[i]; -+} -+ -+/** -+ * tracing_map_read_var - Return the value of a tracing_map_elt's variable field -+ * @elt: The tracing_map_elt -+ * @i: The index of the given variable associated with the tracing_map_elt -+ * -+ * Retrieve the value of the variable i associated with the specified -+ * tracing_map_elt instance. The index i is the index returned by the -+ * call to tracing_map_add_var() when the tracing map was set -+ * up. -+ * -+ * Return: The variable value associated with field i for elt. -+ */ -+u64 tracing_map_read_var(struct tracing_map_elt *elt, unsigned int i) -+{ -+ return (u64)atomic64_read(&elt->vars[i]); -+} -+ -+/** -+ * tracing_map_read_var_once - Return and reset a tracing_map_elt's variable field -+ * @elt: The tracing_map_elt -+ * @i: The index of the given variable associated with the tracing_map_elt -+ * -+ * Retrieve the value of the variable i associated with the specified -+ * tracing_map_elt instance, and reset the variable to the 'not set' -+ * state. The index i is the index returned by the call to -+ * tracing_map_add_var() when the tracing map was set up. The reset -+ * essentially makes the variable a read-once variable if it's only -+ * accessed using this function. -+ * -+ * Return: The variable value associated with field i for elt. -+ */ -+u64 tracing_map_read_var_once(struct tracing_map_elt *elt, unsigned int i) -+{ -+ elt->var_set[i] = false; -+ return (u64)atomic64_read(&elt->vars[i]); -+} -+ - int tracing_map_cmp_string(void *val_a, void *val_b) - { - char *a = val_a; -@@ -171,6 +238,28 @@ int tracing_map_add_sum_field(struct tra - } - - /** -+ * tracing_map_add_var - Add a field describing a tracing_map var -+ * @map: The tracing_map -+ * -+ * Add a var to the map and return the index identifying it in the map -+ * and associated tracing_map_elts. This is the index used for -+ * instance to update a var for a particular tracing_map_elt using -+ * tracing_map_update_var() or reading it via tracing_map_read_var(). -+ * -+ * Return: The index identifying the var in the map and associated -+ * tracing_map_elts, or -EINVAL on error. -+ */ -+int tracing_map_add_var(struct tracing_map *map) -+{ -+ int ret = -EINVAL; -+ -+ if (map->n_vars < TRACING_MAP_VARS_MAX) -+ ret = map->n_vars++; -+ -+ return ret; -+} -+ -+/** - * tracing_map_add_key_field - Add a field describing a tracing_map key - * @map: The tracing_map - * @offset: The offset within the key -@@ -280,6 +369,11 @@ static void tracing_map_elt_clear(struct - if (elt->fields[i].cmp_fn == tracing_map_cmp_atomic64) - atomic64_set(&elt->fields[i].sum, 0); - -+ for (i = 0; i < elt->map->n_vars; i++) { -+ atomic64_set(&elt->vars[i], 0); -+ elt->var_set[i] = false; -+ } -+ - if (elt->map->ops && elt->map->ops->elt_clear) - elt->map->ops->elt_clear(elt); - } -@@ -306,6 +400,8 @@ static void tracing_map_elt_free(struct - if (elt->map->ops && elt->map->ops->elt_free) - elt->map->ops->elt_free(elt); - kfree(elt->fields); -+ kfree(elt->vars); -+ kfree(elt->var_set); - kfree(elt->key); - kfree(elt); - } -@@ -332,6 +428,18 @@ static struct tracing_map_elt *tracing_m - err = -ENOMEM; - goto free; - } -+ -+ elt->vars = kcalloc(map->n_vars, sizeof(*elt->vars), GFP_KERNEL); -+ if (!elt->vars) { -+ err = -ENOMEM; -+ goto free; -+ } -+ -+ elt->var_set = kcalloc(map->n_vars, sizeof(*elt->var_set), GFP_KERNEL); -+ if (!elt->var_set) { -+ err = -ENOMEM; -+ goto free; -+ } - - tracing_map_elt_init_fields(elt); - ---- a/kernel/trace/tracing_map.h -+++ b/kernel/trace/tracing_map.h -@@ -10,6 +10,7 @@ - #define TRACING_MAP_VALS_MAX 3 - #define TRACING_MAP_FIELDS_MAX (TRACING_MAP_KEYS_MAX + \ - TRACING_MAP_VALS_MAX) -+#define TRACING_MAP_VARS_MAX 16 - #define TRACING_MAP_SORT_KEYS_MAX 2 - - typedef int (*tracing_map_cmp_fn_t) (void *val_a, void *val_b); -@@ -137,6 +138,8 @@ struct tracing_map_field { - struct tracing_map_elt { - struct tracing_map *map; - struct tracing_map_field *fields; -+ atomic64_t *vars; -+ bool *var_set; - void *key; - void *private_data; - }; -@@ -192,6 +195,7 @@ struct tracing_map { - int key_idx[TRACING_MAP_KEYS_MAX]; - unsigned int n_keys; - struct tracing_map_sort_key sort_key; -+ unsigned int n_vars; - atomic64_t hits; - atomic64_t drops; - }; -@@ -241,6 +245,7 @@ tracing_map_create(unsigned int map_bits - extern int tracing_map_init(struct tracing_map *map); - - extern int tracing_map_add_sum_field(struct tracing_map *map); -+extern int tracing_map_add_var(struct tracing_map *map); - extern int tracing_map_add_key_field(struct tracing_map *map, - unsigned int offset, - tracing_map_cmp_fn_t cmp_fn); -@@ -260,7 +265,13 @@ extern int tracing_map_cmp_none(void *va - - extern void tracing_map_update_sum(struct tracing_map_elt *elt, - unsigned int i, u64 n); -+extern void tracing_map_set_var(struct tracing_map_elt *elt, -+ unsigned int i, u64 n); -+extern bool tracing_map_var_set(struct tracing_map_elt *elt, unsigned int i); - extern u64 tracing_map_read_sum(struct tracing_map_elt *elt, unsigned int i); -+extern u64 tracing_map_read_var(struct tracing_map_elt *elt, unsigned int i); -+extern u64 tracing_map_read_var_once(struct tracing_map_elt *elt, unsigned int i); -+ - extern void tracing_map_set_field_descr(struct tracing_map *map, - unsigned int i, - unsigned int key_offset, diff --git a/debian/patches/features/all/rt/0012-tracing-Remove-code-which-merges-duplicates.patch b/debian/patches/features/all/rt/0012-tracing-Remove-code-which-merges-duplicates.patch index 9e3b8a75e..e0e3da1ae 100644 --- a/debian/patches/features/all/rt/0012-tracing-Remove-code-which-merges-duplicates.patch +++ b/debian/patches/features/all/rt/0012-tracing-Remove-code-which-merges-duplicates.patch @@ -1,7 +1,6 @@ From: Vedang Patel Date: Mon, 15 Jan 2018 20:51:38 -0600 Subject: [PATCH 12/48] tracing: Remove code which merges duplicates -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz We now have the logic to detect and remove duplicates in the tracing_map hash table. The code which merges duplicates in the diff --git a/debian/patches/features/all/rt/0013-hrtimer-Reduce-conditional-code-hres_active.patch b/debian/patches/features/all/rt/0013-hrtimer-Reduce-conditional-code-hres_active.patch deleted file mode 100644 index cd46b76ea..000000000 --- a/debian/patches/features/all/rt/0013-hrtimer-Reduce-conditional-code-hres_active.patch +++ /dev/null @@ -1,150 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:13:02 +0100 -Subject: [PATCH 13/29] hrtimer: Reduce conditional code (hres_active) -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The hrtimer_cpu_base struct has the CONFIG_HIGH_RES_TIMERS conditional -struct member hres_active. All related functions to this member are -conditional as well. - -There is no functional change, when the hres_active member is -unconditional with all related functions and is set to zero during -initialization. - -The conditional code sections can be avoided by adding IS_ENABLED(HIGHRES) -conditionals into common functions, which ensures dead code elimination. - -Suggested-by: Thomas Gleixner -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - include/linux/hrtimer.h | 20 ++++++++------------ - kernel/time/hrtimer.c | 31 +++++++++++++++---------------- - 2 files changed, 23 insertions(+), 28 deletions(-) - ---- a/include/linux/hrtimer.h -+++ b/include/linux/hrtimer.h -@@ -161,8 +161,8 @@ enum hrtimer_base_type { - * @cpu: cpu number - * @active_bases: Bitfield to mark bases with active timers - * @clock_was_set_seq: Sequence counter of clock was set events -- * @in_hrtirq: hrtimer_interrupt() is currently executing - * @hres_active: State of high resolution mode -+ * @in_hrtirq: hrtimer_interrupt() is currently executing - * @hang_detected: The last hrtimer interrupt detected a hang - * @expires_next: absolute time of the next event, is required for remote - * hrtimer enqueue -@@ -182,9 +182,9 @@ struct hrtimer_cpu_base { - unsigned int cpu; - unsigned int active_bases; - unsigned int clock_was_set_seq; -+ unsigned int hres_active : 1; - #ifdef CONFIG_HIGH_RES_TIMERS - unsigned int in_hrtirq : 1, -- hres_active : 1, - hang_detected : 1; - ktime_t expires_next; - struct hrtimer *next_timer; -@@ -266,16 +266,17 @@ static inline ktime_t hrtimer_cb_get_tim - return timer->base->get_time(); - } - -+static inline int hrtimer_is_hres_active(struct hrtimer *timer) -+{ -+ return IS_ENABLED(CONFIG_HIGH_RES_TIMERS) ? -+ timer->base->cpu_base->hres_active : 0; -+} -+ - #ifdef CONFIG_HIGH_RES_TIMERS - struct clock_event_device; - - extern void hrtimer_interrupt(struct clock_event_device *dev); - --static inline int hrtimer_is_hres_active(struct hrtimer *timer) --{ -- return timer->base->cpu_base->hres_active; --} -- - /* - * The resolution of the clocks. The resolution value is returned in - * the clock_getres() system call to give application programmers an -@@ -298,11 +299,6 @@ extern unsigned int hrtimer_resolution; - - #define hrtimer_resolution (unsigned int)LOW_RES_NSEC - --static inline int hrtimer_is_hres_active(struct hrtimer *timer) --{ -- return 0; --} -- - static inline void clock_was_set_delayed(void) { } - - #endif ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -512,6 +512,20 @@ static inline ktime_t hrtimer_update_bas - offs_real, offs_boot, offs_tai); - } - -+/* -+ * Is the high resolution mode active ? -+ */ -+static inline int __hrtimer_hres_active(struct hrtimer_cpu_base *cpu_base) -+{ -+ return IS_ENABLED(CONFIG_HIGH_RES_TIMERS) ? -+ cpu_base->hres_active : 0; -+} -+ -+static inline int hrtimer_hres_active(void) -+{ -+ return __hrtimer_hres_active(this_cpu_ptr(&hrtimer_bases)); -+} -+ - /* High resolution timer related functions */ - #ifdef CONFIG_HIGH_RES_TIMERS - -@@ -541,19 +555,6 @@ static inline int hrtimer_is_hres_enable - } - - /* -- * Is the high resolution mode active ? -- */ --static inline int __hrtimer_hres_active(struct hrtimer_cpu_base *cpu_base) --{ -- return cpu_base->hres_active; --} -- --static inline int hrtimer_hres_active(void) --{ -- return __hrtimer_hres_active(this_cpu_ptr(&hrtimer_bases)); --} -- --/* - * Reprogram the event source with checking both queues for the - * next event - * Called with interrupts disabled and base->lock held -@@ -662,7 +663,6 @@ static inline void hrtimer_init_hres(str - { - base->expires_next = KTIME_MAX; - base->hang_detected = 0; -- base->hres_active = 0; - base->next_timer = NULL; - } - -@@ -722,8 +722,6 @@ void clock_was_set_delayed(void) - - #else - --static inline int __hrtimer_hres_active(struct hrtimer_cpu_base *b) { return 0; } --static inline int hrtimer_hres_active(void) { return 0; } - static inline int hrtimer_is_hres_enabled(void) { return 0; } - static inline void hrtimer_switch_to_hres(void) { } - static inline void -@@ -1605,6 +1603,7 @@ int hrtimers_prepare_cpu(unsigned int cp - - cpu_base->active_bases = 0; - cpu_base->cpu = cpu; -+ cpu_base->hres_active = 0; - hrtimer_init_hres(cpu_base); - return 0; - } diff --git a/debian/patches/features/all/rt/0013-lustre-get-rid-of-pointless-casts-to-struct-dentry.patch b/debian/patches/features/all/rt/0013-lustre-get-rid-of-pointless-casts-to-struct-dentry.patch index cee7ab2ee..ee995636a 100644 --- a/debian/patches/features/all/rt/0013-lustre-get-rid-of-pointless-casts-to-struct-dentry.patch +++ b/debian/patches/features/all/rt/0013-lustre-get-rid-of-pointless-casts-to-struct-dentry.patch @@ -1,7 +1,6 @@ From: Al Viro Date: Fri, 9 Mar 2018 18:06:03 -0500 Subject: [PATCH 13/17] lustre: get rid of pointless casts to struct dentry * -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 5bf1ddf7ee0e23598a620ef9ea2b0f00e804859d diff --git a/debian/patches/features/all/rt/0013-ring-buffer-Add-interface-for-setting-absolute-time-.patch b/debian/patches/features/all/rt/0013-ring-buffer-Add-interface-for-setting-absolute-time-.patch index 33cf200df..c81c6d08b 100644 --- a/debian/patches/features/all/rt/0013-ring-buffer-Add-interface-for-setting-absolute-time-.patch +++ b/debian/patches/features/all/rt/0013-ring-buffer-Add-interface-for-setting-absolute-time-.patch @@ -2,7 +2,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:39 -0600 Subject: [PATCH 13/48] ring-buffer: Add interface for setting absolute time stamps -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Define a new function, tracing_set_time_stamp_abs(), which can be used to enable or disable the use of absolute timestamps rather than time diff --git a/debian/patches/features/all/rt/0013-tracing-Add-hist_data-member-to-hist_field.patch b/debian/patches/features/all/rt/0013-tracing-Add-hist_data-member-to-hist_field.patch deleted file mode 100644 index 97bcb14f0..000000000 --- a/debian/patches/features/all/rt/0013-tracing-Add-hist_data-member-to-hist_field.patch +++ /dev/null @@ -1,79 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:47 -0600 -Subject: [PATCH 13/37] tracing: Add hist_data member to hist_field -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Allow hist_data access via hist_field. Some users of hist_fields -require or will require more access to the associated hist_data. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 14 +++++++++----- - 1 file changed, 9 insertions(+), 5 deletions(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -39,6 +39,7 @@ struct hist_field { - unsigned int offset; - unsigned int is_signed; - struct hist_field *operands[HIST_FIELD_OPERANDS_MAX]; -+ struct hist_trigger_data *hist_data; - }; - - static u64 hist_field_none(struct hist_field *field, void *event, -@@ -420,7 +421,8 @@ static void destroy_hist_field(struct hi - kfree(hist_field); - } - --static struct hist_field *create_hist_field(struct ftrace_event_field *field, -+static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data, -+ struct ftrace_event_field *field, - unsigned long flags) - { - struct hist_field *hist_field; -@@ -432,6 +434,8 @@ static struct hist_field *create_hist_fi - if (!hist_field) - return NULL; - -+ hist_field->hist_data = hist_data; -+ - if (flags & HIST_FIELD_FL_HITCOUNT) { - hist_field->fn = hist_field_counter; - goto out; -@@ -445,7 +449,7 @@ static struct hist_field *create_hist_fi - if (flags & HIST_FIELD_FL_LOG2) { - unsigned long fl = flags & ~HIST_FIELD_FL_LOG2; - hist_field->fn = hist_field_log2; -- hist_field->operands[0] = create_hist_field(field, fl); -+ hist_field->operands[0] = create_hist_field(hist_data, field, fl); - hist_field->size = hist_field->operands[0]->size; - goto out; - } -@@ -498,7 +502,7 @@ static void destroy_hist_fields(struct h - static int create_hitcount_val(struct hist_trigger_data *hist_data) - { - hist_data->fields[HITCOUNT_IDX] = -- create_hist_field(NULL, HIST_FIELD_FL_HITCOUNT); -+ create_hist_field(hist_data, NULL, HIST_FIELD_FL_HITCOUNT); - if (!hist_data->fields[HITCOUNT_IDX]) - return -ENOMEM; - -@@ -544,7 +548,7 @@ static int create_val_field(struct hist_ - } - } - -- hist_data->fields[val_idx] = create_hist_field(field, flags); -+ hist_data->fields[val_idx] = create_hist_field(hist_data, field, flags); - if (!hist_data->fields[val_idx]) { - ret = -ENOMEM; - goto out; -@@ -654,7 +658,7 @@ static int create_key_field(struct hist_ - } - } - -- hist_data->fields[key_idx] = create_hist_field(field, flags); -+ hist_data->fields[key_idx] = create_hist_field(hist_data, field, flags); - if (!hist_data->fields[key_idx]) { - ret = -ENOMEM; - goto out; diff --git a/debian/patches/features/all/rt/0014-hrtimer-Use-accesor-functions-instead-of-direct-acce.patch b/debian/patches/features/all/rt/0014-hrtimer-Use-accesor-functions-instead-of-direct-acce.patch deleted file mode 100644 index def0e9e32..000000000 --- a/debian/patches/features/all/rt/0014-hrtimer-Use-accesor-functions-instead-of-direct-acce.patch +++ /dev/null @@ -1,36 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:13:03 +0100 -Subject: [PATCH 14/29] hrtimer: Use accesor functions instead of direct access -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -__hrtimer_hres_active() is now available unconditionally. Replace the -direct access to hrtimer_cpu_base.hres_active. - -No functional change. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/time/hrtimer.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -564,7 +564,7 @@ hrtimer_force_reprogram(struct hrtimer_c - { - ktime_t expires_next; - -- if (!cpu_base->hres_active) -+ if (!__hrtimer_hres_active(cpu_base)) - return; - - expires_next = __hrtimer_get_next_event(cpu_base); -@@ -673,7 +673,7 @@ static void retrigger_next_event(void *a - { - struct hrtimer_cpu_base *base = this_cpu_ptr(&hrtimer_bases); - -- if (!base->hres_active) -+ if (!__hrtimer_hres_active(base)) - return; - - raw_spin_lock(&base->lock); diff --git a/debian/patches/features/all/rt/0014-oprofilefs-don-t-oops-on-allocation-failure.patch b/debian/patches/features/all/rt/0014-oprofilefs-don-t-oops-on-allocation-failure.patch index 968eb3971..b36df0e9b 100644 --- a/debian/patches/features/all/rt/0014-oprofilefs-don-t-oops-on-allocation-failure.patch +++ b/debian/patches/features/all/rt/0014-oprofilefs-don-t-oops-on-allocation-failure.patch @@ -1,7 +1,6 @@ From: Al Viro Date: Sat, 10 Mar 2018 16:40:33 -0500 Subject: [PATCH 14/17] oprofilefs: don't oops on allocation failure -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit a7498968338da9b928f5d8054acc8be6ed2bc14c diff --git a/debian/patches/features/all/rt/0014-ring-buffer-Redefine-the-unimplemented-RINGBUF_TYPE_.patch b/debian/patches/features/all/rt/0014-ring-buffer-Redefine-the-unimplemented-RINGBUF_TYPE_.patch index 2ddb547c4..5b2b78668 100644 --- a/debian/patches/features/all/rt/0014-ring-buffer-Redefine-the-unimplemented-RINGBUF_TYPE_.patch +++ b/debian/patches/features/all/rt/0014-ring-buffer-Redefine-the-unimplemented-RINGBUF_TYPE_.patch @@ -2,7 +2,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:40 -0600 Subject: [PATCH 14/48] ring-buffer: Redefine the unimplemented RINGBUF_TYPE_TIME_STAMP -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz RINGBUF_TYPE_TIME_STAMP is defined but not used, and from what I can gather was reserved for something like an absolute timestamp feature diff --git a/debian/patches/features/all/rt/0014-tracing-Add-usecs-modifier-for-hist-trigger-timestam.patch b/debian/patches/features/all/rt/0014-tracing-Add-usecs-modifier-for-hist-trigger-timestam.patch deleted file mode 100644 index b2a59557a..000000000 --- a/debian/patches/features/all/rt/0014-tracing-Add-usecs-modifier-for-hist-trigger-timestam.patch +++ /dev/null @@ -1,154 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:48 -0600 -Subject: [PATCH 14/37] tracing: Add usecs modifier for hist trigger timestamps -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Appending .usecs onto a common_timestamp field will cause the -timestamp value to be in microseconds instead of the default -nanoseconds. A typical latency histogram using usecs would look like -this: - - # echo 'hist:keys=pid,prio:ts0=common_timestamp.usecs ... - # echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0 ... - -This also adds an external trace_clock_in_ns() to trace.c for the -timestamp conversion. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - Documentation/trace/histogram.txt | 1 + - kernel/trace/trace.c | 13 +++++++++++-- - kernel/trace/trace.h | 2 ++ - kernel/trace/trace_events_hist.c | 28 ++++++++++++++++++++++------ - 4 files changed, 36 insertions(+), 8 deletions(-) - ---- a/Documentation/trace/histogram.txt -+++ b/Documentation/trace/histogram.txt -@@ -74,6 +74,7 @@ - .syscall display a syscall id as a system call name - .execname display a common_pid as a program name - .log2 display log2 value rather than raw number -+ .usecs display a common_timestamp in microseconds - - Note that in general the semantics of a given field aren't - interpreted when applying a modifier to it, but there are some ---- a/kernel/trace/trace.c -+++ b/kernel/trace/trace.c -@@ -1170,6 +1170,14 @@ static struct { - ARCH_TRACE_CLOCKS - }; - -+bool trace_clock_in_ns(struct trace_array *tr) -+{ -+ if (trace_clocks[tr->clock_id].in_ns) -+ return true; -+ -+ return false; -+} -+ - /* - * trace_parser_get_init - gets the buffer for trace parser - */ -@@ -4699,8 +4707,9 @@ static const char readme_msg[] = - "\t .sym display an address as a symbol\n" - "\t .sym-offset display an address as a symbol and offset\n" - "\t .execname display a common_pid as a program name\n" -- "\t .syscall display a syscall id as a syscall name\n\n" -- "\t .log2 display log2 value rather than raw number\n\n" -+ "\t .syscall display a syscall id as a syscall name\n" -+ "\t .log2 display log2 value rather than raw number\n" -+ "\t .usecs display a common_timestamp in microseconds\n\n" - "\t The 'pause' parameter can be used to pause an existing hist\n" - "\t trigger or to start a hist trigger but not log any events\n" - "\t until told to do so. 'continue' can be used to start or\n" ---- a/kernel/trace/trace.h -+++ b/kernel/trace/trace.h -@@ -289,6 +289,8 @@ extern void trace_array_put(struct trace - - extern int tracing_set_time_stamp_abs(struct trace_array *tr, bool abs); - -+extern bool trace_clock_in_ns(struct trace_array *tr); -+ - /* - * The global tracer (top) should be the first trace array added, - * but we check the flag anyway. ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -90,12 +90,6 @@ static u64 hist_field_log2(struct hist_f - return (u64) ilog2(roundup_pow_of_two(val)); - } - --static u64 hist_field_timestamp(struct hist_field *hist_field, void *event, -- struct ring_buffer_event *rbe) --{ -- return ring_buffer_event_time_stamp(rbe); --} -- - #define DEFINE_HIST_FIELD_FN(type) \ - static u64 hist_field_##type(struct hist_field *hist_field, \ - void *event, \ -@@ -143,6 +137,7 @@ enum hist_field_flags { - HIST_FIELD_FL_STACKTRACE = 1 << 8, - HIST_FIELD_FL_LOG2 = 1 << 9, - HIST_FIELD_FL_TIMESTAMP = 1 << 10, -+ HIST_FIELD_FL_TIMESTAMP_USECS = 1 << 11, - }; - - struct hist_trigger_attrs { -@@ -153,6 +148,7 @@ struct hist_trigger_attrs { - bool pause; - bool cont; - bool clear; -+ bool ts_in_usecs; - unsigned int map_bits; - }; - -@@ -170,6 +166,20 @@ struct hist_trigger_data { - bool enable_timestamps; - }; - -+static u64 hist_field_timestamp(struct hist_field *hist_field, void *event, -+ struct ring_buffer_event *rbe) -+{ -+ struct hist_trigger_data *hist_data = hist_field->hist_data; -+ struct trace_array *tr = hist_data->event_file->tr; -+ -+ u64 ts = ring_buffer_event_time_stamp(rbe); -+ -+ if (hist_data->attrs->ts_in_usecs && trace_clock_in_ns(tr)) -+ ts = ns2usecs(ts); -+ -+ return ts; -+} -+ - static const char *hist_field_name(struct hist_field *field, - unsigned int level) - { -@@ -634,6 +644,8 @@ static int create_key_field(struct hist_ - flags |= HIST_FIELD_FL_SYSCALL; - else if (strcmp(field_str, "log2") == 0) - flags |= HIST_FIELD_FL_LOG2; -+ else if (strcmp(field_str, "usecs") == 0) -+ flags |= HIST_FIELD_FL_TIMESTAMP_USECS; - else { - ret = -EINVAL; - goto out; -@@ -643,6 +655,8 @@ static int create_key_field(struct hist_ - if (strcmp(field_name, "common_timestamp") == 0) { - flags |= HIST_FIELD_FL_TIMESTAMP; - hist_data->enable_timestamps = true; -+ if (flags & HIST_FIELD_FL_TIMESTAMP_USECS) -+ hist_data->attrs->ts_in_usecs = true; - key_size = sizeof(u64); - } else { - field = trace_find_event_field(file->event_call, field_name); -@@ -1243,6 +1257,8 @@ static const char *get_hist_field_flags( - flags_str = "syscall"; - else if (hist_field->flags & HIST_FIELD_FL_LOG2) - flags_str = "log2"; -+ else if (hist_field->flags & HIST_FIELD_FL_TIMESTAMP_USECS) -+ flags_str = "usecs"; - - return flags_str; - } diff --git a/debian/patches/features/all/rt/0015-hrtimer-Make-the-remote-enqueue-check-unconditional.patch b/debian/patches/features/all/rt/0015-hrtimer-Make-the-remote-enqueue-check-unconditional.patch deleted file mode 100644 index 05e8e61c6..000000000 --- a/debian/patches/features/all/rt/0015-hrtimer-Make-the-remote-enqueue-check-unconditional.patch +++ /dev/null @@ -1,131 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:13:04 +0100 -Subject: [PATCH 15/29] hrtimer: Make the remote enqueue check unconditional -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -hrtimer_cpu_base.expires_next is used to cache the next event armed in the -timer hardware. The value is used to check whether an hrtimer can be -enqueued remotely. If the new hrtimer is expiring before expires_next, then -remote enqueue is not possible as the remote hrtimer hardware cannot be -accessed for reprogramming to an earlier expiry time. - -The remote enqueue check is currently conditional on -CONFIG_HIGH_RES_TIMERS=y and hrtimer_cpu_base.hres_active. There is no -compelling reason to make this conditional. - -Move hrtimer_cpu_base.expires_next out of the CONFIG_HIGH_RES_TIMERS=y -guarded area and remove the conditionals in hrtimer_check_target(). - -The check is currently a NOOP for the CONFIG_HIGH_RES_TIMERS=n and the -!hrtimer_cpu_base.hres_active case because in these cases nothing updates -hrtimer_cpu_base.expires_next yet. This will be changed with later patches -which further reduce the #ifdef zoo in this code. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - include/linux/hrtimer.h | 6 +++--- - kernel/time/hrtimer.c | 26 ++++++-------------------- - 2 files changed, 9 insertions(+), 23 deletions(-) - ---- a/include/linux/hrtimer.h -+++ b/include/linux/hrtimer.h -@@ -164,13 +164,13 @@ enum hrtimer_base_type { - * @hres_active: State of high resolution mode - * @in_hrtirq: hrtimer_interrupt() is currently executing - * @hang_detected: The last hrtimer interrupt detected a hang -- * @expires_next: absolute time of the next event, is required for remote -- * hrtimer enqueue - * @next_timer: Pointer to the first expiring timer - * @nr_events: Total number of hrtimer interrupt events - * @nr_retries: Total number of hrtimer interrupt retries - * @nr_hangs: Total number of hrtimer interrupt hangs - * @max_hang_time: Maximum time spent in hrtimer_interrupt -+ * @expires_next: absolute time of the next event, is required for remote -+ * hrtimer enqueue - * @clock_base: array of clock bases for this cpu - * - * Note: next_timer is just an optimization for __remove_hrtimer(). -@@ -186,13 +186,13 @@ struct hrtimer_cpu_base { - #ifdef CONFIG_HIGH_RES_TIMERS - unsigned int in_hrtirq : 1, - hang_detected : 1; -- ktime_t expires_next; - struct hrtimer *next_timer; - unsigned int nr_events; - unsigned short nr_retries; - unsigned short nr_hangs; - unsigned int max_hang_time; - #endif -+ ktime_t expires_next; - struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES]; - } ____cacheline_aligned; - ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -154,26 +154,21 @@ struct hrtimer_clock_base *lock_hrtimer_ - } - - /* -- * With HIGHRES=y we do not migrate the timer when it is expiring -- * before the next event on the target cpu because we cannot reprogram -- * the target cpu hardware and we would cause it to fire late. -+ * We do not migrate the timer when it is expiring before the next -+ * event on the target cpu. When high resolution is enabled, we cannot -+ * reprogram the target cpu hardware and we would cause it to fire -+ * late. To keep it simple, we handle the high resolution enabled and -+ * disabled case similar. - * - * Called with cpu_base->lock of target cpu held. - */ - static int - hrtimer_check_target(struct hrtimer *timer, struct hrtimer_clock_base *new_base) - { --#ifdef CONFIG_HIGH_RES_TIMERS - ktime_t expires; - -- if (!new_base->cpu_base->hres_active) -- return 0; -- - expires = ktime_sub(hrtimer_get_expires(timer), new_base->offset); - return expires <= new_base->cpu_base->expires_next; --#else -- return 0; --#endif - } - - static inline -@@ -657,16 +652,6 @@ static void hrtimer_reprogram(struct hrt - } - - /* -- * Initialize the high resolution related parts of cpu_base -- */ --static inline void hrtimer_init_hres(struct hrtimer_cpu_base *base) --{ -- base->expires_next = KTIME_MAX; -- base->hang_detected = 0; -- base->next_timer = NULL; --} -- --/* - * Retrigger next event is called after clock was set - * - * Called with interrupts disabled via on_each_cpu() -@@ -731,7 +716,6 @@ static inline int hrtimer_reprogram(stru - { - return 0; - } --static inline void hrtimer_init_hres(struct hrtimer_cpu_base *base) { } - static inline void retrigger_next_event(void *arg) { } - - #endif /* CONFIG_HIGH_RES_TIMERS */ -@@ -1604,7 +1588,7 @@ int hrtimers_prepare_cpu(unsigned int cp - cpu_base->active_bases = 0; - cpu_base->cpu = cpu; - cpu_base->hres_active = 0; -- hrtimer_init_hres(cpu_base); -+ cpu_base->expires_next = KTIME_MAX; - return 0; - } - diff --git a/debian/patches/features/all/rt/0015-make-non-exchanging-__d_move-copy-d_parent-rather-th.patch b/debian/patches/features/all/rt/0015-make-non-exchanging-__d_move-copy-d_parent-rather-th.patch index 8b27168d8..47fa71347 100644 --- a/debian/patches/features/all/rt/0015-make-non-exchanging-__d_move-copy-d_parent-rather-th.patch +++ b/debian/patches/features/all/rt/0015-make-non-exchanging-__d_move-copy-d_parent-rather-th.patch @@ -2,7 +2,6 @@ From: Al Viro Date: Sat, 10 Mar 2018 23:15:52 -0500 Subject: [PATCH 15/17] make non-exchanging __d_move() copy ->d_parent rather than swap them -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 076515fc926793e162fc6525bed1679ef2bbf269 diff --git a/debian/patches/features/all/rt/0015-tracing-Add-timestamp_mode-trace-file.patch b/debian/patches/features/all/rt/0015-tracing-Add-timestamp_mode-trace-file.patch index a40a90582..d748a5716 100644 --- a/debian/patches/features/all/rt/0015-tracing-Add-timestamp_mode-trace-file.patch +++ b/debian/patches/features/all/rt/0015-tracing-Add-timestamp_mode-trace-file.patch @@ -1,7 +1,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:41 -0600 Subject: [PATCH 15/48] tracing: Add timestamp_mode trace file -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Add a new option flag indicating whether or not the ring buffer is in 'absolute timestamp' mode. diff --git a/debian/patches/features/all/rt/0015-tracing-Add-variable-support-to-hist-triggers.patch b/debian/patches/features/all/rt/0015-tracing-Add-variable-support-to-hist-triggers.patch deleted file mode 100644 index 9d342be63..000000000 --- a/debian/patches/features/all/rt/0015-tracing-Add-variable-support-to-hist-triggers.patch +++ /dev/null @@ -1,779 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:49 -0600 -Subject: [PATCH 15/37] tracing: Add variable support to hist triggers -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Add support for saving the value of a current event's event field by -assigning it to a variable that can be read by a subsequent event. - -The basic syntax for saving a variable is to simply prefix a unique -variable name not corresponding to any keyword along with an '=' sign -to any event field. - -Both keys and values can be saved and retrieved in this way: - - # echo 'hist:keys=next_pid:vals=$ts0:ts0=common_timestamp ... - # echo 'hist:timer_pid=common_pid:key=$timer_pid ...' - -If a variable isn't a key variable or prefixed with 'vals=', the -associated event field will be saved in a variable but won't be summed -as a value: - - # echo 'hist:keys=next_pid:ts1=common_timestamp:... - -Multiple variables can be assigned at the same time: - - # echo 'hist:keys=pid:vals=$ts0,$b,field2:ts0=common_timestamp,b=field1 ... - -Multiple (or single) variables can also be assigned at the same time -using separate assignments: - - # echo 'hist:keys=pid:vals=$ts0:ts0=common_timestamp:b=field1:c=field2 ... - -Variables set as above can be used by being referenced from another -event, as described in a subsequent patch. - -Signed-off-by: Tom Zanussi -Signed-off-by: Baohong Liu -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 370 ++++++++++++++++++++++++++++++++++----- - 1 file changed, 331 insertions(+), 39 deletions(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -30,6 +30,13 @@ typedef u64 (*hist_field_fn_t) (struct h - struct ring_buffer_event *rbe); - - #define HIST_FIELD_OPERANDS_MAX 2 -+#define HIST_FIELDS_MAX (TRACING_MAP_FIELDS_MAX + TRACING_MAP_VARS_MAX) -+ -+struct hist_var { -+ char *name; -+ struct hist_trigger_data *hist_data; -+ unsigned int idx; -+}; - - struct hist_field { - struct ftrace_event_field *field; -@@ -40,6 +47,7 @@ struct hist_field { - unsigned int is_signed; - struct hist_field *operands[HIST_FIELD_OPERANDS_MAX]; - struct hist_trigger_data *hist_data; -+ struct hist_var var; - }; - - static u64 hist_field_none(struct hist_field *field, void *event, -@@ -138,6 +146,13 @@ enum hist_field_flags { - HIST_FIELD_FL_LOG2 = 1 << 9, - HIST_FIELD_FL_TIMESTAMP = 1 << 10, - HIST_FIELD_FL_TIMESTAMP_USECS = 1 << 11, -+ HIST_FIELD_FL_VAR = 1 << 12, -+}; -+ -+struct var_defs { -+ unsigned int n_vars; -+ char *name[TRACING_MAP_VARS_MAX]; -+ char *expr[TRACING_MAP_VARS_MAX]; - }; - - struct hist_trigger_attrs { -@@ -150,13 +165,19 @@ struct hist_trigger_attrs { - bool clear; - bool ts_in_usecs; - unsigned int map_bits; -+ -+ char *assignment_str[TRACING_MAP_VARS_MAX]; -+ unsigned int n_assignments; -+ -+ struct var_defs var_defs; - }; - - struct hist_trigger_data { -- struct hist_field *fields[TRACING_MAP_FIELDS_MAX]; -+ struct hist_field *fields[HIST_FIELDS_MAX]; - unsigned int n_vals; - unsigned int n_keys; - unsigned int n_fields; -+ unsigned int n_vars; - unsigned int key_size; - struct tracing_map_sort_key sort_keys[TRACING_MAP_SORT_KEYS_MAX]; - unsigned int n_sort_keys; -@@ -164,6 +185,7 @@ struct hist_trigger_data { - struct hist_trigger_attrs *attrs; - struct tracing_map *map; - bool enable_timestamps; -+ bool remove; - }; - - static u64 hist_field_timestamp(struct hist_field *hist_field, void *event, -@@ -180,6 +202,48 @@ static u64 hist_field_timestamp(struct h - return ts; - } - -+static struct hist_field *find_var_field(struct hist_trigger_data *hist_data, -+ const char *var_name) -+{ -+ struct hist_field *hist_field, *found = NULL; -+ int i; -+ -+ for_each_hist_field(i, hist_data) { -+ hist_field = hist_data->fields[i]; -+ if (hist_field && hist_field->flags & HIST_FIELD_FL_VAR && -+ strcmp(hist_field->var.name, var_name) == 0) { -+ found = hist_field; -+ break; -+ } -+ } -+ -+ return found; -+} -+ -+static struct hist_field *find_var(struct hist_trigger_data *hist_data, -+ struct trace_event_file *file, -+ const char *var_name) -+{ -+ struct hist_trigger_data *test_data; -+ struct event_trigger_data *test; -+ struct hist_field *hist_field; -+ -+ hist_field = find_var_field(hist_data, var_name); -+ if (hist_field) -+ return hist_field; -+ -+ list_for_each_entry_rcu(test, &file->triggers, list) { -+ if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) { -+ test_data = test->private_data; -+ hist_field = find_var_field(test_data, var_name); -+ if (hist_field) -+ return hist_field; -+ } -+ } -+ -+ return NULL; -+} -+ - static const char *hist_field_name(struct hist_field *field, - unsigned int level) - { -@@ -262,9 +326,14 @@ static int parse_map_size(char *str) - - static void destroy_hist_trigger_attrs(struct hist_trigger_attrs *attrs) - { -+ unsigned int i; -+ - if (!attrs) - return; - -+ for (i = 0; i < attrs->n_assignments; i++) -+ kfree(attrs->assignment_str[i]); -+ - kfree(attrs->name); - kfree(attrs->sort_key_str); - kfree(attrs->keys_str); -@@ -311,8 +380,22 @@ static int parse_assignment(char *str, s - goto out; - } - attrs->map_bits = map_bits; -- } else -- ret = -EINVAL; -+ } else { -+ char *assignment; -+ -+ if (attrs->n_assignments == TRACING_MAP_VARS_MAX) { -+ ret = -EINVAL; -+ goto out; -+ } -+ -+ assignment = kstrdup(str, GFP_KERNEL); -+ if (!assignment) { -+ ret = -ENOMEM; -+ goto out; -+ } -+ -+ attrs->assignment_str[attrs->n_assignments++] = assignment; -+ } - out: - return ret; - } -@@ -428,12 +511,15 @@ static void destroy_hist_field(struct hi - for (i = 0; i < HIST_FIELD_OPERANDS_MAX; i++) - destroy_hist_field(hist_field->operands[i], level + 1); - -+ kfree(hist_field->var.name); -+ - kfree(hist_field); - } - - static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data, - struct ftrace_event_field *field, -- unsigned long flags) -+ unsigned long flags, -+ char *var_name) - { - struct hist_field *hist_field; - -@@ -459,7 +545,7 @@ static struct hist_field *create_hist_fi - if (flags & HIST_FIELD_FL_LOG2) { - unsigned long fl = flags & ~HIST_FIELD_FL_LOG2; - hist_field->fn = hist_field_log2; -- hist_field->operands[0] = create_hist_field(hist_data, field, fl); -+ hist_field->operands[0] = create_hist_field(hist_data, field, fl, NULL); - hist_field->size = hist_field->operands[0]->size; - goto out; - } -@@ -494,14 +580,23 @@ static struct hist_field *create_hist_fi - hist_field->field = field; - hist_field->flags = flags; - -+ if (var_name) { -+ hist_field->var.name = kstrdup(var_name, GFP_KERNEL); -+ if (!hist_field->var.name) -+ goto free; -+ } -+ - return hist_field; -+ free: -+ destroy_hist_field(hist_field, 0); -+ return NULL; - } - - static void destroy_hist_fields(struct hist_trigger_data *hist_data) - { - unsigned int i; - -- for (i = 0; i < TRACING_MAP_FIELDS_MAX; i++) { -+ for (i = 0; i < HIST_FIELDS_MAX; i++) { - if (hist_data->fields[i]) { - destroy_hist_field(hist_data->fields[i], 0); - hist_data->fields[i] = NULL; -@@ -512,11 +607,12 @@ static void destroy_hist_fields(struct h - static int create_hitcount_val(struct hist_trigger_data *hist_data) - { - hist_data->fields[HITCOUNT_IDX] = -- create_hist_field(hist_data, NULL, HIST_FIELD_FL_HITCOUNT); -+ create_hist_field(hist_data, NULL, HIST_FIELD_FL_HITCOUNT, NULL); - if (!hist_data->fields[HITCOUNT_IDX]) - return -ENOMEM; - - hist_data->n_vals++; -+ hist_data->n_fields++; - - if (WARN_ON(hist_data->n_vals > TRACING_MAP_VALS_MAX)) - return -EINVAL; -@@ -524,19 +620,16 @@ static int create_hitcount_val(struct hi - return 0; - } - --static int create_val_field(struct hist_trigger_data *hist_data, -- unsigned int val_idx, -- struct trace_event_file *file, -- char *field_str) -+static int __create_val_field(struct hist_trigger_data *hist_data, -+ unsigned int val_idx, -+ struct trace_event_file *file, -+ char *var_name, char *field_str, -+ unsigned long flags) - { - struct ftrace_event_field *field = NULL; -- unsigned long flags = 0; - char *field_name; - int ret = 0; - -- if (WARN_ON(val_idx >= TRACING_MAP_VALS_MAX)) -- return -EINVAL; -- - field_name = strsep(&field_str, "."); - if (field_str) { - if (strcmp(field_str, "hex") == 0) -@@ -558,25 +651,58 @@ static int create_val_field(struct hist_ - } - } - -- hist_data->fields[val_idx] = create_hist_field(hist_data, field, flags); -+ hist_data->fields[val_idx] = create_hist_field(hist_data, field, flags, var_name); - if (!hist_data->fields[val_idx]) { - ret = -ENOMEM; - goto out; - } - - ++hist_data->n_vals; -+ ++hist_data->n_fields; - -- if (WARN_ON(hist_data->n_vals > TRACING_MAP_VALS_MAX)) -+ if (WARN_ON(hist_data->n_vals > TRACING_MAP_VALS_MAX + TRACING_MAP_VARS_MAX)) - ret = -EINVAL; - out: - return ret; - } - -+static int create_val_field(struct hist_trigger_data *hist_data, -+ unsigned int val_idx, -+ struct trace_event_file *file, -+ char *field_str) -+{ -+ if (WARN_ON(val_idx >= TRACING_MAP_VALS_MAX)) -+ return -EINVAL; -+ -+ return __create_val_field(hist_data, val_idx, file, NULL, field_str, 0); -+} -+ -+static int create_var_field(struct hist_trigger_data *hist_data, -+ unsigned int val_idx, -+ struct trace_event_file *file, -+ char *var_name, char *expr_str) -+{ -+ unsigned long flags = 0; -+ -+ if (WARN_ON(val_idx >= TRACING_MAP_VALS_MAX + TRACING_MAP_VARS_MAX)) -+ return -EINVAL; -+ if (find_var(hist_data, file, var_name) && !hist_data->remove) { -+ return -EINVAL; -+ } -+ -+ flags |= HIST_FIELD_FL_VAR; -+ hist_data->n_vars++; -+ if (WARN_ON(hist_data->n_vars > TRACING_MAP_VARS_MAX)) -+ return -EINVAL; -+ -+ return __create_val_field(hist_data, val_idx, file, var_name, expr_str, flags); -+} -+ - static int create_val_fields(struct hist_trigger_data *hist_data, - struct trace_event_file *file) - { - char *fields_str, *field_str; -- unsigned int i, j; -+ unsigned int i, j = 1; - int ret; - - ret = create_hitcount_val(hist_data); -@@ -596,12 +722,15 @@ static int create_val_fields(struct hist - field_str = strsep(&fields_str, ","); - if (!field_str) - break; -+ - if (strcmp(field_str, "hitcount") == 0) - continue; -+ - ret = create_val_field(hist_data, j++, file, field_str); - if (ret) - goto out; - } -+ - if (fields_str && (strcmp(fields_str, "hitcount") != 0)) - ret = -EINVAL; - out: -@@ -615,11 +744,12 @@ static int create_key_field(struct hist_ - char *field_str) - { - struct ftrace_event_field *field = NULL; -+ struct hist_field *hist_field = NULL; - unsigned long flags = 0; - unsigned int key_size; - int ret = 0; - -- if (WARN_ON(key_idx >= TRACING_MAP_FIELDS_MAX)) -+ if (WARN_ON(key_idx >= HIST_FIELDS_MAX)) - return -EINVAL; - - flags |= HIST_FIELD_FL_KEY; -@@ -627,6 +757,7 @@ static int create_key_field(struct hist_ - if (strcmp(field_str, "stacktrace") == 0) { - flags |= HIST_FIELD_FL_STACKTRACE; - key_size = sizeof(unsigned long) * HIST_STACKTRACE_DEPTH; -+ hist_field = create_hist_field(hist_data, NULL, flags, NULL); - } else { - char *field_name = strsep(&field_str, "."); - -@@ -672,7 +803,7 @@ static int create_key_field(struct hist_ - } - } - -- hist_data->fields[key_idx] = create_hist_field(hist_data, field, flags); -+ hist_data->fields[key_idx] = create_hist_field(hist_data, field, flags, NULL); - if (!hist_data->fields[key_idx]) { - ret = -ENOMEM; - goto out; -@@ -688,6 +819,7 @@ static int create_key_field(struct hist_ - } - - hist_data->n_keys++; -+ hist_data->n_fields++; - - if (WARN_ON(hist_data->n_keys > TRACING_MAP_KEYS_MAX)) - return -EINVAL; -@@ -731,21 +863,111 @@ static int create_key_fields(struct hist - return ret; - } - -+static int create_var_fields(struct hist_trigger_data *hist_data, -+ struct trace_event_file *file) -+{ -+ unsigned int i, j = hist_data->n_vals; -+ int ret = 0; -+ -+ unsigned int n_vars = hist_data->attrs->var_defs.n_vars; -+ -+ for (i = 0; i < n_vars; i++) { -+ char *var_name = hist_data->attrs->var_defs.name[i]; -+ char *expr = hist_data->attrs->var_defs.expr[i]; -+ -+ ret = create_var_field(hist_data, j++, file, var_name, expr); -+ if (ret) -+ goto out; -+ } -+ out: -+ return ret; -+} -+ -+static void free_var_defs(struct hist_trigger_data *hist_data) -+{ -+ unsigned int i; -+ -+ for (i = 0; i < hist_data->attrs->var_defs.n_vars; i++) { -+ kfree(hist_data->attrs->var_defs.name[i]); -+ kfree(hist_data->attrs->var_defs.expr[i]); -+ } -+ -+ hist_data->attrs->var_defs.n_vars = 0; -+} -+ -+static int parse_var_defs(struct hist_trigger_data *hist_data) -+{ -+ char *s, *str, *var_name, *field_str; -+ unsigned int i, j, n_vars = 0; -+ int ret = 0; -+ -+ for (i = 0; i < hist_data->attrs->n_assignments; i++) { -+ str = hist_data->attrs->assignment_str[i]; -+ for (j = 0; j < TRACING_MAP_VARS_MAX; j++) { -+ field_str = strsep(&str, ","); -+ if (!field_str) -+ break; -+ -+ var_name = strsep(&field_str, "="); -+ if (!var_name || !field_str) { -+ ret = -EINVAL; -+ goto free; -+ } -+ -+ if (n_vars == TRACING_MAP_VARS_MAX) { -+ ret = -EINVAL; -+ goto free; -+ } -+ -+ s = kstrdup(var_name, GFP_KERNEL); -+ if (!s) { -+ ret = -ENOMEM; -+ goto free; -+ } -+ hist_data->attrs->var_defs.name[n_vars] = s; -+ -+ s = kstrdup(field_str, GFP_KERNEL); -+ if (!s) { -+ kfree(hist_data->attrs->var_defs.name[n_vars]); -+ ret = -ENOMEM; -+ goto free; -+ } -+ hist_data->attrs->var_defs.expr[n_vars++] = s; -+ -+ hist_data->attrs->var_defs.n_vars = n_vars; -+ } -+ } -+ -+ return ret; -+ free: -+ free_var_defs(hist_data); -+ -+ return ret; -+} -+ - static int create_hist_fields(struct hist_trigger_data *hist_data, - struct trace_event_file *file) - { - int ret; - -+ ret = parse_var_defs(hist_data); -+ if (ret) -+ goto out; -+ - ret = create_val_fields(hist_data, file); - if (ret) - goto out; - -- ret = create_key_fields(hist_data, file); -+ ret = create_var_fields(hist_data, file); - if (ret) - goto out; - -- hist_data->n_fields = hist_data->n_vals + hist_data->n_keys; -+ ret = create_key_fields(hist_data, file); -+ if (ret) -+ goto out; - out: -+ free_var_defs(hist_data); -+ - return ret; - } - -@@ -768,7 +990,7 @@ static int create_sort_keys(struct hist_ - char *fields_str = hist_data->attrs->sort_key_str; - struct tracing_map_sort_key *sort_key; - int descending, ret = 0; -- unsigned int i, j; -+ unsigned int i, j, k; - - hist_data->n_sort_keys = 1; /* we always have at least one, hitcount */ - -@@ -816,12 +1038,19 @@ static int create_sort_keys(struct hist_ - continue; - } - -- for (j = 1; j < hist_data->n_fields; j++) { -+ for (j = 1, k = 1; j < hist_data->n_fields; j++) { -+ unsigned int idx; -+ - hist_field = hist_data->fields[j]; -+ if (hist_field->flags & HIST_FIELD_FL_VAR) -+ continue; -+ -+ idx = k++; -+ - test_name = hist_field_name(hist_field, 0); - - if (strcmp(field_name, test_name) == 0) { -- sort_key->field_idx = j; -+ sort_key->field_idx = idx; - descending = is_descending(field_str); - if (descending < 0) { - ret = descending; -@@ -836,6 +1065,7 @@ static int create_sort_keys(struct hist_ - break; - } - } -+ - hist_data->n_sort_keys = i; - out: - return ret; -@@ -876,12 +1106,19 @@ static int create_tracing_map_fields(str - idx = tracing_map_add_key_field(map, - hist_field->offset, - cmp_fn); -- -- } else -+ } else if (!(hist_field->flags & HIST_FIELD_FL_VAR)) - idx = tracing_map_add_sum_field(map); - - if (idx < 0) - return idx; -+ -+ if (hist_field->flags & HIST_FIELD_FL_VAR) { -+ idx = tracing_map_add_var(map); -+ if (idx < 0) -+ return idx; -+ hist_field->var.idx = idx; -+ hist_field->var.hist_data = hist_data; -+ } - } - - return 0; -@@ -905,7 +1142,8 @@ static bool need_tracing_map_ops(struct - static struct hist_trigger_data * - create_hist_data(unsigned int map_bits, - struct hist_trigger_attrs *attrs, -- struct trace_event_file *file) -+ struct trace_event_file *file, -+ bool remove) - { - const struct tracing_map_ops *map_ops = NULL; - struct hist_trigger_data *hist_data; -@@ -916,6 +1154,7 @@ create_hist_data(unsigned int map_bits, - return ERR_PTR(-ENOMEM); - - hist_data->attrs = attrs; -+ hist_data->remove = remove; - - ret = create_hist_fields(hist_data, file); - if (ret) -@@ -962,14 +1201,28 @@ static void hist_trigger_elt_update(stru - struct ring_buffer_event *rbe) - { - struct hist_field *hist_field; -- unsigned int i; -+ unsigned int i, var_idx; - u64 hist_val; - - for_each_hist_val_field(i, hist_data) { - hist_field = hist_data->fields[i]; - hist_val = hist_field->fn(hist_field, rec, rbe); -+ if (hist_field->flags & HIST_FIELD_FL_VAR) { -+ var_idx = hist_field->var.idx; -+ tracing_map_set_var(elt, var_idx, hist_val); -+ continue; -+ } - tracing_map_update_sum(elt, i, hist_val); - } -+ -+ for_each_hist_key_field(i, hist_data) { -+ hist_field = hist_data->fields[i]; -+ if (hist_field->flags & HIST_FIELD_FL_VAR) { -+ hist_val = hist_field->fn(hist_field, rec, rbe); -+ var_idx = hist_field->var.idx; -+ tracing_map_set_var(elt, var_idx, hist_val); -+ } -+ } - } - - static inline void add_to_key(char *compound_key, void *key, -@@ -1144,6 +1397,9 @@ hist_trigger_entry_print(struct seq_file - for (i = 1; i < hist_data->n_vals; i++) { - field_name = hist_field_name(hist_data->fields[i], 0); - -+ if (hist_data->fields[i]->flags & HIST_FIELD_FL_VAR) -+ continue; -+ - if (hist_data->fields[i]->flags & HIST_FIELD_FL_HEX) { - seq_printf(m, " %s: %10llx", field_name, - tracing_map_read_sum(elt, i)); -@@ -1267,6 +1523,9 @@ static void hist_field_print(struct seq_ - { - const char *field_name = hist_field_name(hist_field, 0); - -+ if (hist_field->var.name) -+ seq_printf(m, "%s=", hist_field->var.name); -+ - if (hist_field->flags & HIST_FIELD_FL_TIMESTAMP) - seq_puts(m, "common_timestamp"); - else if (field_name) -@@ -1285,7 +1544,8 @@ static int event_hist_trigger_print(stru - struct event_trigger_data *data) - { - struct hist_trigger_data *hist_data = data->private_data; -- struct hist_field *key_field; -+ struct hist_field *field; -+ bool have_var = false; - unsigned int i; - - seq_puts(m, "hist:"); -@@ -1296,25 +1556,47 @@ static int event_hist_trigger_print(stru - seq_puts(m, "keys="); - - for_each_hist_key_field(i, hist_data) { -- key_field = hist_data->fields[i]; -+ field = hist_data->fields[i]; - - if (i > hist_data->n_vals) - seq_puts(m, ","); - -- if (key_field->flags & HIST_FIELD_FL_STACKTRACE) -+ if (field->flags & HIST_FIELD_FL_STACKTRACE) - seq_puts(m, "stacktrace"); - else -- hist_field_print(m, key_field); -+ hist_field_print(m, field); - } - - seq_puts(m, ":vals="); - - for_each_hist_val_field(i, hist_data) { -+ field = hist_data->fields[i]; -+ if (field->flags & HIST_FIELD_FL_VAR) { -+ have_var = true; -+ continue; -+ } -+ - if (i == HITCOUNT_IDX) - seq_puts(m, "hitcount"); - else { - seq_puts(m, ","); -- hist_field_print(m, hist_data->fields[i]); -+ hist_field_print(m, field); -+ } -+ } -+ -+ if (have_var) { -+ unsigned int n = 0; -+ -+ seq_puts(m, ":"); -+ -+ for_each_hist_val_field(i, hist_data) { -+ field = hist_data->fields[i]; -+ -+ if (field->flags & HIST_FIELD_FL_VAR) { -+ if (n++) -+ seq_puts(m, ","); -+ hist_field_print(m, field); -+ } - } - } - -@@ -1322,7 +1604,10 @@ static int event_hist_trigger_print(stru - - for (i = 0; i < hist_data->n_sort_keys; i++) { - struct tracing_map_sort_key *sort_key; -- unsigned int idx; -+ unsigned int idx, first_key_idx; -+ -+ /* skip VAR vals */ -+ first_key_idx = hist_data->n_vals - hist_data->n_vars; - - sort_key = &hist_data->sort_keys[i]; - idx = sort_key->field_idx; -@@ -1335,8 +1620,11 @@ static int event_hist_trigger_print(stru - - if (idx == HITCOUNT_IDX) - seq_puts(m, "hitcount"); -- else -+ else { -+ if (idx >= first_key_idx) -+ idx += hist_data->n_vars; - hist_field_print(m, hist_data->fields[idx]); -+ } - - if (sort_key->descending) - seq_puts(m, ".descending"); -@@ -1633,7 +1921,7 @@ static void hist_unregister_trigger(char - test->ops->free(test->ops, test); - - if (hist_data->enable_timestamps) { -- if (unregistered) -+ if (!hist_data->remove || unregistered) - tracing_set_time_stamp_abs(file->tr, false); - } - } -@@ -1666,12 +1954,16 @@ static int event_hist_trigger_func(struc - struct hist_trigger_attrs *attrs; - struct event_trigger_ops *trigger_ops; - struct hist_trigger_data *hist_data; -+ bool remove = false; - char *trigger; - int ret = 0; - - if (!param) - return -EINVAL; - -+ if (glob[0] == '!') -+ remove = true; -+ - /* separate the trigger from the filter (k:v [if filter]) */ - trigger = strsep(¶m, " \t"); - if (!trigger) -@@ -1684,7 +1976,7 @@ static int event_hist_trigger_func(struc - if (attrs->map_bits) - hist_trigger_bits = attrs->map_bits; - -- hist_data = create_hist_data(hist_trigger_bits, attrs, file); -+ hist_data = create_hist_data(hist_trigger_bits, attrs, file, remove); - if (IS_ERR(hist_data)) { - destroy_hist_trigger_attrs(attrs); - return PTR_ERR(hist_data); -@@ -1713,7 +2005,7 @@ static int event_hist_trigger_func(struc - goto out_free; - } - -- if (glob[0] == '!') { -+ if (remove) { - cmd_ops->unreg(glob+1, trigger_ops, trigger_data, file); - ret = 0; - goto out_free; diff --git a/debian/patches/features/all/rt/0016-fold-dentry_lock_for_move-into-its-sole-caller-and-c.patch b/debian/patches/features/all/rt/0016-fold-dentry_lock_for_move-into-its-sole-caller-and-c.patch index d3b7d2397..ce45c1ef4 100644 --- a/debian/patches/features/all/rt/0016-fold-dentry_lock_for_move-into-its-sole-caller-and-c.patch +++ b/debian/patches/features/all/rt/0016-fold-dentry_lock_for_move-into-its-sole-caller-and-c.patch @@ -2,7 +2,6 @@ From: Al Viro Date: Sun, 11 Mar 2018 15:15:46 -0400 Subject: [PATCH 16/17] fold dentry_lock_for_move() into its sole caller and clean it up -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 42177007aa277af3e37bf2ae3efdfe795c81d700 diff --git a/debian/patches/features/all/rt/0016-hrtimer-Make-hrtimer_cpu_base.next_timer-handling-un.patch b/debian/patches/features/all/rt/0016-hrtimer-Make-hrtimer_cpu_base.next_timer-handling-un.patch deleted file mode 100644 index fcb8b0407..000000000 --- a/debian/patches/features/all/rt/0016-hrtimer-Make-hrtimer_cpu_base.next_timer-handling-un.patch +++ /dev/null @@ -1,98 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:13:05 +0100 -Subject: [PATCH 16/29] hrtimer: Make hrtimer_cpu_base.next_timer handling - unconditional -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -hrtimer_cpu_base.next_timer stores the pointer to the next expiring timer -in a cpu base. - -This pointer cannot be dereferenced and is solely used to check whether a -hrtimer which is removed is the hrtimer which is the first to expire in the -CPU base. If this is the case, then the timer hardware needs to be -reprogrammed to avoid an extra interrupt for nothing. - -Again, this is conditional functionality, but there is no compelling reason -to make this conditional. As a preparation, hrtimer_cpu_base.next_timer -needs to be available unconditonal. Aside of that the upcoming support for -softirq based hrtimers requires access to this pointer unconditionally. - -Make the update of hrtimer_cpu_base.next_timer unconditional and remove the -ifdef cruft. The impact on CONFIG_HIGH_RES_TIMERS=n && CONFIG_NOHZ=n is -marginal as it's just a store on an already dirtied cacheline. - -No functional change. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - include/linux/hrtimer.h | 4 ++-- - kernel/time/hrtimer.c | 12 ++---------- - 2 files changed, 4 insertions(+), 12 deletions(-) - ---- a/include/linux/hrtimer.h -+++ b/include/linux/hrtimer.h -@@ -164,13 +164,13 @@ enum hrtimer_base_type { - * @hres_active: State of high resolution mode - * @in_hrtirq: hrtimer_interrupt() is currently executing - * @hang_detected: The last hrtimer interrupt detected a hang -- * @next_timer: Pointer to the first expiring timer - * @nr_events: Total number of hrtimer interrupt events - * @nr_retries: Total number of hrtimer interrupt retries - * @nr_hangs: Total number of hrtimer interrupt hangs - * @max_hang_time: Maximum time spent in hrtimer_interrupt - * @expires_next: absolute time of the next event, is required for remote - * hrtimer enqueue -+ * @next_timer: Pointer to the first expiring timer - * @clock_base: array of clock bases for this cpu - * - * Note: next_timer is just an optimization for __remove_hrtimer(). -@@ -186,13 +186,13 @@ struct hrtimer_cpu_base { - #ifdef CONFIG_HIGH_RES_TIMERS - unsigned int in_hrtirq : 1, - hang_detected : 1; -- struct hrtimer *next_timer; - unsigned int nr_events; - unsigned short nr_retries; - unsigned short nr_hangs; - unsigned int max_hang_time; - #endif - ktime_t expires_next; -+ struct hrtimer *next_timer; - struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES]; - } ____cacheline_aligned; - ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -459,21 +459,13 @@ static struct hrtimer_clock_base * - while ((base = __next_base((cpu_base), &(active)))) - - #if defined(CONFIG_NO_HZ_COMMON) || defined(CONFIG_HIGH_RES_TIMERS) --static inline void hrtimer_update_next_timer(struct hrtimer_cpu_base *cpu_base, -- struct hrtimer *timer) --{ --#ifdef CONFIG_HIGH_RES_TIMERS -- cpu_base->next_timer = timer; --#endif --} -- - static ktime_t __hrtimer_get_next_event(struct hrtimer_cpu_base *cpu_base) - { - struct hrtimer_clock_base *base; - unsigned int active = cpu_base->active_bases; - ktime_t expires, expires_next = KTIME_MAX; - -- hrtimer_update_next_timer(cpu_base, NULL); -+ cpu_base->next_timer = NULL; - for_each_active_base(base, cpu_base, active) { - struct timerqueue_node *next; - struct hrtimer *timer; -@@ -483,7 +475,7 @@ static ktime_t __hrtimer_get_next_event( - expires = ktime_sub(hrtimer_get_expires(timer), base->offset); - if (expires < expires_next) { - expires_next = expires; -- hrtimer_update_next_timer(cpu_base, timer); -+ cpu_base->next_timer = timer; - } - } - /* diff --git a/debian/patches/features/all/rt/0016-tracing-Account-for-variables-in-named-trigger-compa.patch b/debian/patches/features/all/rt/0016-tracing-Account-for-variables-in-named-trigger-compa.patch deleted file mode 100644 index 44a48685f..000000000 --- a/debian/patches/features/all/rt/0016-tracing-Account-for-variables-in-named-trigger-compa.patch +++ /dev/null @@ -1,42 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:50 -0600 -Subject: [PATCH 16/37] tracing: Account for variables in named trigger - compatibility -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Named triggers must also have the same set of variables in order to be -considered compatible - update the trigger match test to account for -that. - -The reason for this requirement is that named triggers with variables -are meant to allow one or more events to set the same variable. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -1612,7 +1612,7 @@ static int event_hist_trigger_print(stru - sort_key = &hist_data->sort_keys[i]; - idx = sort_key->field_idx; - -- if (WARN_ON(idx >= TRACING_MAP_FIELDS_MAX)) -+ if (WARN_ON(idx >= HIST_FIELDS_MAX)) - return -EINVAL; - - if (i > 0) -@@ -1800,6 +1800,11 @@ static bool hist_trigger_match(struct ev - return false; - if (key_field->is_signed != key_field_test->is_signed) - return false; -+ if (!!key_field->var.name != !!key_field_test->var.name) -+ return false; -+ if (key_field->var.name && -+ strcmp(key_field->var.name, key_field_test->var.name) != 0) -+ return false; - } - - for (i = 0; i < hist_data->n_sort_keys; i++) { diff --git a/debian/patches/features/all/rt/0016-tracing-Give-event-triggers-access-to-ring_buffer_ev.patch b/debian/patches/features/all/rt/0016-tracing-Give-event-triggers-access-to-ring_buffer_ev.patch index ca04bf4e5..8345f242b 100644 --- a/debian/patches/features/all/rt/0016-tracing-Give-event-triggers-access-to-ring_buffer_ev.patch +++ b/debian/patches/features/all/rt/0016-tracing-Give-event-triggers-access-to-ring_buffer_ev.patch @@ -2,7 +2,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:42 -0600 Subject: [PATCH 16/48] tracing: Give event triggers access to ring_buffer_event -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The ring_buffer event can provide a timestamp that may be useful to various triggers - pass it into the handlers for that purpose. @@ -178,7 +177,7 @@ Signed-off-by: Sebastian Andrzej Siewior } } EXPORT_SYMBOL_GPL(event_triggers_post_call); -@@ -909,7 +910,8 @@ void set_named_trigger_data(struct event +@@ -911,7 +912,8 @@ void set_named_trigger_data(struct event } static void @@ -188,7 +187,7 @@ Signed-off-by: Sebastian Andrzej Siewior { if (tracing_is_on()) return; -@@ -918,7 +920,8 @@ traceon_trigger(struct event_trigger_dat +@@ -920,7 +922,8 @@ traceon_trigger(struct event_trigger_dat } static void @@ -198,7 +197,7 @@ Signed-off-by: Sebastian Andrzej Siewior { if (tracing_is_on()) return; -@@ -933,7 +936,8 @@ traceon_count_trigger(struct event_trigg +@@ -935,7 +938,8 @@ traceon_count_trigger(struct event_trigg } static void @@ -208,7 +207,7 @@ Signed-off-by: Sebastian Andrzej Siewior { if (!tracing_is_on()) return; -@@ -942,7 +946,8 @@ traceoff_trigger(struct event_trigger_da +@@ -944,7 +948,8 @@ traceoff_trigger(struct event_trigger_da } static void @@ -218,7 +217,7 @@ Signed-off-by: Sebastian Andrzej Siewior { if (!tracing_is_on()) return; -@@ -1039,13 +1044,15 @@ static struct event_command trigger_trac +@@ -1041,7 +1046,8 @@ static struct event_command trigger_trac #ifdef CONFIG_TRACER_SNAPSHOT static void @@ -226,7 +225,9 @@ Signed-off-by: Sebastian Andrzej Siewior +snapshot_trigger(struct event_trigger_data *data, void *rec, + struct ring_buffer_event *event) { - tracing_snapshot(); + struct trace_event_file *file = data->private_data; + +@@ -1052,7 +1058,8 @@ snapshot_trigger(struct event_trigger_da } static void @@ -236,7 +237,7 @@ Signed-off-by: Sebastian Andrzej Siewior { if (!data->count) return; -@@ -1053,7 +1060,7 @@ snapshot_count_trigger(struct event_trig +@@ -1060,7 +1067,7 @@ snapshot_count_trigger(struct event_trig if (data->count != -1) (data->count)--; @@ -245,7 +246,7 @@ Signed-off-by: Sebastian Andrzej Siewior } static int -@@ -1141,13 +1148,15 @@ static __init int register_trigger_snaps +@@ -1148,13 +1155,15 @@ static __init int register_trigger_snaps #endif static void @@ -263,7 +264,7 @@ Signed-off-by: Sebastian Andrzej Siewior { if (!data->count) return; -@@ -1155,7 +1164,7 @@ stacktrace_count_trigger(struct event_tr +@@ -1162,7 +1171,7 @@ stacktrace_count_trigger(struct event_tr if (data->count != -1) (data->count)--; @@ -272,7 +273,7 @@ Signed-off-by: Sebastian Andrzej Siewior } static int -@@ -1217,7 +1226,8 @@ static __init void unregister_trigger_tr +@@ -1224,7 +1233,8 @@ static __init void unregister_trigger_tr } static void @@ -282,7 +283,7 @@ Signed-off-by: Sebastian Andrzej Siewior { struct enable_trigger_data *enable_data = data->private_data; -@@ -1228,7 +1238,8 @@ event_enable_trigger(struct event_trigge +@@ -1235,7 +1245,8 @@ event_enable_trigger(struct event_trigge } static void @@ -292,7 +293,7 @@ Signed-off-by: Sebastian Andrzej Siewior { struct enable_trigger_data *enable_data = data->private_data; -@@ -1242,7 +1253,7 @@ event_enable_count_trigger(struct event_ +@@ -1249,7 +1260,7 @@ event_enable_count_trigger(struct event_ if (data->count != -1) (data->count)--; diff --git a/debian/patches/features/all/rt/0017-d_genocide-move-export-to-definition.patch b/debian/patches/features/all/rt/0017-d_genocide-move-export-to-definition.patch index 249abc83c..7c68e32f2 100644 --- a/debian/patches/features/all/rt/0017-d_genocide-move-export-to-definition.patch +++ b/debian/patches/features/all/rt/0017-d_genocide-move-export-to-definition.patch @@ -1,7 +1,6 @@ From: Al Viro Date: Thu, 29 Mar 2018 15:08:21 -0400 Subject: [PATCH 17/17] d_genocide: move export to definition -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit cbd4a5bcb25b5ed0c1c64bc969b893cad9b78acc diff --git a/debian/patches/features/all/rt/0017-hrtimer-Make-hrtimer_reprogramm-unconditional.patch b/debian/patches/features/all/rt/0017-hrtimer-Make-hrtimer_reprogramm-unconditional.patch deleted file mode 100644 index 8fd1fad56..000000000 --- a/debian/patches/features/all/rt/0017-hrtimer-Make-hrtimer_reprogramm-unconditional.patch +++ /dev/null @@ -1,187 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:13:06 +0100 -Subject: [PATCH 17/29] hrtimer: Make hrtimer_reprogramm() unconditional -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -hrtimer_reprogram() needs to be available unconditionally for softirq based -hrtimers. Move the function and all required struct members out of the -CONFIG_HIGH_RES_TIMERS #ifdef. - -There is no functional change because hrtimer_reprogram() is only invoked -when hrtimer_cpu_base.hres_active is true. Making it unconditional -increases the text size for the CONFIG_HIGH_RES_TIMERS=n case, but avoids -replication of that code for the upcoming softirq based hrtimers support. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - include/linux/hrtimer.h | 6 +- - kernel/time/hrtimer.c | 129 +++++++++++++++++++++++------------------------- - 2 files changed, 65 insertions(+), 70 deletions(-) - ---- a/include/linux/hrtimer.h -+++ b/include/linux/hrtimer.h -@@ -182,10 +182,10 @@ struct hrtimer_cpu_base { - unsigned int cpu; - unsigned int active_bases; - unsigned int clock_was_set_seq; -- unsigned int hres_active : 1; --#ifdef CONFIG_HIGH_RES_TIMERS -- unsigned int in_hrtirq : 1, -+ unsigned int hres_active : 1, -+ in_hrtirq : 1, - hang_detected : 1; -+#ifdef CONFIG_HIGH_RES_TIMERS - unsigned int nr_events; - unsigned short nr_retries; - unsigned short nr_hangs; ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -582,68 +582,6 @@ hrtimer_force_reprogram(struct hrtimer_c - } - - /* -- * When a timer is enqueued and expires earlier than the already enqueued -- * timers, we have to check, whether it expires earlier than the timer for -- * which the clock event device was armed. -- * -- * Called with interrupts disabled and base->cpu_base.lock held -- */ --static void hrtimer_reprogram(struct hrtimer *timer, -- struct hrtimer_clock_base *base) --{ -- struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases); -- ktime_t expires = ktime_sub(hrtimer_get_expires(timer), base->offset); -- -- WARN_ON_ONCE(hrtimer_get_expires_tv64(timer) < 0); -- -- /* -- * If the timer is not on the current cpu, we cannot reprogram -- * the other cpus clock event device. -- */ -- if (base->cpu_base != cpu_base) -- return; -- -- /* -- * If the hrtimer interrupt is running, then it will -- * reevaluate the clock bases and reprogram the clock event -- * device. The callbacks are always executed in hard interrupt -- * context so we don't need an extra check for a running -- * callback. -- */ -- if (cpu_base->in_hrtirq) -- return; -- -- /* -- * CLOCK_REALTIME timer might be requested with an absolute -- * expiry time which is less than base->offset. Set it to 0. -- */ -- if (expires < 0) -- expires = 0; -- -- if (expires >= cpu_base->expires_next) -- return; -- -- /* Update the pointer to the next expiring timer */ -- cpu_base->next_timer = timer; -- -- /* -- * If a hang was detected in the last timer interrupt then we -- * do not schedule a timer which is earlier than the expiry -- * which we enforced in the hang detection. We want the system -- * to make progress. -- */ -- if (cpu_base->hang_detected) -- return; -- -- /* -- * Program the timer hardware. We enforce the expiry for -- * events which are already in the past. -- */ -- cpu_base->expires_next = expires; -- tick_program_event(expires, 1); --} -- --/* - * Retrigger next event is called after clock was set - * - * Called with interrupts disabled via on_each_cpu() -@@ -703,16 +641,73 @@ static inline int hrtimer_is_hres_enable - static inline void hrtimer_switch_to_hres(void) { } - static inline void - hrtimer_force_reprogram(struct hrtimer_cpu_base *base, int skip_equal) { } --static inline int hrtimer_reprogram(struct hrtimer *timer, -- struct hrtimer_clock_base *base) --{ -- return 0; --} - static inline void retrigger_next_event(void *arg) { } - - #endif /* CONFIG_HIGH_RES_TIMERS */ - - /* -+ * When a timer is enqueued and expires earlier than the already enqueued -+ * timers, we have to check, whether it expires earlier than the timer for -+ * which the clock event device was armed. -+ * -+ * Called with interrupts disabled and base->cpu_base.lock held -+ */ -+static void hrtimer_reprogram(struct hrtimer *timer, -+ struct hrtimer_clock_base *base) -+{ -+ struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases); -+ ktime_t expires = ktime_sub(hrtimer_get_expires(timer), base->offset); -+ -+ WARN_ON_ONCE(hrtimer_get_expires_tv64(timer) < 0); -+ -+ /* -+ * If the timer is not on the current cpu, we cannot reprogram -+ * the other cpus clock event device. -+ */ -+ if (base->cpu_base != cpu_base) -+ return; -+ -+ /* -+ * If the hrtimer interrupt is running, then it will -+ * reevaluate the clock bases and reprogram the clock event -+ * device. The callbacks are always executed in hard interrupt -+ * context so we don't need an extra check for a running -+ * callback. -+ */ -+ if (cpu_base->in_hrtirq) -+ return; -+ -+ /* -+ * CLOCK_REALTIME timer might be requested with an absolute -+ * expiry time which is less than base->offset. Set it to 0. -+ */ -+ if (expires < 0) -+ expires = 0; -+ -+ if (expires >= cpu_base->expires_next) -+ return; -+ -+ /* Update the pointer to the next expiring timer */ -+ cpu_base->next_timer = timer; -+ -+ /* -+ * If a hang was detected in the last timer interrupt then we -+ * do not schedule a timer which is earlier than the expiry -+ * which we enforced in the hang detection. We want the system -+ * to make progress. -+ */ -+ if (cpu_base->hang_detected) -+ return; -+ -+ /* -+ * Program the timer hardware. We enforce the expiry for -+ * events which are already in the past. -+ */ -+ cpu_base->expires_next = expires; -+ tick_program_event(expires, 1); -+} -+ -+/* - * Clock realtime was set - * - * Change the offset of the realtime clock vs. the monotonic diff --git a/debian/patches/features/all/rt/0017-tracing-Add-ring-buffer-event-param-to-hist-field-fu.patch b/debian/patches/features/all/rt/0017-tracing-Add-ring-buffer-event-param-to-hist-field-fu.patch index da5e637fa..ac7f0824b 100644 --- a/debian/patches/features/all/rt/0017-tracing-Add-ring-buffer-event-param-to-hist-field-fu.patch +++ b/debian/patches/features/all/rt/0017-tracing-Add-ring-buffer-event-param-to-hist-field-fu.patch @@ -2,7 +2,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:43 -0600 Subject: [PATCH 17/48] tracing: Add ring buffer event param to hist field functions -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Some events such as timestamps require access to a ring_buffer_event struct; add a param so that hist field functions can access that. diff --git a/debian/patches/features/all/rt/0017-tracing-Move-get_hist_field_flags.patch b/debian/patches/features/all/rt/0017-tracing-Move-get_hist_field_flags.patch deleted file mode 100644 index 73a79db71..000000000 --- a/debian/patches/features/all/rt/0017-tracing-Move-get_hist_field_flags.patch +++ /dev/null @@ -1,74 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:51 -0600 -Subject: [PATCH 17/37] tracing: Move get_hist_field_flags() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Move get_hist_field_flags() to make it more easily accessible for new -code (and keep the move separate from new functionality). - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 44 +++++++++++++++++++-------------------- - 1 file changed, 22 insertions(+), 22 deletions(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -497,6 +497,28 @@ static const struct tracing_map_ops hist - .elt_init = hist_trigger_elt_comm_init, - }; - -+static const char *get_hist_field_flags(struct hist_field *hist_field) -+{ -+ const char *flags_str = NULL; -+ -+ if (hist_field->flags & HIST_FIELD_FL_HEX) -+ flags_str = "hex"; -+ else if (hist_field->flags & HIST_FIELD_FL_SYM) -+ flags_str = "sym"; -+ else if (hist_field->flags & HIST_FIELD_FL_SYM_OFFSET) -+ flags_str = "sym-offset"; -+ else if (hist_field->flags & HIST_FIELD_FL_EXECNAME) -+ flags_str = "execname"; -+ else if (hist_field->flags & HIST_FIELD_FL_SYSCALL) -+ flags_str = "syscall"; -+ else if (hist_field->flags & HIST_FIELD_FL_LOG2) -+ flags_str = "log2"; -+ else if (hist_field->flags & HIST_FIELD_FL_TIMESTAMP_USECS) -+ flags_str = "usecs"; -+ -+ return flags_str; -+} -+ - static void destroy_hist_field(struct hist_field *hist_field, - unsigned int level) - { -@@ -1497,28 +1519,6 @@ const struct file_operations event_hist_ - .release = single_release, - }; - --static const char *get_hist_field_flags(struct hist_field *hist_field) --{ -- const char *flags_str = NULL; -- -- if (hist_field->flags & HIST_FIELD_FL_HEX) -- flags_str = "hex"; -- else if (hist_field->flags & HIST_FIELD_FL_SYM) -- flags_str = "sym"; -- else if (hist_field->flags & HIST_FIELD_FL_SYM_OFFSET) -- flags_str = "sym-offset"; -- else if (hist_field->flags & HIST_FIELD_FL_EXECNAME) -- flags_str = "execname"; -- else if (hist_field->flags & HIST_FIELD_FL_SYSCALL) -- flags_str = "syscall"; -- else if (hist_field->flags & HIST_FIELD_FL_LOG2) -- flags_str = "log2"; -- else if (hist_field->flags & HIST_FIELD_FL_TIMESTAMP_USECS) -- flags_str = "usecs"; -- -- return flags_str; --} -- - static void hist_field_print(struct seq_file *m, struct hist_field *hist_field) - { - const char *field_name = hist_field_name(hist_field, 0); diff --git a/debian/patches/features/all/rt/0018-hrtimer-Make-hrtimer_force_reprogramm-unconditionall.patch b/debian/patches/features/all/rt/0018-hrtimer-Make-hrtimer_force_reprogramm-unconditionall.patch deleted file mode 100644 index 80b8d5724..000000000 --- a/debian/patches/features/all/rt/0018-hrtimer-Make-hrtimer_force_reprogramm-unconditionall.patch +++ /dev/null @@ -1,106 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:13:07 +0100 -Subject: [PATCH 18/29] hrtimer: Make hrtimer_force_reprogramm() - unconditionally available -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -hrtimer_force_reprogram() needs to be available unconditionally for softirq -based hrtimers. Move the function and all required struct members out of -the CONFIG_HIGH_RES_TIMERS #ifdef. - -There is no functional change because hrtimer_force_reprogram() is only -invoked when hrtimer_cpu_base.hres_active is true and -CONFIG_HIGH_RES_TIMERS=y. - -Making it unconditional increases the text size for the -CONFIG_HIGH_RES_TIMERS=n case slightly, but avoids replication of that code -for the upcoming softirq based hrtimers support. Most of the code gets -eliminated in the CONFIG_HIGH_RES_TIMERS=n case by the compiler. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/time/hrtimer.c | 58 ++++++++++++++++++++++++-------------------------- - 1 file changed, 28 insertions(+), 30 deletions(-) - ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -513,34 +513,6 @@ static inline int hrtimer_hres_active(vo - return __hrtimer_hres_active(this_cpu_ptr(&hrtimer_bases)); - } - --/* High resolution timer related functions */ --#ifdef CONFIG_HIGH_RES_TIMERS -- --/* -- * High resolution timer enabled ? -- */ --static bool hrtimer_hres_enabled __read_mostly = true; --unsigned int hrtimer_resolution __read_mostly = LOW_RES_NSEC; --EXPORT_SYMBOL_GPL(hrtimer_resolution); -- --/* -- * Enable / Disable high resolution mode -- */ --static int __init setup_hrtimer_hres(char *str) --{ -- return (kstrtobool(str, &hrtimer_hres_enabled) == 0); --} -- --__setup("highres=", setup_hrtimer_hres); -- --/* -- * hrtimer_high_res_enabled - query, if the highres mode is enabled -- */ --static inline int hrtimer_is_hres_enabled(void) --{ -- return hrtimer_hres_enabled; --} -- - /* - * Reprogram the event source with checking both queues for the - * next event -@@ -581,6 +553,34 @@ hrtimer_force_reprogram(struct hrtimer_c - tick_program_event(cpu_base->expires_next, 1); - } - -+/* High resolution timer related functions */ -+#ifdef CONFIG_HIGH_RES_TIMERS -+ -+/* -+ * High resolution timer enabled ? -+ */ -+static bool hrtimer_hres_enabled __read_mostly = true; -+unsigned int hrtimer_resolution __read_mostly = LOW_RES_NSEC; -+EXPORT_SYMBOL_GPL(hrtimer_resolution); -+ -+/* -+ * Enable / Disable high resolution mode -+ */ -+static int __init setup_hrtimer_hres(char *str) -+{ -+ return (kstrtobool(str, &hrtimer_hres_enabled) == 0); -+} -+ -+__setup("highres=", setup_hrtimer_hres); -+ -+/* -+ * hrtimer_high_res_enabled - query, if the highres mode is enabled -+ */ -+static inline int hrtimer_is_hres_enabled(void) -+{ -+ return hrtimer_hres_enabled; -+} -+ - /* - * Retrigger next event is called after clock was set - * -@@ -639,8 +639,6 @@ void clock_was_set_delayed(void) - - static inline int hrtimer_is_hres_enabled(void) { return 0; } - static inline void hrtimer_switch_to_hres(void) { } --static inline void --hrtimer_force_reprogram(struct hrtimer_cpu_base *base, int skip_equal) { } - static inline void retrigger_next_event(void *arg) { } - - #endif /* CONFIG_HIGH_RES_TIMERS */ diff --git a/debian/patches/features/all/rt/0018-tracing-Add-simple-expression-support-to-hist-trigge.patch b/debian/patches/features/all/rt/0018-tracing-Add-simple-expression-support-to-hist-trigge.patch deleted file mode 100644 index f2f3332f1..000000000 --- a/debian/patches/features/all/rt/0018-tracing-Add-simple-expression-support-to-hist-trigge.patch +++ /dev/null @@ -1,624 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:52 -0600 -Subject: [PATCH 18/37] tracing: Add simple expression support to hist triggers -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Add support for simple addition, subtraction, and unary expressions -(-(expr) and expr, where expr = b-a, a+b, a+b+c) to hist triggers, in -order to support a minimal set of useful inter-event calculations. - -These operations are needed for calculating latencies between events -(timestamp1-timestamp0) and for combined latencies (latencies over 3 -or more events). - -In the process, factor out some common code from key and value -parsing. - -Signed-off-by: Tom Zanussi -[kbuild test robot fix, add static to parse_atom()] -Signed-off-by: Fengguang Wu -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 487 +++++++++++++++++++++++++++++++++------ - 1 file changed, 413 insertions(+), 74 deletions(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -32,6 +32,13 @@ typedef u64 (*hist_field_fn_t) (struct h - #define HIST_FIELD_OPERANDS_MAX 2 - #define HIST_FIELDS_MAX (TRACING_MAP_FIELDS_MAX + TRACING_MAP_VARS_MAX) - -+enum field_op_id { -+ FIELD_OP_NONE, -+ FIELD_OP_PLUS, -+ FIELD_OP_MINUS, -+ FIELD_OP_UNARY_MINUS, -+}; -+ - struct hist_var { - char *name; - struct hist_trigger_data *hist_data; -@@ -48,6 +55,8 @@ struct hist_field { - struct hist_field *operands[HIST_FIELD_OPERANDS_MAX]; - struct hist_trigger_data *hist_data; - struct hist_var var; -+ enum field_op_id operator; -+ char *name; - }; - - static u64 hist_field_none(struct hist_field *field, void *event, -@@ -98,6 +107,41 @@ static u64 hist_field_log2(struct hist_f - return (u64) ilog2(roundup_pow_of_two(val)); - } - -+static u64 hist_field_plus(struct hist_field *hist_field, void *event, -+ struct ring_buffer_event *rbe) -+{ -+ struct hist_field *operand1 = hist_field->operands[0]; -+ struct hist_field *operand2 = hist_field->operands[1]; -+ -+ u64 val1 = operand1->fn(operand1, event, rbe); -+ u64 val2 = operand2->fn(operand2, event, rbe); -+ -+ return val1 + val2; -+} -+ -+static u64 hist_field_minus(struct hist_field *hist_field, void *event, -+ struct ring_buffer_event *rbe) -+{ -+ struct hist_field *operand1 = hist_field->operands[0]; -+ struct hist_field *operand2 = hist_field->operands[1]; -+ -+ u64 val1 = operand1->fn(operand1, event, rbe); -+ u64 val2 = operand2->fn(operand2, event, rbe); -+ -+ return val1 - val2; -+} -+ -+static u64 hist_field_unary_minus(struct hist_field *hist_field, void *event, -+ struct ring_buffer_event *rbe) -+{ -+ struct hist_field *operand = hist_field->operands[0]; -+ -+ s64 sval = (s64)operand->fn(operand, event, rbe); -+ u64 val = (u64)-sval; -+ -+ return val; -+} -+ - #define DEFINE_HIST_FIELD_FN(type) \ - static u64 hist_field_##type(struct hist_field *hist_field, \ - void *event, \ -@@ -147,6 +191,7 @@ enum hist_field_flags { - HIST_FIELD_FL_TIMESTAMP = 1 << 10, - HIST_FIELD_FL_TIMESTAMP_USECS = 1 << 11, - HIST_FIELD_FL_VAR = 1 << 12, -+ HIST_FIELD_FL_EXPR = 1 << 13, - }; - - struct var_defs { -@@ -258,6 +303,8 @@ static const char *hist_field_name(struc - field_name = hist_field_name(field->operands[0], ++level); - else if (field->flags & HIST_FIELD_FL_TIMESTAMP) - field_name = "common_timestamp"; -+ else if (field->flags & HIST_FIELD_FL_EXPR) -+ field_name = field->name; - - if (field_name == NULL) - field_name = ""; -@@ -519,12 +566,104 @@ static const char *get_hist_field_flags( - return flags_str; - } - -+static void expr_field_str(struct hist_field *field, char *expr) -+{ -+ strcat(expr, hist_field_name(field, 0)); -+ -+ if (field->flags) { -+ const char *flags_str = get_hist_field_flags(field); -+ -+ if (flags_str) { -+ strcat(expr, "."); -+ strcat(expr, flags_str); -+ } -+ } -+} -+ -+static char *expr_str(struct hist_field *field, unsigned int level) -+{ -+ char *expr; -+ -+ if (level > 1) -+ return NULL; -+ -+ expr = kzalloc(MAX_FILTER_STR_VAL, GFP_KERNEL); -+ if (!expr) -+ return NULL; -+ -+ if (!field->operands[0]) { -+ expr_field_str(field, expr); -+ return expr; -+ } -+ -+ if (field->operator == FIELD_OP_UNARY_MINUS) { -+ char *subexpr; -+ -+ strcat(expr, "-("); -+ subexpr = expr_str(field->operands[0], ++level); -+ if (!subexpr) { -+ kfree(expr); -+ return NULL; -+ } -+ strcat(expr, subexpr); -+ strcat(expr, ")"); -+ -+ kfree(subexpr); -+ -+ return expr; -+ } -+ -+ expr_field_str(field->operands[0], expr); -+ -+ switch (field->operator) { -+ case FIELD_OP_MINUS: -+ strcat(expr, "-"); -+ break; -+ case FIELD_OP_PLUS: -+ strcat(expr, "+"); -+ break; -+ default: -+ kfree(expr); -+ return NULL; -+ } -+ -+ expr_field_str(field->operands[1], expr); -+ -+ return expr; -+} -+ -+static int contains_operator(char *str) -+{ -+ enum field_op_id field_op = FIELD_OP_NONE; -+ char *op; -+ -+ op = strpbrk(str, "+-"); -+ if (!op) -+ return FIELD_OP_NONE; -+ -+ switch (*op) { -+ case '-': -+ if (*str == '-') -+ field_op = FIELD_OP_UNARY_MINUS; -+ else -+ field_op = FIELD_OP_MINUS; -+ break; -+ case '+': -+ field_op = FIELD_OP_PLUS; -+ break; -+ default: -+ break; -+ } -+ -+ return field_op; -+} -+ - static void destroy_hist_field(struct hist_field *hist_field, - unsigned int level) - { - unsigned int i; - -- if (level > 2) -+ if (level > 3) - return; - - if (!hist_field) -@@ -534,6 +673,7 @@ static void destroy_hist_field(struct hi - destroy_hist_field(hist_field->operands[i], level + 1); - - kfree(hist_field->var.name); -+ kfree(hist_field->name); - - kfree(hist_field); - } -@@ -554,6 +694,9 @@ static struct hist_field *create_hist_fi - - hist_field->hist_data = hist_data; - -+ if (flags & HIST_FIELD_FL_EXPR) -+ goto out; /* caller will populate */ -+ - if (flags & HIST_FIELD_FL_HITCOUNT) { - hist_field->fn = hist_field_counter; - goto out; -@@ -626,6 +769,257 @@ static void destroy_hist_fields(struct h - } - } - -+static struct ftrace_event_field * -+parse_field(struct hist_trigger_data *hist_data, struct trace_event_file *file, -+ char *field_str, unsigned long *flags) -+{ -+ struct ftrace_event_field *field = NULL; -+ char *field_name, *modifier, *str; -+ -+ modifier = str = kstrdup(field_str, GFP_KERNEL); -+ if (!modifier) -+ return ERR_PTR(-ENOMEM); -+ -+ field_name = strsep(&modifier, "."); -+ if (modifier) { -+ if (strcmp(modifier, "hex") == 0) -+ *flags |= HIST_FIELD_FL_HEX; -+ else if (strcmp(modifier, "sym") == 0) -+ *flags |= HIST_FIELD_FL_SYM; -+ else if (strcmp(modifier, "sym-offset") == 0) -+ *flags |= HIST_FIELD_FL_SYM_OFFSET; -+ else if ((strcmp(modifier, "execname") == 0) && -+ (strcmp(field_name, "common_pid") == 0)) -+ *flags |= HIST_FIELD_FL_EXECNAME; -+ else if (strcmp(modifier, "syscall") == 0) -+ *flags |= HIST_FIELD_FL_SYSCALL; -+ else if (strcmp(modifier, "log2") == 0) -+ *flags |= HIST_FIELD_FL_LOG2; -+ else if (strcmp(modifier, "usecs") == 0) -+ *flags |= HIST_FIELD_FL_TIMESTAMP_USECS; -+ else { -+ field = ERR_PTR(-EINVAL); -+ goto out; -+ } -+ } -+ -+ if (strcmp(field_name, "common_timestamp") == 0) { -+ *flags |= HIST_FIELD_FL_TIMESTAMP; -+ hist_data->enable_timestamps = true; -+ if (*flags & HIST_FIELD_FL_TIMESTAMP_USECS) -+ hist_data->attrs->ts_in_usecs = true; -+ } else { -+ field = trace_find_event_field(file->event_call, field_name); -+ if (!field || !field->size) { -+ field = ERR_PTR(-EINVAL); -+ goto out; -+ } -+ } -+ out: -+ kfree(str); -+ -+ return field; -+} -+ -+static struct hist_field *parse_atom(struct hist_trigger_data *hist_data, -+ struct trace_event_file *file, char *str, -+ unsigned long *flags, char *var_name) -+{ -+ struct ftrace_event_field *field = NULL; -+ struct hist_field *hist_field = NULL; -+ int ret = 0; -+ -+ field = parse_field(hist_data, file, str, flags); -+ if (IS_ERR(field)) { -+ ret = PTR_ERR(field); -+ goto out; -+ } -+ -+ hist_field = create_hist_field(hist_data, field, *flags, var_name); -+ if (!hist_field) { -+ ret = -ENOMEM; -+ goto out; -+ } -+ -+ return hist_field; -+ out: -+ return ERR_PTR(ret); -+} -+ -+static struct hist_field *parse_expr(struct hist_trigger_data *hist_data, -+ struct trace_event_file *file, -+ char *str, unsigned long flags, -+ char *var_name, unsigned int level); -+ -+static struct hist_field *parse_unary(struct hist_trigger_data *hist_data, -+ struct trace_event_file *file, -+ char *str, unsigned long flags, -+ char *var_name, unsigned int level) -+{ -+ struct hist_field *operand1, *expr = NULL; -+ unsigned long operand_flags; -+ int ret = 0; -+ char *s; -+ -+ // we support only -(xxx) i.e. explicit parens required -+ -+ if (level > 3) { -+ ret = -EINVAL; -+ goto free; -+ } -+ -+ str++; // skip leading '-' -+ -+ s = strchr(str, '('); -+ if (s) -+ str++; -+ else { -+ ret = -EINVAL; -+ goto free; -+ } -+ -+ s = strrchr(str, ')'); -+ if (s) -+ *s = '\0'; -+ else { -+ ret = -EINVAL; // no closing ')' -+ goto free; -+ } -+ -+ flags |= HIST_FIELD_FL_EXPR; -+ expr = create_hist_field(hist_data, NULL, flags, var_name); -+ if (!expr) { -+ ret = -ENOMEM; -+ goto free; -+ } -+ -+ operand_flags = 0; -+ operand1 = parse_expr(hist_data, file, str, operand_flags, NULL, ++level); -+ if (IS_ERR(operand1)) { -+ ret = PTR_ERR(operand1); -+ goto free; -+ } -+ -+ expr->flags |= operand1->flags & -+ (HIST_FIELD_FL_TIMESTAMP | HIST_FIELD_FL_TIMESTAMP_USECS); -+ expr->fn = hist_field_unary_minus; -+ expr->operands[0] = operand1; -+ expr->operator = FIELD_OP_UNARY_MINUS; -+ expr->name = expr_str(expr, 0); -+ -+ return expr; -+ free: -+ destroy_hist_field(expr, 0); -+ return ERR_PTR(ret); -+} -+ -+static int check_expr_operands(struct hist_field *operand1, -+ struct hist_field *operand2) -+{ -+ unsigned long operand1_flags = operand1->flags; -+ unsigned long operand2_flags = operand2->flags; -+ -+ if ((operand1_flags & HIST_FIELD_FL_TIMESTAMP_USECS) != -+ (operand2_flags & HIST_FIELD_FL_TIMESTAMP_USECS)) -+ return -EINVAL; -+ -+ return 0; -+} -+ -+static struct hist_field *parse_expr(struct hist_trigger_data *hist_data, -+ struct trace_event_file *file, -+ char *str, unsigned long flags, -+ char *var_name, unsigned int level) -+{ -+ struct hist_field *operand1 = NULL, *operand2 = NULL, *expr = NULL; -+ unsigned long operand_flags; -+ int field_op, ret = -EINVAL; -+ char *sep, *operand1_str; -+ -+ if (level > 3) -+ return ERR_PTR(-EINVAL); -+ -+ field_op = contains_operator(str); -+ -+ if (field_op == FIELD_OP_NONE) -+ return parse_atom(hist_data, file, str, &flags, var_name); -+ -+ if (field_op == FIELD_OP_UNARY_MINUS) -+ return parse_unary(hist_data, file, str, flags, var_name, ++level); -+ -+ switch (field_op) { -+ case FIELD_OP_MINUS: -+ sep = "-"; -+ break; -+ case FIELD_OP_PLUS: -+ sep = "+"; -+ break; -+ default: -+ goto free; -+ } -+ -+ operand1_str = strsep(&str, sep); -+ if (!operand1_str || !str) -+ goto free; -+ -+ operand_flags = 0; -+ operand1 = parse_atom(hist_data, file, operand1_str, -+ &operand_flags, NULL); -+ if (IS_ERR(operand1)) { -+ ret = PTR_ERR(operand1); -+ operand1 = NULL; -+ goto free; -+ } -+ -+ // rest of string could be another expression e.g. b+c in a+b+c -+ operand_flags = 0; -+ operand2 = parse_expr(hist_data, file, str, operand_flags, NULL, ++level); -+ if (IS_ERR(operand2)) { -+ ret = PTR_ERR(operand2); -+ operand2 = NULL; -+ goto free; -+ } -+ -+ ret = check_expr_operands(operand1, operand2); -+ if (ret) -+ goto free; -+ -+ flags |= HIST_FIELD_FL_EXPR; -+ -+ flags |= operand1->flags & -+ (HIST_FIELD_FL_TIMESTAMP | HIST_FIELD_FL_TIMESTAMP_USECS); -+ -+ expr = create_hist_field(hist_data, NULL, flags, var_name); -+ if (!expr) { -+ ret = -ENOMEM; -+ goto free; -+ } -+ -+ expr->operands[0] = operand1; -+ expr->operands[1] = operand2; -+ expr->operator = field_op; -+ expr->name = expr_str(expr, 0); -+ -+ switch (field_op) { -+ case FIELD_OP_MINUS: -+ expr->fn = hist_field_minus; -+ break; -+ case FIELD_OP_PLUS: -+ expr->fn = hist_field_plus; -+ break; -+ default: -+ goto free; -+ } -+ -+ return expr; -+ free: -+ destroy_hist_field(operand1, 0); -+ destroy_hist_field(operand2, 0); -+ destroy_hist_field(expr, 0); -+ -+ return ERR_PTR(ret); -+} -+ - static int create_hitcount_val(struct hist_trigger_data *hist_data) - { - hist_data->fields[HITCOUNT_IDX] = -@@ -648,37 +1042,17 @@ static int __create_val_field(struct his - char *var_name, char *field_str, - unsigned long flags) - { -- struct ftrace_event_field *field = NULL; -- char *field_name; -+ struct hist_field *hist_field; - int ret = 0; - -- field_name = strsep(&field_str, "."); -- if (field_str) { -- if (strcmp(field_str, "hex") == 0) -- flags |= HIST_FIELD_FL_HEX; -- else { -- ret = -EINVAL; -- goto out; -- } -- } -- -- if (strcmp(field_name, "common_timestamp") == 0) { -- flags |= HIST_FIELD_FL_TIMESTAMP; -- hist_data->enable_timestamps = true; -- } else { -- field = trace_find_event_field(file->event_call, field_name); -- if (!field || !field->size) { -- ret = -EINVAL; -- goto out; -- } -- } -- -- hist_data->fields[val_idx] = create_hist_field(hist_data, field, flags, var_name); -- if (!hist_data->fields[val_idx]) { -- ret = -ENOMEM; -+ hist_field = parse_expr(hist_data, file, field_str, flags, var_name, 0); -+ if (IS_ERR(hist_field)) { -+ ret = PTR_ERR(hist_field); - goto out; - } - -+ hist_data->fields[val_idx] = hist_field; -+ - ++hist_data->n_vals; - ++hist_data->n_fields; - -@@ -765,8 +1139,8 @@ static int create_key_field(struct hist_ - struct trace_event_file *file, - char *field_str) - { -- struct ftrace_event_field *field = NULL; - struct hist_field *hist_field = NULL; -+ - unsigned long flags = 0; - unsigned int key_size; - int ret = 0; -@@ -781,60 +1155,24 @@ static int create_key_field(struct hist_ - key_size = sizeof(unsigned long) * HIST_STACKTRACE_DEPTH; - hist_field = create_hist_field(hist_data, NULL, flags, NULL); - } else { -- char *field_name = strsep(&field_str, "."); -- -- if (field_str) { -- if (strcmp(field_str, "hex") == 0) -- flags |= HIST_FIELD_FL_HEX; -- else if (strcmp(field_str, "sym") == 0) -- flags |= HIST_FIELD_FL_SYM; -- else if (strcmp(field_str, "sym-offset") == 0) -- flags |= HIST_FIELD_FL_SYM_OFFSET; -- else if ((strcmp(field_str, "execname") == 0) && -- (strcmp(field_name, "common_pid") == 0)) -- flags |= HIST_FIELD_FL_EXECNAME; -- else if (strcmp(field_str, "syscall") == 0) -- flags |= HIST_FIELD_FL_SYSCALL; -- else if (strcmp(field_str, "log2") == 0) -- flags |= HIST_FIELD_FL_LOG2; -- else if (strcmp(field_str, "usecs") == 0) -- flags |= HIST_FIELD_FL_TIMESTAMP_USECS; -- else { -- ret = -EINVAL; -- goto out; -- } -+ hist_field = parse_expr(hist_data, file, field_str, flags, -+ NULL, 0); -+ if (IS_ERR(hist_field)) { -+ ret = PTR_ERR(hist_field); -+ goto out; - } - -- if (strcmp(field_name, "common_timestamp") == 0) { -- flags |= HIST_FIELD_FL_TIMESTAMP; -- hist_data->enable_timestamps = true; -- if (flags & HIST_FIELD_FL_TIMESTAMP_USECS) -- hist_data->attrs->ts_in_usecs = true; -- key_size = sizeof(u64); -- } else { -- field = trace_find_event_field(file->event_call, field_name); -- if (!field || !field->size) { -- ret = -EINVAL; -- goto out; -- } -- -- if (is_string_field(field)) -- key_size = MAX_FILTER_STR_VAL; -- else -- key_size = field->size; -- } -+ key_size = hist_field->size; - } - -- hist_data->fields[key_idx] = create_hist_field(hist_data, field, flags, NULL); -- if (!hist_data->fields[key_idx]) { -- ret = -ENOMEM; -- goto out; -- } -+ hist_data->fields[key_idx] = hist_field; - - key_size = ALIGN(key_size, sizeof(u64)); - hist_data->fields[key_idx]->size = key_size; - hist_data->fields[key_idx]->offset = key_offset; -+ - hist_data->key_size += key_size; -+ - if (hist_data->key_size > HIST_KEY_SIZE_MAX) { - ret = -EINVAL; - goto out; -@@ -1419,7 +1757,8 @@ hist_trigger_entry_print(struct seq_file - for (i = 1; i < hist_data->n_vals; i++) { - field_name = hist_field_name(hist_data->fields[i], 0); - -- if (hist_data->fields[i]->flags & HIST_FIELD_FL_VAR) -+ if (hist_data->fields[i]->flags & HIST_FIELD_FL_VAR || -+ hist_data->fields[i]->flags & HIST_FIELD_FL_EXPR) - continue; - - if (hist_data->fields[i]->flags & HIST_FIELD_FL_HEX) { diff --git a/debian/patches/features/all/rt/0018-tracing-Break-out-hist-trigger-assignment-parsing.patch b/debian/patches/features/all/rt/0018-tracing-Break-out-hist-trigger-assignment-parsing.patch index 066114e8d..de84be4d2 100644 --- a/debian/patches/features/all/rt/0018-tracing-Break-out-hist-trigger-assignment-parsing.patch +++ b/debian/patches/features/all/rt/0018-tracing-Break-out-hist-trigger-assignment-parsing.patch @@ -1,7 +1,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:44 -0600 Subject: [PATCH 18/48] tracing: Break out hist trigger assignment parsing -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz This will make it easier to add variables, and makes the parsing code cleaner regardless. diff --git a/debian/patches/features/all/rt/0019-hrtimer-Unify-handling-of-hrtimer-remove.patch b/debian/patches/features/all/rt/0019-hrtimer-Unify-handling-of-hrtimer-remove.patch deleted file mode 100644 index 3b6bf3873..000000000 --- a/debian/patches/features/all/rt/0019-hrtimer-Unify-handling-of-hrtimer-remove.patch +++ /dev/null @@ -1,89 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:13:08 +0100 -Subject: [PATCH 19/29] hrtimer: Unify handling of hrtimer remove -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -When the first hrtimer on the current CPU is removed, -hrtimer_force_reprogram() is invoked but only when -CONFIG_HIGH_RES_TIMERS=y and hrtimer_cpu_base.hres_active is set. - -hrtimer_force_reprogram() updates hrtimer_cpu_base.expires_next and -reprograms the clock event device. When CONFIG_HIGH_RES_TIMERS=y and -hrtimer_cpu_base.hres_active is set, a pointless hrtimer interrupt can be -prevented. - -hrtimer_check_target() makes the 'can remote enqueue' decision. As soon as -hrtimer_check_target() is unconditionally available and -hrtimer_cpu_base.expires_next is updated by hrtimer_reprogram(), -hrtimer_force_reprogram() needs to be available unconditionally as well to -prevent the following scenario with CONFIG_HIGH_RES_TIMERS=n: - -- the first hrtimer on this CPU is removed and hrtimer_force_reprogram() is - not executed - -- CPU goes idle (next timer is calculated and hrtimers are taken into - account) - -- a hrtimer is enqueued remote on the idle CPU: hrtimer_check_target() - compares expiry value and hrtimer_cpu_base.expires_next. The expiry value - is after expires_next, so the hrtimer is enqueued. This timer will fire - late, if it expires before the effective first hrtimer on this CPU and - the comparison was with an outdated expires_next value. - -To prevent this scenario, make hrtimer_force_reprogram() unconditional -except the effective reprogramming part, which gets eliminated by the -compiler in the CONFIG_HIGH_RES_TIMERS=n case. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/time/hrtimer.c | 10 ++++------ - 1 file changed, 4 insertions(+), 6 deletions(-) - ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -523,9 +523,6 @@ hrtimer_force_reprogram(struct hrtimer_c - { - ktime_t expires_next; - -- if (!__hrtimer_hres_active(cpu_base)) -- return; -- - expires_next = __hrtimer_get_next_event(cpu_base); - - if (skip_equal && expires_next == cpu_base->expires_next) -@@ -534,6 +531,9 @@ hrtimer_force_reprogram(struct hrtimer_c - cpu_base->expires_next = expires_next; - - /* -+ * If hres is not active, hardware does not have to be -+ * reprogrammed yet. -+ * - * If a hang was detected in the last timer interrupt then we - * leave the hang delay active in the hardware. We want the - * system to make progress. That also prevents the following -@@ -547,7 +547,7 @@ hrtimer_force_reprogram(struct hrtimer_c - * set. So we'd effectivly block all timers until the T2 event - * fires. - */ -- if (cpu_base->hang_detected) -+ if (!__hrtimer_hres_active(cpu_base) || cpu_base->hang_detected) - return; - - tick_program_event(cpu_base->expires_next, 1); -@@ -848,7 +848,6 @@ static void __remove_hrtimer(struct hrti - if (!timerqueue_del(&base->active, &timer->node)) - cpu_base->active_bases &= ~(1 << base->index); - --#ifdef CONFIG_HIGH_RES_TIMERS - /* - * Note: If reprogram is false we do not update - * cpu_base->next_timer. This happens when we remove the first -@@ -859,7 +858,6 @@ static void __remove_hrtimer(struct hrti - */ - if (reprogram && timer == cpu_base->next_timer) - hrtimer_force_reprogram(cpu_base, 1); --#endif - } - - /* diff --git a/debian/patches/features/all/rt/0019-tracing-Add-hist-trigger-timestamp-support.patch b/debian/patches/features/all/rt/0019-tracing-Add-hist-trigger-timestamp-support.patch index 7194150fc..34f0b1f9a 100644 --- a/debian/patches/features/all/rt/0019-tracing-Add-hist-trigger-timestamp-support.patch +++ b/debian/patches/features/all/rt/0019-tracing-Add-hist-trigger-timestamp-support.patch @@ -1,7 +1,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:45 -0600 Subject: [PATCH 19/48] tracing: Add hist trigger timestamp support -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Add support for a timestamp event field. This is actually a 'pseudo-' event field in that it behaves like it's part of the event record, but diff --git a/debian/patches/features/all/rt/0019-tracing-Generalize-per-element-hist-trigger-data.patch b/debian/patches/features/all/rt/0019-tracing-Generalize-per-element-hist-trigger-data.patch deleted file mode 100644 index 86f78d1bb..000000000 --- a/debian/patches/features/all/rt/0019-tracing-Generalize-per-element-hist-trigger-data.patch +++ /dev/null @@ -1,155 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:53 -0600 -Subject: [PATCH 19/37] tracing: Generalize per-element hist trigger data -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Up until now, hist triggers only needed per-element support for saving -'comm' data, which was saved directly as a private data pointer. - -In anticipation of the need to save other data besides 'comm', add a -new hist_elt_data struct for the purpose, and switch the current -'comm'-related code over to that. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 76 ++++++++++++++++++++++----------------- - 1 file changed, 43 insertions(+), 33 deletions(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -289,6 +289,10 @@ static struct hist_field *find_var(struc - return NULL; - } - -+struct hist_elt_data { -+ char *comm; -+}; -+ - static const char *hist_field_name(struct hist_field *field, - unsigned int level) - { -@@ -503,45 +507,61 @@ static inline void save_comm(char *comm, - memcpy(comm, task->comm, TASK_COMM_LEN); - } - --static void hist_trigger_elt_comm_free(struct tracing_map_elt *elt) -+static void hist_elt_data_free(struct hist_elt_data *elt_data) -+{ -+ kfree(elt_data->comm); -+ kfree(elt_data); -+} -+ -+static void hist_trigger_elt_data_free(struct tracing_map_elt *elt) - { -- kfree((char *)elt->private_data); -+ struct hist_elt_data *elt_data = elt->private_data; -+ -+ hist_elt_data_free(elt_data); - } - --static int hist_trigger_elt_comm_alloc(struct tracing_map_elt *elt) -+static int hist_trigger_elt_data_alloc(struct tracing_map_elt *elt) - { - struct hist_trigger_data *hist_data = elt->map->private_data; -+ unsigned int size = TASK_COMM_LEN; -+ struct hist_elt_data *elt_data; - struct hist_field *key_field; - unsigned int i; - -+ elt_data = kzalloc(sizeof(*elt_data), GFP_KERNEL); -+ if (!elt_data) -+ return -ENOMEM; -+ - for_each_hist_key_field(i, hist_data) { - key_field = hist_data->fields[i]; - - if (key_field->flags & HIST_FIELD_FL_EXECNAME) { -- unsigned int size = TASK_COMM_LEN + 1; -- -- elt->private_data = kzalloc(size, GFP_KERNEL); -- if (!elt->private_data) -+ elt_data->comm = kzalloc(size, GFP_KERNEL); -+ if (!elt_data->comm) { -+ kfree(elt_data); - return -ENOMEM; -+ } - break; - } - } - -+ elt->private_data = elt_data; -+ - return 0; - } - --static void hist_trigger_elt_comm_init(struct tracing_map_elt *elt) -+static void hist_trigger_elt_data_init(struct tracing_map_elt *elt) - { -- char *comm = elt->private_data; -+ struct hist_elt_data *elt_data = elt->private_data; - -- if (comm) -- save_comm(comm, current); -+ if (elt_data->comm) -+ save_comm(elt_data->comm, current); - } - --static const struct tracing_map_ops hist_trigger_elt_comm_ops = { -- .elt_alloc = hist_trigger_elt_comm_alloc, -- .elt_free = hist_trigger_elt_comm_free, -- .elt_init = hist_trigger_elt_comm_init, -+static const struct tracing_map_ops hist_trigger_elt_data_ops = { -+ .elt_alloc = hist_trigger_elt_data_alloc, -+ .elt_free = hist_trigger_elt_data_free, -+ .elt_init = hist_trigger_elt_data_init, - }; - - static const char *get_hist_field_flags(struct hist_field *hist_field) -@@ -1484,21 +1504,6 @@ static int create_tracing_map_fields(str - return 0; - } - --static bool need_tracing_map_ops(struct hist_trigger_data *hist_data) --{ -- struct hist_field *key_field; -- unsigned int i; -- -- for_each_hist_key_field(i, hist_data) { -- key_field = hist_data->fields[i]; -- -- if (key_field->flags & HIST_FIELD_FL_EXECNAME) -- return true; -- } -- -- return false; --} -- - static struct hist_trigger_data * - create_hist_data(unsigned int map_bits, - struct hist_trigger_attrs *attrs, -@@ -1524,8 +1529,7 @@ create_hist_data(unsigned int map_bits, - if (ret) - goto free; - -- if (need_tracing_map_ops(hist_data)) -- map_ops = &hist_trigger_elt_comm_ops; -+ map_ops = &hist_trigger_elt_data_ops; - - hist_data->map = tracing_map_create(map_bits, hist_data->key_size, - map_ops, hist_data); -@@ -1713,7 +1717,13 @@ hist_trigger_entry_print(struct seq_file - seq_printf(m, "%s: [%llx] %-55s", field_name, - uval, str); - } else if (key_field->flags & HIST_FIELD_FL_EXECNAME) { -- char *comm = elt->private_data; -+ struct hist_elt_data *elt_data = elt->private_data; -+ char *comm; -+ -+ if (WARN_ON_ONCE(!elt_data)) -+ return; -+ -+ comm = elt_data->comm; - - uval = *(u64 *)(key + key_field->offset); - seq_printf(m, "%s: %-16s[%10llu]", field_name, diff --git a/debian/patches/features/all/rt/0020-hrtimer-Unify-handling-of-remote-enqueue.patch b/debian/patches/features/all/rt/0020-hrtimer-Unify-handling-of-remote-enqueue.patch deleted file mode 100644 index 833a2a8f3..000000000 --- a/debian/patches/features/all/rt/0020-hrtimer-Unify-handling-of-remote-enqueue.patch +++ /dev/null @@ -1,149 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:13:09 +0100 -Subject: [PATCH 20/29] hrtimer: Unify handling of remote enqueue -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -hrtimer_reprogram() is conditionally invoked from hrtimer_start_range_ns() -when hrtimer_cpu_base.hres_active is true. - -In the !hres_active case there is a special condition for the nohz_active -case: - - If the newly enqueued timer expires before the first expiring timer on a - remote CPU then the remote CPU needs to be notified and woken up from a - NOHZ idle sleep to take the new first expiring timer into account. - -Previous changes have already established the prerequisites to make the -remote enqueue behaviour the same whether high resolution mode is active or -not: - - If the to be enqueued timer expires before the first expiring timer on a - remote CPU, then it cannot be enqueued there. - -This was done for the high resolution mode because there is no way to -access the remote CPU timer hardware. The same is true for NOHZ, but was -handled differently by unconditionally enqueuing the timer and waking up -the remote CPU so it can reprogram its timer. Again there is no compelling -reason for this difference. - -hrtimer_check_target(), which makes the 'can remote enqueue' decision is -already unconditional, but not yet functional because nothing updates -hrtimer_cpu_base.expires_next in the !hres_active case. - -To unify this the following changes are required: - - 1) Make the store of the new first expiry time unconditonal in - hrtimer_reprogram() and check __hrtimer_hres_active() before proceeding - to the actual hardware access. This check also lets the compiler - eliminate the rest of the function in case of CONFIG_HIGH_RES_TIMERS=n. - - 2) Invoke hrtimer_reprogram() unconditionally from - hrtimer_start_range_ns() - - 3) Remove the remote wakeup special case for the !high_res && nohz_active - case. - -Confine the timers_nohz_active static key to timer.c which is the only user -now. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/time/hrtimer.c | 18 ++++++------------ - kernel/time/tick-internal.h | 6 ------ - kernel/time/timer.c | 9 ++++++++- - 3 files changed, 14 insertions(+), 19 deletions(-) - ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -687,21 +687,24 @@ static void hrtimer_reprogram(struct hrt - - /* Update the pointer to the next expiring timer */ - cpu_base->next_timer = timer; -+ cpu_base->expires_next = expires; - - /* -+ * If hres is not active, hardware does not have to be -+ * programmed yet. -+ * - * If a hang was detected in the last timer interrupt then we - * do not schedule a timer which is earlier than the expiry - * which we enforced in the hang detection. We want the system - * to make progress. - */ -- if (cpu_base->hang_detected) -+ if (!__hrtimer_hres_active(cpu_base) || cpu_base->hang_detected) - return; - - /* - * Program the timer hardware. We enforce the expiry for - * events which are already in the past. - */ -- cpu_base->expires_next = expires; - tick_program_event(expires, 1); - } - -@@ -940,16 +943,7 @@ void hrtimer_start_range_ns(struct hrtim - if (!leftmost) - goto unlock; - -- if (!hrtimer_is_hres_active(timer)) { -- /* -- * Kick to reschedule the next tick to handle the new timer -- * on dynticks target. -- */ -- if (is_timers_nohz_active()) -- wake_up_nohz_cpu(new_base->cpu_base->cpu); -- } else { -- hrtimer_reprogram(timer, new_base); -- } -+ hrtimer_reprogram(timer, new_base); - unlock: - unlock_hrtimer_base(timer, &flags); - } ---- a/kernel/time/tick-internal.h -+++ b/kernel/time/tick-internal.h -@@ -151,18 +151,12 @@ static inline void tick_nohz_init(void) - #ifdef CONFIG_NO_HZ_COMMON - extern unsigned long tick_nohz_active; - extern void timers_update_nohz(void); --extern struct static_key_false timers_nohz_active; --static inline bool is_timers_nohz_active(void) --{ -- return static_branch_unlikely(&timers_nohz_active); --} - # ifdef CONFIG_SMP - extern struct static_key_false timers_migration_enabled; - # endif - #else /* CONFIG_NO_HZ_COMMON */ - static inline void timers_update_nohz(void) { } - #define tick_nohz_active (0) --static inline bool is_timers_nohz_active(void) { return false; } - #endif - - DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases); ---- a/kernel/time/timer.c -+++ b/kernel/time/timer.c -@@ -210,7 +210,7 @@ static DEFINE_PER_CPU(struct timer_base, - - #ifdef CONFIG_NO_HZ_COMMON - --DEFINE_STATIC_KEY_FALSE(timers_nohz_active); -+static DEFINE_STATIC_KEY_FALSE(timers_nohz_active); - static DEFINE_MUTEX(timer_keys_mutex); - - static void timer_update_keys(struct work_struct *work); -@@ -260,6 +260,13 @@ int timer_migration_handler(struct ctl_t - mutex_unlock(&timer_keys_mutex); - return ret; - } -+ -+static inline bool is_timers_nohz_active(void) -+{ -+ return static_branch_unlikely(&timers_nohz_active); -+} -+#else -+static inline bool is_timers_nohz_active(void) { return false; } - #endif /* NO_HZ_COMMON */ - - static unsigned long round_jiffies_common(unsigned long j, int cpu, diff --git a/debian/patches/features/all/rt/0020-tracing-Add-per-element-variable-support-to-tracing_.patch b/debian/patches/features/all/rt/0020-tracing-Add-per-element-variable-support-to-tracing_.patch index c1d443179..909886416 100644 --- a/debian/patches/features/all/rt/0020-tracing-Add-per-element-variable-support-to-tracing_.patch +++ b/debian/patches/features/all/rt/0020-tracing-Add-per-element-variable-support-to-tracing_.patch @@ -2,7 +2,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:46 -0600 Subject: [PATCH 20/48] tracing: Add per-element variable support to tracing_map -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz In order to allow information to be passed between trace events, add support for per-element variables to tracing_map. This provides a diff --git a/debian/patches/features/all/rt/0020-tracing-Pass-tracing_map_elt-to-hist_field-accessor-.patch b/debian/patches/features/all/rt/0020-tracing-Pass-tracing_map_elt-to-hist_field-accessor-.patch deleted file mode 100644 index 54b72d372..000000000 --- a/debian/patches/features/all/rt/0020-tracing-Pass-tracing_map_elt-to-hist_field-accessor-.patch +++ /dev/null @@ -1,222 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:54 -0600 -Subject: [PATCH 20/37] tracing: Pass tracing_map_elt to hist_field accessor - functions -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Some accessor functions, such as for variable references, require -access to a corrsponding tracing_map_elt. - -Add a tracing_map_elt param to the function signature and update the -accessor functions accordingly. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 91 ++++++++++++++++++++++++--------------- - 1 file changed, 57 insertions(+), 34 deletions(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -26,8 +26,10 @@ - - struct hist_field; - --typedef u64 (*hist_field_fn_t) (struct hist_field *field, void *event, -- struct ring_buffer_event *rbe); -+typedef u64 (*hist_field_fn_t) (struct hist_field *field, -+ struct tracing_map_elt *elt, -+ struct ring_buffer_event *rbe, -+ void *event); - - #define HIST_FIELD_OPERANDS_MAX 2 - #define HIST_FIELDS_MAX (TRACING_MAP_FIELDS_MAX + TRACING_MAP_VARS_MAX) -@@ -59,28 +61,36 @@ struct hist_field { - char *name; - }; - --static u64 hist_field_none(struct hist_field *field, void *event, -- struct ring_buffer_event *rbe) -+static u64 hist_field_none(struct hist_field *field, -+ struct tracing_map_elt *elt, -+ struct ring_buffer_event *rbe, -+ void *event) - { - return 0; - } - --static u64 hist_field_counter(struct hist_field *field, void *event, -- struct ring_buffer_event *rbe) -+static u64 hist_field_counter(struct hist_field *field, -+ struct tracing_map_elt *elt, -+ struct ring_buffer_event *rbe, -+ void *event) - { - return 1; - } - --static u64 hist_field_string(struct hist_field *hist_field, void *event, -- struct ring_buffer_event *rbe) -+static u64 hist_field_string(struct hist_field *hist_field, -+ struct tracing_map_elt *elt, -+ struct ring_buffer_event *rbe, -+ void *event) - { - char *addr = (char *)(event + hist_field->field->offset); - - return (u64)(unsigned long)addr; - } - --static u64 hist_field_dynstring(struct hist_field *hist_field, void *event, -- struct ring_buffer_event *rbe) -+static u64 hist_field_dynstring(struct hist_field *hist_field, -+ struct tracing_map_elt *elt, -+ struct ring_buffer_event *rbe, -+ void *event) - { - u32 str_item = *(u32 *)(event + hist_field->field->offset); - int str_loc = str_item & 0xffff; -@@ -89,54 +99,64 @@ static u64 hist_field_dynstring(struct h - return (u64)(unsigned long)addr; - } - --static u64 hist_field_pstring(struct hist_field *hist_field, void *event, -- struct ring_buffer_event *rbe) -+static u64 hist_field_pstring(struct hist_field *hist_field, -+ struct tracing_map_elt *elt, -+ struct ring_buffer_event *rbe, -+ void *event) - { - char **addr = (char **)(event + hist_field->field->offset); - - return (u64)(unsigned long)*addr; - } - --static u64 hist_field_log2(struct hist_field *hist_field, void *event, -- struct ring_buffer_event *rbe) -+static u64 hist_field_log2(struct hist_field *hist_field, -+ struct tracing_map_elt *elt, -+ struct ring_buffer_event *rbe, -+ void *event) - { - struct hist_field *operand = hist_field->operands[0]; - -- u64 val = operand->fn(operand, event, rbe); -+ u64 val = operand->fn(operand, elt, rbe, event); - - return (u64) ilog2(roundup_pow_of_two(val)); - } - --static u64 hist_field_plus(struct hist_field *hist_field, void *event, -- struct ring_buffer_event *rbe) -+static u64 hist_field_plus(struct hist_field *hist_field, -+ struct tracing_map_elt *elt, -+ struct ring_buffer_event *rbe, -+ void *event) - { - struct hist_field *operand1 = hist_field->operands[0]; - struct hist_field *operand2 = hist_field->operands[1]; - -- u64 val1 = operand1->fn(operand1, event, rbe); -- u64 val2 = operand2->fn(operand2, event, rbe); -+ u64 val1 = operand1->fn(operand1, elt, rbe, event); -+ u64 val2 = operand2->fn(operand2, elt, rbe, event); - - return val1 + val2; - } - --static u64 hist_field_minus(struct hist_field *hist_field, void *event, -- struct ring_buffer_event *rbe) -+static u64 hist_field_minus(struct hist_field *hist_field, -+ struct tracing_map_elt *elt, -+ struct ring_buffer_event *rbe, -+ void *event) - { - struct hist_field *operand1 = hist_field->operands[0]; - struct hist_field *operand2 = hist_field->operands[1]; - -- u64 val1 = operand1->fn(operand1, event, rbe); -- u64 val2 = operand2->fn(operand2, event, rbe); -+ u64 val1 = operand1->fn(operand1, elt, rbe, event); -+ u64 val2 = operand2->fn(operand2, elt, rbe, event); - - return val1 - val2; - } - --static u64 hist_field_unary_minus(struct hist_field *hist_field, void *event, -- struct ring_buffer_event *rbe) -+static u64 hist_field_unary_minus(struct hist_field *hist_field, -+ struct tracing_map_elt *elt, -+ struct ring_buffer_event *rbe, -+ void *event) - { - struct hist_field *operand = hist_field->operands[0]; - -- s64 sval = (s64)operand->fn(operand, event, rbe); -+ s64 sval = (s64)operand->fn(operand, elt, rbe, event); - u64 val = (u64)-sval; - - return val; -@@ -144,8 +164,9 @@ static u64 hist_field_unary_minus(struct - - #define DEFINE_HIST_FIELD_FN(type) \ - static u64 hist_field_##type(struct hist_field *hist_field, \ -- void *event, \ -- struct ring_buffer_event *rbe) \ -+ struct tracing_map_elt *elt, \ -+ struct ring_buffer_event *rbe, \ -+ void *event) \ - { \ - type *addr = (type *)(event + hist_field->field->offset); \ - \ -@@ -233,8 +254,10 @@ struct hist_trigger_data { - bool remove; - }; - --static u64 hist_field_timestamp(struct hist_field *hist_field, void *event, -- struct ring_buffer_event *rbe) -+static u64 hist_field_timestamp(struct hist_field *hist_field, -+ struct tracing_map_elt *elt, -+ struct ring_buffer_event *rbe, -+ void *event) - { - struct hist_trigger_data *hist_data = hist_field->hist_data; - struct trace_array *tr = hist_data->event_file->tr; -@@ -1570,7 +1593,7 @@ static void hist_trigger_elt_update(stru - - for_each_hist_val_field(i, hist_data) { - hist_field = hist_data->fields[i]; -- hist_val = hist_field->fn(hist_field, rec, rbe); -+ hist_val = hist_field->fn(hist_field, elt, rbe, rec); - if (hist_field->flags & HIST_FIELD_FL_VAR) { - var_idx = hist_field->var.idx; - tracing_map_set_var(elt, var_idx, hist_val); -@@ -1582,7 +1605,7 @@ static void hist_trigger_elt_update(stru - for_each_hist_key_field(i, hist_data) { - hist_field = hist_data->fields[i]; - if (hist_field->flags & HIST_FIELD_FL_VAR) { -- hist_val = hist_field->fn(hist_field, rec, rbe); -+ hist_val = hist_field->fn(hist_field, elt, rbe, rec); - var_idx = hist_field->var.idx; - tracing_map_set_var(elt, var_idx, hist_val); - } -@@ -1620,9 +1643,9 @@ static void event_hist_trigger(struct ev - bool use_compound_key = (hist_data->n_keys > 1); - unsigned long entries[HIST_STACKTRACE_DEPTH]; - char compound_key[HIST_KEY_SIZE_MAX]; -+ struct tracing_map_elt *elt = NULL; - struct stack_trace stacktrace; - struct hist_field *key_field; -- struct tracing_map_elt *elt; - u64 field_contents; - void *key = NULL; - unsigned int i; -@@ -1643,7 +1666,7 @@ static void event_hist_trigger(struct ev - - key = entries; - } else { -- field_contents = key_field->fn(key_field, rec, rbe); -+ field_contents = key_field->fn(key_field, elt, rbe, rec); - if (key_field->flags & HIST_FIELD_FL_STRING) { - key = (void *)(unsigned long)field_contents; - use_compound_key = true; diff --git a/debian/patches/features/all/rt/0021-hrtimer-Make-remote-enqueue-decision-less-restrictiv.patch b/debian/patches/features/all/rt/0021-hrtimer-Make-remote-enqueue-decision-less-restrictiv.patch deleted file mode 100644 index 52d668709..000000000 --- a/debian/patches/features/all/rt/0021-hrtimer-Make-remote-enqueue-decision-less-restrictiv.patch +++ /dev/null @@ -1,32 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:13:10 +0100 -Subject: [PATCH 21/29] hrtimer: Make remote enqueue decision less restrictive -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The current decision whether a timer can be queued on a remote CPU checks -for timer->expiry <= remote_cpu_base.expires_next. - -This is too restrictive because a timer with the same expiry time as an -existing timer will be enqueued on right-hand size of the existing timer -inside the rbtree, i.e. behind the first expiring timer. - -So its safe to allow enqueuing timers with the same expiry time as the -first expiring timer on a remote CPU base. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/time/hrtimer.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -168,7 +168,7 @@ hrtimer_check_target(struct hrtimer *tim - ktime_t expires; - - expires = ktime_sub(hrtimer_get_expires(timer), new_base->offset); -- return expires <= new_base->cpu_base->expires_next; -+ return expires < new_base->cpu_base->expires_next; - } - - static inline diff --git a/debian/patches/features/all/rt/0021-tracing-Add-hist_data-member-to-hist_field.patch b/debian/patches/features/all/rt/0021-tracing-Add-hist_data-member-to-hist_field.patch index 3f73a2317..e0041209a 100644 --- a/debian/patches/features/all/rt/0021-tracing-Add-hist_data-member-to-hist_field.patch +++ b/debian/patches/features/all/rt/0021-tracing-Add-hist_data-member-to-hist_field.patch @@ -1,7 +1,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:47 -0600 Subject: [PATCH 21/48] tracing: Add hist_data member to hist_field -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Allow hist_data access via hist_field. Some users of hist_fields require or will require more access to the associated hist_data. diff --git a/debian/patches/features/all/rt/0021-tracing-Add-hist_field-type-field.patch b/debian/patches/features/all/rt/0021-tracing-Add-hist_field-type-field.patch deleted file mode 100644 index f4c923c89..000000000 --- a/debian/patches/features/all/rt/0021-tracing-Add-hist_field-type-field.patch +++ /dev/null @@ -1,114 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:55 -0600 -Subject: [PATCH 21/37] tracing: Add hist_field 'type' field -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Future support for synthetic events requires hist_field 'type' -information, so add a field for that. - -Also, make other hist_field attribute usage consistent (size, -is_signed, etc). - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 33 +++++++++++++++++++++++++++++++++ - 1 file changed, 33 insertions(+) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -54,6 +54,7 @@ struct hist_field { - unsigned int size; - unsigned int offset; - unsigned int is_signed; -+ const char *type; - struct hist_field *operands[HIST_FIELD_OPERANDS_MAX]; - struct hist_trigger_data *hist_data; - struct hist_var var; -@@ -717,6 +718,7 @@ static void destroy_hist_field(struct hi - - kfree(hist_field->var.name); - kfree(hist_field->name); -+ kfree(hist_field->type); - - kfree(hist_field); - } -@@ -742,6 +744,10 @@ static struct hist_field *create_hist_fi - - if (flags & HIST_FIELD_FL_HITCOUNT) { - hist_field->fn = hist_field_counter; -+ hist_field->size = sizeof(u64); -+ hist_field->type = kstrdup("u64", GFP_KERNEL); -+ if (!hist_field->type) -+ goto free; - goto out; - } - -@@ -755,12 +761,18 @@ static struct hist_field *create_hist_fi - hist_field->fn = hist_field_log2; - hist_field->operands[0] = create_hist_field(hist_data, field, fl, NULL); - hist_field->size = hist_field->operands[0]->size; -+ hist_field->type = kstrdup(hist_field->operands[0]->type, GFP_KERNEL); -+ if (!hist_field->type) -+ goto free; - goto out; - } - - if (flags & HIST_FIELD_FL_TIMESTAMP) { - hist_field->fn = hist_field_timestamp; - hist_field->size = sizeof(u64); -+ hist_field->type = kstrdup("u64", GFP_KERNEL); -+ if (!hist_field->type) -+ goto free; - goto out; - } - -@@ -770,6 +782,11 @@ static struct hist_field *create_hist_fi - if (is_string_field(field)) { - flags |= HIST_FIELD_FL_STRING; - -+ hist_field->size = MAX_FILTER_STR_VAL; -+ hist_field->type = kstrdup(field->type, GFP_KERNEL); -+ if (!hist_field->type) -+ goto free; -+ - if (field->filter_type == FILTER_STATIC_STRING) - hist_field->fn = hist_field_string; - else if (field->filter_type == FILTER_DYN_STRING) -@@ -777,6 +794,12 @@ static struct hist_field *create_hist_fi - else - hist_field->fn = hist_field_pstring; - } else { -+ hist_field->size = field->size; -+ hist_field->is_signed = field->is_signed; -+ hist_field->type = kstrdup(field->type, GFP_KERNEL); -+ if (!hist_field->type) -+ goto free; -+ - hist_field->fn = select_value_fn(field->size, - field->is_signed); - if (!hist_field->fn) { -@@ -949,6 +972,11 @@ static struct hist_field *parse_unary(st - expr->operands[0] = operand1; - expr->operator = FIELD_OP_UNARY_MINUS; - expr->name = expr_str(expr, 0); -+ expr->type = kstrdup(operand1->type, GFP_KERNEL); -+ if (!expr->type) { -+ ret = -ENOMEM; -+ goto free; -+ } - - return expr; - free: -@@ -1042,6 +1070,11 @@ static struct hist_field *parse_expr(str - expr->operands[1] = operand2; - expr->operator = field_op; - expr->name = expr_str(expr, 0); -+ expr->type = kstrdup(operand1->type, GFP_KERNEL); -+ if (!expr->type) { -+ ret = -ENOMEM; -+ goto free; -+ } - - switch (field_op) { - case FIELD_OP_MINUS: diff --git a/debian/patches/features/all/rt/0022-hrtimer-Remove-base-argument-from-hrtimer_reprogram.patch b/debian/patches/features/all/rt/0022-hrtimer-Remove-base-argument-from-hrtimer_reprogram.patch deleted file mode 100644 index f64eb1d83..000000000 --- a/debian/patches/features/all/rt/0022-hrtimer-Remove-base-argument-from-hrtimer_reprogram.patch +++ /dev/null @@ -1,50 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:13:11 +0100 -Subject: [PATCH 22/29] hrtimer: Remove base argument from hrtimer_reprogram() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -hrtimer_reprogram() must have access to the hrtimer_clock_base of the new -first expiring timer to access hrtimer_clock_base.offset for adjusting the -expiry time to CLOCK_MONOTONIC. This is required to evaluate whether the -new left most timer in the hrtimer_clock_base is the first expiring timer -of all clock bases in a hrtimer_cpu_base. - -The only user of hrtimer_reprogram() is hrtimer_start_range_ns(), which has -a pointer to hrtimer_clock_base already and hands it in as an argument. But -hrtimer_start_range_ns() will be split for the upcoming support for softirq -based hrtimers to avoid code duplication and will lose the direct access to -the clock base pointer. - -Instead of handing in timer and timer->base as an argument remove the base -argument from hrtimer_reprogram() and retrieve the clock base internally. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/time/hrtimer.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -650,10 +650,10 @@ static inline void retrigger_next_event( - * - * Called with interrupts disabled and base->cpu_base.lock held - */ --static void hrtimer_reprogram(struct hrtimer *timer, -- struct hrtimer_clock_base *base) -+static void hrtimer_reprogram(struct hrtimer *timer) - { - struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases); -+ struct hrtimer_clock_base *base = timer->base; - ktime_t expires = ktime_sub(hrtimer_get_expires(timer), base->offset); - - WARN_ON_ONCE(hrtimer_get_expires_tv64(timer) < 0); -@@ -943,7 +943,7 @@ void hrtimer_start_range_ns(struct hrtim - if (!leftmost) - goto unlock; - -- hrtimer_reprogram(timer, new_base); -+ hrtimer_reprogram(timer); - unlock: - unlock_hrtimer_base(timer, &flags); - } diff --git a/debian/patches/features/all/rt/0022-tracing-Add-usecs-modifier-for-hist-trigger-timestam.patch b/debian/patches/features/all/rt/0022-tracing-Add-usecs-modifier-for-hist-trigger-timestam.patch index 3d4ffcd87..f8fdcbd6f 100644 --- a/debian/patches/features/all/rt/0022-tracing-Add-usecs-modifier-for-hist-trigger-timestam.patch +++ b/debian/patches/features/all/rt/0022-tracing-Add-usecs-modifier-for-hist-trigger-timestam.patch @@ -1,7 +1,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:48 -0600 Subject: [PATCH 22/48] tracing: Add usecs modifier for hist trigger timestamps -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Appending .usecs onto a common_timestamp field will cause the timestamp value to be in microseconds instead of the default diff --git a/debian/patches/features/all/rt/0022-tracing-Add-variable-reference-handling-to-hist-trig.patch b/debian/patches/features/all/rt/0022-tracing-Add-variable-reference-handling-to-hist-trig.patch deleted file mode 100644 index 2c0359b6d..000000000 --- a/debian/patches/features/all/rt/0022-tracing-Add-variable-reference-handling-to-hist-trig.patch +++ /dev/null @@ -1,952 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:56 -0600 -Subject: [PATCH 22/37] tracing: Add variable reference handling to hist - triggers -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Add the necessary infrastructure to allow the variables defined on one -event to be referenced in another. This allows variables set by a -previous event to be referenced and used in expressions combining the -variable values saved by that previous event and the event fields of -the current event. For example, here's how a latency can be -calculated and saved into yet another variable named 'wakeup_lat': - - # echo 'hist:keys=pid,prio:ts0=common_timestamp ... - # echo 'hist:keys=next_pid:wakeup_lat=common_timestamp-$ts0 ... - -In the first event, the event's timetamp is saved into the variable -ts0. In the next line, ts0 is subtracted from the second event's -timestamp to produce the latency. - -Further users of variable references will be described in subsequent -patches, such as for instance how the 'wakeup_lat' variable above can -be displayed in a latency histogram. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace.c | 2 - kernel/trace/trace.h | 3 - kernel/trace/trace_events_hist.c | 661 +++++++++++++++++++++++++++++++++++- - kernel/trace/trace_events_trigger.c | 6 - 4 files changed, 656 insertions(+), 16 deletions(-) - ---- a/kernel/trace/trace.c -+++ b/kernel/trace/trace.c -@@ -7788,6 +7788,7 @@ static int instance_mkdir(const char *na - - INIT_LIST_HEAD(&tr->systems); - INIT_LIST_HEAD(&tr->events); -+ INIT_LIST_HEAD(&tr->hist_vars); - - if (allocate_trace_buffers(tr, trace_buf_size) < 0) - goto out_free_tr; -@@ -8538,6 +8539,7 @@ ssize_t trace_parse_run_command(struct f - - INIT_LIST_HEAD(&global_trace.systems); - INIT_LIST_HEAD(&global_trace.events); -+ INIT_LIST_HEAD(&global_trace.hist_vars); - list_add(&global_trace.list, &ftrace_trace_arrays); - - apply_trace_boot_options(); ---- a/kernel/trace/trace.h -+++ b/kernel/trace/trace.h -@@ -274,6 +274,7 @@ struct trace_array { - int function_enabled; - #endif - int time_stamp_abs_ref; -+ struct list_head hist_vars; - }; - - enum { -@@ -1550,6 +1551,8 @@ extern void pause_named_trigger(struct e - extern void unpause_named_trigger(struct event_trigger_data *data); - extern void set_named_trigger_data(struct event_trigger_data *data, - struct event_trigger_data *named_data); -+extern struct event_trigger_data * -+get_named_trigger_data(struct event_trigger_data *data); - extern int register_event_command(struct event_command *cmd); - extern int unregister_event_command(struct event_command *cmd); - extern int register_trigger_hist_enable_disable_cmds(void); ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -59,7 +59,12 @@ struct hist_field { - struct hist_trigger_data *hist_data; - struct hist_var var; - enum field_op_id operator; -+ char *system; -+ char *event_name; - char *name; -+ unsigned int var_idx; -+ unsigned int var_ref_idx; -+ bool read_once; - }; - - static u64 hist_field_none(struct hist_field *field, -@@ -214,6 +219,7 @@ enum hist_field_flags { - HIST_FIELD_FL_TIMESTAMP_USECS = 1 << 11, - HIST_FIELD_FL_VAR = 1 << 12, - HIST_FIELD_FL_EXPR = 1 << 13, -+ HIST_FIELD_FL_VAR_REF = 1 << 14, - }; - - struct var_defs { -@@ -253,6 +259,8 @@ struct hist_trigger_data { - struct tracing_map *map; - bool enable_timestamps; - bool remove; -+ struct hist_field *var_refs[TRACING_MAP_VARS_MAX]; -+ unsigned int n_var_refs; - }; - - static u64 hist_field_timestamp(struct hist_field *hist_field, -@@ -271,6 +279,214 @@ static u64 hist_field_timestamp(struct h - return ts; - } - -+struct hist_var_data { -+ struct list_head list; -+ struct hist_trigger_data *hist_data; -+}; -+ -+static struct hist_field * -+check_field_for_var_ref(struct hist_field *hist_field, -+ struct hist_trigger_data *var_data, -+ unsigned int var_idx) -+{ -+ struct hist_field *found = NULL; -+ -+ if (hist_field && hist_field->flags & HIST_FIELD_FL_VAR_REF) { -+ if (hist_field->var.idx == var_idx && -+ hist_field->var.hist_data == var_data) { -+ found = hist_field; -+ } -+ } -+ -+ return found; -+} -+ -+static struct hist_field * -+check_field_for_var_refs(struct hist_trigger_data *hist_data, -+ struct hist_field *hist_field, -+ struct hist_trigger_data *var_data, -+ unsigned int var_idx, -+ unsigned int level) -+{ -+ struct hist_field *found = NULL; -+ unsigned int i; -+ -+ if (level > 3) -+ return found; -+ -+ if (!hist_field) -+ return found; -+ -+ found = check_field_for_var_ref(hist_field, var_data, var_idx); -+ if (found) -+ return found; -+ -+ for (i = 0; i < HIST_FIELD_OPERANDS_MAX; i++) { -+ struct hist_field *operand; -+ -+ operand = hist_field->operands[i]; -+ found = check_field_for_var_refs(hist_data, operand, var_data, -+ var_idx, level + 1); -+ if (found) -+ return found; -+ } -+ -+ return found; -+} -+ -+static struct hist_field *find_var_ref(struct hist_trigger_data *hist_data, -+ struct hist_trigger_data *var_data, -+ unsigned int var_idx) -+{ -+ struct hist_field *hist_field, *found = NULL; -+ unsigned int i; -+ -+ for_each_hist_field(i, hist_data) { -+ hist_field = hist_data->fields[i]; -+ found = check_field_for_var_refs(hist_data, hist_field, -+ var_data, var_idx, 0); -+ if (found) -+ return found; -+ } -+ -+ return found; -+} -+ -+static struct hist_field *find_any_var_ref(struct hist_trigger_data *hist_data, -+ unsigned int var_idx) -+{ -+ struct trace_array *tr = hist_data->event_file->tr; -+ struct hist_field *found = NULL; -+ struct hist_var_data *var_data; -+ -+ list_for_each_entry(var_data, &tr->hist_vars, list) { -+ if (var_data->hist_data == hist_data) -+ continue; -+ found = find_var_ref(var_data->hist_data, hist_data, var_idx); -+ if (found) -+ break; -+ } -+ -+ return found; -+} -+ -+static bool check_var_refs(struct hist_trigger_data *hist_data) -+{ -+ struct hist_field *field; -+ bool found = false; -+ int i; -+ -+ for_each_hist_field(i, hist_data) { -+ field = hist_data->fields[i]; -+ if (field && field->flags & HIST_FIELD_FL_VAR) { -+ if (find_any_var_ref(hist_data, field->var.idx)) { -+ found = true; -+ break; -+ } -+ } -+ } -+ -+ return found; -+} -+ -+static struct hist_var_data *find_hist_vars(struct hist_trigger_data *hist_data) -+{ -+ struct trace_array *tr = hist_data->event_file->tr; -+ struct hist_var_data *var_data, *found = NULL; -+ -+ list_for_each_entry(var_data, &tr->hist_vars, list) { -+ if (var_data->hist_data == hist_data) { -+ found = var_data; -+ break; -+ } -+ } -+ -+ return found; -+} -+ -+static bool field_has_hist_vars(struct hist_field *hist_field, -+ unsigned int level) -+{ -+ int i; -+ -+ if (level > 3) -+ return false; -+ -+ if (!hist_field) -+ return false; -+ -+ if (hist_field->flags & HIST_FIELD_FL_VAR || -+ hist_field->flags & HIST_FIELD_FL_VAR_REF) -+ return true; -+ -+ for (i = 0; i < HIST_FIELD_OPERANDS_MAX; i++) { -+ struct hist_field *operand; -+ -+ operand = hist_field->operands[i]; -+ if (field_has_hist_vars(operand, level + 1)) -+ return true; -+ } -+ -+ return false; -+} -+ -+static bool has_hist_vars(struct hist_trigger_data *hist_data) -+{ -+ struct hist_field *hist_field; -+ int i; -+ -+ for_each_hist_field(i, hist_data) { -+ hist_field = hist_data->fields[i]; -+ if (field_has_hist_vars(hist_field, 0)) -+ return true; -+ } -+ -+ return false; -+} -+ -+static int save_hist_vars(struct hist_trigger_data *hist_data) -+{ -+ struct trace_array *tr = hist_data->event_file->tr; -+ struct hist_var_data *var_data; -+ -+ var_data = find_hist_vars(hist_data); -+ if (var_data) -+ return 0; -+ -+ if (trace_array_get(tr) < 0) -+ return -ENODEV; -+ -+ var_data = kzalloc(sizeof(*var_data), GFP_KERNEL); -+ if (!var_data) { -+ trace_array_put(tr); -+ return -ENOMEM; -+ } -+ -+ var_data->hist_data = hist_data; -+ list_add(&var_data->list, &tr->hist_vars); -+ -+ return 0; -+} -+ -+static void remove_hist_vars(struct hist_trigger_data *hist_data) -+{ -+ struct trace_array *tr = hist_data->event_file->tr; -+ struct hist_var_data *var_data; -+ -+ var_data = find_hist_vars(hist_data); -+ if (!var_data) -+ return; -+ -+ if (WARN_ON(check_var_refs(hist_data))) -+ return; -+ -+ list_del(&var_data->list); -+ -+ kfree(var_data); -+ -+ trace_array_put(tr); -+} -+ - static struct hist_field *find_var_field(struct hist_trigger_data *hist_data, - const char *var_name) - { -@@ -313,10 +529,137 @@ static struct hist_field *find_var(struc - return NULL; - } - -+static struct trace_event_file *find_var_file(struct trace_array *tr, -+ char *system, -+ char *event_name, -+ char *var_name) -+{ -+ struct hist_trigger_data *var_hist_data; -+ struct hist_var_data *var_data; -+ struct trace_event_file *file, *found = NULL; -+ -+ if (system) -+ return find_event_file(tr, system, event_name); -+ -+ list_for_each_entry(var_data, &tr->hist_vars, list) { -+ var_hist_data = var_data->hist_data; -+ file = var_hist_data->event_file; -+ if (file == found) -+ continue; -+ -+ if (find_var_field(var_hist_data, var_name)) { -+ if (found) -+ return NULL; -+ -+ found = file; -+ } -+ } -+ -+ return found; -+} -+ -+static struct hist_field *find_file_var(struct trace_event_file *file, -+ const char *var_name) -+{ -+ struct hist_trigger_data *test_data; -+ struct event_trigger_data *test; -+ struct hist_field *hist_field; -+ -+ list_for_each_entry_rcu(test, &file->triggers, list) { -+ if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) { -+ test_data = test->private_data; -+ hist_field = find_var_field(test_data, var_name); -+ if (hist_field) -+ return hist_field; -+ } -+ } -+ -+ return NULL; -+} -+ -+static struct hist_field *find_event_var(struct hist_trigger_data *hist_data, -+ char *system, -+ char *event_name, -+ char *var_name) -+{ -+ struct trace_array *tr = hist_data->event_file->tr; -+ struct hist_field *hist_field = NULL; -+ struct trace_event_file *file; -+ -+ file = find_var_file(tr, system, event_name, var_name); -+ if (!file) -+ return NULL; -+ -+ hist_field = find_file_var(file, var_name); -+ -+ return hist_field; -+} -+ - struct hist_elt_data { - char *comm; -+ u64 *var_ref_vals; - }; - -+static u64 hist_field_var_ref(struct hist_field *hist_field, -+ struct tracing_map_elt *elt, -+ struct ring_buffer_event *rbe, -+ void *event) -+{ -+ struct hist_elt_data *elt_data; -+ u64 var_val = 0; -+ -+ elt_data = elt->private_data; -+ var_val = elt_data->var_ref_vals[hist_field->var_ref_idx]; -+ -+ return var_val; -+} -+ -+static bool resolve_var_refs(struct hist_trigger_data *hist_data, void *key, -+ u64 *var_ref_vals, bool self) -+{ -+ struct hist_trigger_data *var_data; -+ struct tracing_map_elt *var_elt; -+ struct hist_field *hist_field; -+ unsigned int i, var_idx; -+ bool resolved = true; -+ u64 var_val = 0; -+ -+ for (i = 0; i < hist_data->n_var_refs; i++) { -+ hist_field = hist_data->var_refs[i]; -+ var_idx = hist_field->var.idx; -+ var_data = hist_field->var.hist_data; -+ -+ if (var_data == NULL) { -+ resolved = false; -+ break; -+ } -+ -+ if ((self && var_data != hist_data) || -+ (!self && var_data == hist_data)) -+ continue; -+ -+ var_elt = tracing_map_lookup(var_data->map, key); -+ if (!var_elt) { -+ resolved = false; -+ break; -+ } -+ -+ if (!tracing_map_var_set(var_elt, var_idx)) { -+ resolved = false; -+ break; -+ } -+ -+ if (self || !hist_field->read_once) -+ var_val = tracing_map_read_var(var_elt, var_idx); -+ else -+ var_val = tracing_map_read_var_once(var_elt, var_idx); -+ -+ var_ref_vals[i] = var_val; -+ } -+ -+ return resolved; -+} -+ - static const char *hist_field_name(struct hist_field *field, - unsigned int level) - { -@@ -331,8 +674,20 @@ static const char *hist_field_name(struc - field_name = hist_field_name(field->operands[0], ++level); - else if (field->flags & HIST_FIELD_FL_TIMESTAMP) - field_name = "common_timestamp"; -- else if (field->flags & HIST_FIELD_FL_EXPR) -- field_name = field->name; -+ else if (field->flags & HIST_FIELD_FL_EXPR || -+ field->flags & HIST_FIELD_FL_VAR_REF) { -+ if (field->system) { -+ static char full_name[MAX_FILTER_STR_VAL]; -+ -+ strcat(full_name, field->system); -+ strcat(full_name, "."); -+ strcat(full_name, field->event_name); -+ strcat(full_name, "."); -+ strcat(full_name, field->name); -+ field_name = full_name; -+ } else -+ field_name = field->name; -+ } - - if (field_name == NULL) - field_name = ""; -@@ -612,6 +967,9 @@ static const char *get_hist_field_flags( - - static void expr_field_str(struct hist_field *field, char *expr) - { -+ if (field->flags & HIST_FIELD_FL_VAR_REF) -+ strcat(expr, "$"); -+ - strcat(expr, hist_field_name(field, 0)); - - if (field->flags) { -@@ -742,6 +1100,11 @@ static struct hist_field *create_hist_fi - if (flags & HIST_FIELD_FL_EXPR) - goto out; /* caller will populate */ - -+ if (flags & HIST_FIELD_FL_VAR_REF) { -+ hist_field->fn = hist_field_var_ref; -+ goto out; -+ } -+ - if (flags & HIST_FIELD_FL_HITCOUNT) { - hist_field->fn = hist_field_counter; - hist_field->size = sizeof(u64); -@@ -835,6 +1198,144 @@ static void destroy_hist_fields(struct h - } - } - -+static int init_var_ref(struct hist_field *ref_field, -+ struct hist_field *var_field, -+ char *system, char *event_name) -+{ -+ int err = 0; -+ -+ ref_field->var.idx = var_field->var.idx; -+ ref_field->var.hist_data = var_field->hist_data; -+ ref_field->size = var_field->size; -+ ref_field->is_signed = var_field->is_signed; -+ ref_field->flags |= var_field->flags & -+ (HIST_FIELD_FL_TIMESTAMP | HIST_FIELD_FL_TIMESTAMP_USECS); -+ -+ if (system) { -+ ref_field->system = kstrdup(system, GFP_KERNEL); -+ if (!ref_field->system) -+ return -ENOMEM; -+ } -+ -+ if (event_name) { -+ ref_field->event_name = kstrdup(event_name, GFP_KERNEL); -+ if (!ref_field->event_name) { -+ err = -ENOMEM; -+ goto free; -+ } -+ } -+ -+ ref_field->name = kstrdup(var_field->var.name, GFP_KERNEL); -+ if (!ref_field->name) { -+ err = -ENOMEM; -+ goto free; -+ } -+ -+ ref_field->type = kstrdup(var_field->type, GFP_KERNEL); -+ if (!ref_field->type) { -+ err = -ENOMEM; -+ goto free; -+ } -+ out: -+ return err; -+ free: -+ kfree(ref_field->system); -+ kfree(ref_field->event_name); -+ kfree(ref_field->name); -+ -+ goto out; -+} -+ -+static struct hist_field *create_var_ref(struct hist_field *var_field, -+ char *system, char *event_name) -+{ -+ unsigned long flags = HIST_FIELD_FL_VAR_REF; -+ struct hist_field *ref_field; -+ -+ ref_field = create_hist_field(var_field->hist_data, NULL, flags, NULL); -+ if (ref_field) { -+ if (init_var_ref(ref_field, var_field, system, event_name)) { -+ destroy_hist_field(ref_field, 0); -+ return NULL; -+ } -+ } -+ -+ return ref_field; -+} -+ -+static bool is_var_ref(char *var_name) -+{ -+ if (!var_name || strlen(var_name) < 2 || var_name[0] != '$') -+ return false; -+ -+ return true; -+} -+ -+static char *field_name_from_var(struct hist_trigger_data *hist_data, -+ char *var_name) -+{ -+ char *name, *field; -+ unsigned int i; -+ -+ for (i = 0; i < hist_data->attrs->var_defs.n_vars; i++) { -+ name = hist_data->attrs->var_defs.name[i]; -+ -+ if (strcmp(var_name, name) == 0) { -+ field = hist_data->attrs->var_defs.expr[i]; -+ if (contains_operator(field) || is_var_ref(field)) -+ continue; -+ return field; -+ } -+ } -+ -+ return NULL; -+} -+ -+static char *local_field_var_ref(struct hist_trigger_data *hist_data, -+ char *system, char *event_name, -+ char *var_name) -+{ -+ struct trace_event_call *call; -+ -+ if (system && event_name) { -+ call = hist_data->event_file->event_call; -+ -+ if (strcmp(system, call->class->system) != 0) -+ return NULL; -+ -+ if (strcmp(event_name, trace_event_name(call)) != 0) -+ return NULL; -+ } -+ -+ if (!!system != !!event_name) -+ return NULL; -+ -+ if (!is_var_ref(var_name)) -+ return NULL; -+ -+ var_name++; -+ -+ return field_name_from_var(hist_data, var_name); -+} -+ -+static struct hist_field *parse_var_ref(struct hist_trigger_data *hist_data, -+ char *system, char *event_name, -+ char *var_name) -+{ -+ struct hist_field *var_field = NULL, *ref_field = NULL; -+ -+ if (!is_var_ref(var_name)) -+ return NULL; -+ -+ var_name++; -+ -+ var_field = find_event_var(hist_data, system, event_name, var_name); -+ if (var_field) -+ ref_field = create_var_ref(var_field, system, event_name); -+ -+ return ref_field; -+} -+ - static struct ftrace_event_field * - parse_field(struct hist_trigger_data *hist_data, struct trace_event_file *file, - char *field_str, unsigned long *flags) -@@ -891,10 +1392,40 @@ static struct hist_field *parse_atom(str - struct trace_event_file *file, char *str, - unsigned long *flags, char *var_name) - { -+ char *s, *ref_system = NULL, *ref_event = NULL, *ref_var = str; - struct ftrace_event_field *field = NULL; - struct hist_field *hist_field = NULL; - int ret = 0; - -+ s = strchr(str, '.'); -+ if (s) { -+ s = strchr(++s, '.'); -+ if (s) { -+ ref_system = strsep(&str, "."); -+ if (!str) { -+ ret = -EINVAL; -+ goto out; -+ } -+ ref_event = strsep(&str, "."); -+ if (!str) { -+ ret = -EINVAL; -+ goto out; -+ } -+ ref_var = str; -+ } -+ } -+ -+ s = local_field_var_ref(hist_data, ref_system, ref_event, ref_var); -+ if (!s) { -+ hist_field = parse_var_ref(hist_data, ref_system, ref_event, ref_var); -+ if (hist_field) { -+ hist_data->var_refs[hist_data->n_var_refs] = hist_field; -+ hist_field->var_ref_idx = hist_data->n_var_refs++; -+ return hist_field; -+ } -+ } else -+ str = s; -+ - field = parse_field(hist_data, file, str, flags); - if (IS_ERR(field)) { - ret = PTR_ERR(field); -@@ -1066,6 +1597,9 @@ static struct hist_field *parse_expr(str - goto free; - } - -+ operand1->read_once = true; -+ operand2->read_once = true; -+ - expr->operands[0] = operand1; - expr->operands[1] = operand2; - expr->operator = field_op; -@@ -1238,6 +1772,12 @@ static int create_key_field(struct hist_ - goto out; - } - -+ if (hist_field->flags & HIST_FIELD_FL_VAR_REF) { -+ destroy_hist_field(hist_field, 0); -+ ret = -EINVAL; -+ goto out; -+ } -+ - key_size = hist_field->size; - } - -@@ -1576,6 +2116,7 @@ create_hist_data(unsigned int map_bits, - - hist_data->attrs = attrs; - hist_data->remove = remove; -+ hist_data->event_file = file; - - ret = create_hist_fields(hist_data, file); - if (ret) -@@ -1598,12 +2139,6 @@ create_hist_data(unsigned int map_bits, - ret = create_tracing_map_fields(hist_data); - if (ret) - goto free; -- -- ret = tracing_map_init(hist_data->map); -- if (ret) -- goto free; -- -- hist_data->event_file = file; - out: - return hist_data; - free: -@@ -1618,12 +2153,17 @@ create_hist_data(unsigned int map_bits, - - static void hist_trigger_elt_update(struct hist_trigger_data *hist_data, - struct tracing_map_elt *elt, void *rec, -- struct ring_buffer_event *rbe) -+ struct ring_buffer_event *rbe, -+ u64 *var_ref_vals) - { -+ struct hist_elt_data *elt_data; - struct hist_field *hist_field; - unsigned int i, var_idx; - u64 hist_val; - -+ elt_data = elt->private_data; -+ elt_data->var_ref_vals = var_ref_vals; -+ - for_each_hist_val_field(i, hist_data) { - hist_field = hist_data->fields[i]; - hist_val = hist_field->fn(hist_field, elt, rbe, rec); -@@ -1675,6 +2215,7 @@ static void event_hist_trigger(struct ev - struct hist_trigger_data *hist_data = data->private_data; - bool use_compound_key = (hist_data->n_keys > 1); - unsigned long entries[HIST_STACKTRACE_DEPTH]; -+ u64 var_ref_vals[TRACING_MAP_VARS_MAX]; - char compound_key[HIST_KEY_SIZE_MAX]; - struct tracing_map_elt *elt = NULL; - struct stack_trace stacktrace; -@@ -1714,9 +2255,15 @@ static void event_hist_trigger(struct ev - if (use_compound_key) - key = compound_key; - -+ if (hist_data->n_var_refs && -+ !resolve_var_refs(hist_data, key, var_ref_vals, false)) -+ return; -+ - elt = tracing_map_insert(hist_data->map, key); -- if (elt) -- hist_trigger_elt_update(hist_data, elt, rec, rbe); -+ if (!elt) -+ return; -+ -+ hist_trigger_elt_update(hist_data, elt, rec, rbe, var_ref_vals); - } - - static void hist_trigger_stacktrace_print(struct seq_file *m, -@@ -1933,8 +2480,11 @@ static void hist_field_print(struct seq_ - - if (hist_field->flags & HIST_FIELD_FL_TIMESTAMP) - seq_puts(m, "common_timestamp"); -- else if (field_name) -+ else if (field_name) { -+ if (hist_field->flags & HIST_FIELD_FL_VAR_REF) -+ seq_putc(m, '$'); - seq_printf(m, "%s", field_name); -+ } - - if (hist_field->flags) { - const char *flags_str = get_hist_field_flags(hist_field); -@@ -2074,7 +2624,11 @@ static void event_hist_trigger_free(stru - if (!data->ref) { - if (data->name) - del_named_trigger(data); -+ - trigger_data_free(data); -+ -+ remove_hist_vars(hist_data); -+ - destroy_hist_data(hist_data); - } - } -@@ -2287,23 +2841,55 @@ static int hist_register_trigger(char *g - goto out; - } - -- list_add_rcu(&data->list, &file->triggers); - ret++; - -- update_cond_flag(file); -- - if (hist_data->enable_timestamps) - tracing_set_time_stamp_abs(file->tr, true); -+ out: -+ return ret; -+} -+ -+static int hist_trigger_enable(struct event_trigger_data *data, -+ struct trace_event_file *file) -+{ -+ int ret = 0; -+ -+ list_add_tail_rcu(&data->list, &file->triggers); -+ -+ update_cond_flag(file); - - if (trace_event_trigger_enable_disable(file, 1) < 0) { - list_del_rcu(&data->list); - update_cond_flag(file); - ret--; - } -- out: -+ - return ret; - } - -+static bool hist_trigger_check_refs(struct event_trigger_data *data, -+ struct trace_event_file *file) -+{ -+ struct hist_trigger_data *hist_data = data->private_data; -+ struct event_trigger_data *test, *named_data = NULL; -+ -+ if (hist_data->attrs->name) -+ named_data = find_named_trigger(hist_data->attrs->name); -+ -+ list_for_each_entry_rcu(test, &file->triggers, list) { -+ if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) { -+ if (!hist_trigger_match(data, test, named_data, false)) -+ continue; -+ hist_data = test->private_data; -+ if (check_var_refs(hist_data)) -+ return true; -+ break; -+ } -+ } -+ -+ return false; -+} -+ - static void hist_unregister_trigger(char *glob, struct event_trigger_ops *ops, - struct event_trigger_data *data, - struct trace_event_file *file) -@@ -2336,11 +2922,30 @@ static void hist_unregister_trigger(char - } - } - -+static bool hist_file_check_refs(struct trace_event_file *file) -+{ -+ struct hist_trigger_data *hist_data; -+ struct event_trigger_data *test; -+ -+ list_for_each_entry_rcu(test, &file->triggers, list) { -+ if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) { -+ hist_data = test->private_data; -+ if (check_var_refs(hist_data)) -+ return true; -+ } -+ } -+ -+ return false; -+} -+ - static void hist_unreg_all(struct trace_event_file *file) - { - struct event_trigger_data *test, *n; - struct hist_trigger_data *hist_data; - -+ if (hist_file_check_refs(file)) -+ return; -+ - list_for_each_entry_safe(test, n, &file->triggers, list) { - if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) { - hist_data = test->private_data; -@@ -2416,6 +3021,11 @@ static int event_hist_trigger_func(struc - } - - if (remove) { -+ if (hist_trigger_check_refs(trigger_data, file)) { -+ ret = -EBUSY; -+ goto out_free; -+ } -+ - cmd_ops->unreg(glob+1, trigger_ops, trigger_data, file); - ret = 0; - goto out_free; -@@ -2433,14 +3043,33 @@ static int event_hist_trigger_func(struc - goto out_free; - } else if (ret < 0) - goto out_free; -+ -+ if (get_named_trigger_data(trigger_data)) -+ goto enable; -+ -+ if (has_hist_vars(hist_data)) -+ save_hist_vars(hist_data); -+ -+ ret = tracing_map_init(hist_data->map); -+ if (ret) -+ goto out_unreg; -+enable: -+ ret = hist_trigger_enable(trigger_data, file); -+ if (ret) -+ goto out_unreg; -+ - /* Just return zero, not the number of registered triggers */ - ret = 0; - out: - return ret; -+ out_unreg: -+ cmd_ops->unreg(glob+1, trigger_ops, trigger_data, file); - out_free: - if (cmd_ops->set_filter) - cmd_ops->set_filter(NULL, trigger_data, NULL); - -+ remove_hist_vars(hist_data); -+ - kfree(trigger_data); - - destroy_hist_data(hist_data); ---- a/kernel/trace/trace_events_trigger.c -+++ b/kernel/trace/trace_events_trigger.c -@@ -909,6 +909,12 @@ void set_named_trigger_data(struct event - data->named_data = named_data; - } - -+struct event_trigger_data * -+get_named_trigger_data(struct event_trigger_data *data) -+{ -+ return data->named_data; -+} -+ - static void - traceon_trigger(struct event_trigger_data *data, void *rec, - struct ring_buffer_event *event) diff --git a/debian/patches/features/all/rt/0023-hrtimer-Split-hrtimer_start_range_ns.patch b/debian/patches/features/all/rt/0023-hrtimer-Split-hrtimer_start_range_ns.patch deleted file mode 100644 index 8e332f605..000000000 --- a/debian/patches/features/all/rt/0023-hrtimer-Split-hrtimer_start_range_ns.patch +++ /dev/null @@ -1,76 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:13:12 +0100 -Subject: [PATCH 23/29] hrtimer: Split hrtimer_start_range_ns() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Preparatory patch for softirq based hrtimers to avoid code duplication. No -functional change. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/time/hrtimer.c | 44 ++++++++++++++++++++++++-------------------- - 1 file changed, 24 insertions(+), 20 deletions(-) - ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -909,22 +909,11 @@ static inline ktime_t hrtimer_update_low - return tim; - } - --/** -- * hrtimer_start_range_ns - (re)start an hrtimer -- * @timer: the timer to be added -- * @tim: expiry time -- * @delta_ns: "slack" range for the timer -- * @mode: timer mode: absolute (HRTIMER_MODE_ABS) or -- * relative (HRTIMER_MODE_REL), and pinned (HRTIMER_MODE_PINNED) -- */ --void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, -- u64 delta_ns, const enum hrtimer_mode mode) -+static int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, -+ u64 delta_ns, const enum hrtimer_mode mode, -+ struct hrtimer_clock_base *base) - { -- struct hrtimer_clock_base *base, *new_base; -- unsigned long flags; -- int leftmost; -- -- base = lock_hrtimer_base(timer, &flags); -+ struct hrtimer_clock_base *new_base; - - /* Remove an active timer from the queue: */ - remove_hrtimer(timer, base, true); -@@ -939,12 +928,27 @@ void hrtimer_start_range_ns(struct hrtim - /* Switch the timer base, if necessary: */ - new_base = switch_hrtimer_base(timer, base, mode & HRTIMER_MODE_PINNED); - -- leftmost = enqueue_hrtimer(timer, new_base, mode); -- if (!leftmost) -- goto unlock; -+ return enqueue_hrtimer(timer, new_base, mode); -+} -+/** -+ * hrtimer_start_range_ns - (re)start an hrtimer -+ * @timer: the timer to be added -+ * @tim: expiry time -+ * @delta_ns: "slack" range for the timer -+ * @mode: timer mode: absolute (HRTIMER_MODE_ABS) or -+ * relative (HRTIMER_MODE_REL), and pinned (HRTIMER_MODE_PINNED) -+ */ -+void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, -+ u64 delta_ns, const enum hrtimer_mode mode) -+{ -+ struct hrtimer_clock_base *base; -+ unsigned long flags; -+ -+ base = lock_hrtimer_base(timer, &flags); -+ -+ if (__hrtimer_start_range_ns(timer, tim, delta_ns, mode, base)) -+ hrtimer_reprogram(timer); - -- hrtimer_reprogram(timer); --unlock: - unlock_hrtimer_base(timer, &flags); - } - EXPORT_SYMBOL_GPL(hrtimer_start_range_ns); diff --git a/debian/patches/features/all/rt/0023-tracing-Add-hist-trigger-action-hook.patch b/debian/patches/features/all/rt/0023-tracing-Add-hist-trigger-action-hook.patch deleted file mode 100644 index 72f9e56e5..000000000 --- a/debian/patches/features/all/rt/0023-tracing-Add-hist-trigger-action-hook.patch +++ /dev/null @@ -1,212 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:57 -0600 -Subject: [PATCH 23/37] tracing: Add hist trigger action hook -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Add a hook for executing extra actions whenever a histogram entry is -added or updated. - -The default 'action' when a hist entry is added to a histogram is to -update the set of values associated with it. Some applications may -want to perform additional actions at that point, such as generate -another event, or compare and save a maximum. - -Add a simple framework for doing that; specific actions will be -implemented on top of it in later patches. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 106 ++++++++++++++++++++++++++++++++++++++- - 1 file changed, 104 insertions(+), 2 deletions(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -33,6 +33,7 @@ typedef u64 (*hist_field_fn_t) (struct h - - #define HIST_FIELD_OPERANDS_MAX 2 - #define HIST_FIELDS_MAX (TRACING_MAP_FIELDS_MAX + TRACING_MAP_VARS_MAX) -+#define HIST_ACTIONS_MAX 8 - - enum field_op_id { - FIELD_OP_NONE, -@@ -242,6 +243,9 @@ struct hist_trigger_attrs { - char *assignment_str[TRACING_MAP_VARS_MAX]; - unsigned int n_assignments; - -+ char *action_str[HIST_ACTIONS_MAX]; -+ unsigned int n_actions; -+ - struct var_defs var_defs; - }; - -@@ -261,6 +265,21 @@ struct hist_trigger_data { - bool remove; - struct hist_field *var_refs[TRACING_MAP_VARS_MAX]; - unsigned int n_var_refs; -+ -+ struct action_data *actions[HIST_ACTIONS_MAX]; -+ unsigned int n_actions; -+}; -+ -+struct action_data; -+ -+typedef void (*action_fn_t) (struct hist_trigger_data *hist_data, -+ struct tracing_map_elt *elt, void *rec, -+ struct ring_buffer_event *rbe, -+ struct action_data *data, u64 *var_ref_vals); -+ -+struct action_data { -+ action_fn_t fn; -+ unsigned int var_ref_idx; - }; - - static u64 hist_field_timestamp(struct hist_field *hist_field, -@@ -764,6 +783,9 @@ static void destroy_hist_trigger_attrs(s - for (i = 0; i < attrs->n_assignments; i++) - kfree(attrs->assignment_str[i]); - -+ for (i = 0; i < attrs->n_actions; i++) -+ kfree(attrs->action_str[i]); -+ - kfree(attrs->name); - kfree(attrs->sort_key_str); - kfree(attrs->keys_str); -@@ -771,6 +793,16 @@ static void destroy_hist_trigger_attrs(s - kfree(attrs); - } - -+static int parse_action(char *str, struct hist_trigger_attrs *attrs) -+{ -+ int ret = 0; -+ -+ if (attrs->n_actions >= HIST_ACTIONS_MAX) -+ return ret; -+ -+ return ret; -+} -+ - static int parse_assignment(char *str, struct hist_trigger_attrs *attrs) - { - int ret = 0; -@@ -854,8 +886,9 @@ static struct hist_trigger_attrs *parse_ - else if (strcmp(str, "clear") == 0) - attrs->clear = true; - else { -- ret = -EINVAL; -- goto free; -+ ret = parse_action(str, attrs); -+ if (ret) -+ goto free; - } - } - -@@ -2047,11 +2080,55 @@ static int create_sort_keys(struct hist_ - return ret; - } - -+static void destroy_actions(struct hist_trigger_data *hist_data) -+{ -+ unsigned int i; -+ -+ for (i = 0; i < hist_data->n_actions; i++) { -+ struct action_data *data = hist_data->actions[i]; -+ -+ kfree(data); -+ } -+} -+ -+static int parse_actions(struct hist_trigger_data *hist_data) -+{ -+ unsigned int i; -+ int ret = 0; -+ char *str; -+ -+ for (i = 0; i < hist_data->attrs->n_actions; i++) { -+ str = hist_data->attrs->action_str[i]; -+ } -+ -+ return ret; -+} -+ -+static int create_actions(struct hist_trigger_data *hist_data, -+ struct trace_event_file *file) -+{ -+ struct action_data *data; -+ unsigned int i; -+ int ret = 0; -+ -+ for (i = 0; i < hist_data->attrs->n_actions; i++) { -+ data = hist_data->actions[i]; -+ } -+ -+ return ret; -+} -+ - static void destroy_hist_data(struct hist_trigger_data *hist_data) - { -+ if (!hist_data) -+ return; -+ - destroy_hist_trigger_attrs(hist_data->attrs); - destroy_hist_fields(hist_data); - tracing_map_destroy(hist_data->map); -+ -+ destroy_actions(hist_data); -+ - kfree(hist_data); - } - -@@ -2118,6 +2195,10 @@ create_hist_data(unsigned int map_bits, - hist_data->remove = remove; - hist_data->event_file = file; - -+ ret = parse_actions(hist_data); -+ if (ret) -+ goto free; -+ - ret = create_hist_fields(hist_data, file); - if (ret) - goto free; -@@ -2209,6 +2290,20 @@ static inline void add_to_key(char *comp - memcpy(compound_key + key_field->offset, key, size); - } - -+static void -+hist_trigger_actions(struct hist_trigger_data *hist_data, -+ struct tracing_map_elt *elt, void *rec, -+ struct ring_buffer_event *rbe, u64 *var_ref_vals) -+{ -+ struct action_data *data; -+ unsigned int i; -+ -+ for (i = 0; i < hist_data->n_actions; i++) { -+ data = hist_data->actions[i]; -+ data->fn(hist_data, elt, rec, rbe, data, var_ref_vals); -+ } -+} -+ - static void event_hist_trigger(struct event_trigger_data *data, void *rec, - struct ring_buffer_event *rbe) - { -@@ -2264,6 +2359,9 @@ static void event_hist_trigger(struct ev - return; - - hist_trigger_elt_update(hist_data, elt, rec, rbe, var_ref_vals); -+ -+ if (resolve_var_refs(hist_data, key, var_ref_vals, true)) -+ hist_trigger_actions(hist_data, elt, rec, rbe, var_ref_vals); - } - - static void hist_trigger_stacktrace_print(struct seq_file *m, -@@ -3050,6 +3148,10 @@ static int event_hist_trigger_func(struc - if (has_hist_vars(hist_data)) - save_hist_vars(hist_data); - -+ ret = create_actions(hist_data, file); -+ if (ret) -+ goto out_unreg; -+ - ret = tracing_map_init(hist_data->map); - if (ret) - goto out_unreg; diff --git a/debian/patches/features/all/rt/0023-tracing-Add-variable-support-to-hist-triggers.patch b/debian/patches/features/all/rt/0023-tracing-Add-variable-support-to-hist-triggers.patch index 70f5ef0c5..28e6c4ee5 100644 --- a/debian/patches/features/all/rt/0023-tracing-Add-variable-support-to-hist-triggers.patch +++ b/debian/patches/features/all/rt/0023-tracing-Add-variable-support-to-hist-triggers.patch @@ -1,7 +1,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:49 -0600 Subject: [PATCH 23/48] tracing: Add variable support to hist triggers -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Add support for saving the value of a current event's event field by assigning it to a variable that can be read by a subsequent event. diff --git a/debian/patches/features/all/rt/0024-hrtimer-Split-__hrtimer_get_next_event.patch b/debian/patches/features/all/rt/0024-hrtimer-Split-__hrtimer_get_next_event.patch deleted file mode 100644 index fa19ff3b0..000000000 --- a/debian/patches/features/all/rt/0024-hrtimer-Split-__hrtimer_get_next_event.patch +++ /dev/null @@ -1,53 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:13:13 +0100 -Subject: [PATCH 24/29] hrtimer: Split __hrtimer_get_next_event() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Preparatory patch for softirq based hrtimers to avoid code duplication. No -functional change. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/time/hrtimer.c | 20 ++++++++++++++++---- - 1 file changed, 16 insertions(+), 4 deletions(-) - ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -459,13 +459,13 @@ static struct hrtimer_clock_base * - while ((base = __next_base((cpu_base), &(active)))) - - #if defined(CONFIG_NO_HZ_COMMON) || defined(CONFIG_HIGH_RES_TIMERS) --static ktime_t __hrtimer_get_next_event(struct hrtimer_cpu_base *cpu_base) -+static ktime_t __hrtimer_next_event_base(struct hrtimer_cpu_base *cpu_base, -+ unsigned int active, -+ ktime_t expires_next) - { - struct hrtimer_clock_base *base; -- unsigned int active = cpu_base->active_bases; -- ktime_t expires, expires_next = KTIME_MAX; -+ ktime_t expires; - -- cpu_base->next_timer = NULL; - for_each_active_base(base, cpu_base, active) { - struct timerqueue_node *next; - struct hrtimer *timer; -@@ -487,6 +487,18 @@ static ktime_t __hrtimer_get_next_event( - expires_next = 0; - return expires_next; - } -+ -+static ktime_t __hrtimer_get_next_event(struct hrtimer_cpu_base *cpu_base) -+{ -+ unsigned int active = cpu_base->active_bases; -+ ktime_t expires_next = KTIME_MAX; -+ -+ cpu_base->next_timer = NULL; -+ -+ expires_next = __hrtimer_next_event_base(cpu_base, active, expires_next); -+ -+ return expires_next; -+} - #endif - - static inline ktime_t hrtimer_update_base(struct hrtimer_cpu_base *base) diff --git a/debian/patches/features/all/rt/0024-tracing-Account-for-variables-in-named-trigger-compa.patch b/debian/patches/features/all/rt/0024-tracing-Account-for-variables-in-named-trigger-compa.patch index 5ddd0a754..a3738a04f 100644 --- a/debian/patches/features/all/rt/0024-tracing-Account-for-variables-in-named-trigger-compa.patch +++ b/debian/patches/features/all/rt/0024-tracing-Account-for-variables-in-named-trigger-compa.patch @@ -2,7 +2,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:50 -0600 Subject: [PATCH 24/48] tracing: Account for variables in named trigger compatibility -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Named triggers must also have the same set of variables in order to be considered compatible - update the trigger match test to account for diff --git a/debian/patches/features/all/rt/0024-tracing-Add-support-for-synthetic-events.patch b/debian/patches/features/all/rt/0024-tracing-Add-support-for-synthetic-events.patch deleted file mode 100644 index bf1324a14..000000000 --- a/debian/patches/features/all/rt/0024-tracing-Add-support-for-synthetic-events.patch +++ /dev/null @@ -1,1038 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:58 -0600 -Subject: [PATCH 24/37] tracing: Add support for 'synthetic' events -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Synthetic events are user-defined events generated from hist trigger -variables saved from one or more other events. - -To define a synthetic event, the user writes a simple specification -consisting of the name of the new event along with one or more -variables and their type(s), to the tracing/synthetic_events file. - -For instance, the following creates a new event named 'wakeup_latency' -with 3 fields: lat, pid, and prio: - - # echo 'wakeup_latency u64 lat; pid_t pid; int prio' >> \ - /sys/kernel/debug/tracing/synthetic_events - -Reading the tracing/synthetic_events file lists all the -currently-defined synthetic events, in this case the event we defined -above: - - # cat /sys/kernel/debug/tracing/synthetic_events - wakeup_latency u64 lat; pid_t pid; int prio - -At this point, the synthetic event is ready to use, and a histogram -can be defined using it: - - # echo 'hist:keys=pid,prio,lat.log2:sort=pid,lat' >> \ - /sys/kernel/debug/tracing/events/synthetic/wakeup_latency/trigger - -The new event is created under the tracing/events/synthetic/ directory -and looks and behaves just like any other event: - - # ls /sys/kernel/debug/tracing/events/synthetic/wakeup_latency - enable filter format hist id trigger - -Although a histogram can be defined for it, nothing will happen until -an action tracing that event via the trace_synth() function occurs. -The trace_synth() function is very similar to all the other trace_* -invocations spread throughout the kernel, except in this case the -trace_ function and its corresponding tracepoint isn't statically -generated but defined by the user at run-time. - -How this can be automatically hooked up via a hist trigger 'action' is -discussed in a subsequent patch. - -Signed-off-by: Tom Zanussi -[fix noderef.cocci warnings, sizeof pointer for kcalloc of event->fields] -Signed-off-by: Fengguang Wu -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 895 ++++++++++++++++++++++++++++++++++++++- - 1 file changed, 893 insertions(+), 2 deletions(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -20,10 +20,16 @@ - #include - #include - #include -+#include - - #include "tracing_map.h" - #include "trace.h" - -+#define SYNTH_SYSTEM "synthetic" -+#define SYNTH_FIELDS_MAX 16 -+ -+#define STR_VAR_LEN_MAX 32 /* must be multiple of sizeof(u64) */ -+ - struct hist_field; - - typedef u64 (*hist_field_fn_t) (struct hist_field *field, -@@ -270,6 +276,26 @@ struct hist_trigger_data { - unsigned int n_actions; - }; - -+struct synth_field { -+ char *type; -+ char *name; -+ size_t size; -+ bool is_signed; -+ bool is_string; -+}; -+ -+struct synth_event { -+ struct list_head list; -+ int ref; -+ char *name; -+ struct synth_field **fields; -+ unsigned int n_fields; -+ unsigned int n_u64; -+ struct trace_event_class class; -+ struct trace_event_call call; -+ struct tracepoint *tp; -+}; -+ - struct action_data; - - typedef void (*action_fn_t) (struct hist_trigger_data *hist_data, -@@ -282,6 +308,790 @@ struct action_data { - unsigned int var_ref_idx; - }; - -+static LIST_HEAD(synth_event_list); -+static DEFINE_MUTEX(synth_event_mutex); -+ -+struct synth_trace_event { -+ struct trace_entry ent; -+ u64 fields[]; -+}; -+ -+static int synth_event_define_fields(struct trace_event_call *call) -+{ -+ struct synth_trace_event trace; -+ int offset = offsetof(typeof(trace), fields); -+ struct synth_event *event = call->data; -+ unsigned int i, size, n_u64; -+ char *name, *type; -+ bool is_signed; -+ int ret = 0; -+ -+ for (i = 0, n_u64 = 0; i < event->n_fields; i++) { -+ size = event->fields[i]->size; -+ is_signed = event->fields[i]->is_signed; -+ type = event->fields[i]->type; -+ name = event->fields[i]->name; -+ ret = trace_define_field(call, type, name, offset, size, -+ is_signed, FILTER_OTHER); -+ if (ret) -+ break; -+ -+ if (event->fields[i]->is_string) { -+ offset += STR_VAR_LEN_MAX; -+ n_u64 += STR_VAR_LEN_MAX / sizeof(u64); -+ } else { -+ offset += sizeof(u64); -+ n_u64++; -+ } -+ } -+ -+ event->n_u64 = n_u64; -+ -+ return ret; -+} -+ -+static bool synth_field_signed(char *type) -+{ -+ if (strncmp(type, "u", 1) == 0) -+ return false; -+ -+ return true; -+} -+ -+static int synth_field_is_string(char *type) -+{ -+ if (strstr(type, "char[") != NULL) -+ return true; -+ -+ return false; -+} -+ -+static int synth_field_string_size(char *type) -+{ -+ char buf[4], *end, *start; -+ unsigned int len; -+ int size, err; -+ -+ start = strstr(type, "char["); -+ if (start == NULL) -+ return -EINVAL; -+ start += strlen("char["); -+ -+ end = strchr(type, ']'); -+ if (!end || end < start) -+ return -EINVAL; -+ -+ len = end - start; -+ if (len > 3) -+ return -EINVAL; -+ -+ strncpy(buf, start, len); -+ buf[len] = '\0'; -+ -+ err = kstrtouint(buf, 0, &size); -+ if (err) -+ return err; -+ -+ if (size > STR_VAR_LEN_MAX) -+ return -EINVAL; -+ -+ return size; -+} -+ -+static int synth_field_size(char *type) -+{ -+ int size = 0; -+ -+ if (strcmp(type, "s64") == 0) -+ size = sizeof(s64); -+ else if (strcmp(type, "u64") == 0) -+ size = sizeof(u64); -+ else if (strcmp(type, "s32") == 0) -+ size = sizeof(s32); -+ else if (strcmp(type, "u32") == 0) -+ size = sizeof(u32); -+ else if (strcmp(type, "s16") == 0) -+ size = sizeof(s16); -+ else if (strcmp(type, "u16") == 0) -+ size = sizeof(u16); -+ else if (strcmp(type, "s8") == 0) -+ size = sizeof(s8); -+ else if (strcmp(type, "u8") == 0) -+ size = sizeof(u8); -+ else if (strcmp(type, "char") == 0) -+ size = sizeof(char); -+ else if (strcmp(type, "unsigned char") == 0) -+ size = sizeof(unsigned char); -+ else if (strcmp(type, "int") == 0) -+ size = sizeof(int); -+ else if (strcmp(type, "unsigned int") == 0) -+ size = sizeof(unsigned int); -+ else if (strcmp(type, "long") == 0) -+ size = sizeof(long); -+ else if (strcmp(type, "unsigned long") == 0) -+ size = sizeof(unsigned long); -+ else if (strcmp(type, "pid_t") == 0) -+ size = sizeof(pid_t); -+ else if (synth_field_is_string(type)) -+ size = synth_field_string_size(type); -+ -+ return size; -+} -+ -+static const char *synth_field_fmt(char *type) -+{ -+ const char *fmt = "%llu"; -+ -+ if (strcmp(type, "s64") == 0) -+ fmt = "%lld"; -+ else if (strcmp(type, "u64") == 0) -+ fmt = "%llu"; -+ else if (strcmp(type, "s32") == 0) -+ fmt = "%d"; -+ else if (strcmp(type, "u32") == 0) -+ fmt = "%u"; -+ else if (strcmp(type, "s16") == 0) -+ fmt = "%d"; -+ else if (strcmp(type, "u16") == 0) -+ fmt = "%u"; -+ else if (strcmp(type, "s8") == 0) -+ fmt = "%d"; -+ else if (strcmp(type, "u8") == 0) -+ fmt = "%u"; -+ else if (strcmp(type, "char") == 0) -+ fmt = "%d"; -+ else if (strcmp(type, "unsigned char") == 0) -+ fmt = "%u"; -+ else if (strcmp(type, "int") == 0) -+ fmt = "%d"; -+ else if (strcmp(type, "unsigned int") == 0) -+ fmt = "%u"; -+ else if (strcmp(type, "long") == 0) -+ fmt = "%ld"; -+ else if (strcmp(type, "unsigned long") == 0) -+ fmt = "%lu"; -+ else if (strcmp(type, "pid_t") == 0) -+ fmt = "%d"; -+ else if (synth_field_is_string(type)) -+ fmt = "%s"; -+ -+ return fmt; -+} -+ -+static enum print_line_t print_synth_event(struct trace_iterator *iter, -+ int flags, -+ struct trace_event *event) -+{ -+ struct trace_array *tr = iter->tr; -+ struct trace_seq *s = &iter->seq; -+ struct synth_trace_event *entry; -+ struct synth_event *se; -+ unsigned int i, n_u64; -+ char print_fmt[32]; -+ const char *fmt; -+ -+ entry = (struct synth_trace_event *)iter->ent; -+ se = container_of(event, struct synth_event, call.event); -+ -+ trace_seq_printf(s, "%s: ", se->name); -+ -+ for (i = 0, n_u64 = 0; i < se->n_fields; i++) { -+ if (trace_seq_has_overflowed(s)) -+ goto end; -+ -+ fmt = synth_field_fmt(se->fields[i]->type); -+ -+ /* parameter types */ -+ if (tr->trace_flags & TRACE_ITER_VERBOSE) -+ trace_seq_printf(s, "%s ", fmt); -+ -+ snprintf(print_fmt, sizeof(print_fmt), "%%s=%s%%s", fmt); -+ -+ /* parameter values */ -+ if (se->fields[i]->is_string) { -+ trace_seq_printf(s, print_fmt, se->fields[i]->name, -+ (char *)&entry->fields[n_u64], -+ i == se->n_fields - 1 ? "" : " "); -+ n_u64 += STR_VAR_LEN_MAX / sizeof(u64); -+ } else { -+ trace_seq_printf(s, print_fmt, se->fields[i]->name, -+ entry->fields[n_u64], -+ i == se->n_fields - 1 ? "" : " "); -+ n_u64++; -+ } -+ } -+end: -+ trace_seq_putc(s, '\n'); -+ -+ return trace_handle_return(s); -+} -+ -+static struct trace_event_functions synth_event_funcs = { -+ .trace = print_synth_event -+}; -+ -+static notrace void trace_event_raw_event_synth(void *__data, -+ u64 *var_ref_vals, -+ unsigned int var_ref_idx) -+{ -+ struct trace_event_file *trace_file = __data; -+ struct synth_trace_event *entry; -+ struct trace_event_buffer fbuffer; -+ struct synth_event *event; -+ unsigned int i, n_u64; -+ int fields_size = 0; -+ -+ event = trace_file->event_call->data; -+ -+ if (trace_trigger_soft_disabled(trace_file)) -+ return; -+ -+ fields_size = event->n_u64 * sizeof(u64); -+ -+ entry = trace_event_buffer_reserve(&fbuffer, trace_file, -+ sizeof(*entry) + fields_size); -+ if (!entry) -+ return; -+ -+ for (i = 0, n_u64 = 0; i < event->n_fields; i++) { -+ if (event->fields[i]->is_string) { -+ char *str_val = (char *)(long)var_ref_vals[var_ref_idx + i]; -+ char *str_field = (char *)&entry->fields[n_u64]; -+ -+ strncpy(str_field, str_val, STR_VAR_LEN_MAX); -+ n_u64 += STR_VAR_LEN_MAX / sizeof(u64); -+ } else { -+ entry->fields[n_u64] = var_ref_vals[var_ref_idx + i]; -+ n_u64++; -+ } -+ } -+ -+ trace_event_buffer_commit(&fbuffer); -+} -+ -+static void free_synth_event_print_fmt(struct trace_event_call *call) -+{ -+ if (call) { -+ kfree(call->print_fmt); -+ call->print_fmt = NULL; -+ } -+} -+ -+static int __set_synth_event_print_fmt(struct synth_event *event, -+ char *buf, int len) -+{ -+ const char *fmt; -+ int pos = 0; -+ int i; -+ -+ /* When len=0, we just calculate the needed length */ -+#define LEN_OR_ZERO (len ? len - pos : 0) -+ -+ pos += snprintf(buf + pos, LEN_OR_ZERO, "\""); -+ for (i = 0; i < event->n_fields; i++) { -+ fmt = synth_field_fmt(event->fields[i]->type); -+ pos += snprintf(buf + pos, LEN_OR_ZERO, "%s=%s%s", -+ event->fields[i]->name, fmt, -+ i == event->n_fields - 1 ? "" : ", "); -+ } -+ pos += snprintf(buf + pos, LEN_OR_ZERO, "\""); -+ -+ for (i = 0; i < event->n_fields; i++) { -+ pos += snprintf(buf + pos, LEN_OR_ZERO, -+ ", REC->%s", event->fields[i]->name); -+ } -+ -+#undef LEN_OR_ZERO -+ -+ /* return the length of print_fmt */ -+ return pos; -+} -+ -+static int set_synth_event_print_fmt(struct trace_event_call *call) -+{ -+ struct synth_event *event = call->data; -+ char *print_fmt; -+ int len; -+ -+ /* First: called with 0 length to calculate the needed length */ -+ len = __set_synth_event_print_fmt(event, NULL, 0); -+ -+ print_fmt = kmalloc(len + 1, GFP_KERNEL); -+ if (!print_fmt) -+ return -ENOMEM; -+ -+ /* Second: actually write the @print_fmt */ -+ __set_synth_event_print_fmt(event, print_fmt, len + 1); -+ call->print_fmt = print_fmt; -+ -+ return 0; -+} -+ -+static void free_synth_field(struct synth_field *field) -+{ -+ kfree(field->type); -+ kfree(field->name); -+ kfree(field); -+} -+ -+static struct synth_field *parse_synth_field(char *field_type, -+ char *field_name) -+{ -+ struct synth_field *field; -+ int len, ret = 0; -+ char *array; -+ -+ if (field_type[0] == ';') -+ field_type++; -+ -+ len = strlen(field_name); -+ if (field_name[len - 1] == ';') -+ field_name[len - 1] = '\0'; -+ -+ field = kzalloc(sizeof(*field), GFP_KERNEL); -+ if (!field) -+ return ERR_PTR(-ENOMEM); -+ -+ len = strlen(field_type) + 1; -+ array = strchr(field_name, '['); -+ if (array) -+ len += strlen(array); -+ field->type = kzalloc(len, GFP_KERNEL); -+ if (!field->type) { -+ ret = -ENOMEM; -+ goto free; -+ } -+ strcat(field->type, field_type); -+ if (array) { -+ strcat(field->type, array); -+ *array = '\0'; -+ } -+ -+ field->size = synth_field_size(field->type); -+ if (!field->size) { -+ ret = -EINVAL; -+ goto free; -+ } -+ -+ if (synth_field_is_string(field->type)) -+ field->is_string = true; -+ -+ field->is_signed = synth_field_signed(field->type); -+ -+ field->name = kstrdup(field_name, GFP_KERNEL); -+ if (!field->name) { -+ ret = -ENOMEM; -+ goto free; -+ } -+ out: -+ return field; -+ free: -+ free_synth_field(field); -+ field = ERR_PTR(ret); -+ goto out; -+} -+ -+static void free_synth_tracepoint(struct tracepoint *tp) -+{ -+ if (!tp) -+ return; -+ -+ kfree(tp->name); -+ kfree(tp); -+} -+ -+static struct tracepoint *alloc_synth_tracepoint(char *name) -+{ -+ struct tracepoint *tp; -+ -+ tp = kzalloc(sizeof(*tp), GFP_KERNEL); -+ if (!tp) -+ return ERR_PTR(-ENOMEM); -+ -+ tp->name = kstrdup(name, GFP_KERNEL); -+ if (!tp->name) { -+ kfree(tp); -+ return ERR_PTR(-ENOMEM); -+ } -+ -+ return tp; -+} -+ -+typedef void (*synth_probe_func_t) (void *__data, u64 *var_ref_vals, -+ unsigned int var_ref_idx); -+ -+static inline void trace_synth(struct synth_event *event, u64 *var_ref_vals, -+ unsigned int var_ref_idx) -+{ -+ struct tracepoint *tp = event->tp; -+ -+ if (unlikely(atomic_read(&tp->key.enabled) > 0)) { -+ struct tracepoint_func *probe_func_ptr; -+ synth_probe_func_t probe_func; -+ void *__data; -+ -+ if (!(cpu_online(raw_smp_processor_id()))) -+ return; -+ -+ probe_func_ptr = rcu_dereference_sched((tp)->funcs); -+ if (probe_func_ptr) { -+ do { -+ probe_func = probe_func_ptr->func; -+ __data = probe_func_ptr->data; -+ probe_func(__data, var_ref_vals, var_ref_idx); -+ } while ((++probe_func_ptr)->func); -+ } -+ } -+} -+ -+static struct synth_event *find_synth_event(const char *name) -+{ -+ struct synth_event *event; -+ -+ list_for_each_entry(event, &synth_event_list, list) { -+ if (strcmp(event->name, name) == 0) -+ return event; -+ } -+ -+ return NULL; -+} -+ -+static int register_synth_event(struct synth_event *event) -+{ -+ struct trace_event_call *call = &event->call; -+ int ret = 0; -+ -+ event->call.class = &event->class; -+ event->class.system = kstrdup(SYNTH_SYSTEM, GFP_KERNEL); -+ if (!event->class.system) { -+ ret = -ENOMEM; -+ goto out; -+ } -+ -+ event->tp = alloc_synth_tracepoint(event->name); -+ if (IS_ERR(event->tp)) { -+ ret = PTR_ERR(event->tp); -+ event->tp = NULL; -+ goto out; -+ } -+ -+ INIT_LIST_HEAD(&call->class->fields); -+ call->event.funcs = &synth_event_funcs; -+ call->class->define_fields = synth_event_define_fields; -+ -+ ret = register_trace_event(&call->event); -+ if (!ret) { -+ ret = -ENODEV; -+ goto out; -+ } -+ call->flags = TRACE_EVENT_FL_TRACEPOINT; -+ call->class->reg = trace_event_reg; -+ call->class->probe = trace_event_raw_event_synth; -+ call->data = event; -+ call->tp = event->tp; -+ -+ ret = trace_add_event_call(call); -+ if (ret) { -+ pr_warn("Failed to register synthetic event: %s\n", -+ trace_event_name(call)); -+ goto err; -+ } -+ -+ ret = set_synth_event_print_fmt(call); -+ if (ret < 0) { -+ trace_remove_event_call(call); -+ goto err; -+ } -+ out: -+ return ret; -+ err: -+ unregister_trace_event(&call->event); -+ goto out; -+} -+ -+static int unregister_synth_event(struct synth_event *event) -+{ -+ struct trace_event_call *call = &event->call; -+ int ret; -+ -+ ret = trace_remove_event_call(call); -+ -+ return ret; -+} -+ -+static void free_synth_event(struct synth_event *event) -+{ -+ unsigned int i; -+ -+ if (!event) -+ return; -+ -+ for (i = 0; i < event->n_fields; i++) -+ free_synth_field(event->fields[i]); -+ -+ kfree(event->fields); -+ kfree(event->name); -+ kfree(event->class.system); -+ free_synth_tracepoint(event->tp); -+ free_synth_event_print_fmt(&event->call); -+ kfree(event); -+} -+ -+static struct synth_event *alloc_synth_event(char *event_name, int n_fields, -+ struct synth_field **fields) -+{ -+ struct synth_event *event; -+ unsigned int i; -+ -+ event = kzalloc(sizeof(*event), GFP_KERNEL); -+ if (!event) { -+ event = ERR_PTR(-ENOMEM); -+ goto out; -+ } -+ -+ event->name = kstrdup(event_name, GFP_KERNEL); -+ if (!event->name) { -+ kfree(event); -+ event = ERR_PTR(-ENOMEM); -+ goto out; -+ } -+ -+ event->fields = kcalloc(n_fields, sizeof(*event->fields), GFP_KERNEL); -+ if (!event->fields) { -+ free_synth_event(event); -+ event = ERR_PTR(-ENOMEM); -+ goto out; -+ } -+ -+ for (i = 0; i < n_fields; i++) -+ event->fields[i] = fields[i]; -+ -+ event->n_fields = n_fields; -+ out: -+ return event; -+} -+ -+static void add_or_delete_synth_event(struct synth_event *event, int delete) -+{ -+ if (delete) -+ free_synth_event(event); -+ else { -+ mutex_lock(&synth_event_mutex); -+ if (!find_synth_event(event->name)) -+ list_add(&event->list, &synth_event_list); -+ else -+ free_synth_event(event); -+ mutex_unlock(&synth_event_mutex); -+ } -+} -+ -+static int create_synth_event(int argc, char **argv) -+{ -+ struct synth_field *field, *fields[SYNTH_FIELDS_MAX]; -+ struct synth_event *event = NULL; -+ bool delete_event = false; -+ int i, n_fields = 0, ret = 0; -+ char *name; -+ -+ mutex_lock(&synth_event_mutex); -+ -+ /* -+ * Argument syntax: -+ * - Add synthetic event: field[;field] ... -+ * - Remove synthetic event: ! field[;field] ... -+ * where 'field' = type field_name -+ */ -+ if (argc < 1) { -+ ret = -EINVAL; -+ goto out; -+ } -+ -+ name = argv[0]; -+ if (name[0] == '!') { -+ delete_event = true; -+ name++; -+ } -+ -+ event = find_synth_event(name); -+ if (event) { -+ if (delete_event) { -+ if (event->ref) { -+ event = NULL; -+ ret = -EBUSY; -+ goto out; -+ } -+ list_del(&event->list); -+ goto out; -+ } -+ event = NULL; -+ ret = -EEXIST; -+ goto out; -+ } else if (delete_event) -+ goto out; -+ -+ if (argc < 2) { -+ ret = -EINVAL; -+ goto out; -+ } -+ -+ for (i = 1; i < argc - 1; i++) { -+ if (strcmp(argv[i], ";") == 0) -+ continue; -+ if (n_fields == SYNTH_FIELDS_MAX) { -+ ret = -EINVAL; -+ goto err; -+ } -+ -+ field = parse_synth_field(argv[i], argv[i + 1]); -+ if (IS_ERR(field)) { -+ ret = PTR_ERR(field); -+ goto err; -+ } -+ fields[n_fields] = field; -+ i++; n_fields++; -+ } -+ -+ if (i < argc) { -+ ret = -EINVAL; -+ goto err; -+ } -+ -+ event = alloc_synth_event(name, n_fields, fields); -+ if (IS_ERR(event)) { -+ ret = PTR_ERR(event); -+ event = NULL; -+ goto err; -+ } -+ out: -+ mutex_unlock(&synth_event_mutex); -+ -+ if (event) { -+ if (delete_event) { -+ ret = unregister_synth_event(event); -+ add_or_delete_synth_event(event, !ret); -+ } else { -+ ret = register_synth_event(event); -+ add_or_delete_synth_event(event, ret); -+ } -+ } -+ -+ return ret; -+ err: -+ mutex_unlock(&synth_event_mutex); -+ -+ for (i = 0; i < n_fields; i++) -+ free_synth_field(fields[i]); -+ free_synth_event(event); -+ -+ return ret; -+} -+ -+static int release_all_synth_events(void) -+{ -+ struct list_head release_events; -+ struct synth_event *event, *e; -+ int ret = 0; -+ -+ INIT_LIST_HEAD(&release_events); -+ -+ mutex_lock(&synth_event_mutex); -+ -+ list_for_each_entry(event, &synth_event_list, list) { -+ if (event->ref) { -+ mutex_unlock(&synth_event_mutex); -+ return -EBUSY; -+ } -+ } -+ -+ list_splice_init(&event->list, &release_events); -+ -+ mutex_unlock(&synth_event_mutex); -+ -+ list_for_each_entry_safe(event, e, &release_events, list) { -+ list_del(&event->list); -+ -+ ret = unregister_synth_event(event); -+ add_or_delete_synth_event(event, !ret); -+ } -+ -+ return ret; -+} -+ -+ -+static void *synth_events_seq_start(struct seq_file *m, loff_t *pos) -+{ -+ mutex_lock(&synth_event_mutex); -+ -+ return seq_list_start(&synth_event_list, *pos); -+} -+ -+static void *synth_events_seq_next(struct seq_file *m, void *v, loff_t *pos) -+{ -+ return seq_list_next(v, &synth_event_list, pos); -+} -+ -+static void synth_events_seq_stop(struct seq_file *m, void *v) -+{ -+ mutex_unlock(&synth_event_mutex); -+} -+ -+static int synth_events_seq_show(struct seq_file *m, void *v) -+{ -+ struct synth_field *field; -+ struct synth_event *event = v; -+ unsigned int i; -+ -+ seq_printf(m, "%s\t", event->name); -+ -+ for (i = 0; i < event->n_fields; i++) { -+ field = event->fields[i]; -+ -+ /* parameter values */ -+ seq_printf(m, "%s %s%s", field->type, field->name, -+ i == event->n_fields - 1 ? "" : "; "); -+ } -+ -+ seq_putc(m, '\n'); -+ -+ return 0; -+} -+ -+static const struct seq_operations synth_events_seq_op = { -+ .start = synth_events_seq_start, -+ .next = synth_events_seq_next, -+ .stop = synth_events_seq_stop, -+ .show = synth_events_seq_show -+}; -+ -+static int synth_events_open(struct inode *inode, struct file *file) -+{ -+ int ret; -+ -+ if ((file->f_mode & FMODE_WRITE) && (file->f_flags & O_TRUNC)) { -+ ret = release_all_synth_events(); -+ if (ret < 0) -+ return ret; -+ } -+ -+ return seq_open(file, &synth_events_seq_op); -+} -+ -+static ssize_t synth_events_write(struct file *file, -+ const char __user *buffer, -+ size_t count, loff_t *ppos) -+{ -+ return trace_parse_run_command(file, buffer, count, ppos, -+ create_synth_event); -+} -+ -+static const struct file_operations synth_events_fops = { -+ .open = synth_events_open, -+ .write = synth_events_write, -+ .read = seq_read, -+ .llseek = seq_lseek, -+ .release = seq_release, -+}; -+ - static u64 hist_field_timestamp(struct hist_field *hist_field, - struct tracing_map_elt *elt, - struct ring_buffer_event *rbe, -@@ -2965,6 +3775,28 @@ static int hist_trigger_enable(struct ev - return ret; - } - -+static bool have_hist_trigger_match(struct event_trigger_data *data, -+ struct trace_event_file *file) -+{ -+ struct hist_trigger_data *hist_data = data->private_data; -+ struct event_trigger_data *test, *named_data = NULL; -+ bool match = false; -+ -+ if (hist_data->attrs->name) -+ named_data = find_named_trigger(hist_data->attrs->name); -+ -+ list_for_each_entry_rcu(test, &file->triggers, list) { -+ if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) { -+ if (hist_trigger_match(data, test, named_data, false)) { -+ match = true; -+ break; -+ } -+ } -+ } -+ -+ return match; -+} -+ - static bool hist_trigger_check_refs(struct event_trigger_data *data, - struct trace_event_file *file) - { -@@ -3040,6 +3872,8 @@ static void hist_unreg_all(struct trace_ - { - struct event_trigger_data *test, *n; - struct hist_trigger_data *hist_data; -+ struct synth_event *se; -+ const char *se_name; - - if (hist_file_check_refs(file)) - return; -@@ -3049,6 +3883,14 @@ static void hist_unreg_all(struct trace_ - hist_data = test->private_data; - list_del_rcu(&test->list); - trace_event_trigger_enable_disable(file, 0); -+ -+ mutex_lock(&synth_event_mutex); -+ se_name = trace_event_name(file->event_call); -+ se = find_synth_event(se_name); -+ if (se) -+ se->ref--; -+ mutex_unlock(&synth_event_mutex); -+ - update_cond_flag(file); - if (hist_data->enable_timestamps) - tracing_set_time_stamp_abs(file->tr, false); -@@ -3067,6 +3909,8 @@ static int event_hist_trigger_func(struc - struct hist_trigger_attrs *attrs; - struct event_trigger_ops *trigger_ops; - struct hist_trigger_data *hist_data; -+ struct synth_event *se; -+ const char *se_name; - bool remove = false; - char *trigger; - int ret = 0; -@@ -3097,10 +3941,11 @@ static int event_hist_trigger_func(struc - - trigger_ops = cmd_ops->get_trigger_ops(cmd, trigger); - -- ret = -ENOMEM; - trigger_data = kzalloc(sizeof(*trigger_data), GFP_KERNEL); -- if (!trigger_data) -+ if (!trigger_data) { -+ ret = -ENOMEM; - goto out_free; -+ } - - trigger_data->count = -1; - trigger_data->ops = trigger_ops; -@@ -3119,12 +3964,23 @@ static int event_hist_trigger_func(struc - } - - if (remove) { -+ if (!have_hist_trigger_match(trigger_data, file)) -+ goto out_free; -+ - if (hist_trigger_check_refs(trigger_data, file)) { - ret = -EBUSY; - goto out_free; - } - - cmd_ops->unreg(glob+1, trigger_ops, trigger_data, file); -+ -+ mutex_lock(&synth_event_mutex); -+ se_name = trace_event_name(file->event_call); -+ se = find_synth_event(se_name); -+ if (se) -+ se->ref--; -+ mutex_unlock(&synth_event_mutex); -+ - ret = 0; - goto out_free; - } -@@ -3160,6 +4016,13 @@ static int event_hist_trigger_func(struc - if (ret) - goto out_unreg; - -+ mutex_lock(&synth_event_mutex); -+ se_name = trace_event_name(file->event_call); -+ se = find_synth_event(se_name); -+ if (se) -+ se->ref++; -+ mutex_unlock(&synth_event_mutex); -+ - /* Just return zero, not the number of registered triggers */ - ret = 0; - out: -@@ -3332,3 +4195,31 @@ static __init void unregister_trigger_hi - - return ret; - } -+ -+static __init int trace_events_hist_init(void) -+{ -+ struct dentry *entry = NULL; -+ struct dentry *d_tracer; -+ int err = 0; -+ -+ d_tracer = tracing_init_dentry(); -+ if (IS_ERR(d_tracer)) { -+ err = PTR_ERR(d_tracer); -+ goto err; -+ } -+ -+ entry = tracefs_create_file("synthetic_events", 0644, d_tracer, -+ NULL, &synth_events_fops); -+ if (!entry) { -+ err = -ENODEV; -+ goto err; -+ } -+ -+ return err; -+ err: -+ pr_warn("Could not create tracefs 'synthetic_events' entry\n"); -+ -+ return err; -+} -+ -+fs_initcall(trace_events_hist_init); diff --git a/debian/patches/features/all/rt/0025-hrtimer-Use-irqsave-irqrestore-around-__run_hrtimer.patch b/debian/patches/features/all/rt/0025-hrtimer-Use-irqsave-irqrestore-around-__run_hrtimer.patch deleted file mode 100644 index dee146abc..000000000 --- a/debian/patches/features/all/rt/0025-hrtimer-Use-irqsave-irqrestore-around-__run_hrtimer.patch +++ /dev/null @@ -1,145 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:13:14 +0100 -Subject: [PATCH 25/29] hrtimer: Use irqsave/irqrestore around __run_hrtimer() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -__run_hrtimer() is called with the hrtimer_cpu_base.lock held and -interrupts disabled. Before invoking the timer callback the base lock is -dropped, but interrupts stay disabled. - -The upcoming support for softirq based hrtimers requires that interrupts -are enabled before the timer callback is invoked. - -To avoid code duplication, take hrtimer_cpu_base.lock with -raw_spin_lock_irqsave(flags) at the call site and hand in the flags as -argument. So raw_spin_unlock_irqrestore() before the callback invocation -will either keep interrupts disabled in interrupt context or restore to -interrupt enabled state when called from softirq context. - -Suggested-by: Peter Zijlstra -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/time/hrtimer.c | 31 ++++++++++++++++++------------- - 1 file changed, 18 insertions(+), 13 deletions(-) - ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -1163,7 +1163,8 @@ EXPORT_SYMBOL_GPL(hrtimer_active); - - static void __run_hrtimer(struct hrtimer_cpu_base *cpu_base, - struct hrtimer_clock_base *base, -- struct hrtimer *timer, ktime_t *now) -+ struct hrtimer *timer, ktime_t *now, -+ unsigned long flags) - { - enum hrtimer_restart (*fn)(struct hrtimer *); - int restart; -@@ -1198,11 +1199,11 @@ static void __run_hrtimer(struct hrtimer - * protected against migration to a different CPU even if the lock - * is dropped. - */ -- raw_spin_unlock(&cpu_base->lock); -+ raw_spin_unlock_irqrestore(&cpu_base->lock, flags); - trace_hrtimer_expire_entry(timer, now); - restart = fn(timer); - trace_hrtimer_expire_exit(timer); -- raw_spin_lock(&cpu_base->lock); -+ raw_spin_lock_irq(&cpu_base->lock); - - /* - * Note: We clear the running state after enqueue_hrtimer and -@@ -1230,7 +1231,8 @@ static void __run_hrtimer(struct hrtimer - base->running = NULL; - } - --static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t now) -+static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t now, -+ unsigned long flags) - { - struct hrtimer_clock_base *base; - unsigned int active = cpu_base->active_bases; -@@ -1261,7 +1263,7 @@ static void __hrtimer_run_queues(struct - if (basenow < hrtimer_get_softexpires_tv64(timer)) - break; - -- __run_hrtimer(cpu_base, base, timer, &basenow); -+ __run_hrtimer(cpu_base, base, timer, &basenow, flags); - } - } - } -@@ -1276,13 +1278,14 @@ void hrtimer_interrupt(struct clock_even - { - struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases); - ktime_t expires_next, now, entry_time, delta; -+ unsigned long flags; - int retries = 0; - - BUG_ON(!cpu_base->hres_active); - cpu_base->nr_events++; - dev->next_event = KTIME_MAX; - -- raw_spin_lock(&cpu_base->lock); -+ raw_spin_lock_irqsave(&cpu_base->lock, flags); - entry_time = now = hrtimer_update_base(cpu_base); - retry: - cpu_base->in_hrtirq = 1; -@@ -1295,7 +1298,7 @@ void hrtimer_interrupt(struct clock_even - */ - cpu_base->expires_next = KTIME_MAX; - -- __hrtimer_run_queues(cpu_base, now); -+ __hrtimer_run_queues(cpu_base, now, flags); - - /* Reevaluate the clock bases for the next expiry */ - expires_next = __hrtimer_get_next_event(cpu_base); -@@ -1305,7 +1308,7 @@ void hrtimer_interrupt(struct clock_even - */ - cpu_base->expires_next = expires_next; - cpu_base->in_hrtirq = 0; -- raw_spin_unlock(&cpu_base->lock); -+ raw_spin_unlock_irqrestore(&cpu_base->lock, flags); - - /* Reprogramming necessary ? */ - if (!tick_program_event(expires_next, 0)) { -@@ -1326,7 +1329,7 @@ void hrtimer_interrupt(struct clock_even - * Acquire base lock for updating the offsets and retrieving - * the current time. - */ -- raw_spin_lock(&cpu_base->lock); -+ raw_spin_lock_irqsave(&cpu_base->lock, flags); - now = hrtimer_update_base(cpu_base); - cpu_base->nr_retries++; - if (++retries < 3) -@@ -1339,7 +1342,8 @@ void hrtimer_interrupt(struct clock_even - */ - cpu_base->nr_hangs++; - cpu_base->hang_detected = 1; -- raw_spin_unlock(&cpu_base->lock); -+ raw_spin_unlock_irqrestore(&cpu_base->lock, flags); -+ - delta = ktime_sub(now, entry_time); - if ((unsigned int)delta > cpu_base->max_hang_time) - cpu_base->max_hang_time = (unsigned int) delta; -@@ -1381,6 +1385,7 @@ static inline void __hrtimer_peek_ahead_ - void hrtimer_run_queues(void) - { - struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases); -+ unsigned long flags; - ktime_t now; - - if (__hrtimer_hres_active(cpu_base)) -@@ -1398,10 +1403,10 @@ void hrtimer_run_queues(void) - return; - } - -- raw_spin_lock(&cpu_base->lock); -+ raw_spin_lock_irqsave(&cpu_base->lock, flags); - now = hrtimer_update_base(cpu_base); -- __hrtimer_run_queues(cpu_base, now); -- raw_spin_unlock(&cpu_base->lock); -+ __hrtimer_run_queues(cpu_base, now, flags); -+ raw_spin_unlock_irqrestore(&cpu_base->lock, flags); - } - - /* diff --git a/debian/patches/features/all/rt/0025-tracing-Add-support-for-field-variables.patch b/debian/patches/features/all/rt/0025-tracing-Add-support-for-field-variables.patch deleted file mode 100644 index 8c77bfc77..000000000 --- a/debian/patches/features/all/rt/0025-tracing-Add-support-for-field-variables.patch +++ /dev/null @@ -1,663 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:51:59 -0600 -Subject: [PATCH 25/37] tracing: Add support for 'field variables' -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Users should be able to directly specify event fields in hist trigger -'actions' rather than being forced to explicitly create a variable for -that purpose. - -Add support allowing fields to be used directly in actions, which -essentially does just that - creates 'invisible' variables for each -bare field specified in an action. If a bare field refers to a field -on another (matching) event, it even creates a special histogram for -the purpose (since variables can't be defined on an existing histogram -after histogram creation). - -Here's a simple example that demonstrates both. Basically the -onmatch() action creates a list of variables corresponding to the -parameters of the synthetic event to be generated, and then uses those -values to generate the event. So for the wakeup_latency synthetic -event 'call' below the first param, $wakeup_lat, is a variable defined -explicitly on sched_switch, where 'next_pid' is just a normal field on -sched_switch, and prio is a normal field on sched_waking. - -Since the mechanism works on variables, those two normal fields just -have 'invisible' variables created internally for them. In the case of -'prio', which is on another event, we actually need to create an -additional hist trigger and define the invisible variable on that, since -once a hist trigger is defined, variables can't be added to it later. - - echo 'wakeup_latency u64 lat; pid_t pid; int prio' >> - /sys/kernel/debug/tracing/synthetic_events - - echo 'hist:keys=pid:ts0=common_timestamp.usecs >> - /sys/kernel/debug/tracing/events/sched/sched_waking/trigger - -echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0: - onmatch(sched.sched_waking).wakeup_latency($wakeup_lat,next_pid,prio) - >> /sys/kernel/debug/tracing/events/sched/sched_switch/trigger - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 531 ++++++++++++++++++++++++++++++++++++++- - 1 file changed, 530 insertions(+), 1 deletion(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -255,6 +255,16 @@ struct hist_trigger_attrs { - struct var_defs var_defs; - }; - -+struct field_var { -+ struct hist_field *var; -+ struct hist_field *val; -+}; -+ -+struct field_var_hist { -+ struct hist_trigger_data *hist_data; -+ char *cmd; -+}; -+ - struct hist_trigger_data { - struct hist_field *fields[HIST_FIELDS_MAX]; - unsigned int n_vals; -@@ -274,6 +284,12 @@ struct hist_trigger_data { - - struct action_data *actions[HIST_ACTIONS_MAX]; - unsigned int n_actions; -+ -+ struct field_var *field_vars[SYNTH_FIELDS_MAX]; -+ unsigned int n_field_vars; -+ unsigned int n_field_var_str; -+ struct field_var_hist *field_var_hists[SYNTH_FIELDS_MAX]; -+ unsigned int n_field_var_hists; - }; - - struct synth_field { -@@ -1427,6 +1443,7 @@ static struct hist_field *find_event_var - struct hist_elt_data { - char *comm; - u64 *var_ref_vals; -+ char *field_var_str[SYNTH_FIELDS_MAX]; - }; - - static u64 hist_field_var_ref(struct hist_field *hist_field, -@@ -1731,6 +1748,11 @@ static inline void save_comm(char *comm, - - static void hist_elt_data_free(struct hist_elt_data *elt_data) - { -+ unsigned int i; -+ -+ for (i = 0; i < SYNTH_FIELDS_MAX; i++) -+ kfree(elt_data->field_var_str[i]); -+ - kfree(elt_data->comm); - kfree(elt_data); - } -@@ -1748,7 +1770,7 @@ static int hist_trigger_elt_data_alloc(s - unsigned int size = TASK_COMM_LEN; - struct hist_elt_data *elt_data; - struct hist_field *key_field; -- unsigned int i; -+ unsigned int i, n_str; - - elt_data = kzalloc(sizeof(*elt_data), GFP_KERNEL); - if (!elt_data) -@@ -1767,6 +1789,18 @@ static int hist_trigger_elt_data_alloc(s - } - } - -+ n_str = hist_data->n_field_var_str; -+ -+ size = STR_VAR_LEN_MAX; -+ -+ for (i = 0; i < n_str; i++) { -+ elt_data->field_var_str[i] = kzalloc(size, GFP_KERNEL); -+ if (!elt_data->field_var_str[i]) { -+ hist_elt_data_free(elt_data); -+ return -ENOMEM; -+ } -+ } -+ - elt->private_data = elt_data; - - return 0; -@@ -2473,6 +2507,470 @@ static struct hist_field *parse_expr(str - return ERR_PTR(ret); - } - -+static char *find_trigger_filter(struct hist_trigger_data *hist_data, -+ struct trace_event_file *file) -+{ -+ struct event_trigger_data *test; -+ -+ list_for_each_entry_rcu(test, &file->triggers, list) { -+ if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) { -+ if (test->private_data == hist_data) -+ return test->filter_str; -+ } -+ } -+ -+ return NULL; -+} -+ -+static struct event_command trigger_hist_cmd; -+static int event_hist_trigger_func(struct event_command *cmd_ops, -+ struct trace_event_file *file, -+ char *glob, char *cmd, char *param); -+ -+static bool compatible_keys(struct hist_trigger_data *target_hist_data, -+ struct hist_trigger_data *hist_data, -+ unsigned int n_keys) -+{ -+ struct hist_field *target_hist_field, *hist_field; -+ unsigned int n, i, j; -+ -+ if (hist_data->n_fields - hist_data->n_vals != n_keys) -+ return false; -+ -+ i = hist_data->n_vals; -+ j = target_hist_data->n_vals; -+ -+ for (n = 0; n < n_keys; n++) { -+ hist_field = hist_data->fields[i + n]; -+ target_hist_field = target_hist_data->fields[j + n]; -+ -+ if (strcmp(hist_field->type, target_hist_field->type) != 0) -+ return false; -+ if (hist_field->size != target_hist_field->size) -+ return false; -+ if (hist_field->is_signed != target_hist_field->is_signed) -+ return false; -+ } -+ -+ return true; -+} -+ -+static struct hist_trigger_data * -+find_compatible_hist(struct hist_trigger_data *target_hist_data, -+ struct trace_event_file *file) -+{ -+ struct hist_trigger_data *hist_data; -+ struct event_trigger_data *test; -+ unsigned int n_keys; -+ -+ n_keys = target_hist_data->n_fields - target_hist_data->n_vals; -+ -+ list_for_each_entry_rcu(test, &file->triggers, list) { -+ if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) { -+ hist_data = test->private_data; -+ -+ if (compatible_keys(target_hist_data, hist_data, n_keys)) -+ return hist_data; -+ } -+ } -+ -+ return NULL; -+} -+ -+static struct trace_event_file *event_file(struct trace_array *tr, -+ char *system, char *event_name) -+{ -+ struct trace_event_file *file; -+ -+ file = find_event_file(tr, system, event_name); -+ if (!file) -+ return ERR_PTR(-EINVAL); -+ -+ return file; -+} -+ -+static struct hist_field * -+find_synthetic_field_var(struct hist_trigger_data *target_hist_data, -+ char *system, char *event_name, char *field_name) -+{ -+ struct hist_field *event_var; -+ char *synthetic_name; -+ -+ synthetic_name = kzalloc(MAX_FILTER_STR_VAL, GFP_KERNEL); -+ if (!synthetic_name) -+ return ERR_PTR(-ENOMEM); -+ -+ strcpy(synthetic_name, "synthetic_"); -+ strcat(synthetic_name, field_name); -+ -+ event_var = find_event_var(target_hist_data, system, event_name, synthetic_name); -+ -+ kfree(synthetic_name); -+ -+ return event_var; -+} -+ -+/** -+ * create_field_var_hist - Automatically create a histogram and var for a field -+ * @target_hist_data: The target hist trigger -+ * @subsys_name: Optional subsystem name -+ * @event_name: Optional event name -+ * @field_name: The name of the field (and the resulting variable) -+ * -+ * Hist trigger actions fetch data from variables, not directly from -+ * events. However, for convenience, users are allowed to directly -+ * specify an event field in an action, which will be automatically -+ * converted into a variable on their behalf. -+ -+ * If a user specifies a field on an event that isn't the event the -+ * histogram currently being defined (the target event histogram), the -+ * only way that can be accomplished is if a new hist trigger is -+ * created and the field variable defined on that. -+ * -+ * This function creates a new histogram compatible with the target -+ * event (meaning a histogram with the same key as the target -+ * histogram), and creates a variable for the specified field, but -+ * with 'synthetic_' prepended to the variable name in order to avoid -+ * collision with normal field variables. -+ * -+ * Return: The variable created for the field. -+ */ -+struct hist_field * -+create_field_var_hist(struct hist_trigger_data *target_hist_data, -+ char *subsys_name, char *event_name, char *field_name) -+{ -+ struct trace_array *tr = target_hist_data->event_file->tr; -+ struct hist_field *event_var = ERR_PTR(-EINVAL); -+ struct hist_trigger_data *hist_data; -+ unsigned int i, n, first = true; -+ struct field_var_hist *var_hist; -+ struct trace_event_file *file; -+ struct hist_field *key_field; -+ char *saved_filter; -+ char *cmd; -+ int ret; -+ -+ if (target_hist_data->n_field_var_hists >= SYNTH_FIELDS_MAX) -+ return ERR_PTR(-EINVAL); -+ -+ file = event_file(tr, subsys_name, event_name); -+ -+ if (IS_ERR(file)) { -+ ret = PTR_ERR(file); -+ return ERR_PTR(ret); -+ } -+ -+ /* -+ * Look for a histogram compatible with target. We'll use the -+ * found histogram specification to create a new matching -+ * histogram with our variable on it. target_hist_data is not -+ * yet a registered histogram so we can't use that. -+ */ -+ hist_data = find_compatible_hist(target_hist_data, file); -+ if (!hist_data) -+ return ERR_PTR(-EINVAL); -+ -+ /* See if a synthetic field variable has already been created */ -+ event_var = find_synthetic_field_var(target_hist_data, subsys_name, -+ event_name, field_name); -+ if (!IS_ERR_OR_NULL(event_var)) -+ return event_var; -+ -+ var_hist = kzalloc(sizeof(*var_hist), GFP_KERNEL); -+ if (!var_hist) -+ return ERR_PTR(-ENOMEM); -+ -+ cmd = kzalloc(MAX_FILTER_STR_VAL, GFP_KERNEL); -+ if (!cmd) { -+ kfree(var_hist); -+ return ERR_PTR(-ENOMEM); -+ } -+ -+ /* Use the same keys as the compatible histogram */ -+ strcat(cmd, "keys="); -+ -+ for_each_hist_key_field(i, hist_data) { -+ key_field = hist_data->fields[i]; -+ if (!first) -+ strcat(cmd, ","); -+ strcat(cmd, key_field->field->name); -+ first = false; -+ } -+ -+ /* Create the synthetic field variable specification */ -+ strcat(cmd, ":synthetic_"); -+ strcat(cmd, field_name); -+ strcat(cmd, "="); -+ strcat(cmd, field_name); -+ -+ /* Use the same filter as the compatible histogram */ -+ saved_filter = find_trigger_filter(hist_data, file); -+ if (saved_filter) { -+ strcat(cmd, " if "); -+ strcat(cmd, saved_filter); -+ } -+ -+ var_hist->cmd = kstrdup(cmd, GFP_KERNEL); -+ if (!var_hist->cmd) { -+ kfree(cmd); -+ kfree(var_hist); -+ return ERR_PTR(-ENOMEM); -+ } -+ -+ /* Save the compatible histogram information */ -+ var_hist->hist_data = hist_data; -+ -+ /* Create the new histogram with our variable */ -+ ret = event_hist_trigger_func(&trigger_hist_cmd, file, -+ "", "hist", cmd); -+ if (ret) { -+ kfree(cmd); -+ kfree(var_hist->cmd); -+ kfree(var_hist); -+ return ERR_PTR(ret); -+ } -+ -+ kfree(cmd); -+ -+ /* If we can't find the variable, something went wrong */ -+ event_var = find_synthetic_field_var(target_hist_data, subsys_name, -+ event_name, field_name); -+ if (IS_ERR_OR_NULL(event_var)) { -+ kfree(var_hist->cmd); -+ kfree(var_hist); -+ return ERR_PTR(-EINVAL); -+ } -+ -+ n = target_hist_data->n_field_var_hists; -+ target_hist_data->field_var_hists[n] = var_hist; -+ target_hist_data->n_field_var_hists++; -+ -+ return event_var; -+} -+ -+struct hist_field * -+find_target_event_var(struct hist_trigger_data *hist_data, -+ char *subsys_name, char *event_name, char *var_name) -+{ -+ struct trace_event_file *file = hist_data->event_file; -+ struct hist_field *hist_field = NULL; -+ -+ if (subsys_name) { -+ struct trace_event_call *call; -+ -+ if (!event_name) -+ return NULL; -+ -+ call = file->event_call; -+ -+ if (strcmp(subsys_name, call->class->system) != 0) -+ return NULL; -+ -+ if (strcmp(event_name, trace_event_name(call)) != 0) -+ return NULL; -+ } -+ -+ hist_field = find_var_field(hist_data, var_name); -+ -+ return hist_field; -+} -+ -+static inline void __update_field_vars(struct tracing_map_elt *elt, -+ struct ring_buffer_event *rbe, -+ void *rec, -+ struct field_var **field_vars, -+ unsigned int n_field_vars, -+ unsigned int field_var_str_start) -+{ -+ struct hist_elt_data *elt_data = elt->private_data; -+ unsigned int i, j, var_idx; -+ u64 var_val; -+ -+ for (i = 0, j = field_var_str_start; i < n_field_vars; i++) { -+ struct field_var *field_var = field_vars[i]; -+ struct hist_field *var = field_var->var; -+ struct hist_field *val = field_var->val; -+ -+ var_val = val->fn(val, elt, rbe, rec); -+ var_idx = var->var.idx; -+ -+ if (val->flags & HIST_FIELD_FL_STRING) { -+ char *str = elt_data->field_var_str[j++]; -+ char *val_str = (char *)(uintptr_t)var_val; -+ -+ strncpy(str, val_str, STR_VAR_LEN_MAX); -+ var_val = (u64)(uintptr_t)str; -+ } -+ tracing_map_set_var(elt, var_idx, var_val); -+ } -+} -+ -+static void update_field_vars(struct hist_trigger_data *hist_data, -+ struct tracing_map_elt *elt, -+ struct ring_buffer_event *rbe, -+ void *rec) -+{ -+ __update_field_vars(elt, rbe, rec, hist_data->field_vars, -+ hist_data->n_field_vars, 0); -+} -+ -+static struct hist_field *create_var(struct hist_trigger_data *hist_data, -+ struct trace_event_file *file, -+ char *name, int size, const char *type) -+{ -+ struct hist_field *var; -+ int idx; -+ -+ if (find_var(hist_data, file, name) && !hist_data->remove) { -+ var = ERR_PTR(-EINVAL); -+ goto out; -+ } -+ -+ var = kzalloc(sizeof(struct hist_field), GFP_KERNEL); -+ if (!var) { -+ var = ERR_PTR(-ENOMEM); -+ goto out; -+ } -+ -+ idx = tracing_map_add_var(hist_data->map); -+ if (idx < 0) { -+ kfree(var); -+ var = ERR_PTR(-EINVAL); -+ goto out; -+ } -+ -+ var->flags = HIST_FIELD_FL_VAR; -+ var->var.idx = idx; -+ var->var.hist_data = var->hist_data = hist_data; -+ var->size = size; -+ var->var.name = kstrdup(name, GFP_KERNEL); -+ var->type = kstrdup(type, GFP_KERNEL); -+ if (!var->var.name || !var->type) { -+ kfree(var->var.name); -+ kfree(var->type); -+ kfree(var); -+ var = ERR_PTR(-ENOMEM); -+ } -+ out: -+ return var; -+} -+ -+static struct field_var *create_field_var(struct hist_trigger_data *hist_data, -+ struct trace_event_file *file, -+ char *field_name) -+{ -+ struct hist_field *val = NULL, *var = NULL; -+ unsigned long flags = HIST_FIELD_FL_VAR; -+ struct field_var *field_var; -+ int ret = 0; -+ -+ if (hist_data->n_field_vars >= SYNTH_FIELDS_MAX) { -+ ret = -EINVAL; -+ goto err; -+ } -+ -+ val = parse_atom(hist_data, file, field_name, &flags, NULL); -+ if (IS_ERR(val)) { -+ ret = PTR_ERR(val); -+ goto err; -+ } -+ -+ var = create_var(hist_data, file, field_name, val->size, val->type); -+ if (IS_ERR(var)) { -+ kfree(val); -+ ret = PTR_ERR(var); -+ goto err; -+ } -+ -+ field_var = kzalloc(sizeof(struct field_var), GFP_KERNEL); -+ if (!field_var) { -+ kfree(val); -+ kfree(var); -+ ret = -ENOMEM; -+ goto err; -+ } -+ -+ field_var->var = var; -+ field_var->val = val; -+ out: -+ return field_var; -+ err: -+ field_var = ERR_PTR(ret); -+ goto out; -+} -+ -+/** -+ * create_target_field_var - Automatically create a variable for a field -+ * @target_hist_data: The target hist trigger -+ * @subsys_name: Optional subsystem name -+ * @event_name: Optional event name -+ * @var_name: The name of the field (and the resulting variable) -+ * -+ * Hist trigger actions fetch data from variables, not directly from -+ * events. However, for convenience, users are allowed to directly -+ * specify an event field in an action, which will be automatically -+ * converted into a variable on their behalf. -+ -+ * This function creates a field variable with the name var_name on -+ * the hist trigger currently being defined on the target event. If -+ * subsys_name and event_name are specified, this function simply -+ * verifies that they do in fact match the target event subsystem and -+ * event name. -+ * -+ * Return: The variable created for the field. -+ */ -+struct field_var * -+create_target_field_var(struct hist_trigger_data *target_hist_data, -+ char *subsys_name, char *event_name, char *var_name) -+{ -+ struct trace_event_file *file = target_hist_data->event_file; -+ -+ if (subsys_name) { -+ struct trace_event_call *call; -+ -+ if (!event_name) -+ return NULL; -+ -+ call = file->event_call; -+ -+ if (strcmp(subsys_name, call->class->system) != 0) -+ return NULL; -+ -+ if (strcmp(event_name, trace_event_name(call)) != 0) -+ return NULL; -+ } -+ -+ return create_field_var(target_hist_data, file, var_name); -+} -+ -+static void destroy_field_var(struct field_var *field_var) -+{ -+ if (!field_var) -+ return; -+ -+ destroy_hist_field(field_var->var, 0); -+ destroy_hist_field(field_var->val, 0); -+ -+ kfree(field_var); -+} -+ -+static void destroy_field_vars(struct hist_trigger_data *hist_data) -+{ -+ unsigned int i; -+ -+ for (i = 0; i < hist_data->n_field_vars; i++) -+ destroy_field_var(hist_data->field_vars[i]); -+} -+ -+void save_field_var(struct hist_trigger_data *hist_data, -+ struct field_var *field_var) -+{ -+ hist_data->field_vars[hist_data->n_field_vars++] = field_var; -+ -+ if (field_var->val->flags & HIST_FIELD_FL_STRING) -+ hist_data->n_field_var_str++; -+} -+ - static int create_hitcount_val(struct hist_trigger_data *hist_data) - { - hist_data->fields[HITCOUNT_IDX] = -@@ -2928,6 +3426,16 @@ static int create_actions(struct hist_tr - return ret; - } - -+static void destroy_field_var_hists(struct hist_trigger_data *hist_data) -+{ -+ unsigned int i; -+ -+ for (i = 0; i < hist_data->n_field_var_hists; i++) { -+ kfree(hist_data->field_var_hists[i]->cmd); -+ kfree(hist_data->field_var_hists[i]); -+ } -+} -+ - static void destroy_hist_data(struct hist_trigger_data *hist_data) - { - if (!hist_data) -@@ -2938,6 +3446,8 @@ static void destroy_hist_data(struct his - tracing_map_destroy(hist_data->map); - - destroy_actions(hist_data); -+ destroy_field_vars(hist_data); -+ destroy_field_var_hists(hist_data); - - kfree(hist_data); - } -@@ -3074,6 +3584,8 @@ static void hist_trigger_elt_update(stru - tracing_map_set_var(elt, var_idx, hist_val); - } - } -+ -+ update_field_vars(hist_data, elt, rbe, rec); - } - - static inline void add_to_key(char *compound_key, void *key, -@@ -3520,6 +4032,21 @@ static int event_hist_trigger_init(struc - return 0; - } - -+static void unregister_field_var_hists(struct hist_trigger_data *hist_data) -+{ -+ struct trace_event_file *file; -+ unsigned int i; -+ char *cmd; -+ int ret; -+ -+ for (i = 0; i < hist_data->n_field_var_hists; i++) { -+ file = hist_data->field_var_hists[i]->hist_data->event_file; -+ cmd = hist_data->field_var_hists[i]->cmd; -+ ret = event_hist_trigger_func(&trigger_hist_cmd, file, -+ "!hist", "hist", cmd); -+ } -+} -+ - static void event_hist_trigger_free(struct event_trigger_ops *ops, - struct event_trigger_data *data) - { -@@ -3537,6 +4064,8 @@ static void event_hist_trigger_free(stru - - remove_hist_vars(hist_data); - -+ unregister_field_var_hists(hist_data); -+ - destroy_hist_data(hist_data); - } - } diff --git a/debian/patches/features/all/rt/0025-tracing-Move-get_hist_field_flags.patch b/debian/patches/features/all/rt/0025-tracing-Move-get_hist_field_flags.patch index 607b1327b..740d52e3c 100644 --- a/debian/patches/features/all/rt/0025-tracing-Move-get_hist_field_flags.patch +++ b/debian/patches/features/all/rt/0025-tracing-Move-get_hist_field_flags.patch @@ -1,7 +1,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:51 -0600 Subject: [PATCH 25/48] tracing: Move get_hist_field_flags() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Move get_hist_field_flags() to make it more easily accessible for new code (and keep the move separate from new functionality). diff --git a/debian/patches/features/all/rt/0026-hrtimer-Add-clock-bases-and-hrtimer-mode-for-soft-ir.patch b/debian/patches/features/all/rt/0026-hrtimer-Add-clock-bases-and-hrtimer-mode-for-soft-ir.patch deleted file mode 100644 index a45d0e9ec..000000000 --- a/debian/patches/features/all/rt/0026-hrtimer-Add-clock-bases-and-hrtimer-mode-for-soft-ir.patch +++ /dev/null @@ -1,109 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:13:15 +0100 -Subject: [PATCH 26/29] hrtimer: Add clock bases and hrtimer mode for soft irq - context -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -hrtimer callback functions are always executed in hard interrupt -context. Users of hrtimer which need their timer function to be executed -in soft interrupt context, make use of tasklets to get the proper context. - -Add additional hrtimer clock bases for timers which must expire in softirq -context, so the detour via the tasklet can be avoided. This is also -required for RT, where the majority of hrtimer is moved into softirq -hrtimer context. - -The selection of the expiry mode happens via a mode bit. Introduce -HRTIMER_MODE_SOFT and the matching combinations with the ABS/REL/PINNED -bits and update the decoding of hrtimer_mode in tracepoints. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - include/linux/hrtimer.h | 14 ++++++++++++++ - include/trace/events/timer.h | 6 +++++- - kernel/time/hrtimer.c | 20 ++++++++++++++++++++ - 3 files changed, 39 insertions(+), 1 deletion(-) - ---- a/include/linux/hrtimer.h -+++ b/include/linux/hrtimer.h -@@ -33,14 +33,24 @@ struct hrtimer_cpu_base; - * HRTIMER_MODE_REL - Time value is relative to now - * HRTIMER_MODE_PINNED - Timer is bound to CPU (is only considered - * when starting the timer) -+ * HRTIMER_MODE_SOFT - Timer callback function will be executed in -+ * soft irq context - */ - enum hrtimer_mode { - HRTIMER_MODE_ABS = 0x00, - HRTIMER_MODE_REL = 0x01, - HRTIMER_MODE_PINNED = 0x02, -+ HRTIMER_MODE_SOFT = 0x04, - - HRTIMER_MODE_ABS_PINNED = HRTIMER_MODE_ABS | HRTIMER_MODE_PINNED, - HRTIMER_MODE_REL_PINNED = HRTIMER_MODE_REL | HRTIMER_MODE_PINNED, -+ -+ HRTIMER_MODE_ABS_SOFT = HRTIMER_MODE_ABS | HRTIMER_MODE_SOFT, -+ HRTIMER_MODE_REL_SOFT = HRTIMER_MODE_REL | HRTIMER_MODE_SOFT, -+ -+ HRTIMER_MODE_ABS_PINNED_SOFT = HRTIMER_MODE_ABS_PINNED | HRTIMER_MODE_SOFT, -+ HRTIMER_MODE_REL_PINNED_SOFT = HRTIMER_MODE_REL_PINNED | HRTIMER_MODE_SOFT, -+ - }; - - /* -@@ -151,6 +161,10 @@ enum hrtimer_base_type { - HRTIMER_BASE_REALTIME, - HRTIMER_BASE_BOOTTIME, - HRTIMER_BASE_TAI, -+ HRTIMER_BASE_MONOTONIC_SOFT, -+ HRTIMER_BASE_REALTIME_SOFT, -+ HRTIMER_BASE_BOOTTIME_SOFT, -+ HRTIMER_BASE_TAI_SOFT, - HRTIMER_MAX_CLOCK_BASES, - }; - ---- a/include/trace/events/timer.h -+++ b/include/trace/events/timer.h -@@ -148,7 +148,11 @@ DEFINE_EVENT(timer_class, timer_cancel, - { HRTIMER_MODE_ABS, "ABS" }, \ - { HRTIMER_MODE_REL, "REL" }, \ - { HRTIMER_MODE_ABS_PINNED, "ABS|PINNED" }, \ -- { HRTIMER_MODE_REL_PINNED, "REL|PINNED" }) -+ { HRTIMER_MODE_REL_PINNED, "REL|PINNED" }, \ -+ { HRTIMER_MODE_ABS_SOFT, "ABS|SOFT" }, \ -+ { HRTIMER_MODE_REL_SOFT, "REL|SOFT" }, \ -+ { HRTIMER_MODE_ABS_PINNED_SOFT, "ABS|PINNED|SOFT" }, \ -+ { HRTIMER_MODE_REL_PINNED_SOFT, "REL|PINNED|SOFT" }) - - /** - * hrtimer_init - called when the hrtimer is initialized ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -92,6 +92,26 @@ DEFINE_PER_CPU(struct hrtimer_cpu_base, - .clockid = CLOCK_TAI, - .get_time = &ktime_get_clocktai, - }, -+ { -+ .index = HRTIMER_BASE_MONOTONIC_SOFT, -+ .clockid = CLOCK_MONOTONIC, -+ .get_time = &ktime_get, -+ }, -+ { -+ .index = HRTIMER_BASE_REALTIME_SOFT, -+ .clockid = CLOCK_REALTIME, -+ .get_time = &ktime_get_real, -+ }, -+ { -+ .index = HRTIMER_BASE_BOOTTIME_SOFT, -+ .clockid = CLOCK_BOOTTIME, -+ .get_time = &ktime_get_boottime, -+ }, -+ { -+ .index = HRTIMER_BASE_TAI_SOFT, -+ .clockid = CLOCK_TAI, -+ .get_time = &ktime_get_clocktai, -+ }, - } - }; - diff --git a/debian/patches/features/all/rt/0026-tracing-Add-onmatch-hist-trigger-action-support.patch b/debian/patches/features/all/rt/0026-tracing-Add-onmatch-hist-trigger-action-support.patch deleted file mode 100644 index 633cd99f1..000000000 --- a/debian/patches/features/all/rt/0026-tracing-Add-onmatch-hist-trigger-action-support.patch +++ /dev/null @@ -1,684 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:52:00 -0600 -Subject: [PATCH 26/37] tracing: Add 'onmatch' hist trigger action support -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Add an 'onmatch(matching.event).(param list)' -hist trigger action which is invoked with the set of variables or -event fields named in the 'param list'. The result is the generation -of a synthetic event that consists of the values contained in those -variables and/or fields at the time the invoking event was hit. - -As an example the below defines a simple synthetic event using a -variable defined on the sched_wakeup_new event, and shows the event -definition with unresolved fields, since the sched_wakeup_new event -with the testpid variable hasn't been defined yet: - - # echo 'wakeup_new_test pid_t pid; int prio' >> \ - /sys/kernel/debug/tracing/synthetic_events - - # cat /sys/kernel/debug/tracing/synthetic_events - wakeup_new_test pid_t pid; int prio - -The following hist trigger both defines a testpid variable and -specifies an onmatch() trace action that uses that variable along with -a non-variable field to generate a wakeup_new_test synthetic event -whenever a sched_wakeup_new event occurs, which because of the 'if -comm == "cyclictest"' filter only happens when the executable is -cyclictest: - - # echo 'hist:testpid=pid:keys=$testpid:\ - onmatch(sched.sched_wakeup_new).wakeup_new_test($testpid, prio) \ - if comm=="cyclictest"' >> \ - /sys/kernel/debug/tracing/events/sched/sched_wakeup_new/trigger - -Creating and displaying a histogram based on those events is now just -a matter of using the fields and new synthetic event in the -tracing/events/synthetic directory, as usual: - - # echo 'hist:keys=pid,prio:sort=pid,prio' >> \ - /sys/kernel/debug/tracing/events/synthetic/wakeup_new_test/trigger - -Signed-off-by: Tom Zanussi -Signed-off-by: Rajvi Jingar -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 488 +++++++++++++++++++++++++++++++++++++-- - 1 file changed, 475 insertions(+), 13 deletions(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -285,6 +285,8 @@ struct hist_trigger_data { - struct action_data *actions[HIST_ACTIONS_MAX]; - unsigned int n_actions; - -+ struct hist_field *synth_var_refs[SYNTH_FIELDS_MAX]; -+ unsigned int n_synth_var_refs; - struct field_var *field_vars[SYNTH_FIELDS_MAX]; - unsigned int n_field_vars; - unsigned int n_field_var_str; -@@ -321,7 +323,18 @@ typedef void (*action_fn_t) (struct hist - - struct action_data { - action_fn_t fn; -- unsigned int var_ref_idx; -+ unsigned int n_params; -+ char *params[SYNTH_FIELDS_MAX]; -+ -+ union { -+ struct { -+ unsigned int var_ref_idx; -+ char *match_event; -+ char *match_event_system; -+ char *synth_event_name; -+ struct synth_event *synth_event; -+ } onmatch; -+ }; - }; - - static LIST_HEAD(synth_event_list); -@@ -887,6 +900,21 @@ static struct synth_event *alloc_synth_e - return event; - } - -+static void action_trace(struct hist_trigger_data *hist_data, -+ struct tracing_map_elt *elt, void *rec, -+ struct ring_buffer_event *rbe, -+ struct action_data *data, u64 *var_ref_vals) -+{ -+ struct synth_event *event = data->onmatch.synth_event; -+ -+ trace_synth(event, var_ref_vals, data->onmatch.var_ref_idx); -+} -+ -+struct hist_var_data { -+ struct list_head list; -+ struct hist_trigger_data *hist_data; -+}; -+ - static void add_or_delete_synth_event(struct synth_event *event, int delete) - { - if (delete) -@@ -1124,11 +1152,6 @@ static u64 hist_field_timestamp(struct h - return ts; - } - --struct hist_var_data { -- struct list_head list; -- struct hist_trigger_data *hist_data; --}; -- - static struct hist_field * - check_field_for_var_ref(struct hist_field *hist_field, - struct hist_trigger_data *var_data, -@@ -1194,6 +1217,14 @@ static struct hist_field *find_var_ref(s - return found; - } - -+ for (i = 0; i < hist_data->n_synth_var_refs; i++) { -+ hist_field = hist_data->synth_var_refs[i]; -+ found = check_field_for_var_refs(hist_data, hist_field, -+ var_data, var_idx, 0); -+ if (found) -+ return found; -+ } -+ - return found; - } - -@@ -1422,6 +1453,37 @@ static struct hist_field *find_file_var( - return NULL; - } - -+static struct hist_field * -+find_match_var(struct hist_trigger_data *hist_data, char *var_name) -+{ -+ struct trace_array *tr = hist_data->event_file->tr; -+ struct hist_field *hist_field, *found = NULL; -+ struct trace_event_file *file; -+ unsigned int i; -+ -+ for (i = 0; i < hist_data->n_actions; i++) { -+ struct action_data *data = hist_data->actions[i]; -+ -+ if (data->fn == action_trace) { -+ char *system = data->onmatch.match_event_system; -+ char *event_name = data->onmatch.match_event; -+ -+ file = find_var_file(tr, system, event_name, var_name); -+ if (!file) -+ continue; -+ hist_field = find_file_var(file, var_name); -+ if (hist_field) { -+ if (found) { -+ return ERR_PTR(-EINVAL); -+ } -+ -+ found = hist_field; -+ } -+ } -+ } -+ return found; -+} -+ - static struct hist_field *find_event_var(struct hist_trigger_data *hist_data, - char *system, - char *event_name, -@@ -1431,6 +1493,14 @@ static struct hist_field *find_event_var - struct hist_field *hist_field = NULL; - struct trace_event_file *file; - -+ if (!system || !event_name) { -+ hist_field = find_match_var(hist_data, var_name); -+ if (IS_ERR(hist_field)) -+ return NULL; -+ if (hist_field) -+ return hist_field; -+ } -+ - file = find_var_file(tr, system, event_name, var_name); - if (!file) - return NULL; -@@ -1622,11 +1692,21 @@ static void destroy_hist_trigger_attrs(s - - static int parse_action(char *str, struct hist_trigger_attrs *attrs) - { -- int ret = 0; -+ int ret = -EINVAL; - - if (attrs->n_actions >= HIST_ACTIONS_MAX) - return ret; - -+ if ((strncmp(str, "onmatch(", strlen("onmatch(")) == 0)) { -+ attrs->action_str[attrs->n_actions] = kstrdup(str, GFP_KERNEL); -+ if (!attrs->action_str[attrs->n_actions]) { -+ ret = -ENOMEM; -+ return ret; -+ } -+ attrs->n_actions++; -+ ret = 0; -+ } -+ - return ret; - } - -@@ -2635,7 +2715,7 @@ find_synthetic_field_var(struct hist_tri - * - * Return: The variable created for the field. - */ --struct hist_field * -+static struct hist_field * - create_field_var_hist(struct hist_trigger_data *target_hist_data, - char *subsys_name, char *event_name, char *field_name) - { -@@ -2748,7 +2828,7 @@ create_field_var_hist(struct hist_trigge - return event_var; - } - --struct hist_field * -+static struct hist_field * - find_target_event_var(struct hist_trigger_data *hist_data, - char *subsys_name, char *event_name, char *var_name) - { -@@ -2919,7 +2999,7 @@ static struct field_var *create_field_va - * - * Return: The variable created for the field. - */ --struct field_var * -+static struct field_var * - create_target_field_var(struct hist_trigger_data *target_hist_data, - char *subsys_name, char *event_name, char *var_name) - { -@@ -2943,6 +3023,27 @@ create_target_field_var(struct hist_trig - return create_field_var(target_hist_data, file, var_name); - } - -+static void onmatch_destroy(struct action_data *data) -+{ -+ unsigned int i; -+ -+ mutex_lock(&synth_event_mutex); -+ -+ kfree(data->onmatch.match_event); -+ kfree(data->onmatch.match_event_system); -+ kfree(data->onmatch.synth_event_name); -+ -+ for (i = 0; i < data->n_params; i++) -+ kfree(data->params[i]); -+ -+ if (data->onmatch.synth_event) -+ data->onmatch.synth_event->ref--; -+ -+ kfree(data); -+ -+ mutex_unlock(&synth_event_mutex); -+} -+ - static void destroy_field_var(struct field_var *field_var) - { - if (!field_var) -@@ -2962,8 +3063,8 @@ static void destroy_field_vars(struct hi - destroy_field_var(hist_data->field_vars[i]); - } - --void save_field_var(struct hist_trigger_data *hist_data, -- struct field_var *field_var) -+static void save_field_var(struct hist_trigger_data *hist_data, -+ struct field_var *field_var) - { - hist_data->field_vars[hist_data->n_field_vars++] = field_var; - -@@ -2971,6 +3072,304 @@ void save_field_var(struct hist_trigger_ - hist_data->n_field_var_str++; - } - -+ -+static void destroy_synth_var_refs(struct hist_trigger_data *hist_data) -+{ -+ unsigned int i; -+ -+ for (i = 0; i < hist_data->n_synth_var_refs; i++) -+ destroy_hist_field(hist_data->synth_var_refs[i], 0); -+} -+ -+static void save_synth_var_ref(struct hist_trigger_data *hist_data, -+ struct hist_field *var_ref) -+{ -+ hist_data->synth_var_refs[hist_data->n_synth_var_refs++] = var_ref; -+ -+ hist_data->var_refs[hist_data->n_var_refs] = var_ref; -+ var_ref->var_ref_idx = hist_data->n_var_refs++; -+} -+ -+static int check_synth_field(struct synth_event *event, -+ struct hist_field *hist_field, -+ unsigned int field_pos) -+{ -+ struct synth_field *field; -+ -+ if (field_pos >= event->n_fields) -+ return -EINVAL; -+ -+ field = event->fields[field_pos]; -+ -+ if (strcmp(field->type, hist_field->type) != 0) -+ return -EINVAL; -+ -+ return 0; -+} -+ -+static int parse_action_params(char *params, struct action_data *data) -+{ -+ char *param, *saved_param; -+ int ret = 0; -+ -+ while (params) { -+ if (data->n_params >= SYNTH_FIELDS_MAX) -+ goto out; -+ -+ param = strsep(¶ms, ","); -+ if (!param) { -+ ret = -EINVAL; -+ goto out; -+ } -+ -+ param = strstrip(param); -+ if (strlen(param) < 2) { -+ ret = -EINVAL; -+ goto out; -+ } -+ -+ saved_param = kstrdup(param, GFP_KERNEL); -+ if (!saved_param) { -+ ret = -ENOMEM; -+ goto out; -+ } -+ -+ data->params[data->n_params++] = saved_param; -+ } -+ out: -+ return ret; -+} -+ -+static struct hist_field * -+onmatch_find_var(struct hist_trigger_data *hist_data, struct action_data *data, -+ char *system, char *event, char *var) -+{ -+ struct hist_field *hist_field; -+ -+ var++; /* skip '$' */ -+ -+ hist_field = find_target_event_var(hist_data, system, event, var); -+ if (!hist_field) { -+ if (!system) { -+ system = data->onmatch.match_event_system; -+ event = data->onmatch.match_event; -+ } -+ -+ hist_field = find_event_var(hist_data, system, event, var); -+ } -+ -+ return hist_field; -+} -+ -+static struct hist_field * -+onmatch_create_field_var(struct hist_trigger_data *hist_data, -+ struct action_data *data, char *system, -+ char *event, char *var) -+{ -+ struct hist_field *hist_field = NULL; -+ struct field_var *field_var; -+ -+ /* -+ * First try to create a field var on the target event (the -+ * currently being defined). This will create a variable for -+ * unqualified fields on the target event, or if qualified, -+ * target fields that have qualified names matching the target. -+ */ -+ field_var = create_target_field_var(hist_data, system, event, var); -+ -+ if (field_var && !IS_ERR(field_var)) { -+ save_field_var(hist_data, field_var); -+ hist_field = field_var->var; -+ } else { -+ field_var = NULL; -+ /* -+ * If no explicit system.event is specfied, default to -+ * looking for fields on the onmatch(system.event.xxx) -+ * event. -+ */ -+ if (!system) { -+ system = data->onmatch.match_event_system; -+ event = data->onmatch.match_event; -+ } -+ -+ /* -+ * At this point, we're looking at a field on another -+ * event. Because we can't modify a hist trigger on -+ * another event to add a variable for a field, we need -+ * to create a new trigger on that event and create the -+ * variable at the same time. -+ */ -+ hist_field = create_field_var_hist(hist_data, system, event, var); -+ if (IS_ERR(hist_field)) -+ goto free; -+ } -+ out: -+ return hist_field; -+ free: -+ destroy_field_var(field_var); -+ hist_field = NULL; -+ goto out; -+} -+ -+static int onmatch_create(struct hist_trigger_data *hist_data, -+ struct trace_event_file *file, -+ struct action_data *data) -+{ -+ char *event_name, *param, *system = NULL; -+ struct hist_field *hist_field, *var_ref; -+ unsigned int i, var_ref_idx; -+ unsigned int field_pos = 0; -+ struct synth_event *event; -+ int ret = 0; -+ -+ mutex_lock(&synth_event_mutex); -+ event = find_synth_event(data->onmatch.synth_event_name); -+ if (!event) { -+ mutex_unlock(&synth_event_mutex); -+ return -EINVAL; -+ } -+ event->ref++; -+ mutex_unlock(&synth_event_mutex); -+ -+ var_ref_idx = hist_data->n_var_refs; -+ -+ for (i = 0; i < data->n_params; i++) { -+ char *p; -+ -+ p = param = kstrdup(data->params[i], GFP_KERNEL); -+ if (!param) { -+ ret = -ENOMEM; -+ goto err; -+ } -+ -+ system = strsep(¶m, "."); -+ if (!param) { -+ param = (char *)system; -+ system = event_name = NULL; -+ } else { -+ event_name = strsep(¶m, "."); -+ if (!param) { -+ kfree(p); -+ ret = -EINVAL; -+ goto err; -+ } -+ } -+ -+ if (param[0] == '$') -+ hist_field = onmatch_find_var(hist_data, data, system, -+ event_name, param); -+ else -+ hist_field = onmatch_create_field_var(hist_data, data, -+ system, -+ event_name, -+ param); -+ -+ if (!hist_field) { -+ kfree(p); -+ ret = -EINVAL; -+ goto err; -+ } -+ -+ if (check_synth_field(event, hist_field, field_pos) == 0) { -+ var_ref = create_var_ref(hist_field, system, event_name); -+ if (!var_ref) { -+ kfree(p); -+ ret = -ENOMEM; -+ goto err; -+ } -+ -+ save_synth_var_ref(hist_data, var_ref); -+ field_pos++; -+ kfree(p); -+ continue; -+ } -+ -+ kfree(p); -+ ret = -EINVAL; -+ goto err; -+ } -+ -+ if (field_pos != event->n_fields) { -+ ret = -EINVAL; -+ goto err; -+ } -+ -+ data->fn = action_trace; -+ data->onmatch.synth_event = event; -+ data->onmatch.var_ref_idx = var_ref_idx; -+ out: -+ return ret; -+ err: -+ mutex_lock(&synth_event_mutex); -+ event->ref--; -+ mutex_unlock(&synth_event_mutex); -+ -+ goto out; -+} -+ -+static struct action_data *onmatch_parse(struct trace_array *tr, char *str) -+{ -+ char *match_event, *match_event_system; -+ char *synth_event_name, *params; -+ struct action_data *data; -+ int ret = -EINVAL; -+ -+ data = kzalloc(sizeof(*data), GFP_KERNEL); -+ if (!data) -+ return ERR_PTR(-ENOMEM); -+ -+ match_event = strsep(&str, ")"); -+ if (!match_event || !str) -+ goto free; -+ -+ match_event_system = strsep(&match_event, "."); -+ if (!match_event) -+ goto free; -+ -+ if (IS_ERR(event_file(tr, match_event_system, match_event))) -+ goto free; -+ -+ data->onmatch.match_event = kstrdup(match_event, GFP_KERNEL); -+ if (!data->onmatch.match_event) { -+ ret = -ENOMEM; -+ goto free; -+ } -+ -+ data->onmatch.match_event_system = kstrdup(match_event_system, GFP_KERNEL); -+ if (!data->onmatch.match_event_system) { -+ ret = -ENOMEM; -+ goto free; -+ } -+ -+ strsep(&str, "."); -+ if (!str) -+ goto free; -+ -+ synth_event_name = strsep(&str, "("); -+ if (!synth_event_name || !str) -+ goto free; -+ -+ data->onmatch.synth_event_name = kstrdup(synth_event_name, GFP_KERNEL); -+ if (!data->onmatch.synth_event_name) { -+ ret = -ENOMEM; -+ goto free; -+ } -+ -+ params = strsep(&str, ")"); -+ if (!params || !str || (str && strlen(str))) -+ goto free; -+ -+ ret = parse_action_params(params, data); -+ if (ret) -+ goto free; -+ out: -+ return data; -+ free: -+ onmatch_destroy(data); -+ data = ERR_PTR(ret); -+ goto out; -+} -+ - static int create_hitcount_val(struct hist_trigger_data *hist_data) - { - hist_data->fields[HITCOUNT_IDX] = -@@ -3395,18 +3794,39 @@ static void destroy_actions(struct hist_ - for (i = 0; i < hist_data->n_actions; i++) { - struct action_data *data = hist_data->actions[i]; - -- kfree(data); -+ if (data->fn == action_trace) -+ onmatch_destroy(data); -+ else -+ kfree(data); - } - } - - static int parse_actions(struct hist_trigger_data *hist_data) - { -+ struct trace_array *tr = hist_data->event_file->tr; -+ struct action_data *data; - unsigned int i; - int ret = 0; - char *str; - - for (i = 0; i < hist_data->attrs->n_actions; i++) { - str = hist_data->attrs->action_str[i]; -+ -+ if (strncmp(str, "onmatch(", strlen("onmatch(")) == 0) { -+ char *action_str = str + strlen("onmatch("); -+ -+ data = onmatch_parse(tr, action_str); -+ if (IS_ERR(data)) { -+ ret = PTR_ERR(data); -+ break; -+ } -+ data->fn = action_trace; -+ } else { -+ ret = -EINVAL; -+ break; -+ } -+ -+ hist_data->actions[hist_data->n_actions++] = data; - } - - return ret; -@@ -3421,11 +3841,50 @@ static int create_actions(struct hist_tr - - for (i = 0; i < hist_data->attrs->n_actions; i++) { - data = hist_data->actions[i]; -+ -+ if (data->fn == action_trace) { -+ ret = onmatch_create(hist_data, file, data); -+ if (ret) -+ return ret; -+ } - } - - return ret; - } - -+static void print_onmatch_spec(struct seq_file *m, -+ struct hist_trigger_data *hist_data, -+ struct action_data *data) -+{ -+ unsigned int i; -+ -+ seq_printf(m, ":onmatch(%s.%s).", data->onmatch.match_event_system, -+ data->onmatch.match_event); -+ -+ seq_printf(m, "%s(", data->onmatch.synth_event->name); -+ -+ for (i = 0; i < data->n_params; i++) { -+ if (i) -+ seq_puts(m, ","); -+ seq_printf(m, "%s", data->params[i]); -+ } -+ -+ seq_puts(m, ")"); -+} -+ -+static void print_actions_spec(struct seq_file *m, -+ struct hist_trigger_data *hist_data) -+{ -+ unsigned int i; -+ -+ for (i = 0; i < hist_data->n_actions; i++) { -+ struct action_data *data = hist_data->actions[i]; -+ -+ if (data->fn == action_trace) -+ print_onmatch_spec(m, hist_data, data); -+ } -+} -+ - static void destroy_field_var_hists(struct hist_trigger_data *hist_data) - { - unsigned int i; -@@ -3448,6 +3907,7 @@ static void destroy_hist_data(struct his - destroy_actions(hist_data); - destroy_field_vars(hist_data); - destroy_field_var_hists(hist_data); -+ destroy_synth_var_refs(hist_data); - - kfree(hist_data); - } -@@ -4006,6 +4466,8 @@ static int event_hist_trigger_print(stru - } - seq_printf(m, ":size=%u", (1 << hist_data->map->map_bits)); - -+ print_actions_spec(m, hist_data); -+ - if (data->filter_str) - seq_printf(m, " if %s", data->filter_str); - diff --git a/debian/patches/features/all/rt/0026-tracing-Add-simple-expression-support-to-hist-trigge.patch b/debian/patches/features/all/rt/0026-tracing-Add-simple-expression-support-to-hist-trigge.patch index ff365787e..acfd1dd1f 100644 --- a/debian/patches/features/all/rt/0026-tracing-Add-simple-expression-support-to-hist-trigge.patch +++ b/debian/patches/features/all/rt/0026-tracing-Add-simple-expression-support-to-hist-trigge.patch @@ -1,7 +1,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:52 -0600 Subject: [PATCH 26/48] tracing: Add simple expression support to hist triggers -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Add support for simple addition, subtraction, and unary expressions (-(expr) and expr, where expr = b-a, a+b, a+b+c) to hist triggers, in diff --git a/debian/patches/features/all/rt/0027-hrtimer-Prepare-handling-of-hard-and-softirq-based-h.patch b/debian/patches/features/all/rt/0027-hrtimer-Prepare-handling-of-hard-and-softirq-based-h.patch deleted file mode 100644 index 0b3cdabff..000000000 --- a/debian/patches/features/all/rt/0027-hrtimer-Prepare-handling-of-hard-and-softirq-based-h.patch +++ /dev/null @@ -1,117 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:13:16 +0100 -Subject: [PATCH 27/29] hrtimer: Prepare handling of hard and softirq based - hrtimers -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The softirq based hrtimer can utilize most of the existing hrtimers -functions, but need to operate on a different data set. - -Add an active_mask argument to various functions so the hard and soft bases -can be selected. Fixup the existing callers and hand in the ACTIVE_HARD -mask. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/time/hrtimer.c | 38 +++++++++++++++++++++++++++++--------- - 1 file changed, 29 insertions(+), 9 deletions(-) - ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -60,6 +60,15 @@ - #include "tick-internal.h" - - /* -+ * Masks for selecting the soft and hard context timers from -+ * cpu_base->active -+ */ -+#define MASK_SHIFT (HRTIMER_BASE_MONOTONIC_SOFT) -+#define HRTIMER_ACTIVE_HARD ((1U << MASK_SHIFT) - 1) -+#define HRTIMER_ACTIVE_SOFT (HRTIMER_ACTIVE_HARD << MASK_SHIFT) -+#define HRTIMER_ACTIVE_ALL (HRTIMER_ACTIVE_SOFT | HRTIMER_ACTIVE_HARD) -+ -+/* - * The timer bases: - * - * There are more clockids than hrtimer bases. Thus, we index -@@ -508,13 +517,24 @@ static ktime_t __hrtimer_next_event_base - return expires_next; - } - --static ktime_t __hrtimer_get_next_event(struct hrtimer_cpu_base *cpu_base) -+/* -+ * Recomputes cpu_base::*next_timer and returns the earliest expires_next but -+ * does not set cpu_base::*expires_next, that is done by hrtimer_reprogram. -+ * -+ * @active_mask must be one of: -+ * - HRTIMER_ACTIVE, -+ * - HRTIMER_ACTIVE_SOFT, or -+ * - HRTIMER_ACTIVE_HARD. -+ */ -+static ktime_t __hrtimer_get_next_event(struct hrtimer_cpu_base *cpu_base, -+ unsigned int active_mask) - { -- unsigned int active = cpu_base->active_bases; -+ unsigned int active; - ktime_t expires_next = KTIME_MAX; - - cpu_base->next_timer = NULL; - -+ active = cpu_base->active_bases & active_mask; - expires_next = __hrtimer_next_event_base(cpu_base, active, expires_next); - - return expires_next; -@@ -555,7 +575,7 @@ hrtimer_force_reprogram(struct hrtimer_c - { - ktime_t expires_next; - -- expires_next = __hrtimer_get_next_event(cpu_base); -+ expires_next = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_HARD); - - if (skip_equal && expires_next == cpu_base->expires_next) - return; -@@ -1078,7 +1098,7 @@ u64 hrtimer_get_next_event(void) - raw_spin_lock_irqsave(&cpu_base->lock, flags); - - if (!__hrtimer_hres_active(cpu_base)) -- expires = __hrtimer_get_next_event(cpu_base); -+ expires = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_HARD); - - raw_spin_unlock_irqrestore(&cpu_base->lock, flags); - -@@ -1252,10 +1272,10 @@ static void __run_hrtimer(struct hrtimer - } - - static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t now, -- unsigned long flags) -+ unsigned long flags, unsigned int active_mask) - { - struct hrtimer_clock_base *base; -- unsigned int active = cpu_base->active_bases; -+ unsigned int active = cpu_base->active_bases & active_mask; - - for_each_active_base(base, cpu_base, active) { - struct timerqueue_node *node; -@@ -1318,10 +1338,10 @@ void hrtimer_interrupt(struct clock_even - */ - cpu_base->expires_next = KTIME_MAX; - -- __hrtimer_run_queues(cpu_base, now, flags); -+ __hrtimer_run_queues(cpu_base, now, flags, HRTIMER_ACTIVE_HARD); - - /* Reevaluate the clock bases for the next expiry */ -- expires_next = __hrtimer_get_next_event(cpu_base); -+ expires_next = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_HARD); - /* - * Store the new expiry value so the migration code can verify - * against it. -@@ -1425,7 +1445,7 @@ void hrtimer_run_queues(void) - - raw_spin_lock_irqsave(&cpu_base->lock, flags); - now = hrtimer_update_base(cpu_base); -- __hrtimer_run_queues(cpu_base, now, flags); -+ __hrtimer_run_queues(cpu_base, now, flags, HRTIMER_ACTIVE_HARD); - raw_spin_unlock_irqrestore(&cpu_base->lock, flags); - } - diff --git a/debian/patches/features/all/rt/0027-tracing-Add-onmax-hist-trigger-action-support.patch b/debian/patches/features/all/rt/0027-tracing-Add-onmax-hist-trigger-action-support.patch deleted file mode 100644 index 8544f9198..000000000 --- a/debian/patches/features/all/rt/0027-tracing-Add-onmax-hist-trigger-action-support.patch +++ /dev/null @@ -1,483 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:52:01 -0600 -Subject: [PATCH 27/37] tracing: Add 'onmax' hist trigger action support -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Add an 'onmax(var).save(field,...)' hist trigger action which is -invoked whenever an event exceeds the current maximum. - -The end result is that the trace event fields or variables specified -as the onmax.save() params will be saved if 'var' exceeds the current -maximum for that hist trigger entry. This allows context from the -event that exhibited the new maximum to be saved for later reference. -When the histogram is displayed, additional fields displaying the -saved values will be printed. - -As an example the below defines a couple of hist triggers, one for -sched_wakeup and another for sched_switch, keyed on pid. Whenever a -sched_wakeup occurs, the timestamp is saved in the entry corresponding -to the current pid, and when the scheduler switches back to that pid, -the timestamp difference is calculated. If the resulting latency -exceeds the current maximum latency, the specified save() values are -saved: - - # echo 'hist:keys=pid:ts0=common_timestamp.usecs \ - if comm=="cyclictest"' >> \ - /sys/kernel/debug/tracing/events/sched/sched_wakeup/trigger - - # echo 'hist:keys=next_pid:\ - wakeup_lat=common_timestamp.usecs-$ts0:\ - onmax($wakeup_lat).save(next_comm,prev_pid,prev_prio,prev_comm) \ - if next_comm=="cyclictest"' >> \ - /sys/kernel/debug/tracing/events/sched/sched_switch/trigger - -When the histogram is displayed, the max value and the saved values -corresponding to the max are displayed following the rest of the -fields: - - # cat /sys/kernel/debug/tracing/events/sched/sched_switch/hist - - { next_pid: 3728 } hitcount: 199 \ - max: 123 next_comm: cyclictest prev_pid: 0 \ - prev_prio: 120 prev_comm: swapper/3 - { next_pid: 3730 } hitcount: 1321 \ - max: 15 next_comm: cyclictest prev_pid: 0 \ - prev_prio: 120 prev_comm: swapper/1 - { next_pid: 3729 } hitcount: 1973\ - max: 25 next_comm: cyclictest prev_pid: 0 \ - prev_prio: 120 prev_comm: swapper/0 - - Totals: - Hits: 3493 - Entries: 3 - Dropped: 0 - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 331 ++++++++++++++++++++++++++++++++++----- - 1 file changed, 296 insertions(+), 35 deletions(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -292,6 +292,10 @@ struct hist_trigger_data { - unsigned int n_field_var_str; - struct field_var_hist *field_var_hists[SYNTH_FIELDS_MAX]; - unsigned int n_field_var_hists; -+ -+ struct field_var *max_vars[SYNTH_FIELDS_MAX]; -+ unsigned int n_max_vars; -+ unsigned int n_max_var_str; - }; - - struct synth_field { -@@ -334,6 +338,14 @@ struct action_data { - char *synth_event_name; - struct synth_event *synth_event; - } onmatch; -+ -+ struct { -+ char *var_str; -+ char *fn_name; -+ unsigned int max_var_ref_idx; -+ struct hist_field *max_var; -+ struct hist_field *var; -+ } onmax; - }; - }; - -@@ -1697,7 +1709,8 @@ static int parse_action(char *str, struc - if (attrs->n_actions >= HIST_ACTIONS_MAX) - return ret; - -- if ((strncmp(str, "onmatch(", strlen("onmatch(")) == 0)) { -+ if ((strncmp(str, "onmatch(", strlen("onmatch(")) == 0) || -+ (strncmp(str, "onmax(", strlen("onmax(")) == 0)) { - attrs->action_str[attrs->n_actions] = kstrdup(str, GFP_KERNEL); - if (!attrs->action_str[attrs->n_actions]) { - ret = -ENOMEM; -@@ -1869,7 +1882,7 @@ static int hist_trigger_elt_data_alloc(s - } - } - -- n_str = hist_data->n_field_var_str; -+ n_str = hist_data->n_field_var_str + hist_data->n_max_var_str; - - size = STR_VAR_LEN_MAX; - -@@ -2894,6 +2907,15 @@ static void update_field_vars(struct his - hist_data->n_field_vars, 0); - } - -+static void update_max_vars(struct hist_trigger_data *hist_data, -+ struct tracing_map_elt *elt, -+ struct ring_buffer_event *rbe, -+ void *rec) -+{ -+ __update_field_vars(elt, rbe, rec, hist_data->max_vars, -+ hist_data->n_max_vars, hist_data->n_field_var_str); -+} -+ - static struct hist_field *create_var(struct hist_trigger_data *hist_data, - struct trace_event_file *file, - char *name, int size, const char *type) -@@ -3023,6 +3045,227 @@ create_target_field_var(struct hist_trig - return create_field_var(target_hist_data, file, var_name); - } - -+static void onmax_print(struct seq_file *m, -+ struct hist_trigger_data *hist_data, -+ struct tracing_map_elt *elt, -+ struct action_data *data) -+{ -+ unsigned int i, save_var_idx, max_idx = data->onmax.max_var->var.idx; -+ -+ seq_printf(m, "\n\tmax: %10llu", tracing_map_read_var(elt, max_idx)); -+ -+ for (i = 0; i < hist_data->n_max_vars; i++) { -+ struct hist_field *save_val = hist_data->max_vars[i]->val; -+ struct hist_field *save_var = hist_data->max_vars[i]->var; -+ u64 val; -+ -+ save_var_idx = save_var->var.idx; -+ -+ val = tracing_map_read_var(elt, save_var_idx); -+ -+ if (save_val->flags & HIST_FIELD_FL_STRING) { -+ seq_printf(m, " %s: %-32s", save_var->var.name, -+ (char *)(uintptr_t)(val)); -+ } else -+ seq_printf(m, " %s: %10llu", save_var->var.name, val); -+ } -+} -+ -+static void onmax_save(struct hist_trigger_data *hist_data, -+ struct tracing_map_elt *elt, void *rec, -+ struct ring_buffer_event *rbe, -+ struct action_data *data, u64 *var_ref_vals) -+{ -+ unsigned int max_idx = data->onmax.max_var->var.idx; -+ unsigned int max_var_ref_idx = data->onmax.max_var_ref_idx; -+ -+ u64 var_val, max_val; -+ -+ var_val = var_ref_vals[max_var_ref_idx]; -+ max_val = tracing_map_read_var(elt, max_idx); -+ -+ if (var_val <= max_val) -+ return; -+ -+ tracing_map_set_var(elt, max_idx, var_val); -+ -+ update_max_vars(hist_data, elt, rbe, rec); -+} -+ -+static void onmax_destroy(struct action_data *data) -+{ -+ unsigned int i; -+ -+ destroy_hist_field(data->onmax.max_var, 0); -+ destroy_hist_field(data->onmax.var, 0); -+ -+ kfree(data->onmax.var_str); -+ kfree(data->onmax.fn_name); -+ -+ for (i = 0; i < data->n_params; i++) -+ kfree(data->params[i]); -+ -+ kfree(data); -+} -+ -+static int onmax_create(struct hist_trigger_data *hist_data, -+ struct action_data *data) -+{ -+ struct trace_event_file *file = hist_data->event_file; -+ struct hist_field *var_field, *ref_field, *max_var; -+ unsigned int var_ref_idx = hist_data->n_var_refs; -+ struct field_var *field_var; -+ char *onmax_var_str, *param; -+ unsigned long flags; -+ unsigned int i; -+ int ret = 0; -+ -+ onmax_var_str = data->onmax.var_str; -+ if (onmax_var_str[0] != '$') -+ return -EINVAL; -+ onmax_var_str++; -+ -+ var_field = find_target_event_var(hist_data, NULL, NULL, onmax_var_str); -+ if (!var_field) -+ return -EINVAL; -+ -+ flags = HIST_FIELD_FL_VAR_REF; -+ ref_field = create_hist_field(hist_data, NULL, flags, NULL); -+ if (!ref_field) -+ return -ENOMEM; -+ -+ if (init_var_ref(ref_field, var_field, NULL, NULL)) { -+ destroy_hist_field(ref_field, 0); -+ ret = -ENOMEM; -+ goto out; -+ } -+ hist_data->var_refs[hist_data->n_var_refs] = ref_field; -+ ref_field->var_ref_idx = hist_data->n_var_refs++; -+ data->onmax.var = ref_field; -+ -+ data->fn = onmax_save; -+ data->onmax.max_var_ref_idx = var_ref_idx; -+ max_var = create_var(hist_data, file, "max", sizeof(u64), "u64"); -+ if (IS_ERR(max_var)) { -+ ret = PTR_ERR(max_var); -+ goto out; -+ } -+ data->onmax.max_var = max_var; -+ -+ for (i = 0; i < data->n_params; i++) { -+ param = kstrdup(data->params[i], GFP_KERNEL); -+ if (!param) { -+ ret = -ENOMEM; -+ goto out; -+ } -+ -+ field_var = create_target_field_var(hist_data, NULL, NULL, param); -+ if (IS_ERR(field_var)) { -+ ret = PTR_ERR(field_var); -+ kfree(param); -+ goto out; -+ } -+ -+ hist_data->max_vars[hist_data->n_max_vars++] = field_var; -+ if (field_var->val->flags & HIST_FIELD_FL_STRING) -+ hist_data->n_max_var_str++; -+ -+ kfree(param); -+ } -+ out: -+ return ret; -+} -+ -+static int parse_action_params(char *params, struct action_data *data) -+{ -+ char *param, *saved_param; -+ int ret = 0; -+ -+ while (params) { -+ if (data->n_params >= SYNTH_FIELDS_MAX) -+ goto out; -+ -+ param = strsep(¶ms, ","); -+ if (!param) { -+ ret = -EINVAL; -+ goto out; -+ } -+ -+ param = strstrip(param); -+ if (strlen(param) < 2) { -+ ret = -EINVAL; -+ goto out; -+ } -+ -+ saved_param = kstrdup(param, GFP_KERNEL); -+ if (!saved_param) { -+ ret = -ENOMEM; -+ goto out; -+ } -+ -+ data->params[data->n_params++] = saved_param; -+ } -+ out: -+ return ret; -+} -+ -+static struct action_data *onmax_parse(char *str) -+{ -+ char *onmax_fn_name, *onmax_var_str; -+ struct action_data *data; -+ int ret = -EINVAL; -+ -+ data = kzalloc(sizeof(*data), GFP_KERNEL); -+ if (!data) -+ return ERR_PTR(-ENOMEM); -+ -+ onmax_var_str = strsep(&str, ")"); -+ if (!onmax_var_str || !str) { -+ ret = -EINVAL; -+ goto free; -+ } -+ -+ data->onmax.var_str = kstrdup(onmax_var_str, GFP_KERNEL); -+ if (!data->onmax.var_str) { -+ ret = -ENOMEM; -+ goto free; -+ } -+ -+ strsep(&str, "."); -+ if (!str) -+ goto free; -+ -+ onmax_fn_name = strsep(&str, "("); -+ if (!onmax_fn_name || !str) -+ goto free; -+ -+ if (strncmp(onmax_fn_name, "save", strlen("save")) == 0) { -+ char *params = strsep(&str, ")"); -+ -+ if (!params) { -+ ret = -EINVAL; -+ goto free; -+ } -+ -+ ret = parse_action_params(params, data); -+ if (ret) -+ goto free; -+ } else -+ goto free; -+ -+ data->onmax.fn_name = kstrdup(onmax_fn_name, GFP_KERNEL); -+ if (!data->onmax.fn_name) { -+ ret = -ENOMEM; -+ goto free; -+ } -+ out: -+ return data; -+ free: -+ onmax_destroy(data); -+ data = ERR_PTR(ret); -+ goto out; -+} -+ - static void onmatch_destroy(struct action_data *data) - { - unsigned int i; -@@ -3107,39 +3350,6 @@ static int check_synth_field(struct synt - return 0; - } - --static int parse_action_params(char *params, struct action_data *data) --{ -- char *param, *saved_param; -- int ret = 0; -- -- while (params) { -- if (data->n_params >= SYNTH_FIELDS_MAX) -- goto out; -- -- param = strsep(¶ms, ","); -- if (!param) { -- ret = -EINVAL; -- goto out; -- } -- -- param = strstrip(param); -- if (strlen(param) < 2) { -- ret = -EINVAL; -- goto out; -- } -- -- saved_param = kstrdup(param, GFP_KERNEL); -- if (!saved_param) { -- ret = -ENOMEM; -- goto out; -- } -- -- data->params[data->n_params++] = saved_param; -- } -- out: -- return ret; --} -- - static struct hist_field * - onmatch_find_var(struct hist_trigger_data *hist_data, struct action_data *data, - char *system, char *event, char *var) -@@ -3796,6 +4006,8 @@ static void destroy_actions(struct hist_ - - if (data->fn == action_trace) - onmatch_destroy(data); -+ else if (data->fn == onmax_save) -+ onmax_destroy(data); - else - kfree(data); - } -@@ -3821,6 +4033,15 @@ static int parse_actions(struct hist_tri - break; - } - data->fn = action_trace; -+ } else if (strncmp(str, "onmax(", strlen("onmax(")) == 0) { -+ char *action_str = str + strlen("onmax("); -+ -+ data = onmax_parse(action_str); -+ if (IS_ERR(data)) { -+ ret = PTR_ERR(data); -+ break; -+ } -+ data->fn = onmax_save; - } else { - ret = -EINVAL; - break; -@@ -3846,12 +4067,48 @@ static int create_actions(struct hist_tr - ret = onmatch_create(hist_data, file, data); - if (ret) - return ret; -+ } else if (data->fn == onmax_save) { -+ ret = onmax_create(hist_data, data); -+ if (ret) -+ return ret; - } - } - - return ret; - } - -+static void print_actions(struct seq_file *m, -+ struct hist_trigger_data *hist_data, -+ struct tracing_map_elt *elt) -+{ -+ unsigned int i; -+ -+ for (i = 0; i < hist_data->n_actions; i++) { -+ struct action_data *data = hist_data->actions[i]; -+ -+ if (data->fn == onmax_save) -+ onmax_print(m, hist_data, elt, data); -+ } -+} -+ -+static void print_onmax_spec(struct seq_file *m, -+ struct hist_trigger_data *hist_data, -+ struct action_data *data) -+{ -+ unsigned int i; -+ -+ seq_puts(m, ":onmax("); -+ seq_printf(m, "%s", data->onmax.var_str); -+ seq_printf(m, ").%s(", data->onmax.fn_name); -+ -+ for (i = 0; i < hist_data->n_max_vars; i++) { -+ seq_printf(m, "%s", hist_data->max_vars[i]->var->var.name); -+ if (i < hist_data->n_max_vars - 1) -+ seq_puts(m, ","); -+ } -+ seq_puts(m, ")"); -+} -+ - static void print_onmatch_spec(struct seq_file *m, - struct hist_trigger_data *hist_data, - struct action_data *data) -@@ -3882,6 +4139,8 @@ static void print_actions_spec(struct se - - if (data->fn == action_trace) - print_onmatch_spec(m, hist_data, data); -+ else if (data->fn == onmax_save) -+ print_onmax_spec(m, hist_data, data); - } - } - -@@ -4263,6 +4522,8 @@ hist_trigger_entry_print(struct seq_file - } - } - -+ print_actions(m, hist_data, elt); -+ - seq_puts(m, "\n"); - } - diff --git a/debian/patches/features/all/rt/0027-tracing-Generalize-per-element-hist-trigger-data.patch b/debian/patches/features/all/rt/0027-tracing-Generalize-per-element-hist-trigger-data.patch index c900f0fb5..c51640d37 100644 --- a/debian/patches/features/all/rt/0027-tracing-Generalize-per-element-hist-trigger-data.patch +++ b/debian/patches/features/all/rt/0027-tracing-Generalize-per-element-hist-trigger-data.patch @@ -1,7 +1,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:53 -0600 Subject: [PATCH 27/48] tracing: Generalize per-element hist trigger data -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Up until now, hist triggers only needed per-element support for saving 'comm' data, which was saved directly as a private data pointer. diff --git a/debian/patches/features/all/rt/0028-hrtimer-Implement-support-for-softirq-based-hrtimers.patch b/debian/patches/features/all/rt/0028-hrtimer-Implement-support-for-softirq-based-hrtimers.patch deleted file mode 100644 index 40f6e1247..000000000 --- a/debian/patches/features/all/rt/0028-hrtimer-Implement-support-for-softirq-based-hrtimers.patch +++ /dev/null @@ -1,497 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:13:17 +0100 -Subject: [PATCH 28/29] hrtimer: Implement support for softirq based hrtimers -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -hrtimer callbacks are always invoked in hard interrupt context. Several -users in tree require soft interrupt context for their callbacks and -achieve this by combining a hrtimer with a tasklet. The hrtimer schedules -the tasklet in hard interrupt context and the tasklet callback gets invoked -in softirq context later. - -That's suboptimal and aside of that the real-time patch moves most of the -hrtimers into softirq context. So adding native support for hrtimers -expiring in softirq context is a valuable extension for both mainline and -the RT patch set. - -Each valid hrtimer clock id has two associated hrtimer clock bases: one for -timers expiring in hardirq context and one for timers expiring in softirq -context. - -Implement the functionality to associate a hrtimer with the hard or softirq -related clock bases and update the relevant functions to take them into -account when the next expiry time needs to be evaluated. - -Add a check into the hard interrupt context handler functions to check -whether the first expiring softirq based timer has expired. If it's expired -the softirq is raised and the accounting of softirq based timers to -evaluate the next expiry time for programming the timer hardware is skipped -until the softirq processing has finished. At the end of the softirq -processing the regular processing is resumed. - -Suggested-by: Thomas Gleixner -Suggested-by: Peter Zijlstra -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - include/linux/hrtimer.h | 21 +++-- - kernel/time/hrtimer.c | 198 +++++++++++++++++++++++++++++++++++++++++------- - 2 files changed, 188 insertions(+), 31 deletions(-) - ---- a/include/linux/hrtimer.h -+++ b/include/linux/hrtimer.h -@@ -103,6 +103,7 @@ enum hrtimer_restart { - * @base: pointer to the timer base (per cpu and per clock) - * @state: state information (See bit values above) - * @is_rel: Set if the timer was armed relative -+ * @is_soft: Set if hrtimer will be expired in soft interrupt context. - * - * The hrtimer structure must be initialized by hrtimer_init() - */ -@@ -113,6 +114,7 @@ struct hrtimer { - struct hrtimer_clock_base *base; - u8 state; - u8 is_rel; -+ u8 is_soft; - }; - - /** -@@ -178,13 +180,18 @@ enum hrtimer_base_type { - * @hres_active: State of high resolution mode - * @in_hrtirq: hrtimer_interrupt() is currently executing - * @hang_detected: The last hrtimer interrupt detected a hang -+ * @softirq_activated: displays, if the softirq is raised - update of softirq -+ * related settings is not required then. - * @nr_events: Total number of hrtimer interrupt events - * @nr_retries: Total number of hrtimer interrupt retries - * @nr_hangs: Total number of hrtimer interrupt hangs - * @max_hang_time: Maximum time spent in hrtimer_interrupt - * @expires_next: absolute time of the next event, is required for remote -- * hrtimer enqueue -+ * hrtimer enqueue; it is the total first expiry time (hard -+ * and soft hrtimer are taken into account) - * @next_timer: Pointer to the first expiring timer -+ * @softirq_expires_next: Time to check, if soft queues needs also to be expired -+ * @softirq_next_timer: Pointer to the first expiring softirq based timer - * @clock_base: array of clock bases for this cpu - * - * Note: next_timer is just an optimization for __remove_hrtimer(). -@@ -196,9 +203,10 @@ struct hrtimer_cpu_base { - unsigned int cpu; - unsigned int active_bases; - unsigned int clock_was_set_seq; -- unsigned int hres_active : 1, -- in_hrtirq : 1, -- hang_detected : 1; -+ unsigned int hres_active : 1, -+ in_hrtirq : 1, -+ hang_detected : 1, -+ softirq_activated : 1; - #ifdef CONFIG_HIGH_RES_TIMERS - unsigned int nr_events; - unsigned short nr_retries; -@@ -207,6 +215,8 @@ struct hrtimer_cpu_base { - #endif - ktime_t expires_next; - struct hrtimer *next_timer; -+ ktime_t softirq_expires_next; -+ struct hrtimer *softirq_next_timer; - struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES]; - } ____cacheline_aligned; - -@@ -379,7 +389,8 @@ extern void hrtimer_start_range_ns(struc - * @timer: the timer to be added - * @tim: expiry time - * @mode: timer mode: absolute (HRTIMER_MODE_ABS) or -- * relative (HRTIMER_MODE_REL), and pinned (HRTIMER_MODE_PINNED) -+ * relative (HRTIMER_MODE_REL), and pinned (HRTIMER_MODE_PINNED); -+ * softirq based mode is considered for debug purpose only! - */ - static inline void hrtimer_start(struct hrtimer *timer, ktime_t tim, - const enum hrtimer_mode mode) ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -411,7 +411,8 @@ static inline void debug_hrtimer_init(st - debug_object_init(timer, &hrtimer_debug_descr); - } - --static inline void debug_hrtimer_activate(struct hrtimer *timer) -+static inline void debug_hrtimer_activate(struct hrtimer *timer, -+ enum hrtimer_mode mode) - { - debug_object_activate(timer, &hrtimer_debug_descr); - } -@@ -444,8 +445,10 @@ void destroy_hrtimer_on_stack(struct hrt - EXPORT_SYMBOL_GPL(destroy_hrtimer_on_stack); - - #else -+ - static inline void debug_hrtimer_init(struct hrtimer *timer) { } --static inline void debug_hrtimer_activate(struct hrtimer *timer) { } -+static inline void debug_hrtimer_activate(struct hrtimer *timer, -+ enum hrtimer_mode mode) { } - static inline void debug_hrtimer_deactivate(struct hrtimer *timer) { } - #endif - -@@ -460,7 +463,7 @@ debug_init(struct hrtimer *timer, clocki - static inline void debug_activate(struct hrtimer *timer, - enum hrtimer_mode mode) - { -- debug_hrtimer_activate(timer); -+ debug_hrtimer_activate(timer, mode); - trace_hrtimer_start(timer, mode); - } - -@@ -487,7 +490,6 @@ static struct hrtimer_clock_base * - #define for_each_active_base(base, cpu_base, active) \ - while ((base = __next_base((cpu_base), &(active)))) - --#if defined(CONFIG_NO_HZ_COMMON) || defined(CONFIG_HIGH_RES_TIMERS) - static ktime_t __hrtimer_next_event_base(struct hrtimer_cpu_base *cpu_base, - unsigned int active, - ktime_t expires_next) -@@ -504,7 +506,10 @@ static ktime_t __hrtimer_next_event_base - expires = ktime_sub(hrtimer_get_expires(timer), base->offset); - if (expires < expires_next) { - expires_next = expires; -- cpu_base->next_timer = timer; -+ if (timer->is_soft) -+ cpu_base->softirq_next_timer = timer; -+ else -+ cpu_base->next_timer = timer; - } - } - /* -@@ -521,25 +526,42 @@ static ktime_t __hrtimer_next_event_base - * Recomputes cpu_base::*next_timer and returns the earliest expires_next but - * does not set cpu_base::*expires_next, that is done by hrtimer_reprogram. - * -+ * When a softirq is pending, we can ignore the HRTIMER_ACTIVE_SOFT bases, -+ * those timers will get run whenever the softirq gets handled, at the end of -+ * hrtimer_run_softirq(), hrtimer_update_softirq_timer() will re-add these bases. -+ * -+ * Therefore softirq values are those from the HRTIMER_ACTIVE_SOFT clock bases. -+ * The !softirq values are the minima across HRTIMER_ACTIVE_ALL, unless an actual -+ * softirq is pending, in which case they're the minima of HRTIMER_ACTIVE_HARD. -+ * - * @active_mask must be one of: -- * - HRTIMER_ACTIVE, -+ * - HRTIMER_ACTIVE_ALL, - * - HRTIMER_ACTIVE_SOFT, or - * - HRTIMER_ACTIVE_HARD. - */ --static ktime_t __hrtimer_get_next_event(struct hrtimer_cpu_base *cpu_base, -- unsigned int active_mask) -+static ktime_t -+__hrtimer_get_next_event(struct hrtimer_cpu_base *cpu_base, unsigned int active_mask) - { - unsigned int active; -+ struct hrtimer *next_timer = NULL; - ktime_t expires_next = KTIME_MAX; - -- cpu_base->next_timer = NULL; -+ if (!cpu_base->softirq_activated && (active_mask & HRTIMER_ACTIVE_SOFT)) { -+ active = cpu_base->active_bases & HRTIMER_ACTIVE_SOFT; -+ cpu_base->softirq_next_timer = NULL; -+ expires_next = __hrtimer_next_event_base(cpu_base, active, KTIME_MAX); -+ -+ next_timer = cpu_base->softirq_next_timer; -+ } - -- active = cpu_base->active_bases & active_mask; -- expires_next = __hrtimer_next_event_base(cpu_base, active, expires_next); -+ if (active_mask & HRTIMER_ACTIVE_HARD) { -+ active = cpu_base->active_bases & HRTIMER_ACTIVE_HARD; -+ cpu_base->next_timer = next_timer; -+ expires_next = __hrtimer_next_event_base(cpu_base, active, expires_next); -+ } - - return expires_next; - } --#endif - - static inline ktime_t hrtimer_update_base(struct hrtimer_cpu_base *base) - { -@@ -547,8 +569,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; - } - - /* -@@ -575,7 +603,23 @@ hrtimer_force_reprogram(struct hrtimer_c - { - ktime_t expires_next; - -- expires_next = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_HARD); -+ /* -+ * Find the current next expiration time. -+ */ -+ expires_next = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_ALL); -+ -+ if (cpu_base->next_timer && cpu_base->next_timer->is_soft) { -+ /* -+ * When the softirq is activated, hrtimer has to be -+ * programmed with the first hard hrtimer because soft -+ * timer interrupt could occur too late. -+ */ -+ if (cpu_base->softirq_activated) -+ expires_next = __hrtimer_get_next_event(cpu_base, -+ HRTIMER_ACTIVE_HARD); -+ else -+ cpu_base->softirq_expires_next = expires_next; -+ } - - if (skip_equal && expires_next == cpu_base->expires_next) - return; -@@ -702,7 +746,7 @@ static inline void retrigger_next_event( - * - * Called with interrupts disabled and base->cpu_base.lock held - */ --static void hrtimer_reprogram(struct hrtimer *timer) -+static void hrtimer_reprogram(struct hrtimer *timer, bool reprogram) - { - struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases); - struct hrtimer_clock_base *base = timer->base; -@@ -711,6 +755,37 @@ static void hrtimer_reprogram(struct hrt - WARN_ON_ONCE(hrtimer_get_expires_tv64(timer) < 0); - - /* -+ * CLOCK_REALTIME timer might be requested with an absolute -+ * expiry time which is less than base->offset. Set it to 0. -+ */ -+ if (expires < 0) -+ expires = 0; -+ -+ if (timer->is_soft) { -+ /* -+ * soft hrtimer could be started on a remote CPU. In this -+ * case softirq_expires_next needs to be updated on the -+ * remote CPU. The soft hrtimer will not expire before the -+ * first hard hrtimer on the remote CPU - -+ * hrtimer_check_target() prevents this case. -+ */ -+ struct hrtimer_cpu_base *timer_cpu_base = base->cpu_base; -+ -+ if (timer_cpu_base->softirq_activated) -+ return; -+ -+ if (!ktime_before(expires, timer_cpu_base->softirq_expires_next)) -+ return; -+ -+ timer_cpu_base->softirq_next_timer = timer; -+ timer_cpu_base->softirq_expires_next = expires; -+ -+ if (!ktime_before(expires, timer_cpu_base->expires_next) || -+ !reprogram) -+ return; -+ } -+ -+ /* - * If the timer is not on the current cpu, we cannot reprogram - * the other cpus clock event device. - */ -@@ -727,13 +802,6 @@ static void hrtimer_reprogram(struct hrt - if (cpu_base->in_hrtirq) - return; - -- /* -- * CLOCK_REALTIME timer might be requested with an absolute -- * expiry time which is less than base->offset. Set it to 0. -- */ -- if (expires < 0) -- expires = 0; -- - if (expires >= cpu_base->expires_next) - return; - -@@ -961,6 +1029,31 @@ static inline ktime_t hrtimer_update_low - return tim; - } - -+static void -+hrtimer_update_softirq_timer(struct hrtimer_cpu_base *cpu_base, bool reprogram) -+{ -+ ktime_t expires; -+ -+ /* -+ * Find the next SOFT expiration. -+ */ -+ expires = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_SOFT); -+ -+ /* -+ * reprogramming needs to be triggered, even if the next soft -+ * hrtimer expires at the same time than the next hard -+ * hrtimer. cpu_base->softirq_expires_next needs to be updated! -+ */ -+ if (expires == KTIME_MAX) -+ return; -+ -+ /* -+ * cpu_base->*next_timer is recomputed by __hrtimer_get_next_event() -+ * cpu_base->*expires_next is only set by hrtimer_reprogram() -+ */ -+ hrtimer_reprogram(cpu_base->softirq_next_timer, reprogram); -+} -+ - static int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, - u64 delta_ns, const enum hrtimer_mode mode, - struct hrtimer_clock_base *base) -@@ -982,13 +1075,15 @@ static int __hrtimer_start_range_ns(stru - - return enqueue_hrtimer(timer, new_base, mode); - } -+ - /** - * hrtimer_start_range_ns - (re)start an hrtimer - * @timer: the timer to be added - * @tim: expiry time - * @delta_ns: "slack" range for the timer - * @mode: timer mode: absolute (HRTIMER_MODE_ABS) or -- * relative (HRTIMER_MODE_REL), and pinned (HRTIMER_MODE_PINNED) -+ * relative (HRTIMER_MODE_REL), and pinned (HRTIMER_MODE_PINNED); -+ * softirq based mode is considered for debug purpose only! - */ - void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, - u64 delta_ns, const enum hrtimer_mode mode) -@@ -996,10 +1091,16 @@ void hrtimer_start_range_ns(struct hrtim - struct hrtimer_clock_base *base; - unsigned long flags; - -+ /* -+ * Check whether the HRTIMER_MODE_SOFT bit and hrtimer.is_soft -+ * match. -+ */ -+ WARN_ON_ONCE(!(mode & HRTIMER_MODE_SOFT) ^ !timer->is_soft); -+ - base = lock_hrtimer_base(timer, &flags); - - if (__hrtimer_start_range_ns(timer, tim, delta_ns, mode, base)) -- hrtimer_reprogram(timer); -+ hrtimer_reprogram(timer, true); - - unlock_hrtimer_base(timer, &flags); - } -@@ -1098,7 +1199,7 @@ u64 hrtimer_get_next_event(void) - raw_spin_lock_irqsave(&cpu_base->lock, flags); - - if (!__hrtimer_hres_active(cpu_base)) -- expires = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_HARD); -+ expires = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_ALL); - - raw_spin_unlock_irqrestore(&cpu_base->lock, flags); - -@@ -1308,6 +1409,23 @@ static void __hrtimer_run_queues(struct - } - } - -+static __latent_entropy void hrtimer_run_softirq(struct softirq_action *h) -+{ -+ struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases); -+ unsigned long flags; -+ ktime_t now; -+ -+ raw_spin_lock_irqsave(&cpu_base->lock, flags); -+ -+ now = hrtimer_update_base(cpu_base); -+ __hrtimer_run_queues(cpu_base, now, flags, HRTIMER_ACTIVE_SOFT); -+ -+ cpu_base->softirq_activated = 0; -+ hrtimer_update_softirq_timer(cpu_base, true); -+ -+ raw_spin_unlock_irqrestore(&cpu_base->lock, flags); -+} -+ - #ifdef CONFIG_HIGH_RES_TIMERS - - /* -@@ -1338,10 +1456,16 @@ void hrtimer_interrupt(struct clock_even - */ - cpu_base->expires_next = KTIME_MAX; - -+ if (!ktime_before(now, cpu_base->softirq_expires_next)) { -+ cpu_base->softirq_expires_next = KTIME_MAX; -+ cpu_base->softirq_activated = 1; -+ raise_softirq_irqoff(HRTIMER_SOFTIRQ); -+ } -+ - __hrtimer_run_queues(cpu_base, now, flags, HRTIMER_ACTIVE_HARD); - - /* Reevaluate the clock bases for the next expiry */ -- expires_next = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_HARD); -+ expires_next = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_ALL); - /* - * Store the new expiry value so the migration code can verify - * against it. -@@ -1445,6 +1569,13 @@ void hrtimer_run_queues(void) - - raw_spin_lock_irqsave(&cpu_base->lock, flags); - now = hrtimer_update_base(cpu_base); -+ -+ if (!ktime_before(now, cpu_base->softirq_expires_next)) { -+ cpu_base->softirq_expires_next = KTIME_MAX; -+ cpu_base->softirq_activated = 1; -+ raise_softirq_irqoff(HRTIMER_SOFTIRQ); -+ } -+ - __hrtimer_run_queues(cpu_base, now, flags, HRTIMER_ACTIVE_HARD); - raw_spin_unlock_irqrestore(&cpu_base->lock, flags); - } -@@ -1626,6 +1757,7 @@ int hrtimers_prepare_cpu(unsigned int cp - cpu_base->cpu = cpu; - cpu_base->hres_active = 0; - cpu_base->expires_next = KTIME_MAX; -+ cpu_base->softirq_expires_next = KTIME_MAX; - return 0; - } - -@@ -1669,6 +1801,12 @@ int hrtimers_dead_cpu(unsigned int scpu) - BUG_ON(cpu_online(scpu)); - tick_cancel_sched_timer(scpu); - -+ /* -+ * this BH disable ensures that raise_softirq_irqoff() does -+ * not wakeup ksoftirqd (and acquire the pi-lock) while -+ * holding the cpu_base lock -+ */ -+ local_bh_disable(); - local_irq_disable(); - old_base = &per_cpu(hrtimer_bases, scpu); - new_base = this_cpu_ptr(&hrtimer_bases); -@@ -1684,12 +1822,19 @@ int hrtimers_dead_cpu(unsigned int scpu) - &new_base->clock_base[i]); - } - -+ /* -+ * The migration might have changed the first expiring softirq -+ * timer on this CPU. Update it. -+ */ -+ hrtimer_update_softirq_timer(new_base, false); -+ - raw_spin_unlock(&old_base->lock); - raw_spin_unlock(&new_base->lock); - - /* Check, if we got expired work to do */ - __hrtimer_peek_ahead_timers(); - local_irq_enable(); -+ local_bh_enable(); - return 0; - } - -@@ -1698,6 +1843,7 @@ int hrtimers_dead_cpu(unsigned int scpu) - void __init hrtimers_init(void) - { - hrtimers_prepare_cpu(smp_processor_id()); -+ open_softirq(HRTIMER_SOFTIRQ, hrtimer_run_softirq); - } - - /** diff --git a/debian/patches/features/all/rt/0028-tracing-Allow-whitespace-to-surround-hist-trigger-fi.patch b/debian/patches/features/all/rt/0028-tracing-Allow-whitespace-to-surround-hist-trigger-fi.patch deleted file mode 100644 index 0b15f23d9..000000000 --- a/debian/patches/features/all/rt/0028-tracing-Allow-whitespace-to-surround-hist-trigger-fi.patch +++ /dev/null @@ -1,72 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:52:02 -0600 -Subject: [PATCH 28/37] tracing: Allow whitespace to surround hist trigger - filter -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The existing code only allows for one space before and after the 'if' -specifying the filter for a hist trigger. Add code to make that more -permissive as far as whitespace goes. Specifically, we want to allow -spaces in the trigger itself now that we have additional syntax -(onmatch/onmax) where spaces are more natural e.g. spaces after commas -in param lists. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 37 ++++++++++++++++++++++++++++++++----- - 1 file changed, 32 insertions(+), 5 deletions(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -5164,7 +5164,7 @@ static int event_hist_trigger_func(struc - struct synth_event *se; - const char *se_name; - bool remove = false; -- char *trigger; -+ char *trigger, *p; - int ret = 0; - - if (!param) -@@ -5173,10 +5173,37 @@ static int event_hist_trigger_func(struc - if (glob[0] == '!') - remove = true; - -- /* separate the trigger from the filter (k:v [if filter]) */ -- trigger = strsep(¶m, " \t"); -- if (!trigger) -- return -EINVAL; -+ /* -+ * separate the trigger from the filter (k:v [if filter]) -+ * allowing for whitespace in the trigger -+ */ -+ p = trigger = param; -+ do { -+ p = strstr(p, "if"); -+ if (!p) -+ break; -+ if (p == param) -+ return -EINVAL; -+ if (*(p - 1) != ' ' && *(p - 1) != '\t') { -+ p++; -+ continue; -+ } -+ if (p >= param + strlen(param) - strlen("if") - 1) -+ return -EINVAL; -+ if (*(p + strlen("if")) != ' ' && *(p + strlen("if")) != '\t') { -+ p++; -+ continue; -+ } -+ break; -+ } while (p); -+ -+ if (!p) -+ param = NULL; -+ else { -+ *(p - 1) = '\0'; -+ param = strstrip(p); -+ trigger = strstrip(trigger); -+ } - - attrs = parse_hist_trigger_attrs(trigger); - if (IS_ERR(attrs)) diff --git a/debian/patches/features/all/rt/0028-tracing-Pass-tracing_map_elt-to-hist_field-accessor-.patch b/debian/patches/features/all/rt/0028-tracing-Pass-tracing_map_elt-to-hist_field-accessor-.patch index b94ee9e2b..1634c7210 100644 --- a/debian/patches/features/all/rt/0028-tracing-Pass-tracing_map_elt-to-hist_field-accessor-.patch +++ b/debian/patches/features/all/rt/0028-tracing-Pass-tracing_map_elt-to-hist_field-accessor-.patch @@ -2,7 +2,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:54 -0600 Subject: [PATCH 28/48] tracing: Pass tracing_map_elt to hist_field accessor functions -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Some accessor functions, such as for variable references, require access to a corrsponding tracing_map_elt. diff --git a/debian/patches/features/all/rt/0029-hrtimer-Implement-SOFT-HARD-clock-base-selection.patch b/debian/patches/features/all/rt/0029-hrtimer-Implement-SOFT-HARD-clock-base-selection.patch deleted file mode 100644 index 280bde98c..000000000 --- a/debian/patches/features/all/rt/0029-hrtimer-Implement-SOFT-HARD-clock-base-selection.patch +++ /dev/null @@ -1,56 +0,0 @@ -From: Anna-Maria Gleixner -Date: Wed, 20 Dec 2017 17:13:18 +0100 -Subject: [PATCH 29/29] hrtimer: Implement SOFT/HARD clock base selection -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -All prerequisites to handle hrtimers for expiry in either hard or soft -interrupt context are in place. - -Add the missing bit in hrtimer_init() which associates the timer to the -hard or the soft irq clock base. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/time/hrtimer.c | 15 +++++++++++---- - 1 file changed, 11 insertions(+), 4 deletions(-) - ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -1222,8 +1222,9 @@ static inline int hrtimer_clockid_to_bas - static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id, - enum hrtimer_mode mode) - { -+ bool softtimer = !!(mode & HRTIMER_MODE_SOFT); -+ int base = softtimer ? HRTIMER_MAX_CLOCK_BASES / 2 : 0; - struct hrtimer_cpu_base *cpu_base; -- int base; - - memset(timer, 0, sizeof(struct hrtimer)); - -@@ -1237,7 +1238,8 @@ static void __hrtimer_init(struct hrtime - if (clock_id == CLOCK_REALTIME && mode & HRTIMER_MODE_REL) - clock_id = CLOCK_MONOTONIC; - -- base = hrtimer_clockid_to_base(clock_id); -+ base += hrtimer_clockid_to_base(clock_id); -+ timer->is_soft = softtimer; - timer->base = &cpu_base->clock_base[base]; - timerqueue_init(&timer->node); - } -@@ -1246,8 +1248,13 @@ static void __hrtimer_init(struct hrtime - * hrtimer_init - initialize a timer to the given clock - * @timer: the timer to be initialized - * @clock_id: the clock to be used -- * @mode: timer mode: absolute (HRTIMER_MODE_ABS) or -- * relative (HRTIMER_MODE_REL); pinned is not considered here! -+ * @mode: The modes which are relevant for intitialization: -+ * HRTIMER_MODE_ABS, HRTIMER_MODE_REL, HRTIMER_MODE_ABS_SOFT, -+ * HRTIMER_MODE_REL_SOFT -+ * -+ * The PINNED variants of the above can be handed in, -+ * but the PINNED bit is ignored as pinning happens -+ * when the hrtimer is started - */ - void hrtimer_init(struct hrtimer *timer, clockid_t clock_id, - enum hrtimer_mode mode) diff --git a/debian/patches/features/all/rt/0029-tracing-Add-cpu-field-for-hist-triggers.patch b/debian/patches/features/all/rt/0029-tracing-Add-cpu-field-for-hist-triggers.patch deleted file mode 100644 index bb46bfc57..000000000 --- a/debian/patches/features/all/rt/0029-tracing-Add-cpu-field-for-hist-triggers.patch +++ /dev/null @@ -1,111 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:52:03 -0600 -Subject: [PATCH 29/37] tracing: Add cpu field for hist triggers -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -A common key to use in a histogram is the cpuid - add a new cpu -'synthetic' field named 'cpu' for that purpose. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - Documentation/trace/histogram.txt | 15 +++++++++++++++ - kernel/trace/trace_events_hist.c | 28 +++++++++++++++++++++++++++- - 2 files changed, 42 insertions(+), 1 deletion(-) - ---- a/Documentation/trace/histogram.txt -+++ b/Documentation/trace/histogram.txt -@@ -172,6 +172,21 @@ - The examples below provide a more concrete illustration of the - concepts and typical usage patterns discussed above. - -+ 'special' event fields -+ ------------------------ -+ -+ There are a number of 'special event fields' available for use as -+ keys or values in a hist trigger. These look like and behave as if -+ they were actual event fields, but aren't really part of the event's -+ field definition or format file. They are however available for any -+ event, and can be used anywhere an actual event field could be. -+ They are: -+ -+ common_timestamp u64 - timestamp (from ring buffer) associated -+ with the event, in nanoseconds. May be -+ modified by .usecs to have timestamps -+ interpreted as microseconds. -+ cpu int - the cpu on which the event occurred. - - 6.2 'hist' trigger examples - --------------------------- ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -227,6 +227,7 @@ enum hist_field_flags { - HIST_FIELD_FL_VAR = 1 << 12, - HIST_FIELD_FL_EXPR = 1 << 13, - HIST_FIELD_FL_VAR_REF = 1 << 14, -+ HIST_FIELD_FL_CPU = 1 << 15, - }; - - struct var_defs { -@@ -1164,6 +1165,16 @@ static u64 hist_field_timestamp(struct h - return ts; - } - -+static u64 hist_field_cpu(struct hist_field *hist_field, -+ struct tracing_map_elt *elt, -+ struct ring_buffer_event *rbe, -+ void *event) -+{ -+ int cpu = smp_processor_id(); -+ -+ return cpu; -+} -+ - static struct hist_field * - check_field_for_var_ref(struct hist_field *hist_field, - struct hist_trigger_data *var_data, -@@ -1602,6 +1613,8 @@ static const char *hist_field_name(struc - field_name = hist_field_name(field->operands[0], ++level); - else if (field->flags & HIST_FIELD_FL_TIMESTAMP) - field_name = "common_timestamp"; -+ else if (field->flags & HIST_FIELD_FL_CPU) -+ field_name = "cpu"; - else if (field->flags & HIST_FIELD_FL_EXPR || - field->flags & HIST_FIELD_FL_VAR_REF) { - if (field->system) { -@@ -2109,6 +2122,15 @@ static struct hist_field *create_hist_fi - goto out; - } - -+ if (flags & HIST_FIELD_FL_CPU) { -+ hist_field->fn = hist_field_cpu; -+ hist_field->size = sizeof(int); -+ hist_field->type = kstrdup("unsigned int", GFP_KERNEL); -+ if (!hist_field->type) -+ goto free; -+ goto out; -+ } -+ - if (WARN_ON_ONCE(!field)) - goto out; - -@@ -2345,7 +2367,9 @@ parse_field(struct hist_trigger_data *hi - hist_data->enable_timestamps = true; - if (*flags & HIST_FIELD_FL_TIMESTAMP_USECS) - hist_data->attrs->ts_in_usecs = true; -- } else { -+ } else if (strcmp(field_name, "cpu") == 0) -+ *flags |= HIST_FIELD_FL_CPU; -+ else { - field = trace_find_event_field(file->event_call, field_name); - if (!field || !field->size) { - field = ERR_PTR(-EINVAL); -@@ -4621,6 +4645,8 @@ static void hist_field_print(struct seq_ - - if (hist_field->flags & HIST_FIELD_FL_TIMESTAMP) - seq_puts(m, "common_timestamp"); -+ else if (hist_field->flags & HIST_FIELD_FL_CPU) -+ seq_puts(m, "cpu"); - else if (field_name) { - if (hist_field->flags & HIST_FIELD_FL_VAR_REF) - seq_putc(m, '$'); diff --git a/debian/patches/features/all/rt/0029-tracing-Add-hist_field-type-field.patch b/debian/patches/features/all/rt/0029-tracing-Add-hist_field-type-field.patch index 7cb1c8c63..8b4ed0015 100644 --- a/debian/patches/features/all/rt/0029-tracing-Add-hist_field-type-field.patch +++ b/debian/patches/features/all/rt/0029-tracing-Add-hist_field-type-field.patch @@ -1,7 +1,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:55 -0600 Subject: [PATCH 29/48] tracing: Add hist_field 'type' field -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Future support for synthetic events requires hist_field 'type' information, so add a field for that. diff --git a/debian/patches/features/all/rt/0030-can-bcm-Replace-hrtimer_tasklet-with-softirq-based-h.patch b/debian/patches/features/all/rt/0030-can-bcm-Replace-hrtimer_tasklet-with-softirq-based-h.patch deleted file mode 100644 index 307ac7f40..000000000 --- a/debian/patches/features/all/rt/0030-can-bcm-Replace-hrtimer_tasklet-with-softirq-based-h.patch +++ /dev/null @@ -1,316 +0,0 @@ -From: Thomas Gleixner -Date: Thu, 23 Nov 2017 16:39:11 +0100 -Subject: [PATCH 30/36] can/bcm: Replace hrtimer_tasklet with softirq based - hrtimer -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Switch the timer to HRTIMER_MODE_SOFT, which executed the timer -callback in softirq context and remove the hrtimer_tasklet. - -Signed-off-by: Thomas Gleixner -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Thomas Gleixner -Cc: Oliver Hartkopp -Cc: Marc Kleine-Budde -Cc: linux-can@vger.kernel.org -Signed-off-by: Sebastian Andrzej Siewior ---- - net/can/bcm.c | 156 +++++++++++++++++++--------------------------------------- - 1 file changed, 52 insertions(+), 104 deletions(-) - ---- a/net/can/bcm.c -+++ b/net/can/bcm.c -@@ -102,7 +102,6 @@ struct bcm_op { - unsigned long frames_abs, frames_filtered; - struct bcm_timeval ival1, ival2; - struct hrtimer timer, thrtimer; -- struct tasklet_struct tsklet, thrtsklet; - ktime_t rx_stamp, kt_ival1, kt_ival2, kt_lastmsg; - int rx_ifindex; - int cfsiz; -@@ -364,25 +363,34 @@ static void bcm_send_to_user(struct bcm_ - } - } - --static void bcm_tx_start_timer(struct bcm_op *op) -+static bool bcm_tx_set_expiry(struct bcm_op *op, struct hrtimer *hrt) - { -+ ktime_t ival; -+ - if (op->kt_ival1 && op->count) -- hrtimer_start(&op->timer, -- ktime_add(ktime_get(), op->kt_ival1), -- HRTIMER_MODE_ABS); -+ ival = op->kt_ival1; - else if (op->kt_ival2) -- hrtimer_start(&op->timer, -- ktime_add(ktime_get(), op->kt_ival2), -- HRTIMER_MODE_ABS); -+ ival = op->kt_ival2; -+ else -+ return false; -+ -+ hrtimer_set_expires(hrt, ktime_add(ktime_get(), ival)); -+ return true; - } - --static void bcm_tx_timeout_tsklet(unsigned long data) -+static void bcm_tx_start_timer(struct bcm_op *op) - { -- struct bcm_op *op = (struct bcm_op *)data; -+ if (bcm_tx_set_expiry(op, &op->timer)) -+ hrtimer_start_expires(&op->timer, HRTIMER_MODE_ABS_SOFT); -+} -+ -+/* bcm_tx_timeout_handler - performs cyclic CAN frame transmissions */ -+static enum hrtimer_restart bcm_tx_timeout_handler(struct hrtimer *hrtimer) -+{ -+ struct bcm_op *op = container_of(hrtimer, struct bcm_op, timer); - struct bcm_msg_head msg_head; - - if (op->kt_ival1 && (op->count > 0)) { -- - op->count--; - if (!op->count && (op->flags & TX_COUNTEVT)) { - -@@ -399,22 +407,12 @@ static void bcm_tx_timeout_tsklet(unsign - } - bcm_can_tx(op); - -- } else if (op->kt_ival2) -+ } else if (op->kt_ival2) { - bcm_can_tx(op); -+ } - -- bcm_tx_start_timer(op); --} -- --/* -- * bcm_tx_timeout_handler - performs cyclic CAN frame transmissions -- */ --static enum hrtimer_restart bcm_tx_timeout_handler(struct hrtimer *hrtimer) --{ -- struct bcm_op *op = container_of(hrtimer, struct bcm_op, timer); -- -- tasklet_schedule(&op->tsklet); -- -- return HRTIMER_NORESTART; -+ return bcm_tx_set_expiry(op, &op->timer) ? -+ HRTIMER_RESTART : HRTIMER_NORESTART; - } - - /* -@@ -480,7 +478,7 @@ static void bcm_rx_update_and_send(struc - /* do not send the saved data - only start throttle timer */ - hrtimer_start(&op->thrtimer, - ktime_add(op->kt_lastmsg, op->kt_ival2), -- HRTIMER_MODE_ABS); -+ HRTIMER_MODE_ABS_SOFT); - return; - } - -@@ -539,14 +537,21 @@ static void bcm_rx_starttimer(struct bcm - return; - - if (op->kt_ival1) -- hrtimer_start(&op->timer, op->kt_ival1, HRTIMER_MODE_REL); -+ hrtimer_start(&op->timer, op->kt_ival1, HRTIMER_MODE_REL_SOFT); - } - --static void bcm_rx_timeout_tsklet(unsigned long data) -+/* bcm_rx_timeout_handler - when the (cyclic) CAN frame reception timed out */ -+static enum hrtimer_restart bcm_rx_timeout_handler(struct hrtimer *hrtimer) - { -- struct bcm_op *op = (struct bcm_op *)data; -+ struct bcm_op *op = container_of(hrtimer, struct bcm_op, timer); - struct bcm_msg_head msg_head; - -+ /* if user wants to be informed, when cyclic CAN-Messages come back */ -+ if ((op->flags & RX_ANNOUNCE_RESUME) && op->last_frames) { -+ /* clear received CAN frames to indicate 'nothing received' */ -+ memset(op->last_frames, 0, op->nframes * op->cfsiz); -+ } -+ - /* create notification to user */ - msg_head.opcode = RX_TIMEOUT; - msg_head.flags = op->flags; -@@ -557,25 +562,6 @@ static void bcm_rx_timeout_tsklet(unsign - msg_head.nframes = 0; - - bcm_send_to_user(op, &msg_head, NULL, 0); --} -- --/* -- * bcm_rx_timeout_handler - when the (cyclic) CAN frame reception timed out -- */ --static enum hrtimer_restart bcm_rx_timeout_handler(struct hrtimer *hrtimer) --{ -- struct bcm_op *op = container_of(hrtimer, struct bcm_op, timer); -- -- /* schedule before NET_RX_SOFTIRQ */ -- tasklet_hi_schedule(&op->tsklet); -- -- /* no restart of the timer is done here! */ -- -- /* if user wants to be informed, when cyclic CAN-Messages come back */ -- if ((op->flags & RX_ANNOUNCE_RESUME) && op->last_frames) { -- /* clear received CAN frames to indicate 'nothing received' */ -- memset(op->last_frames, 0, op->nframes * op->cfsiz); -- } - - return HRTIMER_NORESTART; - } -@@ -583,14 +569,12 @@ static enum hrtimer_restart bcm_rx_timeo - /* - * bcm_rx_do_flush - helper for bcm_rx_thr_flush - */ --static inline int bcm_rx_do_flush(struct bcm_op *op, int update, -- unsigned int index) -+static inline int bcm_rx_do_flush(struct bcm_op *op, unsigned int index) - { - struct canfd_frame *lcf = op->last_frames + op->cfsiz * index; - - if ((op->last_frames) && (lcf->flags & RX_THR)) { -- if (update) -- bcm_rx_changed(op, lcf); -+ bcm_rx_changed(op, lcf); - return 1; - } - return 0; -@@ -598,11 +582,8 @@ static inline int bcm_rx_do_flush(struct - - /* - * bcm_rx_thr_flush - Check for throttled data and send it to the userspace -- * -- * update == 0 : just check if throttled data is available (any irq context) -- * update == 1 : check and send throttled data to userspace (soft_irq context) - */ --static int bcm_rx_thr_flush(struct bcm_op *op, int update) -+static int bcm_rx_thr_flush(struct bcm_op *op) - { - int updated = 0; - -@@ -611,24 +592,16 @@ static int bcm_rx_thr_flush(struct bcm_o - - /* for MUX filter we start at index 1 */ - for (i = 1; i < op->nframes; i++) -- updated += bcm_rx_do_flush(op, update, i); -+ updated += bcm_rx_do_flush(op, i); - - } else { - /* for RX_FILTER_ID and simple filter */ -- updated += bcm_rx_do_flush(op, update, 0); -+ updated += bcm_rx_do_flush(op, 0); - } - - return updated; - } - --static void bcm_rx_thr_tsklet(unsigned long data) --{ -- struct bcm_op *op = (struct bcm_op *)data; -- -- /* push the changed data to the userspace */ -- bcm_rx_thr_flush(op, 1); --} -- - /* - * bcm_rx_thr_handler - the time for blocked content updates is over now: - * Check for throttled data and send it to the userspace -@@ -637,9 +610,7 @@ static enum hrtimer_restart bcm_rx_thr_h - { - struct bcm_op *op = container_of(hrtimer, struct bcm_op, thrtimer); - -- tasklet_schedule(&op->thrtsklet); -- -- if (bcm_rx_thr_flush(op, 0)) { -+ if (bcm_rx_thr_flush(op)) { - hrtimer_forward(hrtimer, ktime_get(), op->kt_ival2); - return HRTIMER_RESTART; - } else { -@@ -735,23 +706,8 @@ static struct bcm_op *bcm_find_op(struct - - static void bcm_remove_op(struct bcm_op *op) - { -- if (op->tsklet.func) { -- while (test_bit(TASKLET_STATE_SCHED, &op->tsklet.state) || -- test_bit(TASKLET_STATE_RUN, &op->tsklet.state) || -- hrtimer_active(&op->timer)) { -- hrtimer_cancel(&op->timer); -- tasklet_kill(&op->tsklet); -- } -- } -- -- if (op->thrtsklet.func) { -- while (test_bit(TASKLET_STATE_SCHED, &op->thrtsklet.state) || -- test_bit(TASKLET_STATE_RUN, &op->thrtsklet.state) || -- hrtimer_active(&op->thrtimer)) { -- hrtimer_cancel(&op->thrtimer); -- tasklet_kill(&op->thrtsklet); -- } -- } -+ hrtimer_cancel(&op->timer); -+ hrtimer_cancel(&op->thrtimer); - - if ((op->frames) && (op->frames != &op->sframe)) - kfree(op->frames); -@@ -979,15 +935,13 @@ static int bcm_tx_setup(struct bcm_msg_h - op->ifindex = ifindex; - - /* initialize uninitialized (kzalloc) structure */ -- hrtimer_init(&op->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); -+ hrtimer_init(&op->timer, CLOCK_MONOTONIC, -+ HRTIMER_MODE_REL_SOFT); - op->timer.function = bcm_tx_timeout_handler; - -- /* initialize tasklet for tx countevent notification */ -- tasklet_init(&op->tsklet, bcm_tx_timeout_tsklet, -- (unsigned long) op); -- - /* currently unused in tx_ops */ -- hrtimer_init(&op->thrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); -+ hrtimer_init(&op->thrtimer, CLOCK_MONOTONIC, -+ HRTIMER_MODE_REL_SOFT); - - /* add this bcm_op to the list of the tx_ops */ - list_add(&op->list, &bo->tx_ops); -@@ -1150,20 +1104,14 @@ static int bcm_rx_setup(struct bcm_msg_h - op->rx_ifindex = ifindex; - - /* initialize uninitialized (kzalloc) structure */ -- hrtimer_init(&op->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); -+ hrtimer_init(&op->timer, CLOCK_MONOTONIC, -+ HRTIMER_MODE_REL_SOFT); - op->timer.function = bcm_rx_timeout_handler; - -- /* initialize tasklet for rx timeout notification */ -- tasklet_init(&op->tsklet, bcm_rx_timeout_tsklet, -- (unsigned long) op); -- -- hrtimer_init(&op->thrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); -+ hrtimer_init(&op->thrtimer, CLOCK_MONOTONIC, -+ HRTIMER_MODE_REL_SOFT); - op->thrtimer.function = bcm_rx_thr_handler; - -- /* initialize tasklet for rx throttle handling */ -- tasklet_init(&op->thrtsklet, bcm_rx_thr_tsklet, -- (unsigned long) op); -- - /* add this bcm_op to the list of the rx_ops */ - list_add(&op->list, &bo->rx_ops); - -@@ -1209,12 +1157,12 @@ static int bcm_rx_setup(struct bcm_msg_h - */ - op->kt_lastmsg = 0; - hrtimer_cancel(&op->thrtimer); -- bcm_rx_thr_flush(op, 1); -+ bcm_rx_thr_flush(op); - } - - if ((op->flags & STARTTIMER) && op->kt_ival1) - hrtimer_start(&op->timer, op->kt_ival1, -- HRTIMER_MODE_REL); -+ HRTIMER_MODE_REL_SOFT); - } - - /* now we can register for can_ids, if we added a new bcm_op */ diff --git a/debian/patches/features/all/rt/0030-tracing-Add-hist-trigger-support-for-variable-refere.patch b/debian/patches/features/all/rt/0030-tracing-Add-hist-trigger-support-for-variable-refere.patch deleted file mode 100644 index 9f3563900..000000000 --- a/debian/patches/features/all/rt/0030-tracing-Add-hist-trigger-support-for-variable-refere.patch +++ /dev/null @@ -1,161 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:52:04 -0600 -Subject: [PATCH 30/37] tracing: Add hist trigger support for variable - reference aliases -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Add support for alias=$somevar where alias can be used as -onmatch.xxx($alias). - -Aliases are a way of creating a new name for an existing variable, for -flexibly in making naming more clear in certain cases. For example in -the below the user perhaps feels that using $new_lat in the synthetic -event invocation is opaque or doesn't fit well stylistically with -previous triggers, so creates an alias of $new_lat named $latency and -uses that in the call instead: - - # echo 'hist:keys=next_pid:new_lat=common_timestamp.usecs' > - /sys/kernel/debug/tracing/events/sched/sched_switch/trigger - - # echo 'hist:keys=pid:latency=$new_lat: - onmatch(sched.sched_switch).wake2($latency,pid)' > - /sys/kernel/debug/tracing/events/synthetic/wake1/trigger - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace_events_hist.c | 74 +++++++++++++++++++++++++++++++++++---- - 1 file changed, 67 insertions(+), 7 deletions(-) - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -228,6 +228,7 @@ enum hist_field_flags { - HIST_FIELD_FL_EXPR = 1 << 13, - HIST_FIELD_FL_VAR_REF = 1 << 14, - HIST_FIELD_FL_CPU = 1 << 15, -+ HIST_FIELD_FL_ALIAS = 1 << 16, - }; - - struct var_defs { -@@ -1609,7 +1610,8 @@ static const char *hist_field_name(struc - - if (field->field) - field_name = field->field->name; -- else if (field->flags & HIST_FIELD_FL_LOG2) -+ else if (field->flags & HIST_FIELD_FL_LOG2 || -+ field->flags & HIST_FIELD_FL_ALIAS) - field_name = hist_field_name(field->operands[0], ++level); - else if (field->flags & HIST_FIELD_FL_TIMESTAMP) - field_name = "common_timestamp"; -@@ -2080,7 +2082,7 @@ static struct hist_field *create_hist_fi - - hist_field->hist_data = hist_data; - -- if (flags & HIST_FIELD_FL_EXPR) -+ if (flags & HIST_FIELD_FL_EXPR || flags & HIST_FIELD_FL_ALIAS) - goto out; /* caller will populate */ - - if (flags & HIST_FIELD_FL_VAR_REF) { -@@ -2217,10 +2219,18 @@ static int init_var_ref(struct hist_fiel - } - } - -- ref_field->name = kstrdup(var_field->var.name, GFP_KERNEL); -- if (!ref_field->name) { -- err = -ENOMEM; -- goto free; -+ if (var_field->var.name) { -+ ref_field->name = kstrdup(var_field->var.name, GFP_KERNEL); -+ if (!ref_field->name) { -+ err = -ENOMEM; -+ goto free; -+ } -+ } else if (var_field->name) { -+ ref_field->name = kstrdup(var_field->name, GFP_KERNEL); -+ if (!ref_field->name) { -+ err = -ENOMEM; -+ goto free; -+ } - } - - ref_field->type = kstrdup(var_field->type, GFP_KERNEL); -@@ -2382,6 +2392,28 @@ parse_field(struct hist_trigger_data *hi - return field; - } - -+static struct hist_field *create_alias(struct hist_trigger_data *hist_data, -+ struct hist_field *var_ref, -+ char *var_name) -+{ -+ struct hist_field *alias = NULL; -+ unsigned long flags = HIST_FIELD_FL_ALIAS | HIST_FIELD_FL_VAR; -+ -+ alias = create_hist_field(hist_data, NULL, flags, var_name); -+ if (!alias) -+ return NULL; -+ -+ alias->fn = var_ref->fn; -+ alias->operands[0] = var_ref; -+ -+ if (init_var_ref(alias, var_ref, var_ref->system, var_ref->event_name)) { -+ destroy_hist_field(alias, 0); -+ return NULL; -+ } -+ -+ return alias; -+} -+ - static struct hist_field *parse_atom(struct hist_trigger_data *hist_data, - struct trace_event_file *file, char *str, - unsigned long *flags, char *var_name) -@@ -2415,6 +2447,13 @@ static struct hist_field *parse_atom(str - if (hist_field) { - hist_data->var_refs[hist_data->n_var_refs] = hist_field; - hist_field->var_ref_idx = hist_data->n_var_refs++; -+ if (var_name) { -+ hist_field = create_alias(hist_data, hist_field, var_name); -+ if (!hist_field) { -+ ret = -ENOMEM; -+ goto out; -+ } -+ } - return hist_field; - } - } else -@@ -2515,6 +2554,26 @@ static int check_expr_operands(struct hi - unsigned long operand1_flags = operand1->flags; - unsigned long operand2_flags = operand2->flags; - -+ if ((operand1_flags & HIST_FIELD_FL_VAR_REF) || -+ (operand1_flags & HIST_FIELD_FL_ALIAS)) { -+ struct hist_field *var; -+ -+ var = find_var_field(operand1->var.hist_data, operand1->name); -+ if (!var) -+ return -EINVAL; -+ operand1_flags = var->flags; -+ } -+ -+ if ((operand2_flags & HIST_FIELD_FL_VAR_REF) || -+ (operand2_flags & HIST_FIELD_FL_ALIAS)) { -+ struct hist_field *var; -+ -+ var = find_var_field(operand2->var.hist_data, operand2->name); -+ if (!var) -+ return -EINVAL; -+ operand2_flags = var->flags; -+ } -+ - if ((operand1_flags & HIST_FIELD_FL_TIMESTAMP_USECS) != - (operand2_flags & HIST_FIELD_FL_TIMESTAMP_USECS)) - return -EINVAL; -@@ -4648,7 +4707,8 @@ static void hist_field_print(struct seq_ - else if (hist_field->flags & HIST_FIELD_FL_CPU) - seq_puts(m, "cpu"); - else if (field_name) { -- if (hist_field->flags & HIST_FIELD_FL_VAR_REF) -+ if (hist_field->flags & HIST_FIELD_FL_VAR_REF || -+ hist_field->flags & HIST_FIELD_FL_ALIAS) - seq_putc(m, '$'); - seq_printf(m, "%s", field_name); - } diff --git a/debian/patches/features/all/rt/0030-tracing-Add-variable-reference-handling-to-hist-trig.patch b/debian/patches/features/all/rt/0030-tracing-Add-variable-reference-handling-to-hist-trig.patch index 747c507bb..50fbbd8e4 100644 --- a/debian/patches/features/all/rt/0030-tracing-Add-variable-reference-handling-to-hist-trig.patch +++ b/debian/patches/features/all/rt/0030-tracing-Add-variable-reference-handling-to-hist-trig.patch @@ -2,7 +2,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:56 -0600 Subject: [PATCH 30/48] tracing: Add variable reference handling to hist triggers -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Add the necessary infrastructure to allow the variables defined on one event to be referenced in another. This allows variables set by a diff --git a/debian/patches/features/all/rt/0031-mac80211_hwsim-Replace-hrtimer-tasklet-with-softirq-.patch b/debian/patches/features/all/rt/0031-mac80211_hwsim-Replace-hrtimer-tasklet-with-softirq-.patch deleted file mode 100644 index 57fead06b..000000000 --- a/debian/patches/features/all/rt/0031-mac80211_hwsim-Replace-hrtimer-tasklet-with-softirq-.patch +++ /dev/null @@ -1,136 +0,0 @@ -From: Thomas Gleixner -Date: Thu, 23 Nov 2017 16:39:12 +0100 -Subject: [PATCH 31/36] mac80211_hwsim: Replace hrtimer tasklet with softirq - hrtimer -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Switch the timer to HRTIMER_MODE_SOFT, which executed the timer -callback in softirq context and remove the hrtimer_tasklet. - -Signed-off-by: Thomas Gleixner -Signed-off-by: Anna-Maria Gleixner -Cc: linux-wireless@vger.kernel.org -Cc: Johannes Berg -Cc: Kalle Valo -Signed-off-by: Sebastian Andrzej Siewior ---- - drivers/net/wireless/mac80211_hwsim.c | 44 +++++++++++++++------------------- - 1 file changed, 20 insertions(+), 24 deletions(-) - ---- a/drivers/net/wireless/mac80211_hwsim.c -+++ b/drivers/net/wireless/mac80211_hwsim.c -@@ -537,7 +537,7 @@ struct mac80211_hwsim_data { - unsigned int rx_filter; - bool started, idle, scanning; - struct mutex mutex; -- struct tasklet_hrtimer beacon_timer; -+ struct hrtimer beacon_timer; - enum ps_mode { - PS_DISABLED, PS_ENABLED, PS_AUTO_POLL, PS_MANUAL_POLL - } ps; -@@ -1418,7 +1418,7 @@ static void mac80211_hwsim_stop(struct i - { - struct mac80211_hwsim_data *data = hw->priv; - data->started = false; -- tasklet_hrtimer_cancel(&data->beacon_timer); -+ hrtimer_cancel(&data->beacon_timer); - wiphy_debug(hw->wiphy, "%s\n", __func__); - } - -@@ -1541,14 +1541,12 @@ static enum hrtimer_restart - mac80211_hwsim_beacon(struct hrtimer *timer) - { - struct mac80211_hwsim_data *data = -- container_of(timer, struct mac80211_hwsim_data, -- beacon_timer.timer); -+ container_of(timer, struct mac80211_hwsim_data, beacon_timer); - struct ieee80211_hw *hw = data->hw; - u64 bcn_int = data->beacon_int; -- ktime_t next_bcn; - - if (!data->started) -- goto out; -+ return HRTIMER_NORESTART; - - ieee80211_iterate_active_interfaces_atomic( - hw, IEEE80211_IFACE_ITER_NORMAL, -@@ -1560,11 +1558,9 @@ mac80211_hwsim_beacon(struct hrtimer *ti - data->bcn_delta = 0; - } - -- next_bcn = ktime_add(hrtimer_get_expires(timer), -- ns_to_ktime(bcn_int * 1000)); -- tasklet_hrtimer_start(&data->beacon_timer, next_bcn, HRTIMER_MODE_ABS); --out: -- return HRTIMER_NORESTART; -+ hrtimer_forward(&data->beacon_timer, hrtimer_get_expires(timer), -+ ns_to_ktime(bcn_int * NSEC_PER_USEC)); -+ return HRTIMER_RESTART; - } - - static const char * const hwsim_chanwidths[] = { -@@ -1638,15 +1634,15 @@ static int mac80211_hwsim_config(struct - mutex_unlock(&data->mutex); - - if (!data->started || !data->beacon_int) -- tasklet_hrtimer_cancel(&data->beacon_timer); -- else if (!hrtimer_is_queued(&data->beacon_timer.timer)) { -+ hrtimer_cancel(&data->beacon_timer); -+ else if (!hrtimer_is_queued(&data->beacon_timer)) { - u64 tsf = mac80211_hwsim_get_tsf(hw, NULL); - u32 bcn_int = data->beacon_int; - u64 until_tbtt = bcn_int - do_div(tsf, bcn_int); - -- tasklet_hrtimer_start(&data->beacon_timer, -- ns_to_ktime(until_tbtt * 1000), -- HRTIMER_MODE_REL); -+ hrtimer_start(&data->beacon_timer, -+ ns_to_ktime(until_tbtt * 1000), -+ HRTIMER_MODE_REL_SOFT); - } - - return 0; -@@ -1709,7 +1705,7 @@ static void mac80211_hwsim_bss_info_chan - info->enable_beacon, info->beacon_int); - vp->bcn_en = info->enable_beacon; - if (data->started && -- !hrtimer_is_queued(&data->beacon_timer.timer) && -+ !hrtimer_is_queued(&data->beacon_timer) && - info->enable_beacon) { - u64 tsf, until_tbtt; - u32 bcn_int; -@@ -1717,9 +1713,9 @@ static void mac80211_hwsim_bss_info_chan - tsf = mac80211_hwsim_get_tsf(hw, vif); - bcn_int = data->beacon_int; - until_tbtt = bcn_int - do_div(tsf, bcn_int); -- tasklet_hrtimer_start(&data->beacon_timer, -- ns_to_ktime(until_tbtt * 1000), -- HRTIMER_MODE_REL); -+ hrtimer_start(&data->beacon_timer, -+ ns_to_ktime(until_tbtt * 1000), -+ HRTIMER_MODE_REL_SOFT); - } else if (!info->enable_beacon) { - unsigned int count = 0; - ieee80211_iterate_active_interfaces_atomic( -@@ -1728,7 +1724,7 @@ static void mac80211_hwsim_bss_info_chan - wiphy_debug(hw->wiphy, " beaconing vifs remaining: %u", - count); - if (count == 0) { -- tasklet_hrtimer_cancel(&data->beacon_timer); -+ hrtimer_cancel(&data->beacon_timer); - data->beacon_int = 0; - } - } -@@ -2720,9 +2716,9 @@ static int mac80211_hwsim_new_radio(stru - data->debugfs, - data, &hwsim_simulate_radar); - -- tasklet_hrtimer_init(&data->beacon_timer, -- mac80211_hwsim_beacon, -- CLOCK_MONOTONIC, HRTIMER_MODE_ABS); -+ hrtimer_init(&data->beacon_timer, CLOCK_MONOTONIC, -+ HRTIMER_MODE_ABS_SOFT); -+ data->beacon_timer.function = mac80211_hwsim_beacon; - - spin_lock_bh(&hwsim_radio_lock); - list_add_tail(&data->list, &hwsim_radios); diff --git a/debian/patches/features/all/rt/0031-tracing-Add-hist-trigger-action-hook.patch b/debian/patches/features/all/rt/0031-tracing-Add-hist-trigger-action-hook.patch index 4851d8dd3..94bf39285 100644 --- a/debian/patches/features/all/rt/0031-tracing-Add-hist-trigger-action-hook.patch +++ b/debian/patches/features/all/rt/0031-tracing-Add-hist-trigger-action-hook.patch @@ -1,7 +1,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:57 -0600 Subject: [PATCH 31/48] tracing: Add hist trigger action hook -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Add a hook for executing extra actions whenever a histogram entry is added or updated. diff --git a/debian/patches/features/all/rt/0031-tracing-Add-last-error-error-facility-for-hist-trigg.patch b/debian/patches/features/all/rt/0031-tracing-Add-last-error-error-facility-for-hist-trigg.patch deleted file mode 100644 index 19bbdbd9e..000000000 --- a/debian/patches/features/all/rt/0031-tracing-Add-last-error-error-facility-for-hist-trigg.patch +++ /dev/null @@ -1,499 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:52:05 -0600 -Subject: [PATCH 31/37] tracing: Add 'last error' error facility for hist - triggers -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -With the addition of variables and actions, it's become necessary to -provide more detailed error information to users about syntax errors. - -Add a 'last error' facility accessible via the erroring event's 'hist' -file. Reading the hist file after an error will display more detailed -information about what went wrong, if information is available. This -extended error information will be available until the next hist -trigger command for that event. - - # echo xxx > /sys/kernel/debug/tracing/events/sched/sched_wakeup/trigger - echo: write error: Invalid argument - - # cat /sys/kernel/debug/tracing/events/sched/sched_wakeup/hist - - ERROR: Couldn't yyy: zzz - Last command: xxx - -Also add specific error messages for variable and action errors. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - Documentation/trace/histogram.txt | 20 ++++ - kernel/trace/trace_events_hist.c | 164 ++++++++++++++++++++++++++++++++++---- - 2 files changed, 170 insertions(+), 14 deletions(-) - ---- a/Documentation/trace/histogram.txt -+++ b/Documentation/trace/histogram.txt -@@ -188,6 +188,26 @@ - interpreted as microseconds. - cpu int - the cpu on which the event occurred. - -+ Extended error information -+ -------------------------- -+ -+ For some error conditions encountered when invoking a hist trigger -+ command, extended error information is available via the -+ corresponding event's 'hist' file. Reading the hist file after an -+ error will display more detailed information about what went wrong, -+ if information is available. This extended error information will -+ be available until the next hist trigger command for that event. -+ -+ If available for a given error condition, the extended error -+ information and usage takes the following form: -+ -+ # echo xxx > /sys/kernel/debug/tracing/events/sched/sched_wakeup/trigger -+ echo: write error: Invalid argument -+ -+ # cat /sys/kernel/debug/tracing/events/sched/sched_wakeup/hist -+ ERROR: Couldn't yyy: zzz -+ Last command: xxx -+ - 6.2 'hist' trigger examples - --------------------------- - ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -351,6 +351,65 @@ struct action_data { - }; - }; - -+ -+static char last_hist_cmd[MAX_FILTER_STR_VAL]; -+static char hist_err_str[MAX_FILTER_STR_VAL]; -+ -+static void last_cmd_set(char *str) -+{ -+ if (!str) -+ return; -+ -+ strncpy(last_hist_cmd, str, MAX_FILTER_STR_VAL - 1); -+} -+ -+static void hist_err(char *str, char *var) -+{ -+ int maxlen = MAX_FILTER_STR_VAL - 1; -+ -+ if (!str) -+ return; -+ -+ if (strlen(hist_err_str)) -+ return; -+ -+ if (!var) -+ var = ""; -+ -+ if (strlen(hist_err_str) + strlen(str) + strlen(var) > maxlen) -+ return; -+ -+ strcat(hist_err_str, str); -+ strcat(hist_err_str, var); -+} -+ -+static void hist_err_event(char *str, char *system, char *event, char *var) -+{ -+ char err[MAX_FILTER_STR_VAL]; -+ -+ if (system && var) -+ snprintf(err, MAX_FILTER_STR_VAL, "%s.%s.%s", system, event, var); -+ else if (system) -+ snprintf(err, MAX_FILTER_STR_VAL, "%s.%s", system, event); -+ else -+ strncpy(err, var, MAX_FILTER_STR_VAL); -+ -+ hist_err(str, err); -+} -+ -+static void hist_err_clear(void) -+{ -+ hist_err_str[0] = '\0'; -+} -+ -+static bool have_hist_err(void) -+{ -+ if (strlen(hist_err_str)) -+ return true; -+ -+ return false; -+} -+ - static LIST_HEAD(synth_event_list); - static DEFINE_MUTEX(synth_event_mutex); - -@@ -1448,8 +1507,10 @@ static struct trace_event_file *find_var - continue; - - if (find_var_field(var_hist_data, var_name)) { -- if (found) -+ if (found) { -+ hist_err_event("Variable name not unique, need to use fully qualified name (subsys.event.var) for variable: ", system, event_name, var_name); - return NULL; -+ } - - found = file; - } -@@ -1498,6 +1559,7 @@ find_match_var(struct hist_trigger_data - hist_field = find_file_var(file, var_name); - if (hist_field) { - if (found) { -+ hist_err_event("Variable name not unique, need to use fully qualified name (subsys.event.var) for variable: ", system, event_name, var_name); - return ERR_PTR(-EINVAL); - } - -@@ -1781,6 +1843,7 @@ static int parse_assignment(char *str, s - char *assignment; - - if (attrs->n_assignments == TRACING_MAP_VARS_MAX) { -+ hist_err("Too many variables defined: ", str); - ret = -EINVAL; - goto out; - } -@@ -2335,6 +2398,10 @@ static struct hist_field *parse_var_ref( - if (var_field) - ref_field = create_var_ref(var_field, system, event_name); - -+ if (!ref_field) -+ hist_err_event("Couldn't find variable: $", -+ system, event_name, var_name); -+ - return ref_field; - } - -@@ -2494,6 +2561,7 @@ static struct hist_field *parse_unary(st - // we support only -(xxx) i.e. explicit parens required - - if (level > 3) { -+ hist_err("Too many subexpressions (3 max): ", str); - ret = -EINVAL; - goto free; - } -@@ -2575,8 +2643,10 @@ static int check_expr_operands(struct hi - } - - if ((operand1_flags & HIST_FIELD_FL_TIMESTAMP_USECS) != -- (operand2_flags & HIST_FIELD_FL_TIMESTAMP_USECS)) -+ (operand2_flags & HIST_FIELD_FL_TIMESTAMP_USECS)) { -+ hist_err("Timestamp units in expression don't match", NULL); - return -EINVAL; -+ } - - return 0; - } -@@ -2591,8 +2661,10 @@ static struct hist_field *parse_expr(str - int field_op, ret = -EINVAL; - char *sep, *operand1_str; - -- if (level > 3) -+ if (level > 3) { -+ hist_err("Too many subexpressions (3 max): ", str); - return ERR_PTR(-EINVAL); -+ } - - field_op = contains_operator(str); - -@@ -2826,12 +2898,17 @@ create_field_var_hist(struct hist_trigge - char *cmd; - int ret; - -- if (target_hist_data->n_field_var_hists >= SYNTH_FIELDS_MAX) -+ if (target_hist_data->n_field_var_hists >= SYNTH_FIELDS_MAX) { -+ hist_err_event("onmatch: Too many field variables defined: ", -+ subsys_name, event_name, field_name); - return ERR_PTR(-EINVAL); -+ } - - file = event_file(tr, subsys_name, event_name); - - if (IS_ERR(file)) { -+ hist_err_event("onmatch: Event file not found: ", -+ subsys_name, event_name, field_name); - ret = PTR_ERR(file); - return ERR_PTR(ret); - } -@@ -2843,8 +2920,11 @@ create_field_var_hist(struct hist_trigge - * yet a registered histogram so we can't use that. - */ - hist_data = find_compatible_hist(target_hist_data, file); -- if (!hist_data) -+ if (!hist_data) { -+ hist_err_event("onmatch: Matching event histogram not found: ", -+ subsys_name, event_name, field_name); - return ERR_PTR(-EINVAL); -+ } - - /* See if a synthetic field variable has already been created */ - event_var = find_synthetic_field_var(target_hist_data, subsys_name, -@@ -2903,6 +2983,8 @@ create_field_var_hist(struct hist_trigge - kfree(cmd); - kfree(var_hist->cmd); - kfree(var_hist); -+ hist_err_event("onmatch: Couldn't create histogram for field: ", -+ subsys_name, event_name, field_name); - return ERR_PTR(ret); - } - -@@ -2914,6 +2996,8 @@ create_field_var_hist(struct hist_trigge - if (IS_ERR_OR_NULL(event_var)) { - kfree(var_hist->cmd); - kfree(var_hist); -+ hist_err_event("onmatch: Couldn't find synthetic variable: ", -+ subsys_name, event_name, field_name); - return ERR_PTR(-EINVAL); - } - -@@ -3050,18 +3134,21 @@ static struct field_var *create_field_va - int ret = 0; - - if (hist_data->n_field_vars >= SYNTH_FIELDS_MAX) { -+ hist_err("Too many field variables defined: ", field_name); - ret = -EINVAL; - goto err; - } - - val = parse_atom(hist_data, file, field_name, &flags, NULL); - if (IS_ERR(val)) { -+ hist_err("Couldn't parse field variable: ", field_name); - ret = PTR_ERR(val); - goto err; - } - - var = create_var(hist_data, file, field_name, val->size, val->type); - if (IS_ERR(var)) { -+ hist_err("Couldn't create or find variable: ", field_name); - kfree(val); - ret = PTR_ERR(var); - goto err; -@@ -3204,13 +3291,17 @@ static int onmax_create(struct hist_trig - int ret = 0; - - onmax_var_str = data->onmax.var_str; -- if (onmax_var_str[0] != '$') -+ if (onmax_var_str[0] != '$') { -+ hist_err("onmax: For onmax(x), x must be a variable: ", onmax_var_str); - return -EINVAL; -+ } - onmax_var_str++; - - var_field = find_target_event_var(hist_data, NULL, NULL, onmax_var_str); -- if (!var_field) -+ if (!var_field) { -+ hist_err("onmax: Couldn't find onmax variable: ", onmax_var_str); - return -EINVAL; -+ } - - flags = HIST_FIELD_FL_VAR_REF; - ref_field = create_hist_field(hist_data, NULL, flags, NULL); -@@ -3230,6 +3321,7 @@ static int onmax_create(struct hist_trig - data->onmax.max_var_ref_idx = var_ref_idx; - max_var = create_var(hist_data, file, "max", sizeof(u64), "u64"); - if (IS_ERR(max_var)) { -+ hist_err("onmax: Couldn't create onmax variable: ", "max"); - ret = PTR_ERR(max_var); - goto out; - } -@@ -3244,6 +3336,7 @@ static int onmax_create(struct hist_trig - - field_var = create_target_field_var(hist_data, NULL, NULL, param); - if (IS_ERR(field_var)) { -+ hist_err("onmax: Couldn't create field variable: ", param); - ret = PTR_ERR(field_var); - kfree(param); - goto out; -@@ -3276,6 +3369,7 @@ static int parse_action_params(char *par - - param = strstrip(param); - if (strlen(param) < 2) { -+ hist_err("Invalid action param: ", param); - ret = -EINVAL; - goto out; - } -@@ -3451,6 +3545,9 @@ onmatch_find_var(struct hist_trigger_dat - hist_field = find_event_var(hist_data, system, event, var); - } - -+ if (!hist_field) -+ hist_err_event("onmatch: Couldn't find onmatch param: $", system, event, var); -+ - return hist_field; - } - -@@ -3518,6 +3615,7 @@ static int onmatch_create(struct hist_tr - mutex_lock(&synth_event_mutex); - event = find_synth_event(data->onmatch.synth_event_name); - if (!event) { -+ hist_err("onmatch: Couldn't find synthetic event: ", data->onmatch.synth_event_name); - mutex_unlock(&synth_event_mutex); - return -EINVAL; - } -@@ -3577,12 +3675,15 @@ static int onmatch_create(struct hist_tr - continue; - } - -+ hist_err_event("onmatch: Param type doesn't match synthetic event field type: ", -+ system, event_name, param); - kfree(p); - ret = -EINVAL; - goto err; - } - - if (field_pos != event->n_fields) { -+ hist_err("onmatch: Param count doesn't match synthetic event field count: ", event->name); - ret = -EINVAL; - goto err; - } -@@ -3612,15 +3713,22 @@ static struct action_data *onmatch_parse - return ERR_PTR(-ENOMEM); - - match_event = strsep(&str, ")"); -- if (!match_event || !str) -+ if (!match_event || !str) { -+ hist_err("onmatch: Missing closing paren: ", match_event); - goto free; -+ } - - match_event_system = strsep(&match_event, "."); -- if (!match_event) -+ if (!match_event) { -+ hist_err("onmatch: Missing subsystem for match event: ", match_event_system); - goto free; -+ } - -- if (IS_ERR(event_file(tr, match_event_system, match_event))) -+ if (IS_ERR(event_file(tr, match_event_system, match_event))) { -+ hist_err_event("onmatch: Invalid subsystem or event name: ", -+ match_event_system, match_event, NULL); - goto free; -+ } - - data->onmatch.match_event = kstrdup(match_event, GFP_KERNEL); - if (!data->onmatch.match_event) { -@@ -3635,12 +3743,16 @@ static struct action_data *onmatch_parse - } - - strsep(&str, "."); -- if (!str) -+ if (!str) { -+ hist_err("onmatch: Missing . after onmatch(): ", str); - goto free; -+ } - - synth_event_name = strsep(&str, "("); -- if (!synth_event_name || !str) -+ if (!synth_event_name || !str) { -+ hist_err("onmatch: Missing opening paramlist paren: ", synth_event_name); - goto free; -+ } - - data->onmatch.synth_event_name = kstrdup(synth_event_name, GFP_KERNEL); - if (!data->onmatch.synth_event_name) { -@@ -3649,8 +3761,10 @@ static struct action_data *onmatch_parse - } - - params = strsep(&str, ")"); -- if (!params || !str || (str && strlen(str))) -+ if (!params || !str || (str && strlen(str))) { -+ hist_err("onmatch: Missing closing paramlist paren: ", params); - goto free; -+ } - - ret = parse_action_params(params, data); - if (ret) -@@ -3725,7 +3839,9 @@ static int create_var_field(struct hist_ - - if (WARN_ON(val_idx >= TRACING_MAP_VALS_MAX + TRACING_MAP_VARS_MAX)) - return -EINVAL; -+ - if (find_var(hist_data, file, var_name) && !hist_data->remove) { -+ hist_err("Variable already defined: ", var_name); - return -EINVAL; - } - -@@ -3806,6 +3922,7 @@ static int create_key_field(struct hist_ - } - - if (hist_field->flags & HIST_FIELD_FL_VAR_REF) { -+ hist_err("Using variable references as keys not supported: ", field_str); - destroy_hist_field(hist_field, 0); - ret = -EINVAL; - goto out; -@@ -3919,11 +4036,13 @@ static int parse_var_defs(struct hist_tr - - var_name = strsep(&field_str, "="); - if (!var_name || !field_str) { -+ hist_err("Malformed assignment: ", var_name); - ret = -EINVAL; - goto free; - } - - if (n_vars == TRACING_MAP_VARS_MAX) { -+ hist_err("Too many variables defined: ", var_name); - ret = -EINVAL; - goto free; - } -@@ -4677,6 +4796,11 @@ static int hist_show(struct seq_file *m, - hist_trigger_show(m, data, n++); - } - -+ if (have_hist_err()) { -+ seq_printf(m, "\nERROR: %s\n", hist_err_str); -+ seq_printf(m, " Last command: %s\n", last_hist_cmd); -+ } -+ - out_unlock: - mutex_unlock(&event_mutex); - -@@ -5041,6 +5165,7 @@ static int hist_register_trigger(char *g - if (named_data) { - if (!hist_trigger_match(data, named_data, named_data, - true)) { -+ hist_err("Named hist trigger doesn't match existing named trigger (includes variables): ", hist_data->attrs->name); - ret = -EINVAL; - goto out; - } -@@ -5060,13 +5185,16 @@ static int hist_register_trigger(char *g - test->paused = false; - else if (hist_data->attrs->clear) - hist_clear(test); -- else -+ else { -+ hist_err("Hist trigger already exists", NULL); - ret = -EEXIST; -+ } - goto out; - } - } - new: - if (hist_data->attrs->cont || hist_data->attrs->clear) { -+ hist_err("Can't clear or continue a nonexistent hist trigger", NULL); - ret = -ENOENT; - goto out; - } -@@ -5253,6 +5381,11 @@ static int event_hist_trigger_func(struc - char *trigger, *p; - int ret = 0; - -+ if (glob && strlen(glob)) { -+ last_cmd_set(param); -+ hist_err_clear(); -+ } -+ - if (!param) - return -EINVAL; - -@@ -5391,6 +5524,9 @@ static int event_hist_trigger_func(struc - /* Just return zero, not the number of registered triggers */ - ret = 0; - out: -+ if (ret == 0) -+ hist_err_clear(); -+ - return ret; - out_unreg: - cmd_ops->unreg(glob+1, trigger_ops, trigger_data, file); diff --git a/debian/patches/features/all/rt/0032-tracing-Add-inter-event-hist-trigger-Documentation.patch b/debian/patches/features/all/rt/0032-tracing-Add-inter-event-hist-trigger-Documentation.patch deleted file mode 100644 index 039fb6533..000000000 --- a/debian/patches/features/all/rt/0032-tracing-Add-inter-event-hist-trigger-Documentation.patch +++ /dev/null @@ -1,402 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:52:06 -0600 -Subject: [PATCH 32/37] tracing: Add inter-event hist trigger Documentation -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Add background and details on inter-event hist triggers, including -hist variables, synthetic events, and actions. - -Signed-off-by: Tom Zanussi -Signed-off-by: Baohong Liu -Signed-off-by: Sebastian Andrzej Siewior ---- - Documentation/trace/histogram.txt | 381 ++++++++++++++++++++++++++++++++++++++ - 1 file changed, 381 insertions(+) - ---- a/Documentation/trace/histogram.txt -+++ b/Documentation/trace/histogram.txt -@@ -1603,3 +1603,384 @@ - Hits: 489 - Entries: 7 - Dropped: 0 -+ -+ -+2.2 Inter-event hist triggers -+----------------------------- -+ -+Inter-event hist triggers are hist triggers that combine values from -+one or more other events and create a histogram using that data. Data -+from an inter-event histogram can in turn become the source for -+further combined histograms, thus providing a chain of related -+histograms, which is important for some applications. -+ -+The most important example of an inter-event quantity that can be used -+in this manner is latency, which is simply a difference in timestamps -+between two events. Although latency is the most important -+inter-event quantity, note that because the support is completely -+general across the trace event subsystem, any event field can be used -+in an inter-event quantity. -+ -+An example of a histogram that combines data from other histograms -+into a useful chain would be a 'wakeupswitch latency' histogram that -+combines a 'wakeup latency' histogram and a 'switch latency' -+histogram. -+ -+Normally, a hist trigger specification consists of a (possibly -+compound) key along with one or more numeric values, which are -+continually updated sums associated with that key. A histogram -+specification in this case consists of individual key and value -+specifications that refer to trace event fields associated with a -+single event type. -+ -+The inter-event hist trigger extension allows fields from multiple -+events to be referenced and combined into a multi-event histogram -+specification. In support of this overall goal, a few enabling -+features have been added to the hist trigger support: -+ -+ - In order to compute an inter-event quantity, a value from one -+ event needs to saved and then referenced from another event. This -+ requires the introduction of support for histogram 'variables'. -+ -+ - The computation of inter-event quantities and their combination -+ require some minimal amount of support for applying simple -+ expressions to variables (+ and -). -+ -+ - A histogram consisting of inter-event quantities isn't logically a -+ histogram on either event (so having the 'hist' file for either -+ event host the histogram output doesn't really make sense). To -+ address the idea that the histogram is associated with a -+ combination of events, support is added allowing the creation of -+ 'synthetic' events that are events derived from other events. -+ These synthetic events are full-fledged events just like any other -+ and can be used as such, as for instance to create the -+ 'combination' histograms mentioned previously. -+ -+ - A set of 'actions' can be associated with histogram entries - -+ these can be used to generate the previously mentioned synthetic -+ events, but can also be used for other purposes, such as for -+ example saving context when a 'max' latency has been hit. -+ -+ - Trace events don't have a 'timestamp' associated with them, but -+ there is an implicit timestamp saved along with an event in the -+ underlying ftrace ring buffer. This timestamp is now exposed as a -+ a synthetic field named 'common_timestamp' which can be used in -+ histograms as if it were any other event field; it isn't an actual -+ field in the trace format but rather is a synthesized value that -+ nonetheless can be used as if it were an actual field. By default -+ it is in units of nanoseconds; appending '.usecs' to a -+ common_timestamp field changes the units to microseconds. -+ -+These features are decribed in more detail in the following sections. -+ -+2.2.1 Histogram Variables -+------------------------- -+ -+Variables are simply named locations used for saving and retrieving -+values between matching events. A 'matching' event is defined as an -+event that has a matching key - if a variable is saved for a histogram -+entry corresponding to that key, any subsequent event with a matching -+key can access that variable. -+ -+A variable's value is normally available to any subsequent event until -+it is set to something else by a subsequent event. The one exception -+to that rule is that any variable used in an expression is essentially -+'read-once' - once it's used by an expression in a subsequent event, -+it's reset to its 'unset' state, which means it can't be used again -+unless it's set again. This ensures not only that an event doesn't -+use an uninitialized variable in a calculation, but that that variable -+is used only once and not for any unrelated subsequent match. -+ -+The basic syntax for saving a variable is to simply prefix a unique -+variable name not corresponding to any keyword along with an '=' sign -+to any event field. -+ -+Either keys or values can be saved and retrieved in this way. This -+creates a variable named 'ts0' for a histogram entry with the key -+'next_pid': -+ -+ # echo 'hist:keys=next_pid:vals=$ts0:ts0=common_timestamp ... >> \ -+ event/trigger -+ -+The ts0 variable can be accessed by any subsequent event having the -+same pid as 'next_pid'. -+ -+Variable references are formed by prepending the variable name with -+the '$' sign. Thus for example, the ts0 variable above would be -+referenced as '$ts0' in expressions. -+ -+Because 'vals=' is used, the common_timestamp variable value above -+will also be summed as a normal histogram value would (though for a -+timestamp it makes little sense). -+ -+The below shows that a key value can also be saved in the same way: -+ -+ # echo 'hist:timer_pid=common_pid:key=timer_pid ...' >> event/trigger -+ -+If a variable isn't a key variable or prefixed with 'vals=', the -+associated event field will be saved in a variable but won't be summed -+as a value: -+ -+ # echo 'hist:keys=next_pid:ts1=common_timestamp ... >> event/trigger -+ -+Multiple variables can be assigned at the same time. The below would -+result in both ts0 and b being created as variables, with both -+common_timestamp and field1 additionally being summed as values: -+ -+ # echo 'hist:keys=pid:vals=$ts0,$b:ts0=common_timestamp,b=field1 ... >> \ -+ event/trigger -+ -+Note that variable assignments can appear either preceding or -+following their use. The command below behaves identically to the -+command above: -+ -+ # echo 'hist:keys=pid:ts0=common_timestamp,b=field1:vals=$ts0,$b ... >> \ -+ event/trigger -+ -+Any number of variables not bound to a 'vals=' prefix can also be -+assigned by simply separating them with colons. Below is the same -+thing but without the values being summed in the histogram: -+ -+ # echo 'hist:keys=pid:ts0=common_timestamp:b=field1 ... >> event/trigger -+ -+Variables set as above can be referenced and used in expressions on -+another event. -+ -+For example, here's how a latency can be calculated: -+ -+ # echo 'hist:keys=pid,prio:ts0=common_timestamp ... >> event1/trigger -+ # echo 'hist:keys=next_pid:wakeup_lat=common_timestamp-$ts0 ... >> event2/trigger -+ -+In the first line above, the event's timetamp is saved into the -+variable ts0. In the next line, ts0 is subtracted from the second -+event's timestamp to produce the latency, which is then assigned into -+yet another variable, 'wakeup_lat'. The hist trigger below in turn -+makes use of the wakeup_lat variable to compute a combined latency -+using the same key and variable from yet another event: -+ -+ # echo 'hist:key=pid:wakeupswitch_lat=$wakeup_lat+$switchtime_lat ... >> event3/trigger -+ -+2.2.2 Synthetic Events -+---------------------- -+ -+Synthetic events are user-defined events generated from hist trigger -+variables or fields associated with one or more other events. Their -+purpose is to provide a mechanism for displaying data spanning -+multiple events consistent with the existing and already familiar -+usage for normal events. -+ -+To define a synthetic event, the user writes a simple specification -+consisting of the name of the new event along with one or more -+variables and their types, which can be any valid field type, -+separated by semicolons, to the tracing/synthetic_events file. -+ -+For instance, the following creates a new event named 'wakeup_latency' -+with 3 fields: lat, pid, and prio. Each of those fields is simply a -+variable reference to a variable on another event: -+ -+ # echo 'wakeup_latency \ -+ u64 lat; \ -+ pid_t pid; \ -+ int prio' >> \ -+ /sys/kernel/debug/tracing/synthetic_events -+ -+Reading the tracing/synthetic_events file lists all the currently -+defined synthetic events, in this case the event defined above: -+ -+ # cat /sys/kernel/debug/tracing/synthetic_events -+ wakeup_latency u64 lat; pid_t pid; int prio -+ -+An existing synthetic event definition can be removed by prepending -+the command that defined it with a '!': -+ -+ # echo '!wakeup_latency u64 lat pid_t pid int prio' >> \ -+ /sys/kernel/debug/tracing/synthetic_events -+ -+At this point, there isn't yet an actual 'wakeup_latency' event -+instantiated in the event subsytem - for this to happen, a 'hist -+trigger action' needs to be instantiated and bound to actual fields -+and variables defined on other events (see Section 6.3.3 below). -+ -+Once that is done, an event instance is created, and a histogram can -+be defined using it: -+ -+ # echo 'hist:keys=pid,prio,lat.log2:sort=pid,lat' >> \ -+ /sys/kernel/debug/tracing/events/synthetic/wakeup_latency/trigger -+ -+The new event is created under the tracing/events/synthetic/ directory -+and looks and behaves just like any other event: -+ -+ # ls /sys/kernel/debug/tracing/events/synthetic/wakeup_latency -+ enable filter format hist id trigger -+ -+Like any other event, once a histogram is enabled for the event, the -+output can be displayed by reading the event's 'hist' file. -+ -+2.2.3 Hist trigger 'actions' -+---------------------------- -+ -+A hist trigger 'action' is a function that's executed whenever a -+histogram entry is added or updated. -+ -+The default 'action' if no special function is explicity specified is -+as it always has been, to simply update the set of values associated -+with an entry. Some applications, however, may want to perform -+additional actions at that point, such as generate another event, or -+compare and save a maximum. -+ -+The following additional actions are available. To specify an action -+for a given event, simply specify the action between colons in the -+hist trigger specification. -+ -+ - onmatch(matching.event).(param list) -+ -+ The 'onmatch(matching.event).(params)' hist -+ trigger action is invoked whenever an event matches and the -+ histogram entry would be added or updated. It causes the named -+ synthetic event to be generated with the values given in the -+ 'param list'. The result is the generation of a synthetic event -+ that consists of the values contained in those variables at the -+ time the invoking event was hit. -+ -+ The 'param list' consists of one or more parameters which may be -+ either variables or fields defined on either the 'matching.event' -+ or the target event. The variables or fields specified in the -+ param list may be either fully-qualified or unqualified. If a -+ variable is specified as unqualified, it must be unique between -+ the two events. A field name used as a param can be unqualified -+ if it refers to the target event, but must be fully qualified if -+ it refers to the matching event. A fully-qualified name is of the -+ form 'system.event_name.$var_name' or 'system.event_name.field'. -+ -+ The 'matching.event' specification is simply the fully qualified -+ event name of the event that matches the target event for the -+ onmatch() functionality, in the form 'system.event_name'. -+ -+ Finally, the number and type of variables/fields in the 'param -+ list' must match the number and types of the fields in the -+ synthetic event being generated. -+ -+ As an example the below defines a simple synthetic event and uses -+ a variable defined on the sched_wakeup_new event as a parameter -+ when invoking the synthetic event. Here we define the synthetic -+ event: -+ -+ # echo 'wakeup_new_test pid_t pid' >> \ -+ /sys/kernel/debug/tracing/synthetic_events -+ -+ # cat /sys/kernel/debug/tracing/synthetic_events -+ wakeup_new_test pid_t pid -+ -+ The following hist trigger both defines the missing testpid -+ variable and specifies an onmatch() action that generates a -+ wakeup_new_test synthetic event whenever a sched_wakeup_new event -+ occurs, which because of the 'if comm == "cyclictest"' filter only -+ happens when the executable is cyclictest: -+ -+ # echo 'hist:keys=$testpid:testpid=pid:onmatch(sched.sched_wakeup_new).\ -+ wakeup_new_test($testpid) if comm=="cyclictest"' >> \ -+ /sys/kernel/debug/tracing/events/sched/sched_wakeup_new/trigger -+ -+ Creating and displaying a histogram based on those events is now -+ just a matter of using the fields and new synthetic event in the -+ tracing/events/synthetic directory, as usual: -+ -+ # echo 'hist:keys=pid:sort=pid' >> \ -+ /sys/kernel/debug/tracing/events/synthetic/wakeup_new_test/trigger -+ -+ Running 'cyclictest' should cause wakeup_new events to generate -+ wakeup_new_test synthetic events which should result in histogram -+ output in the wakeup_new_test event's hist file: -+ -+ # cat /sys/kernel/debug/tracing/events/synthetic/wakeup_new_test/hist -+ -+ A more typical usage would be to use two events to calculate a -+ latency. The following example uses a set of hist triggers to -+ produce a 'wakeup_latency' histogram: -+ -+ First, we define a 'wakeup_latency' synthetic event: -+ -+ # echo 'wakeup_latency u64 lat; pid_t pid; int prio' >> \ -+ /sys/kernel/debug/tracing/synthetic_events -+ -+ Next, we specify that whenever we see a sched_waking event for a -+ cyclictest thread, save the timestamp in a 'ts0' variable: -+ -+ # echo 'hist:keys=$saved_pid:saved_pid=pid:ts0=common_timestamp.usecs \ -+ if comm=="cyclictest"' >> \ -+ /sys/kernel/debug/tracing/events/sched/sched_waking/trigger -+ -+ Then, when the corresponding thread is actually scheduled onto the -+ CPU by a sched_switch event, calculate the latency and use that -+ along with another variable and an event field to generate a -+ wakeup_latency synthetic event: -+ -+ # echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:\ -+ onmatch(sched.sched_waking).wakeup_latency($wakeup_lat,\ -+ $saved_pid,next_prio) if next_comm=="cyclictest"' >> \ -+ /sys/kernel/debug/tracing/events/sched/sched_switch/trigger -+ -+ We also need to create a histogram on the wakeup_latency synthetic -+ event in order to aggregate the generated synthetic event data: -+ -+ # echo 'hist:keys=pid,prio,lat:sort=pid,lat' >> \ -+ /sys/kernel/debug/tracing/events/synthetic/wakeup_latency/trigger -+ -+ Finally, once we've run cyclictest to actually generate some -+ events, we can see the output by looking at the wakeup_latency -+ synthetic event's hist file: -+ -+ # cat /sys/kernel/debug/tracing/events/synthetic/wakeup_latency/hist -+ -+ - onmax(var).save(field,.. .) -+ -+ The 'onmax(var).save(field,...)' hist trigger action is invoked -+ whenever the value of 'var' associated with a histogram entry -+ exceeds the current maximum contained in that variable. -+ -+ The end result is that the trace event fields specified as the -+ onmax.save() params will be saved if 'var' exceeds the current -+ maximum for that hist trigger entry. This allows context from the -+ event that exhibited the new maximum to be saved for later -+ reference. When the histogram is displayed, additional fields -+ displaying the saved values will be printed. -+ -+ As an example the below defines a couple of hist triggers, one for -+ sched_waking and another for sched_switch, keyed on pid. Whenever -+ a sched_waking occurs, the timestamp is saved in the entry -+ corresponding to the current pid, and when the scheduler switches -+ back to that pid, the timestamp difference is calculated. If the -+ resulting latency, stored in wakeup_lat, exceeds the current -+ maximum latency, the values specified in the save() fields are -+ recoreded: -+ -+ # echo 'hist:keys=pid:ts0=common_timestamp.usecs \ -+ if comm=="cyclictest"' >> \ -+ /sys/kernel/debug/tracing/events/sched/sched_waking/trigger -+ -+ # echo 'hist:keys=next_pid:\ -+ wakeup_lat=common_timestamp.usecs-$ts0:\ -+ onmax($wakeup_lat).save(next_comm,prev_pid,prev_prio,prev_comm) \ -+ if next_comm=="cyclictest"' >> \ -+ /sys/kernel/debug/tracing/events/sched/sched_switch/trigger -+ -+ When the histogram is displayed, the max value and the saved -+ values corresponding to the max are displayed following the rest -+ of the fields: -+ -+ # cat /sys/kernel/debug/tracing/events/sched/sched_switch/hist -+ { next_pid: 2255 } hitcount: 239 -+ common_timestamp-ts0: 0 -+ max: 27 -+ next_comm: cyclictest -+ prev_pid: 0 prev_prio: 120 prev_comm: swapper/1 -+ -+ { next_pid: 2256 } hitcount: 2355 -+ common_timestamp-ts0: 0 -+ max: 49 next_comm: cyclictest -+ prev_pid: 0 prev_prio: 120 prev_comm: swapper/0 -+ -+ Totals: -+ Hits: 12970 -+ Entries: 2 -+ Dropped: 0 diff --git a/debian/patches/features/all/rt/0032-tracing-Add-support-for-synthetic-events.patch b/debian/patches/features/all/rt/0032-tracing-Add-support-for-synthetic-events.patch index 5847f847c..e560e6d0b 100644 --- a/debian/patches/features/all/rt/0032-tracing-Add-support-for-synthetic-events.patch +++ b/debian/patches/features/all/rt/0032-tracing-Add-support-for-synthetic-events.patch @@ -1,7 +1,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:58 -0600 Subject: [PATCH 32/48] tracing: Add support for 'synthetic' events -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Synthetic events are user-defined events generated from hist trigger variables saved from one or more other events. diff --git a/debian/patches/features/all/rt/0032-xfrm-Replace-hrtimer-tasklet-with-softirq-hrtimer.patch b/debian/patches/features/all/rt/0032-xfrm-Replace-hrtimer-tasklet-with-softirq-hrtimer.patch deleted file mode 100644 index 266304c33..000000000 --- a/debian/patches/features/all/rt/0032-xfrm-Replace-hrtimer-tasklet-with-softirq-hrtimer.patch +++ /dev/null @@ -1,133 +0,0 @@ -From: Thomas Gleixner -Date: Thu, 23 Nov 2017 16:39:13 +0100 -Subject: [PATCH 32/36] xfrm: Replace hrtimer tasklet with softirq hrtimer -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Switch the timer to HRTIMER_MODE_SOFT, which executed the timer -callback in softirq context and remove the hrtimer_tasklet. - -Signed-off-by: Thomas Gleixner -Signed-off-by: Anna-Maria Gleixner -Cc: Steffen Klassert -Cc: netdev@vger.kernel.org -Cc: Herbert Xu -Cc: "David S. Miller" -Signed-off-by: Sebastian Andrzej Siewior ---- - include/net/xfrm.h | 2 +- - net/xfrm/xfrm_state.c | 30 ++++++++++++++++++------------ - 2 files changed, 19 insertions(+), 13 deletions(-) - ---- a/include/net/xfrm.h -+++ b/include/net/xfrm.h -@@ -217,7 +217,7 @@ struct xfrm_state { - struct xfrm_stats stats; - - struct xfrm_lifetime_cur curlft; -- struct tasklet_hrtimer mtimer; -+ struct hrtimer mtimer; - - struct xfrm_state_offload xso; - ---- a/net/xfrm/xfrm_state.c -+++ b/net/xfrm/xfrm_state.c -@@ -426,7 +426,7 @@ static void xfrm_put_mode(struct xfrm_mo - - static void xfrm_state_gc_destroy(struct xfrm_state *x) - { -- tasklet_hrtimer_cancel(&x->mtimer); -+ hrtimer_cancel(&x->mtimer); - del_timer_sync(&x->rtimer); - kfree(x->aead); - kfree(x->aalg); -@@ -471,8 +471,8 @@ static void xfrm_state_gc_task(struct wo - - static enum hrtimer_restart xfrm_timer_handler(struct hrtimer *me) - { -- struct tasklet_hrtimer *thr = container_of(me, struct tasklet_hrtimer, timer); -- struct xfrm_state *x = container_of(thr, struct xfrm_state, mtimer); -+ struct xfrm_state *x = container_of(me, struct xfrm_state, mtimer); -+ enum hrtimer_restart ret = HRTIMER_NORESTART; - unsigned long now = get_seconds(); - long next = LONG_MAX; - int warn = 0; -@@ -536,7 +536,8 @@ static enum hrtimer_restart xfrm_timer_h - km_state_expired(x, 0, 0); - resched: - if (next != LONG_MAX) { -- tasklet_hrtimer_start(&x->mtimer, ktime_set(next, 0), HRTIMER_MODE_REL); -+ hrtimer_forward_now(&x->mtimer, ktime_set(next, 0)); -+ ret = HRTIMER_RESTART; - } - - goto out; -@@ -553,7 +554,7 @@ static enum hrtimer_restart xfrm_timer_h - - out: - spin_unlock(&x->lock); -- return HRTIMER_NORESTART; -+ return ret; - } - - static void xfrm_replay_timer_handler(unsigned long data); -@@ -572,8 +573,8 @@ struct xfrm_state *xfrm_state_alloc(stru - INIT_HLIST_NODE(&x->bydst); - INIT_HLIST_NODE(&x->bysrc); - INIT_HLIST_NODE(&x->byspi); -- tasklet_hrtimer_init(&x->mtimer, xfrm_timer_handler, -- CLOCK_BOOTTIME, HRTIMER_MODE_ABS); -+ hrtimer_init(&x->mtimer, CLOCK_BOOTTIME, HRTIMER_MODE_ABS_SOFT); -+ x->mtimer.function = xfrm_timer_handler; - setup_timer(&x->rtimer, xfrm_replay_timer_handler, - (unsigned long)x); - x->curlft.add_time = get_seconds(); -@@ -1030,7 +1031,9 @@ xfrm_state_find(const xfrm_address_t *da - hlist_add_head_rcu(&x->byspi, net->xfrm.state_byspi + h); - } - x->lft.hard_add_expires_seconds = net->xfrm.sysctl_acq_expires; -- tasklet_hrtimer_start(&x->mtimer, ktime_set(net->xfrm.sysctl_acq_expires, 0), HRTIMER_MODE_REL); -+ hrtimer_start(&x->mtimer, -+ ktime_set(net->xfrm.sysctl_acq_expires, 0), -+ HRTIMER_MODE_REL_SOFT); - net->xfrm.state_num++; - xfrm_hash_grow_check(net, x->bydst.next != NULL); - spin_unlock_bh(&net->xfrm.xfrm_state_lock); -@@ -1141,7 +1144,7 @@ static void __xfrm_state_insert(struct x - hlist_add_head_rcu(&x->byspi, net->xfrm.state_byspi + h); - } - -- tasklet_hrtimer_start(&x->mtimer, ktime_set(1, 0), HRTIMER_MODE_REL); -+ hrtimer_start(&x->mtimer, ktime_set(1, 0), HRTIMER_MODE_REL_SOFT); - if (x->replay_maxage) - mod_timer(&x->rtimer, jiffies + x->replay_maxage); - -@@ -1245,7 +1248,9 @@ static struct xfrm_state *__find_acq_cor - x->mark.m = m->m; - x->lft.hard_add_expires_seconds = net->xfrm.sysctl_acq_expires; - xfrm_state_hold(x); -- tasklet_hrtimer_start(&x->mtimer, ktime_set(net->xfrm.sysctl_acq_expires, 0), HRTIMER_MODE_REL); -+ hrtimer_start(&x->mtimer, -+ ktime_set(net->xfrm.sysctl_acq_expires, 0), -+ HRTIMER_MODE_REL_SOFT); - list_add(&x->km.all, &net->xfrm.state_all); - hlist_add_head_rcu(&x->bydst, net->xfrm.state_bydst + h); - h = xfrm_src_hash(net, daddr, saddr, family); -@@ -1544,7 +1549,8 @@ int xfrm_state_update(struct xfrm_state - memcpy(&x1->lft, &x->lft, sizeof(x1->lft)); - x1->km.dying = 0; - -- tasklet_hrtimer_start(&x1->mtimer, ktime_set(1, 0), HRTIMER_MODE_REL); -+ hrtimer_start(&x1->mtimer, ktime_set(1, 0), -+ HRTIMER_MODE_REL_SOFT); - if (x1->curlft.use_time) - xfrm_state_check_expire(x1); - -@@ -1568,7 +1574,7 @@ int xfrm_state_check_expire(struct xfrm_ - if (x->curlft.bytes >= x->lft.hard_byte_limit || - x->curlft.packets >= x->lft.hard_packet_limit) { - x->km.state = XFRM_STATE_EXPIRED; -- tasklet_hrtimer_start(&x->mtimer, 0, HRTIMER_MODE_REL); -+ hrtimer_start(&x->mtimer, 0, HRTIMER_MODE_REL_SOFT); - return -EINVAL; - } - diff --git a/debian/patches/features/all/rt/0033-softirq-Remove-tasklet_hrtimer.patch b/debian/patches/features/all/rt/0033-softirq-Remove-tasklet_hrtimer.patch deleted file mode 100644 index 0a57c6ec2..000000000 --- a/debian/patches/features/all/rt/0033-softirq-Remove-tasklet_hrtimer.patch +++ /dev/null @@ -1,110 +0,0 @@ -From: Thomas Gleixner -Date: Thu, 23 Nov 2017 16:39:14 +0100 -Subject: [PATCH 33/36] softirq: Remove tasklet_hrtimer -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -There are no more tasklet_hrtimer users of this interface. -Remove it. - -Signed-off-by: Thomas Gleixner -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - include/linux/interrupt.h | 25 ---------------------- - kernel/softirq.c | 51 ---------------------------------------------- - 2 files changed, 76 deletions(-) - ---- a/include/linux/interrupt.h -+++ b/include/linux/interrupt.h -@@ -633,31 +633,6 @@ extern void tasklet_kill_immediate(struc - extern void tasklet_init(struct tasklet_struct *t, - void (*func)(unsigned long), unsigned long data); - --struct tasklet_hrtimer { -- struct hrtimer timer; -- struct tasklet_struct tasklet; -- enum hrtimer_restart (*function)(struct hrtimer *); --}; -- --extern void --tasklet_hrtimer_init(struct tasklet_hrtimer *ttimer, -- enum hrtimer_restart (*function)(struct hrtimer *), -- clockid_t which_clock, enum hrtimer_mode mode); -- --static inline --void tasklet_hrtimer_start(struct tasklet_hrtimer *ttimer, ktime_t time, -- const enum hrtimer_mode mode) --{ -- hrtimer_start(&ttimer->timer, time, mode); --} -- --static inline --void tasklet_hrtimer_cancel(struct tasklet_hrtimer *ttimer) --{ -- hrtimer_cancel(&ttimer->timer); -- tasklet_kill(&ttimer->tasklet); --} -- - /* - * Autoprobing for irqs: - * ---- a/kernel/softirq.c -+++ b/kernel/softirq.c -@@ -594,57 +594,6 @@ void tasklet_kill(struct tasklet_struct - } - EXPORT_SYMBOL(tasklet_kill); - --/* -- * tasklet_hrtimer -- */ -- --/* -- * The trampoline is called when the hrtimer expires. It schedules a tasklet -- * to run __tasklet_hrtimer_trampoline() which in turn will call the intended -- * hrtimer callback, but from softirq context. -- */ --static enum hrtimer_restart __hrtimer_tasklet_trampoline(struct hrtimer *timer) --{ -- struct tasklet_hrtimer *ttimer = -- container_of(timer, struct tasklet_hrtimer, timer); -- -- tasklet_hi_schedule(&ttimer->tasklet); -- return HRTIMER_NORESTART; --} -- --/* -- * Helper function which calls the hrtimer callback from -- * tasklet/softirq context -- */ --static void __tasklet_hrtimer_trampoline(unsigned long data) --{ -- struct tasklet_hrtimer *ttimer = (void *)data; -- enum hrtimer_restart restart; -- -- restart = ttimer->function(&ttimer->timer); -- if (restart != HRTIMER_NORESTART) -- hrtimer_restart(&ttimer->timer); --} -- --/** -- * tasklet_hrtimer_init - Init a tasklet/hrtimer combo for softirq callbacks -- * @ttimer: tasklet_hrtimer which is initialized -- * @function: hrtimer callback function which gets called from softirq context -- * @which_clock: clock id (CLOCK_MONOTONIC/CLOCK_REALTIME) -- * @mode: hrtimer mode (HRTIMER_MODE_ABS/HRTIMER_MODE_REL) -- */ --void tasklet_hrtimer_init(struct tasklet_hrtimer *ttimer, -- enum hrtimer_restart (*function)(struct hrtimer *), -- clockid_t which_clock, enum hrtimer_mode mode) --{ -- hrtimer_init(&ttimer->timer, which_clock, mode); -- ttimer->timer.function = __hrtimer_tasklet_trampoline; -- tasklet_init(&ttimer->tasklet, __tasklet_hrtimer_trampoline, -- (unsigned long)ttimer); -- ttimer->function = function; --} --EXPORT_SYMBOL_GPL(tasklet_hrtimer_init); -- - void __init softirq_init(void) - { - int cpu; diff --git a/debian/patches/features/all/rt/0033-tracing-Add-support-for-field-variables.patch b/debian/patches/features/all/rt/0033-tracing-Add-support-for-field-variables.patch index c93a5c482..77caa17e5 100644 --- a/debian/patches/features/all/rt/0033-tracing-Add-support-for-field-variables.patch +++ b/debian/patches/features/all/rt/0033-tracing-Add-support-for-field-variables.patch @@ -1,7 +1,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:51:59 -0600 Subject: [PATCH 33/48] tracing: Add support for 'field variables' -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Users should be able to directly specify event fields in hist trigger 'actions' rather than being forced to explicitly create a variable for diff --git a/debian/patches/features/all/rt/0033-tracing-Make-tracing_set_clock-non-static.patch b/debian/patches/features/all/rt/0033-tracing-Make-tracing_set_clock-non-static.patch deleted file mode 100644 index 6831af435..000000000 --- a/debian/patches/features/all/rt/0033-tracing-Make-tracing_set_clock-non-static.patch +++ /dev/null @@ -1,40 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:52:07 -0600 -Subject: [PATCH 33/37] tracing: Make tracing_set_clock() non-static -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Allow tracing code outside of trace.c to access tracing_set_clock(). - -Some applications may require a particular clock in order to function -properly, such as latency calculations. - -Also, add an accessor returning the current clock string. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/trace.c | 2 +- - kernel/trace/trace.h | 1 + - 2 files changed, 2 insertions(+), 1 deletion(-) - ---- a/kernel/trace/trace.c -+++ b/kernel/trace/trace.c -@@ -6219,7 +6219,7 @@ static int tracing_clock_show(struct seq - return 0; - } - --static int tracing_set_clock(struct trace_array *tr, const char *clockstr) -+int tracing_set_clock(struct trace_array *tr, const char *clockstr) - { - int i; - ---- a/kernel/trace/trace.h -+++ b/kernel/trace/trace.h -@@ -289,6 +289,7 @@ extern int trace_array_get(struct trace_ - extern void trace_array_put(struct trace_array *tr); - - extern int tracing_set_time_stamp_abs(struct trace_array *tr, bool abs); -+extern int tracing_set_clock(struct trace_array *tr, const char *clockstr); - - extern bool trace_clock_in_ns(struct trace_array *tr); - diff --git a/debian/patches/features/all/rt/0034-ALSA-dummy-Replace-tasklet-with-softirq-hrtimer.patch b/debian/patches/features/all/rt/0034-ALSA-dummy-Replace-tasklet-with-softirq-hrtimer.patch deleted file mode 100644 index e4e9849fc..000000000 --- a/debian/patches/features/all/rt/0034-ALSA-dummy-Replace-tasklet-with-softirq-hrtimer.patch +++ /dev/null @@ -1,100 +0,0 @@ -From: Thomas Gleixner -Date: Thu, 23 Nov 2017 16:39:15 +0100 -Subject: [PATCH 34/36] ALSA/dummy: Replace tasklet with softirq hrtimer -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The tasklet is used to defer the execution of snd_pcm_period_elapsed() to -the softirq context. Using the HRTIMER_MODE_SOFT mode invokes the timer -callback in softirq context as well which renders the tasklet useless. - -[o-takashi: avoid stall due to a call of hrtimer_cancel() on a callback - of hrtimer] - -Signed-off-by: Thomas Gleixner -Signed-off-by: Anna-Maria Gleixner -Cc: alsa-devel@alsa-project.org -Cc: Takashi Sakamoto -Cc: Takashi Iwai -Cc: Jaroslav Kysela -Link: http://lkml.kernel.org/r/20170905161820.jtysvxtfleunbbmf@breakpoint.cc -Signed-off-by: Sebastian Andrzej Siewior ---- - sound/drivers/dummy.c | 27 ++++++++++++--------------- - 1 file changed, 12 insertions(+), 15 deletions(-) - ---- a/sound/drivers/dummy.c -+++ b/sound/drivers/dummy.c -@@ -376,17 +376,9 @@ struct dummy_hrtimer_pcm { - ktime_t period_time; - atomic_t running; - struct hrtimer timer; -- struct tasklet_struct tasklet; - struct snd_pcm_substream *substream; - }; - --static void dummy_hrtimer_pcm_elapsed(unsigned long priv) --{ -- struct dummy_hrtimer_pcm *dpcm = (struct dummy_hrtimer_pcm *)priv; -- if (atomic_read(&dpcm->running)) -- snd_pcm_period_elapsed(dpcm->substream); --} -- - static enum hrtimer_restart dummy_hrtimer_callback(struct hrtimer *timer) - { - struct dummy_hrtimer_pcm *dpcm; -@@ -394,7 +386,14 @@ static enum hrtimer_restart dummy_hrtime - dpcm = container_of(timer, struct dummy_hrtimer_pcm, timer); - if (!atomic_read(&dpcm->running)) - return HRTIMER_NORESTART; -- tasklet_schedule(&dpcm->tasklet); -+ /* -+ * In cases of XRUN and draining, this calls .trigger to stop PCM -+ * substream. -+ */ -+ snd_pcm_period_elapsed(dpcm->substream); -+ if (!atomic_read(&dpcm->running)) -+ return HRTIMER_NORESTART; -+ - hrtimer_forward_now(timer, dpcm->period_time); - return HRTIMER_RESTART; - } -@@ -404,7 +403,7 @@ static int dummy_hrtimer_start(struct sn - struct dummy_hrtimer_pcm *dpcm = substream->runtime->private_data; - - dpcm->base_time = hrtimer_cb_get_time(&dpcm->timer); -- hrtimer_start(&dpcm->timer, dpcm->period_time, HRTIMER_MODE_REL); -+ hrtimer_start(&dpcm->timer, dpcm->period_time, HRTIMER_MODE_REL_SOFT); - atomic_set(&dpcm->running, 1); - return 0; - } -@@ -414,14 +413,14 @@ static int dummy_hrtimer_stop(struct snd - struct dummy_hrtimer_pcm *dpcm = substream->runtime->private_data; - - atomic_set(&dpcm->running, 0); -- hrtimer_cancel(&dpcm->timer); -+ if (!hrtimer_callback_running(&dpcm->timer)) -+ hrtimer_cancel(&dpcm->timer); - return 0; - } - - static inline void dummy_hrtimer_sync(struct dummy_hrtimer_pcm *dpcm) - { - hrtimer_cancel(&dpcm->timer); -- tasklet_kill(&dpcm->tasklet); - } - - static snd_pcm_uframes_t -@@ -466,12 +465,10 @@ static int dummy_hrtimer_create(struct s - if (!dpcm) - return -ENOMEM; - substream->runtime->private_data = dpcm; -- hrtimer_init(&dpcm->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); -+ hrtimer_init(&dpcm->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT); - dpcm->timer.function = dummy_hrtimer_callback; - dpcm->substream = substream; - atomic_set(&dpcm->running, 0); -- tasklet_init(&dpcm->tasklet, dummy_hrtimer_pcm_elapsed, -- (unsigned long)dpcm); - return 0; - } - diff --git a/debian/patches/features/all/rt/0034-tracing-Add-a-clock-attribute-for-hist-triggers.patch b/debian/patches/features/all/rt/0034-tracing-Add-a-clock-attribute-for-hist-triggers.patch deleted file mode 100644 index 6590eba24..000000000 --- a/debian/patches/features/all/rt/0034-tracing-Add-a-clock-attribute-for-hist-triggers.patch +++ /dev/null @@ -1,134 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:52:08 -0600 -Subject: [PATCH 34/37] tracing: Add a clock attribute for hist triggers -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The default clock if timestamps are used in a histogram is "global". -If timestamps aren't used, the clock is irrelevant. - -Use the "clock=" param only if you want to override the default -"global" clock for a histogram with timestamps. - -Signed-off-by: Tom Zanussi -Signed-off-by: Rajvi Jingar -Signed-off-by: Sebastian Andrzej Siewior ---- - Documentation/trace/histogram.txt | 11 +++++++++ - kernel/trace/trace_events_hist.c | 42 +++++++++++++++++++++++++++++++++++--- - 2 files changed, 49 insertions(+), 4 deletions(-) - ---- a/Documentation/trace/histogram.txt -+++ b/Documentation/trace/histogram.txt -@@ -1671,7 +1671,16 @@ specification. In support of this overa - it is in units of nanoseconds; appending '.usecs' to a - common_timestamp field changes the units to microseconds. - --These features are decribed in more detail in the following sections. -+A note on inter-event timestamps: If common_timestamp is used in a -+histogram, the trace buffer is automatically switched over to using -+absolute timestamps and the "global" trace clock, in order to avoid -+bogus timestamp differences with other clocks that aren't coherent -+across CPUs. This can be overridden by specifying one of the other -+trace clocks instead, using the "clock=XXX" hist trigger attribute, -+where XXX is any of the clocks listed in the tracing/trace_clock -+pseudo-file. -+ -+These features are described in more detail in the following sections. - - 2.2.1 Histogram Variables - ------------------------- ---- a/kernel/trace/trace_events_hist.c -+++ b/kernel/trace/trace_events_hist.c -@@ -242,6 +242,7 @@ struct hist_trigger_attrs { - char *vals_str; - char *sort_key_str; - char *name; -+ char *clock; - bool pause; - bool cont; - bool clear; -@@ -1776,6 +1777,7 @@ static void destroy_hist_trigger_attrs(s - kfree(attrs->sort_key_str); - kfree(attrs->keys_str); - kfree(attrs->vals_str); -+ kfree(attrs->clock); - kfree(attrs); - } - -@@ -1831,6 +1833,19 @@ static int parse_assignment(char *str, s - ret = -ENOMEM; - goto out; - } -+ } else if (strncmp(str, "clock=", strlen("clock=")) == 0) { -+ strsep(&str, "="); -+ if (!str) { -+ ret = -EINVAL; -+ goto out; -+ } -+ -+ str = strstrip(str); -+ attrs->clock = kstrdup(str, GFP_KERNEL); -+ if (!attrs->clock) { -+ ret = -ENOMEM; -+ goto out; -+ } - } else if (strncmp(str, "size=", strlen("size=")) == 0) { - int map_bits = parse_map_size(str); - -@@ -1895,6 +1910,14 @@ static struct hist_trigger_attrs *parse_ - goto free; - } - -+ if (!attrs->clock) { -+ attrs->clock = kstrdup("global", GFP_KERNEL); -+ if (!attrs->clock) { -+ ret = -ENOMEM; -+ goto free; -+ } -+ } -+ - return attrs; - free: - destroy_hist_trigger_attrs(attrs); -@@ -4936,6 +4959,8 @@ static int event_hist_trigger_print(stru - seq_puts(m, ".descending"); - } - seq_printf(m, ":size=%u", (1 << hist_data->map->map_bits)); -+ if (hist_data->enable_timestamps) -+ seq_printf(m, ":clock=%s", hist_data->attrs->clock); - - print_actions_spec(m, hist_data); - -@@ -5203,7 +5228,6 @@ static int hist_register_trigger(char *g - data->paused = true; - - if (named_data) { -- destroy_hist_data(data->private_data); - data->private_data = named_data->private_data; - set_named_trigger_data(data, named_data); - data->ops = &event_hist_trigger_named_ops; -@@ -5215,10 +5239,22 @@ static int hist_register_trigger(char *g - goto out; - } - -- ret++; -+ if (hist_data->enable_timestamps) { -+ char *clock = hist_data->attrs->clock; -+ -+ ret = tracing_set_clock(file->tr, hist_data->attrs->clock); -+ if (ret) { -+ hist_err("Couldn't set trace_clock: ", clock); -+ goto out; -+ } - -- if (hist_data->enable_timestamps) - tracing_set_time_stamp_abs(file->tr, true); -+ } -+ -+ if (named_data) -+ destroy_hist_data(hist_data); -+ -+ ret++; - out: - return ret; - } diff --git a/debian/patches/features/all/rt/0034-tracing-Add-onmatch-hist-trigger-action-support.patch b/debian/patches/features/all/rt/0034-tracing-Add-onmatch-hist-trigger-action-support.patch index 89e31f2db..0d9774fd3 100644 --- a/debian/patches/features/all/rt/0034-tracing-Add-onmatch-hist-trigger-action-support.patch +++ b/debian/patches/features/all/rt/0034-tracing-Add-onmatch-hist-trigger-action-support.patch @@ -1,7 +1,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:52:00 -0600 Subject: [PATCH 34/48] tracing: Add 'onmatch' hist trigger action support -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Add an 'onmatch(matching.event).(param list)' hist trigger action which is invoked with the set of variables or diff --git a/debian/patches/features/all/rt/0035-tracing-Add-onmax-hist-trigger-action-support.patch b/debian/patches/features/all/rt/0035-tracing-Add-onmax-hist-trigger-action-support.patch index e44f08c56..57f3d28ef 100644 --- a/debian/patches/features/all/rt/0035-tracing-Add-onmax-hist-trigger-action-support.patch +++ b/debian/patches/features/all/rt/0035-tracing-Add-onmax-hist-trigger-action-support.patch @@ -1,7 +1,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:52:01 -0600 Subject: [PATCH 35/48] tracing: Add 'onmax' hist trigger action support -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Add an 'onmax(var).save(field,...)' hist trigger action which is invoked whenever an event exceeds the current maximum. diff --git a/debian/patches/features/all/rt/0035-tracing-Increase-trace_recursive_lock-limit-for-synt.patch b/debian/patches/features/all/rt/0035-tracing-Increase-trace_recursive_lock-limit-for-synt.patch deleted file mode 100644 index 250bc8670..000000000 --- a/debian/patches/features/all/rt/0035-tracing-Increase-trace_recursive_lock-limit-for-synt.patch +++ /dev/null @@ -1,44 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:52:09 -0600 -Subject: [PATCH 35/37] tracing: Increase trace_recursive_lock() limit for - synthetic events -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Synthetic event generation needs to happen while the current event is -still in progress, so add 1 to the trace_recursive_lock() recursion -limit to account for that. - -Because we also want to allow for the possibility of a synthetic event -being generated from another synthetic event, add an additional -increment for that as well. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/ring_buffer.c | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - ---- a/kernel/trace/ring_buffer.c -+++ b/kernel/trace/ring_buffer.c -@@ -2593,16 +2593,16 @@ rb_wakeups(struct ring_buffer *buffer, s - * 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 -- * recusive loop and do not let it go further. -+ * If for some reason the ring buffer starts to recurse, we only allow -+ * that to happen at most 6 times (one for each context, plus possibly -+ * two levels of synthetic event generation). If it happens 7 times, -+ * then we consider this a recusive loop and do not let it go further. - */ - - static __always_inline int - trace_recursive_lock(struct ring_buffer_per_cpu *cpu_buffer) - { -- if (cpu_buffer->current_context >= 4) -+ if (cpu_buffer->current_context >= 6) - return 1; - - cpu_buffer->current_context++; diff --git a/debian/patches/features/all/rt/0035-usb-gadget-NCM-Replace-tasklet-with-softirq-hrtimer.patch b/debian/patches/features/all/rt/0035-usb-gadget-NCM-Replace-tasklet-with-softirq-hrtimer.patch deleted file mode 100644 index 844cb5bc3..000000000 --- a/debian/patches/features/all/rt/0035-usb-gadget-NCM-Replace-tasklet-with-softirq-hrtimer.patch +++ /dev/null @@ -1,97 +0,0 @@ -From: Thomas Gleixner -Date: Thu, 23 Nov 2017 16:39:16 +0100 -Subject: [PATCH 35/36] usb/gadget/NCM: Replace tasklet with softirq hrtimer -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The tx_tasklet tasklet is used in invoke the hrtimer (task_timer) in -softirq context. This can be also achieved without the tasklet but -with HRTIMER_MODE_SOFT as hrtimer mode. - -Signed-off-by: Thomas Gleixner -Signed-off-by: Anna-Maria Gleixner -Cc: Felipe Balbi -Cc: linux-usb@vger.kernel.org -Signed-off-by: Sebastian Andrzej Siewior ---- - drivers/usb/gadget/function/f_ncm.c | 30 +++++++----------------------- - 1 file changed, 7 insertions(+), 23 deletions(-) - ---- a/drivers/usb/gadget/function/f_ncm.c -+++ b/drivers/usb/gadget/function/f_ncm.c -@@ -77,9 +77,7 @@ struct f_ncm { - struct sk_buff *skb_tx_ndp; - u16 ndp_dgram_count; - bool timer_force_tx; -- struct tasklet_struct tx_tasklet; - struct hrtimer task_timer; -- - bool timer_stopping; - }; - -@@ -1108,7 +1106,7 @@ static struct sk_buff *ncm_wrap_ntb(stru - - /* Delay the timer. */ - hrtimer_start(&ncm->task_timer, TX_TIMEOUT_NSECS, -- HRTIMER_MODE_REL); -+ HRTIMER_MODE_REL_SOFT); - - /* Add the datagram position entries */ - ntb_ndp = skb_put_zero(ncm->skb_tx_ndp, dgram_idx_len); -@@ -1152,17 +1150,15 @@ static struct sk_buff *ncm_wrap_ntb(stru - } - - /* -- * This transmits the NTB if there are frames waiting. -+ * The transmit should only be run if no skb data has been sent -+ * for a certain duration. - */ --static void ncm_tx_tasklet(unsigned long data) -+static enum hrtimer_restart ncm_tx_timeout(struct hrtimer *data) - { -- struct f_ncm *ncm = (void *)data; -- -- if (ncm->timer_stopping) -- return; -+ struct f_ncm *ncm = container_of(data, struct f_ncm, task_timer); - - /* Only send if data is available. */ -- if (ncm->skb_tx_data) { -+ if (!ncm->timer_stopping && ncm->skb_tx_data) { - ncm->timer_force_tx = true; - - /* XXX This allowance of a NULL skb argument to ndo_start_xmit -@@ -1175,16 +1171,6 @@ static void ncm_tx_tasklet(unsigned long - - ncm->timer_force_tx = false; - } --} -- --/* -- * The transmit should only be run if no skb data has been sent -- * for a certain duration. -- */ --static enum hrtimer_restart ncm_tx_timeout(struct hrtimer *data) --{ -- struct f_ncm *ncm = container_of(data, struct f_ncm, task_timer); -- tasklet_schedule(&ncm->tx_tasklet); - return HRTIMER_NORESTART; - } - -@@ -1517,8 +1503,7 @@ static int ncm_bind(struct usb_configura - ncm->port.open = ncm_open; - ncm->port.close = ncm_close; - -- tasklet_init(&ncm->tx_tasklet, ncm_tx_tasklet, (unsigned long) ncm); -- hrtimer_init(&ncm->task_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); -+ hrtimer_init(&ncm->task_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_SOFT); - ncm->task_timer.function = ncm_tx_timeout; - - DBG(cdev, "CDC Network: %s speed IN/%s OUT/%s NOTIFY/%s\n", -@@ -1627,7 +1612,6 @@ static void ncm_unbind(struct usb_config - DBG(c->cdev, "ncm unbind\n"); - - hrtimer_cancel(&ncm->task_timer); -- tasklet_kill(&ncm->tx_tasklet); - - ncm_string_defs[0].id = 0; - usb_free_all_descriptors(f); diff --git a/debian/patches/features/all/rt/0036-net-mvpp2-Replace-tasklet-with-softirq-hrtimer.patch b/debian/patches/features/all/rt/0036-net-mvpp2-Replace-tasklet-with-softirq-hrtimer.patch deleted file mode 100644 index e4994c3a5..000000000 --- a/debian/patches/features/all/rt/0036-net-mvpp2-Replace-tasklet-with-softirq-hrtimer.patch +++ /dev/null @@ -1,133 +0,0 @@ -From: Thomas Gleixner -Date: Thu, 23 Nov 2017 16:39:17 +0100 -Subject: [PATCH 36/36] net/mvpp2: Replace tasklet with softirq hrtimer -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The tx_done_tasklet tasklet is used in invoke the hrtimer -(mvpp2_hr_timer_cb) in softirq context. This can be also achieved without -the tasklet but with HRTIMER_MODE_SOFT as hrtimer mode. - -Signed-off-by: Thomas Gleixner -Signed-off-by: Anna-Maria Gleixner -Cc: Thomas Petazzoni -Cc: netdev@vger.kernel.org -Cc: "David S. Miller" -Signed-off-by: Sebastian Andrzej Siewior ---- - drivers/net/ethernet/marvell/mvpp2.c | 62 ++++++++++++++--------------------- - 1 file changed, 25 insertions(+), 37 deletions(-) - ---- a/drivers/net/ethernet/marvell/mvpp2.c -+++ b/drivers/net/ethernet/marvell/mvpp2.c -@@ -830,9 +830,8 @@ struct mvpp2_pcpu_stats { - /* Per-CPU port control */ - struct mvpp2_port_pcpu { - struct hrtimer tx_done_timer; -+ struct net_device *dev; - bool timer_scheduled; -- /* Tasklet for egress finalization */ -- struct tasklet_struct tx_done_tasklet; - }; - - struct mvpp2_queue_vector { -@@ -5970,46 +5969,34 @@ static void mvpp2_link_event(struct net_ - } - } - --static void mvpp2_timer_set(struct mvpp2_port_pcpu *port_pcpu) --{ -- ktime_t interval; -- -- if (!port_pcpu->timer_scheduled) { -- port_pcpu->timer_scheduled = true; -- interval = MVPP2_TXDONE_HRTIMER_PERIOD_NS; -- hrtimer_start(&port_pcpu->tx_done_timer, interval, -- HRTIMER_MODE_REL_PINNED); -- } --} -- --static void mvpp2_tx_proc_cb(unsigned long data) -+static enum hrtimer_restart mvpp2_hr_timer_cb(struct hrtimer *timer) - { -- struct net_device *dev = (struct net_device *)data; -- struct mvpp2_port *port = netdev_priv(dev); -- struct mvpp2_port_pcpu *port_pcpu = this_cpu_ptr(port->pcpu); -+ struct net_device *dev; -+ struct mvpp2_port *port; -+ struct mvpp2_port_pcpu *port_pcpu; - unsigned int tx_todo, cause; - -+ port_pcpu = container_of(timer, struct mvpp2_port_pcpu, tx_done_timer); -+ dev = port_pcpu->dev; -+ - if (!netif_running(dev)) -- return; -+ return HRTIMER_NORESTART; -+ - port_pcpu->timer_scheduled = false; -+ port = netdev_priv(dev); - - /* Process all the Tx queues */ - cause = (1 << port->ntxqs) - 1; - tx_todo = mvpp2_tx_done(port, cause, smp_processor_id()); - - /* Set the timer in case not all the packets were processed */ -- if (tx_todo) -- mvpp2_timer_set(port_pcpu); --} -- --static enum hrtimer_restart mvpp2_hr_timer_cb(struct hrtimer *timer) --{ -- struct mvpp2_port_pcpu *port_pcpu = container_of(timer, -- struct mvpp2_port_pcpu, -- tx_done_timer); -- -- tasklet_schedule(&port_pcpu->tx_done_tasklet); -+ if (tx_todo && !port_pcpu->timer_scheduled) { -+ port_pcpu->timer_scheduled = true; -+ hrtimer_forward_now(&port_pcpu->tx_done_timer, -+ MVPP2_TXDONE_HRTIMER_PERIOD_NS); - -+ return HRTIMER_RESTART; -+ } - return HRTIMER_NORESTART; - } - -@@ -6498,7 +6485,12 @@ static int mvpp2_tx(struct sk_buff *skb, - txq_pcpu->count > 0) { - struct mvpp2_port_pcpu *port_pcpu = this_cpu_ptr(port->pcpu); - -- mvpp2_timer_set(port_pcpu); -+ if (!port_pcpu->timer_scheduled) { -+ port_pcpu->timer_scheduled = true; -+ hrtimer_start(&port_pcpu->tx_done_timer, -+ MVPP2_TXDONE_HRTIMER_PERIOD_NS, -+ HRTIMER_MODE_REL_PINNED_SOFT); -+ } - } - - return NETDEV_TX_OK; -@@ -6887,7 +6879,6 @@ static int mvpp2_stop(struct net_device - - hrtimer_cancel(&port_pcpu->tx_done_timer); - port_pcpu->timer_scheduled = false; -- tasklet_kill(&port_pcpu->tx_done_tasklet); - } - } - mvpp2_cleanup_rxqs(port); -@@ -7655,13 +7646,10 @@ static int mvpp2_port_probe(struct platf - port_pcpu = per_cpu_ptr(port->pcpu, cpu); - - hrtimer_init(&port_pcpu->tx_done_timer, CLOCK_MONOTONIC, -- HRTIMER_MODE_REL_PINNED); -+ HRTIMER_MODE_REL_PINNED_SOFT); - port_pcpu->tx_done_timer.function = mvpp2_hr_timer_cb; - port_pcpu->timer_scheduled = false; -- -- tasklet_init(&port_pcpu->tx_done_tasklet, -- mvpp2_tx_proc_cb, -- (unsigned long)dev); -+ port_pcpu->dev = dev; - } - } - diff --git a/debian/patches/features/all/rt/0036-tracing-Add-inter-event-blurb-to-HIST_TRIGGERS-confi.patch b/debian/patches/features/all/rt/0036-tracing-Add-inter-event-blurb-to-HIST_TRIGGERS-confi.patch deleted file mode 100644 index b5a3ae5e7..000000000 --- a/debian/patches/features/all/rt/0036-tracing-Add-inter-event-blurb-to-HIST_TRIGGERS-confi.patch +++ /dev/null @@ -1,30 +0,0 @@ -From: Tom Zanussi -Date: Mon, 15 Jan 2018 20:52:10 -0600 -Subject: [PATCH 36/37] tracing: Add inter-event blurb to HIST_TRIGGERS config - option -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -So that users know that inter-event tracing is supported as part of -the HIST_TRIGGERS option, include text to that effect in the help -text. - -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/trace/Kconfig | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - ---- a/kernel/trace/Kconfig -+++ b/kernel/trace/Kconfig -@@ -585,7 +585,10 @@ config HIST_TRIGGERS - event activity as an initial guide for further investigation - using more advanced tools. - -- See Documentation/trace/events.txt. -+ Inter-event tracing of quantities such as latencies is also -+ supported using hist triggers under this option. -+ -+ See Documentation/trace/histogram.txt. - If in doubt, say N. - - config MMIOTRACE_TEST diff --git a/debian/patches/features/all/rt/0036-tracing-Allow-whitespace-to-surround-hist-trigger-fi.patch b/debian/patches/features/all/rt/0036-tracing-Allow-whitespace-to-surround-hist-trigger-fi.patch index 4c21505c9..0dc4661bd 100644 --- a/debian/patches/features/all/rt/0036-tracing-Allow-whitespace-to-surround-hist-trigger-fi.patch +++ b/debian/patches/features/all/rt/0036-tracing-Allow-whitespace-to-surround-hist-trigger-fi.patch @@ -2,7 +2,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:52:02 -0600 Subject: [PATCH 36/48] tracing: Allow whitespace to surround hist trigger filter -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The existing code only allows for one space before and after the 'if' specifying the filter for a hist trigger. Add code to make that more diff --git a/debian/patches/features/all/rt/0037-selftests-ftrace-Add-inter-event-hist-triggers-testc.patch b/debian/patches/features/all/rt/0037-selftests-ftrace-Add-inter-event-hist-triggers-testc.patch deleted file mode 100644 index 592148972..000000000 --- a/debian/patches/features/all/rt/0037-selftests-ftrace-Add-inter-event-hist-triggers-testc.patch +++ /dev/null @@ -1,439 +0,0 @@ -From: Rajvi Jingar -Date: Mon, 15 Jan 2018 20:52:11 -0600 -Subject: [PATCH 37/37] selftests: ftrace: Add inter-event hist triggers - testcases -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - - This adds inter-event hist triggers testcases which covers following: - - create/remove synthetic event - - disable histogram for synthetic event - - extended error support - - field variable support - - histogram variables - - histogram trigger onmatch action - - histogram trigger onmax action - - histogram trigger onmatch-onmax action - - simple expression support - - combined histogram - - Here is the test result. - === Ftrace unit tests === - [1] event trigger - test extended error support [PASS] - [2] event trigger - test field variable support [PASS] - [3] event trigger - test inter-event combined histogram trigger [PASS] - [4] event trigger - test inter-event histogram trigger onmatch action [PASS] - [5] event trigger - test inter-event histogram trigger onmatch-onmax action [PASS] - [6] event trigger - test inter-event histogram trigger onmax action [PASS] - [7] event trigger - test synthetic event create remove [PASS] - -Signed-off-by: Rajvi Jingar -Signed-off-by: Tom Zanussi -Signed-off-by: Sebastian Andrzej Siewior ---- - tools/testing/selftests/ftrace/test.d/functions | 7 + - tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-extended-error-support.tc | 39 ++++++ - tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-field-variable-support.tc | 54 +++++++++ - tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc | 58 ++++++++++ - tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-action-hist.tc | 50 ++++++++ - tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-onmax-action-hist.tc | 50 ++++++++ - tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc | 48 ++++++++ - tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-createremove.tc | 54 +++++++++ - 8 files changed, 360 insertions(+) - create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-extended-error-support.tc - create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-field-variable-support.tc - create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc - create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-action-hist.tc - create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-onmax-action-hist.tc - create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc - create mode 100644 tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-createremove.tc - ---- a/tools/testing/selftests/ftrace/test.d/functions -+++ b/tools/testing/selftests/ftrace/test.d/functions -@@ -55,6 +55,13 @@ disable_events() { - echo 0 > events/enable - } - -+clear_synthetic_events() { # reset all current synthetic events -+ grep -v ^# synthetic_events | -+ while read line; do -+ echo "!$line" >> synthetic_events -+ done -+} -+ - initialize_ftrace() { # Reset ftrace to initial-state - # As the initial state, ftrace will be set to nop tracer, - # no events, no triggers, no filters, no function filters, ---- /dev/null -+++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-extended-error-support.tc -@@ -0,0 +1,39 @@ -+#!/bin/sh -+# description: event trigger - test extended error support -+ -+ -+do_reset() { -+ reset_trigger -+ echo > set_event -+ clear_trace -+} -+ -+fail() { #msg -+ do_reset -+ echo $1 -+ exit_fail -+} -+ -+if [ ! -f set_event ]; then -+ echo "event tracing is not supported" -+ exit_unsupported -+fi -+ -+if [ ! -f synthetic_events ]; then -+ echo "synthetic event is not supported" -+ exit_unsupported -+fi -+ -+reset_tracer -+do_reset -+ -+echo "Test extended error support" -+echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_wakeup/trigger -+echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' >> events/sched/sched_wakeup/trigger &>/dev/null -+if ! grep -q "ERROR:" events/sched/sched_wakeup/hist; then -+ fail "Failed to generate extended error in histogram" -+fi -+ -+do_reset -+ -+exit 0 ---- /dev/null -+++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-field-variable-support.tc -@@ -0,0 +1,54 @@ -+#!/bin/sh -+# description: event trigger - test field variable support -+ -+do_reset() { -+ reset_trigger -+ echo > set_event -+ clear_trace -+} -+ -+fail() { #msg -+ do_reset -+ echo $1 -+ exit_fail -+} -+ -+if [ ! -f set_event ]; then -+ echo "event tracing is not supported" -+ exit_unsupported -+fi -+ -+if [ ! -f synthetic_events ]; then -+ echo "synthetic event is not supported" -+ exit_unsupported -+fi -+ -+clear_synthetic_events -+reset_tracer -+do_reset -+ -+echo "Test field variable support" -+ -+echo 'wakeup_latency u64 lat; pid_t pid; int prio; char comm[16]' > synthetic_events -+echo 'hist:keys=comm:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_waking/trigger -+echo 'hist:keys=next_comm:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_waking).wakeup_latency($wakeup_lat,next_pid,sched.sched_waking.prio,next_comm) if next_comm=="ping"' > events/sched/sched_switch/trigger -+echo 'hist:keys=pid,prio,comm:vals=lat:sort=pid,prio' > events/synthetic/wakeup_latency/trigger -+ -+ping localhost -c 3 -+if ! grep -q "ping" events/synthetic/wakeup_latency/hist; then -+ fail "Failed to create inter-event histogram" -+fi -+ -+if ! grep -q "synthetic_prio=prio" events/sched/sched_waking/hist; then -+ fail "Failed to create histogram with field variable" -+fi -+ -+echo '!hist:keys=next_comm:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_waking).wakeup_latency($wakeup_lat,next_pid,sched.sched_waking.prio,next_comm) if next_comm=="ping"' >> events/sched/sched_switch/trigger -+ -+if grep -q "synthetic_prio=prio" events/sched/sched_waking/hist; then -+ fail "Failed to remove histogram with field variable" -+fi -+ -+do_reset -+ -+exit 0 ---- /dev/null -+++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-inter-event-combined-hist.tc -@@ -0,0 +1,58 @@ -+#!/bin/sh -+# description: event trigger - test inter-event combined histogram trigger -+ -+do_reset() { -+ reset_trigger -+ echo > set_event -+ clear_trace -+} -+ -+fail() { #msg -+ do_reset -+ echo $1 -+ exit_fail -+} -+ -+if [ ! -f set_event ]; then -+ echo "event tracing is not supported" -+ exit_unsupported -+fi -+ -+if [ ! -f synthetic_events ]; then -+ echo "synthetic event is not supported" -+ exit_unsupported -+fi -+ -+reset_tracer -+do_reset -+clear_synthetic_events -+ -+echo "Test create synthetic event" -+ -+echo 'waking_latency u64 lat pid_t pid' > synthetic_events -+if [ ! -d events/synthetic/waking_latency ]; then -+ fail "Failed to create waking_latency synthetic event" -+fi -+ -+echo "Test combined histogram" -+ -+echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_waking/trigger -+echo 'hist:keys=pid:waking_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_waking).waking_latency($waking_lat,pid) if comm=="ping"' > events/sched/sched_wakeup/trigger -+echo 'hist:keys=pid,lat:sort=pid,lat' > events/synthetic/waking_latency/trigger -+ -+echo 'wakeup_latency u64 lat pid_t pid' >> synthetic_events -+echo 'hist:keys=pid:ts1=common_timestamp.usecs if comm=="ping"' >> events/sched/sched_wakeup/trigger -+echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts1:onmatch(sched.sched_wakeup).wakeup_latency($wakeup_lat,next_pid) if next_comm=="ping"' > events/sched/sched_switch/trigger -+ -+echo 'waking+wakeup_latency u64 lat; pid_t pid' >> synthetic_events -+echo 'hist:keys=pid,lat:sort=pid,lat:ww_lat=$waking_lat+$wakeup_lat:onmatch(synthetic.wakeup_latency).waking+wakeup_latency($ww_lat,pid)' >> events/synthetic/wakeup_latency/trigger -+echo 'hist:keys=pid,lat:sort=pid,lat' >> events/synthetic/waking+wakeup_latency/trigger -+ -+ping localhost -c 3 -+if ! grep -q "pid:" events/synthetic/waking+wakeup_latency/hist; then -+ fail "Failed to create combined histogram" -+fi -+ -+do_reset -+ -+exit 0 ---- /dev/null -+++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-action-hist.tc -@@ -0,0 +1,50 @@ -+#!/bin/sh -+# description: event trigger - test inter-event histogram trigger onmatch action -+ -+do_reset() { -+ reset_trigger -+ echo > set_event -+ clear_trace -+} -+ -+fail() { #msg -+ do_reset -+ echo $1 -+ exit_fail -+} -+ -+if [ ! -f set_event ]; then -+ echo "event tracing is not supported" -+ exit_unsupported -+fi -+ -+if [ ! -f synthetic_events ]; then -+ echo "synthetic event is not supported" -+ exit_unsupported -+fi -+ -+clear_synthetic_events -+reset_tracer -+do_reset -+ -+echo "Test create synthetic event" -+ -+echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events -+if [ ! -d events/synthetic/wakeup_latency ]; then -+ fail "Failed to create wakeup_latency synthetic event" -+fi -+ -+echo "Test create histogram for synthetic event" -+echo "Test histogram variables,simple expression support and onmatch action" -+ -+echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_wakeup/trigger -+echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_wakeup).wakeup_latency($wakeup_lat,next_pid,next_comm) if next_comm=="ping"' > events/sched/sched_switch/trigger -+echo 'hist:keys=comm,pid,lat:wakeup_lat=lat:sort=lat' > events/synthetic/wakeup_latency/trigger -+ping localhost -c 5 -+if ! grep -q "ping" events/synthetic/wakeup_latency/hist; then -+ fail "Failed to create onmatch action inter-event histogram" -+fi -+ -+do_reset -+ -+exit 0 ---- /dev/null -+++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmatch-onmax-action-hist.tc -@@ -0,0 +1,50 @@ -+#!/bin/sh -+# description: event trigger - test inter-event histogram trigger onmatch-onmax action -+ -+do_reset() { -+ reset_trigger -+ echo > set_event -+ clear_trace -+} -+ -+fail() { #msg -+ do_reset -+ echo $1 -+ exit_fail -+} -+ -+if [ ! -f set_event ]; then -+ echo "event tracing is not supported" -+ exit_unsupported -+fi -+ -+if [ ! -f synthetic_events ]; then -+ echo "synthetic event is not supported" -+ exit_unsupported -+fi -+ -+clear_synthetic_events -+reset_tracer -+do_reset -+ -+echo "Test create synthetic event" -+ -+echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events -+if [ ! -d events/synthetic/wakeup_latency ]; then -+ fail "Failed to create wakeup_latency synthetic event" -+fi -+ -+echo "Test create histogram for synthetic event" -+echo "Test histogram variables,simple expression support and onmatch-onmax action" -+ -+echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' > events/sched/sched_wakeup/trigger -+echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmatch(sched.sched_wakeup).wakeup_latency($wakeup_lat,next_pid,next_comm):onmax($wakeup_lat).save(next_comm,prev_pid,prev_prio,prev_comm) if next_comm=="ping"' >> events/sched/sched_switch/trigger -+echo 'hist:keys=comm,pid,lat:wakeup_lat=lat:sort=lat' > events/synthetic/wakeup_latency/trigger -+ping localhost -c 5 -+if [ ! grep -q "ping" events/synthetic/wakeup_latency/hist -o ! grep -q "max:" events/sched/sched_switch/hist]; then -+ fail "Failed to create onmatch-onmax action inter-event histogram" -+fi -+ -+do_reset -+ -+exit 0 ---- /dev/null -+++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onmax-action-hist.tc -@@ -0,0 +1,48 @@ -+#!/bin/sh -+# description: event trigger - test inter-event histogram trigger onmax action -+ -+do_reset() { -+ reset_trigger -+ echo > set_event -+ clear_trace -+} -+ -+fail() { #msg -+ do_reset -+ echo $1 -+ exit_fail -+} -+ -+if [ ! -f set_event ]; then -+ echo "event tracing is not supported" -+ exit_unsupported -+fi -+ -+if [ ! -f synthetic_events ]; then -+ echo "synthetic event is not supported" -+ exit_unsupported -+fi -+ -+clear_synthetic_events -+reset_tracer -+do_reset -+ -+echo "Test create synthetic event" -+ -+echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events -+if [ ! -d events/synthetic/wakeup_latency ]; then -+ fail "Failed to create wakeup_latency synthetic event" -+fi -+ -+echo "Test onmax action" -+ -+echo 'hist:keys=pid:ts0=common_timestamp.usecs if comm=="ping"' >> events/sched/sched_waking/trigger -+echo 'hist:keys=next_pid:wakeup_lat=common_timestamp.usecs-$ts0:onmax($wakeup_lat).save(next_comm,prev_pid,prev_prio,prev_comm) if next_comm=="ping"' >> events/sched/sched_switch/trigger -+ping localhost -c 3 -+if ! grep -q "max:" events/sched/sched_switch/hist; then -+ fail "Failed to create onmax action inter-event histogram" -+fi -+ -+do_reset -+ -+exit 0 ---- /dev/null -+++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-createremove.tc -@@ -0,0 +1,54 @@ -+#!/bin/sh -+# description: event trigger - test synthetic event create remove -+do_reset() { -+ reset_trigger -+ echo > set_event -+ clear_trace -+} -+ -+fail() { #msg -+ do_reset -+ echo $1 -+ exit_fail -+} -+ -+if [ ! -f set_event ]; then -+ echo "event tracing is not supported" -+ exit_unsupported -+fi -+ -+if [ ! -f synthetic_events ]; then -+ echo "synthetic event is not supported" -+ exit_unsupported -+fi -+ -+clear_synthetic_events -+reset_tracer -+do_reset -+ -+echo "Test create synthetic event" -+ -+echo 'wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events -+if [ ! -d events/synthetic/wakeup_latency ]; then -+ fail "Failed to create wakeup_latency synthetic event" -+fi -+ -+reset_trigger -+ -+echo "Test create synthetic event with an error" -+echo 'wakeup_latency u64 lat pid_t pid char' > synthetic_events > /dev/null -+if [ -d events/synthetic/wakeup_latency ]; then -+ fail "Created wakeup_latency synthetic event with an invalid format" -+fi -+ -+reset_trigger -+ -+echo "Test remove synthetic event" -+echo '!wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events -+if [ -d events/synthetic/wakeup_latency ]; then -+ fail "Failed to delete wakeup_latency synthetic event" -+fi -+ -+do_reset -+ -+exit 0 diff --git a/debian/patches/features/all/rt/0037-tracing-Add-cpu-field-for-hist-triggers.patch b/debian/patches/features/all/rt/0037-tracing-Add-cpu-field-for-hist-triggers.patch index b2c4db092..c85261dd9 100644 --- a/debian/patches/features/all/rt/0037-tracing-Add-cpu-field-for-hist-triggers.patch +++ b/debian/patches/features/all/rt/0037-tracing-Add-cpu-field-for-hist-triggers.patch @@ -1,7 +1,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:52:03 -0600 Subject: [PATCH 37/48] tracing: Add cpu field for hist triggers -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz A common key to use in a histogram is the cpuid - add a new cpu 'synthetic' field named 'cpu' for that purpose. diff --git a/debian/patches/features/all/rt/0038-tracing-Add-hist-trigger-support-for-variable-refere.patch b/debian/patches/features/all/rt/0038-tracing-Add-hist-trigger-support-for-variable-refere.patch index 48c94d9bf..daba4fe7e 100644 --- a/debian/patches/features/all/rt/0038-tracing-Add-hist-trigger-support-for-variable-refere.patch +++ b/debian/patches/features/all/rt/0038-tracing-Add-hist-trigger-support-for-variable-refere.patch @@ -2,7 +2,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:52:04 -0600 Subject: [PATCH 38/48] tracing: Add hist trigger support for variable reference aliases -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Add support for alias=$somevar where alias can be used as onmatch.xxx($alias). diff --git a/debian/patches/features/all/rt/0039-tracing-Add-last-error-error-facility-for-hist-trigg.patch b/debian/patches/features/all/rt/0039-tracing-Add-last-error-error-facility-for-hist-trigg.patch index 800eb613e..1c95ca499 100644 --- a/debian/patches/features/all/rt/0039-tracing-Add-last-error-error-facility-for-hist-trigg.patch +++ b/debian/patches/features/all/rt/0039-tracing-Add-last-error-error-facility-for-hist-trigg.patch @@ -2,7 +2,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:52:05 -0600 Subject: [PATCH 39/48] tracing: Add 'last error' error facility for hist triggers -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz With the addition of variables and actions, it's become necessary to provide more detailed error information to users about syntax errors. diff --git a/debian/patches/features/all/rt/0040-tracing-Add-inter-event-hist-trigger-Documentation.patch b/debian/patches/features/all/rt/0040-tracing-Add-inter-event-hist-trigger-Documentation.patch index 1ffc09b9c..362cb9490 100644 --- a/debian/patches/features/all/rt/0040-tracing-Add-inter-event-hist-trigger-Documentation.patch +++ b/debian/patches/features/all/rt/0040-tracing-Add-inter-event-hist-trigger-Documentation.patch @@ -1,7 +1,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:52:06 -0600 Subject: [PATCH 40/48] tracing: Add inter-event hist trigger Documentation -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Add background and details on inter-event hist triggers, including hist variables, synthetic events, and actions. diff --git a/debian/patches/features/all/rt/0041-tracing-Make-tracing_set_clock-non-static.patch b/debian/patches/features/all/rt/0041-tracing-Make-tracing_set_clock-non-static.patch index 51193f950..dcb598864 100644 --- a/debian/patches/features/all/rt/0041-tracing-Make-tracing_set_clock-non-static.patch +++ b/debian/patches/features/all/rt/0041-tracing-Make-tracing_set_clock-non-static.patch @@ -1,7 +1,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:52:07 -0600 Subject: [PATCH 41/48] tracing: Make tracing_set_clock() non-static -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Allow tracing code outside of trace.c to access tracing_set_clock(). diff --git a/debian/patches/features/all/rt/0042-tracing-Add-a-clock-attribute-for-hist-triggers.patch b/debian/patches/features/all/rt/0042-tracing-Add-a-clock-attribute-for-hist-triggers.patch index 9325cfd5f..f863efe98 100644 --- a/debian/patches/features/all/rt/0042-tracing-Add-a-clock-attribute-for-hist-triggers.patch +++ b/debian/patches/features/all/rt/0042-tracing-Add-a-clock-attribute-for-hist-triggers.patch @@ -1,7 +1,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:52:08 -0600 Subject: [PATCH 42/48] tracing: Add a clock attribute for hist triggers -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The default clock if timestamps are used in a histogram is "global". If timestamps aren't used, the clock is irrelevant. diff --git a/debian/patches/features/all/rt/0045-ring-buffer-Add-nesting-for-adding-events-within-eve.patch b/debian/patches/features/all/rt/0045-ring-buffer-Add-nesting-for-adding-events-within-eve.patch index ac86523c6..e854f8065 100644 --- a/debian/patches/features/all/rt/0045-ring-buffer-Add-nesting-for-adding-events-within-eve.patch +++ b/debian/patches/features/all/rt/0045-ring-buffer-Add-nesting-for-adding-events-within-eve.patch @@ -2,7 +2,6 @@ From: "Steven Rostedt (VMware)" Date: Wed, 7 Feb 2018 17:26:32 -0500 Subject: [PATCH 45/48] ring-buffer: Add nesting for adding events within events -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The ring-buffer code has recusion protection in case tracing ends up tracing itself, the ring-buffer will detect that it was called at the same context diff --git a/debian/patches/features/all/rt/0046-tracing-Use-the-ring-buffer-nesting-to-allow-synthet.patch b/debian/patches/features/all/rt/0046-tracing-Use-the-ring-buffer-nesting-to-allow-synthet.patch index 2b8d35f90..006fb2afb 100644 --- a/debian/patches/features/all/rt/0046-tracing-Use-the-ring-buffer-nesting-to-allow-synthet.patch +++ b/debian/patches/features/all/rt/0046-tracing-Use-the-ring-buffer-nesting-to-allow-synthet.patch @@ -2,7 +2,6 @@ From: "Steven Rostedt (VMware)" Date: Wed, 7 Feb 2018 17:29:46 -0500 Subject: [PATCH 46/48] tracing: Use the ring-buffer nesting to allow synthetic events to be traced -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Synthetic events can be done within the recording of other events. Notify the ring buffer via ring_buffer_nest_start() and ring_buffer_nest_end() that diff --git a/debian/patches/features/all/rt/0047-tracing-Add-inter-event-blurb-to-HIST_TRIGGERS-confi.patch b/debian/patches/features/all/rt/0047-tracing-Add-inter-event-blurb-to-HIST_TRIGGERS-confi.patch index 77e267208..43595f0f0 100644 --- a/debian/patches/features/all/rt/0047-tracing-Add-inter-event-blurb-to-HIST_TRIGGERS-confi.patch +++ b/debian/patches/features/all/rt/0047-tracing-Add-inter-event-blurb-to-HIST_TRIGGERS-confi.patch @@ -2,7 +2,6 @@ From: Tom Zanussi Date: Mon, 15 Jan 2018 20:52:10 -0600 Subject: [PATCH 47/48] tracing: Add inter-event blurb to HIST_TRIGGERS config option -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz So that users know that inter-event tracing is supported as part of the HIST_TRIGGERS option, include text to that effect in the help diff --git a/debian/patches/features/all/rt/0048-selftests-ftrace-Add-inter-event-hist-triggers-testc.patch b/debian/patches/features/all/rt/0048-selftests-ftrace-Add-inter-event-hist-triggers-testc.patch index 941999f5f..e6460cf88 100644 --- a/debian/patches/features/all/rt/0048-selftests-ftrace-Add-inter-event-hist-triggers-testc.patch +++ b/debian/patches/features/all/rt/0048-selftests-ftrace-Add-inter-event-hist-triggers-testc.patch @@ -2,7 +2,6 @@ From: Rajvi Jingar Date: Mon, 15 Jan 2018 20:52:11 -0600 Subject: [PATCH 48/48] selftests: ftrace: Add inter-event hist triggers testcases -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz This adds inter-event hist triggers testcases which covers following: - create/remove synthetic event diff --git a/debian/patches/features/all/rt/ACPICA-Convert-acpi_gbl_hardware-lock-back-to-an-acp.patch b/debian/patches/features/all/rt/ACPICA-Convert-acpi_gbl_hardware-lock-back-to-an-acp.patch index 2d7e1e54f..45ea45870 100644 --- a/debian/patches/features/all/rt/ACPICA-Convert-acpi_gbl_hardware-lock-back-to-an-acp.patch +++ b/debian/patches/features/all/rt/ACPICA-Convert-acpi_gbl_hardware-lock-back-to-an-acp.patch @@ -5,7 +5,6 @@ Subject: [PATCH] ACPICA: Convert acpi_gbl_hardware lock back to an MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz We hit the following bug with -RT: diff --git a/debian/patches/features/all/rt/ACPICA-provide-abstraction-for-raw_spinlock_t.patch b/debian/patches/features/all/rt/ACPICA-provide-abstraction-for-raw_spinlock_t.patch index f6455dc00..1f2f1c4d3 100644 --- a/debian/patches/features/all/rt/ACPICA-provide-abstraction-for-raw_spinlock_t.patch +++ b/debian/patches/features/all/rt/ACPICA-provide-abstraction-for-raw_spinlock_t.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 25 Apr 2018 15:19:42 +0200 Subject: [PATCH] ACPICA: provide abstraction for raw_spinlock_t -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Provide a new lock type acpi_raw_spinlock which is implemented as raw_spinlock_t on Linux. This type should be used in code which covers diff --git a/debian/patches/features/all/rt/ALSA-pcm-Hide-local_irq_disable-enable-and-local_irq.patch b/debian/patches/features/all/rt/ALSA-pcm-Hide-local_irq_disable-enable-and-local_irq.patch index 975495c03..e42427fac 100644 --- a/debian/patches/features/all/rt/ALSA-pcm-Hide-local_irq_disable-enable-and-local_irq.patch +++ b/debian/patches/features/all/rt/ALSA-pcm-Hide-local_irq_disable-enable-and-local_irq.patch @@ -2,7 +2,6 @@ From: Anna-Maria Gleixner Date: Thu, 29 Mar 2018 17:09:27 +0200 Subject: [PATCH] ALSA: pcm: Hide local_irq_disable/enable() and local_irqsave/restore() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The snd_pcm_stream_lock_irq*() functions decouple disabling interrupts from the actual locking process. This does not work as expected if the diff --git a/debian/patches/features/all/rt/ARM-enable-irq-in-translation-section-permission-fau.patch b/debian/patches/features/all/rt/ARM-enable-irq-in-translation-section-permission-fau.patch index 27c226e94..98d9e901e 100644 --- a/debian/patches/features/all/rt/ARM-enable-irq-in-translation-section-permission-fau.patch +++ b/debian/patches/features/all/rt/ARM-enable-irq-in-translation-section-permission-fau.patch @@ -1,7 +1,6 @@ From: "Yadi.hu" Date: Wed, 10 Dec 2014 10:32:09 +0800 Subject: ARM: enable irq in translation/section permission fault handlers -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Probably happens on all ARM, with CONFIG_PREEMPT_RT_FULL diff --git a/debian/patches/features/all/rt/Bluetooth-avoid-recursive-locking-in-hci_send_to_cha.patch b/debian/patches/features/all/rt/Bluetooth-avoid-recursive-locking-in-hci_send_to_cha.patch deleted file mode 100644 index 83f760027..000000000 --- a/debian/patches/features/all/rt/Bluetooth-avoid-recursive-locking-in-hci_send_to_cha.patch +++ /dev/null @@ -1,71 +0,0 @@ -From: Sebastian Andrzej Siewior -Date: Thu, 21 Sep 2017 15:35:57 +0200 -Subject: Bluetooth: avoid recursive locking in - hci_send_to_channel() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Mart reported a deadlock in -RT in the call path: - hci_send_monitor_ctrl_event() -> hci_send_to_channel() - -because both functions acquire the same read lock hci_sk_list.lock. This -is also a mainline issue because the qrwlock implementation is writer -fair (the traditional rwlock implementation is reader biased). - -To avoid the deadlock there is now __hci_send_to_channel() which expects -the readlock to be held. - -Cc: Marcel Holtmann -Cc: Johan Hedberg -Cc: stable-rt@vger.kernel.org -Fixes: 38ceaa00d02d ("Bluetooth: Add support for sending MGMT commands and events to monitor") -Reported-by: Mart van de Wege -Signed-off-by: Sebastian Andrzej Siewior ---- - net/bluetooth/hci_sock.c | 17 +++++++++++------ - 1 file changed, 11 insertions(+), 6 deletions(-) - ---- a/net/bluetooth/hci_sock.c -+++ b/net/bluetooth/hci_sock.c -@@ -251,15 +251,13 @@ void hci_send_to_sock(struct hci_dev *hd - } - - /* Send frame to sockets with specific channel */ --void hci_send_to_channel(unsigned short channel, struct sk_buff *skb, -- int flag, struct sock *skip_sk) -+static void __hci_send_to_channel(unsigned short channel, struct sk_buff *skb, -+ int flag, struct sock *skip_sk) - { - struct sock *sk; - - BT_DBG("channel %u len %d", channel, skb->len); - -- read_lock(&hci_sk_list.lock); -- - sk_for_each(sk, &hci_sk_list.head) { - struct sk_buff *nskb; - -@@ -285,6 +283,13 @@ void hci_send_to_channel(unsigned short - kfree_skb(nskb); - } - -+} -+ -+void hci_send_to_channel(unsigned short channel, struct sk_buff *skb, -+ int flag, struct sock *skip_sk) -+{ -+ read_lock(&hci_sk_list.lock); -+ __hci_send_to_channel(channel, skb, flag, skip_sk); - read_unlock(&hci_sk_list.lock); - } - -@@ -388,8 +393,8 @@ void hci_send_monitor_ctrl_event(struct - hdr->index = index; - hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE); - -- hci_send_to_channel(HCI_CHANNEL_MONITOR, skb, -- HCI_SOCK_TRUSTED, NULL); -+ __hci_send_to_channel(HCI_CHANNEL_MONITOR, skb, -+ HCI_SOCK_TRUSTED, NULL); - kfree_skb(skb); - } - diff --git a/debian/patches/features/all/rt/HACK-printk-drop-the-logbuf_lock-more-often.patch b/debian/patches/features/all/rt/HACK-printk-drop-the-logbuf_lock-more-often.patch index 3d3a93133..ae918a775 100644 --- a/debian/patches/features/all/rt/HACK-printk-drop-the-logbuf_lock-more-often.patch +++ b/debian/patches/features/all/rt/HACK-printk-drop-the-logbuf_lock-more-often.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 21 Mar 2013 19:01:05 +0100 Subject: printk: Drop the logbuf_lock more often -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The lock is hold with irgs off. The latency drops 500us+ on my arm bugs with a "full" buffer after executing "dmesg" on the shell. diff --git a/debian/patches/features/all/rt/IB-ipoib-replace-local_irq_disable-with-proper-locki.patch b/debian/patches/features/all/rt/IB-ipoib-replace-local_irq_disable-with-proper-locki.patch index 7ba6ba016..9962e1db0 100644 --- a/debian/patches/features/all/rt/IB-ipoib-replace-local_irq_disable-with-proper-locki.patch +++ b/debian/patches/features/all/rt/IB-ipoib-replace-local_irq_disable-with-proper-locki.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 11 Apr 2018 13:34:26 +0200 Subject: [PATCH] IB/ipoib: replace local_irq_disable() with proper locking -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Commit 78bfe0b5b67f ("IPoIB: Take dev->xmit_lock around mc_list accesses") introduced xmit_lock lock in ipoib_mcast_restart_task() and commit diff --git a/debian/patches/features/all/rt/KVM-arm-arm64-downgrade-preempt_disable-d-region-to-.patch b/debian/patches/features/all/rt/KVM-arm-arm64-downgrade-preempt_disable-d-region-to-.patch index dc53cfab6..26e9f224c 100644 --- a/debian/patches/features/all/rt/KVM-arm-arm64-downgrade-preempt_disable-d-region-to-.patch +++ b/debian/patches/features/all/rt/KVM-arm-arm64-downgrade-preempt_disable-d-region-to-.patch @@ -1,7 +1,6 @@ From: Josh Cartwright Date: Thu, 11 Feb 2016 11:54:01 -0600 Subject: KVM: arm/arm64: downgrade preempt_disable()d region to migrate_disable() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz kvm_arch_vcpu_ioctl_run() disables the use of preemption when updating the vgic and timer states to prevent the calling task from migrating to diff --git a/debian/patches/features/all/rt/NFSv4-replace-seqcount_t-with-a-seqlock_t.patch b/debian/patches/features/all/rt/NFSv4-replace-seqcount_t-with-a-seqlock_t.patch index 05c0df248..3db9a97e9 100644 --- a/debian/patches/features/all/rt/NFSv4-replace-seqcount_t-with-a-seqlock_t.patch +++ b/debian/patches/features/all/rt/NFSv4-replace-seqcount_t-with-a-seqlock_t.patch @@ -5,7 +5,6 @@ Cc: Anna Schumaker , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de Subject: NFSv4: replace seqcount_t with a seqlock_t -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The raw_write_seqcount_begin() in nfs4_reclaim_open_state() bugs me because it maps to preempt_disable() in -RT which I can't have at this diff --git a/debian/patches/features/all/rt/RCU-skip-the-schedule-in-RCU-section-warning-on-UP-t.patch b/debian/patches/features/all/rt/RCU-skip-the-schedule-in-RCU-section-warning-on-UP-t.patch index c864c72c1..0eefee6fb 100644 --- a/debian/patches/features/all/rt/RCU-skip-the-schedule-in-RCU-section-warning-on-UP-t.patch +++ b/debian/patches/features/all/rt/RCU-skip-the-schedule-in-RCU-section-warning-on-UP-t.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Fri, 16 Feb 2018 11:45:13 +0100 Subject: [PATCH] RCU: skip the "schedule() in RCU section" warning on UP, too -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz In "RCU: we need to skip that warning but only on sleeping locks" we skipped a warning on SMP systems in case we schedule out in a RCU @@ -69,7 +68,7 @@ Signed-off-by: Sebastian Andrzej Siewior WARN_ON_ONCE(!preempt && t->rcu_read_lock_nesting > 0 && !mg_counter); --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -7278,4 +7278,49 @@ void migrate_enable(void) +@@ -7283,4 +7283,49 @@ void migrate_enable(void) preempt_enable(); } EXPORT_SYMBOL(migrate_enable); diff --git a/debian/patches/features/all/rt/RCU-we-need-to-skip-that-warning-but-only-on-sleepin.patch b/debian/patches/features/all/rt/RCU-we-need-to-skip-that-warning-but-only-on-sleepin.patch index 042640444..8a24f92e7 100644 --- a/debian/patches/features/all/rt/RCU-we-need-to-skip-that-warning-but-only-on-sleepin.patch +++ b/debian/patches/features/all/rt/RCU-we-need-to-skip-that-warning-but-only-on-sleepin.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 21 Sep 2017 14:25:13 +0200 Subject: [PATCH] RCU: we need to skip that warning but only on sleeping locks -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz This check is okay for upstream. On RT we trigger this while blocking on sleeping lock. In this case, it is okay to schedule() within a RCU diff --git a/debian/patches/features/all/rt/Revert-fs-jbd2-pull-your-plug-when-waiting-for-space.patch b/debian/patches/features/all/rt/Revert-fs-jbd2-pull-your-plug-when-waiting-for-space.patch deleted file mode 100644 index 62008be3f..000000000 --- a/debian/patches/features/all/rt/Revert-fs-jbd2-pull-your-plug-when-waiting-for-space.patch +++ /dev/null @@ -1,26 +0,0 @@ -From: Sebastian Andrzej Siewior -Date: Thu, 23 Nov 2017 17:51:51 +0100 -Subject: [PATCH] Revert "fs: jbd2: pull your plug when waiting for space" -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -This reverts commit "fs: jbd2: pull your plug when waiting for space". -This was a duct-tape fix which shouldn't be needed since commit -"locking/rt-mutex: fix deadlock in device mapper / block-IO". - -Cc: stable-rt@vger.kernel.org -Signed-off-by: Sebastian Andrzej Siewior ---- - fs/jbd2/checkpoint.c | 2 -- - 1 file changed, 2 deletions(-) - ---- a/fs/jbd2/checkpoint.c -+++ b/fs/jbd2/checkpoint.c -@@ -116,8 +116,6 @@ void __jbd2_log_wait_for_space(journal_t - nblocks = jbd2_space_needed(journal); - while (jbd2_log_space_left(journal) < nblocks) { - write_unlock(&journal->j_state_lock); -- if (current->plug) -- io_schedule(); - mutex_lock(&journal->j_checkpoint_mutex); - - /* diff --git a/debian/patches/features/all/rt/Revert-memcontrol-Prevent-scheduling-while-atomic-in.patch b/debian/patches/features/all/rt/Revert-memcontrol-Prevent-scheduling-while-atomic-in.patch deleted file mode 100644 index ac89c5236..000000000 --- a/debian/patches/features/all/rt/Revert-memcontrol-Prevent-scheduling-while-atomic-in.patch +++ /dev/null @@ -1,101 +0,0 @@ -From: "Steven Rostedt (VMware)" -Date: Wed, 22 Nov 2017 07:31:19 -0500 -Subject: [PATCH] Revert "memcontrol: Prevent scheduling while atomic in cgroup - code" -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The commit "memcontrol: Prevent scheduling while atomic in cgroup code" -fixed this issue: - - refill_stock() - get_cpu_var() - drain_stock() - res_counter_uncharge() - res_counter_uncharge_until() - spin_lock() <== boom - -But commit 3e32cb2e0a12b ("mm: memcontrol: lockless page counters") replaced -the calls to res_counter_uncharge() in drain_stock() to the lockless -function page_counter_uncharge(). There is no more spin lock there and no -more reason to have that local lock. - -Cc: -Reported-by: Haiyang HY1 Tan -Signed-off-by: Steven Rostedt (VMware) -[bigeasy: That upstream commit appeared in v3.19 and the patch in - question in v3.18.7-rt2 and v3.18 seems still to be maintained. So I - guess that v3.18 would need the locallocks that we are about to remove - here. I am not sure if any earlier versions have the patch - backported. - The stable tag here is because Haiyang reported (and debugged) a crash - in 4.4-RT with this patch applied (which has get_cpu_light() instead - the locallocks it gained in v4.9-RT). - https://lkml.kernel.org/r/05AA4EC5C6EC1D48BE2CDCFF3AE0B8A637F78A15@CNMAILEX04.lenovo.com -] -Signed-off-by: Sebastian Andrzej Siewior ---- - mm/memcontrol.c | 13 ++++++------- - 1 file changed, 6 insertions(+), 7 deletions(-) - ---- a/mm/memcontrol.c -+++ b/mm/memcontrol.c -@@ -1723,7 +1723,6 @@ struct memcg_stock_pcp { - #define FLUSHING_CACHED_CHARGE 0 - }; - static DEFINE_PER_CPU(struct memcg_stock_pcp, memcg_stock); --static DEFINE_LOCAL_IRQ_LOCK(memcg_stock_ll); - static DEFINE_MUTEX(percpu_charge_mutex); - - /** -@@ -1746,7 +1745,7 @@ static bool consume_stock(struct mem_cgr - if (nr_pages > CHARGE_BATCH) - return ret; - -- local_lock_irqsave(memcg_stock_ll, flags); -+ local_irq_save(flags); - - stock = this_cpu_ptr(&memcg_stock); - if (memcg == stock->cached && stock->nr_pages >= nr_pages) { -@@ -1754,7 +1753,7 @@ static bool consume_stock(struct mem_cgr - ret = true; - } - -- local_unlock_irqrestore(memcg_stock_ll, flags); -+ local_irq_restore(flags); - - return ret; - } -@@ -1785,13 +1784,13 @@ static void drain_local_stock(struct wor - * The only protection from memory hotplug vs. drain_stock races is - * that we always operate on local CPU stock here with IRQ disabled - */ -- local_lock_irqsave(memcg_stock_ll, flags); -+ local_irq_save(flags); - - stock = this_cpu_ptr(&memcg_stock); - drain_stock(stock); - clear_bit(FLUSHING_CACHED_CHARGE, &stock->flags); - -- local_unlock_irqrestore(memcg_stock_ll, flags); -+ local_irq_restore(flags); - } - - /* -@@ -1803,7 +1802,7 @@ static void refill_stock(struct mem_cgro - struct memcg_stock_pcp *stock; - unsigned long flags; - -- local_lock_irqsave(memcg_stock_ll, flags); -+ local_irq_save(flags); - - stock = this_cpu_ptr(&memcg_stock); - if (stock->cached != memcg) { /* reset if necessary */ -@@ -1815,7 +1814,7 @@ static void refill_stock(struct mem_cgro - if (stock->nr_pages > CHARGE_BATCH) - drain_stock(stock); - -- local_unlock_irqrestore(memcg_stock_ll, flags); -+ local_irq_restore(flags); - } - - /* diff --git a/debian/patches/features/all/rt/Revert-mm-vmstat.c-fix-vmstat_update-preemption-BUG.patch b/debian/patches/features/all/rt/Revert-mm-vmstat.c-fix-vmstat_update-preemption-BUG.patch index 0a56d894e..a8d5a754f 100644 --- a/debian/patches/features/all/rt/Revert-mm-vmstat.c-fix-vmstat_update-preemption-BUG.patch +++ b/debian/patches/features/all/rt/Revert-mm-vmstat.c-fix-vmstat_update-preemption-BUG.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 11 Apr 2018 11:27:44 +0200 Subject: [PATCH] Revert mm/vmstat.c: fix vmstat_update() preemption BUG -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz This patch reverts commit c7f26ccfb2c3 ("mm/vmstat.c: fix vmstat_update() preemption BUG"). diff --git a/debian/patches/features/all/rt/SCSI-libsas-remove-irq-save-in-sas_ata_qc_issue.patch b/debian/patches/features/all/rt/SCSI-libsas-remove-irq-save-in-sas_ata_qc_issue.patch index 67577b410..f35270865 100644 --- a/debian/patches/features/all/rt/SCSI-libsas-remove-irq-save-in-sas_ata_qc_issue.patch +++ b/debian/patches/features/all/rt/SCSI-libsas-remove-irq-save-in-sas_ata_qc_issue.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 12 Apr 2018 09:16:22 +0200 Subject: [PATCH] [SCSI] libsas: remove irq save in sas_ata_qc_issue() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Since commit 312d3e56119a ("[SCSI] libsas: remove ata_port.lock management duties from lldds") the sas_ata_qc_issue() function unlocks diff --git a/debian/patches/features/all/rt/SCSI-qla2xxx-remove-irq-save-in-qla2x00_poll.patch b/debian/patches/features/all/rt/SCSI-qla2xxx-remove-irq-save-in-qla2x00_poll.patch index e4bda5e7c..4d9aa8f54 100644 --- a/debian/patches/features/all/rt/SCSI-qla2xxx-remove-irq-save-in-qla2x00_poll.patch +++ b/debian/patches/features/all/rt/SCSI-qla2xxx-remove-irq-save-in-qla2x00_poll.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 12 Apr 2018 09:55:25 +0200 Subject: [PATCH] [SCSI] qla2xxx: remove irq save in qla2x00_poll() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz In commit d2ba5675d899 ("[SCSI] qla2xxx: Disable local-interrupts while polling for RISC status.") added a local_irq_disable() before invoking diff --git a/debian/patches/features/all/rt/acpi-rt-Convert-acpi_gbl_hardware-lock-back-to-a-raw.patch b/debian/patches/features/all/rt/acpi-rt-Convert-acpi_gbl_hardware-lock-back-to-a-raw.patch deleted file mode 100644 index 0490c4c8c..000000000 --- a/debian/patches/features/all/rt/acpi-rt-Convert-acpi_gbl_hardware-lock-back-to-a-raw.patch +++ /dev/null @@ -1,174 +0,0 @@ -From: Steven Rostedt -Date: Wed, 13 Feb 2013 09:26:05 -0500 -Subject: acpi/rt: Convert acpi_gbl_hardware lock back to a raw_spinlock_t -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -We hit the following bug with 3.6-rt: - -[ 5.898990] BUG: scheduling while atomic: swapper/3/0/0x00000002 -[ 5.898991] no locks held by swapper/3/0. -[ 5.898993] Modules linked in: -[ 5.898996] Pid: 0, comm: swapper/3 Not tainted 3.6.11-rt28.19.el6rt.x86_64.debug #1 -[ 5.898997] Call Trace: -[ 5.899011] [] __schedule_bug+0x67/0x90 -[ 5.899028] [] __schedule+0x793/0x7a0 -[ 5.899032] [] ? debug_rt_mutex_print_deadlock+0x50/0x200 -[ 5.899034] [] schedule+0x29/0x70 -[ 5.899036] BUG: scheduling while atomic: swapper/7/0/0x00000002 -[ 5.899037] no locks held by swapper/7/0. -[ 5.899039] [] rt_spin_lock_slowlock+0xe5/0x2f0 -[ 5.899040] Modules linked in: -[ 5.899041] -[ 5.899045] [] ? _raw_spin_unlock_irqrestore+0x38/0x90 -[ 5.899046] Pid: 0, comm: swapper/7 Not tainted 3.6.11-rt28.19.el6rt.x86_64.debug #1 -[ 5.899047] Call Trace: -[ 5.899049] [] rt_spin_lock+0x16/0x40 -[ 5.899052] [] __schedule_bug+0x67/0x90 -[ 5.899054] [] ? notifier_call_chain+0x80/0x80 -[ 5.899056] [] __schedule+0x793/0x7a0 -[ 5.899059] [] acpi_os_acquire_lock+0x1f/0x23 -[ 5.899062] [] ? debug_rt_mutex_print_deadlock+0x50/0x200 -[ 5.899068] [] acpi_write_bit_register+0x33/0xb0 -[ 5.899071] [] schedule+0x29/0x70 -[ 5.899072] [] ? acpi_read_bit_register+0x33/0x51 -[ 5.899074] [] rt_spin_lock_slowlock+0xe5/0x2f0 -[ 5.899077] [] acpi_idle_enter_bm+0x8a/0x28e -[ 5.899079] [] ? _raw_spin_unlock_irqrestore+0x38/0x90 -[ 5.899081] [] ? this_cpu_load+0x1a/0x30 -[ 5.899083] [] rt_spin_lock+0x16/0x40 -[ 5.899087] [] cpuidle_enter+0x19/0x20 -[ 5.899088] [] ? notifier_call_chain+0x80/0x80 -[ 5.899090] [] cpuidle_enter_state+0x17/0x50 -[ 5.899092] [] acpi_os_acquire_lock+0x1f/0x23 -[ 5.899094] [] cpuidle899101] [] ? - -As the acpi code disables interrupts in acpi_idle_enter_bm, and calls -code that grabs the acpi lock, it causes issues as the lock is currently -in RT a sleeping lock. - -The lock was converted from a raw to a sleeping lock due to some -previous issues, and tests that showed it didn't seem to matter. -Unfortunately, it did matter for one of our boxes. - -This patch converts the lock back to a raw lock. I've run this code on a -few of my own machines, one being my laptop that uses the acpi quite -extensively. I've been able to suspend and resume without issues. - -[ tglx: Made the change exclusive for acpi_gbl_hardware_lock ] - -Signed-off-by: Steven Rostedt -Cc: John Kacur -Cc: Clark Williams -Link: http://lkml.kernel.org/r/1360765565.23152.5.camel@gandalf.local.home - -Signed-off-by: Thomas Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - drivers/acpi/acpica/acglobal.h | 2 +- - drivers/acpi/acpica/hwregs.c | 4 ++-- - drivers/acpi/acpica/hwxface.c | 4 ++-- - drivers/acpi/acpica/utmutex.c | 4 ++-- - include/acpi/platform/aclinux.h | 15 +++++++++++++++ - 5 files changed, 22 insertions(+), 7 deletions(-) - ---- a/drivers/acpi/acpica/acglobal.h -+++ b/drivers/acpi/acpica/acglobal.h -@@ -116,7 +116,7 @@ ACPI_GLOBAL(u8, acpi_gbl_global_lock_pen - * interrupt level - */ - ACPI_GLOBAL(acpi_spinlock, acpi_gbl_gpe_lock); /* For GPE data structs and registers */ --ACPI_GLOBAL(acpi_spinlock, acpi_gbl_hardware_lock); /* For ACPI H/W except GPE registers */ -+ACPI_GLOBAL(acpi_raw_spinlock, acpi_gbl_hardware_lock); /* For ACPI H/W except GPE registers */ - ACPI_GLOBAL(acpi_spinlock, acpi_gbl_reference_count_lock); - - /* Mutex for _OSI support */ ---- a/drivers/acpi/acpica/hwregs.c -+++ b/drivers/acpi/acpica/hwregs.c -@@ -428,14 +428,14 @@ acpi_status acpi_hw_clear_acpi_status(vo - ACPI_BITMASK_ALL_FIXED_STATUS, - ACPI_FORMAT_UINT64(acpi_gbl_xpm1a_status.address))); - -- lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); -+ raw_spin_lock_irqsave(acpi_gbl_hardware_lock, lock_flags); - - /* Clear the fixed events in PM1 A/B */ - - status = acpi_hw_register_write(ACPI_REGISTER_PM1_STATUS, - ACPI_BITMASK_ALL_FIXED_STATUS); - -- acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); -+ raw_spin_unlock_irqrestore(acpi_gbl_hardware_lock, lock_flags); - - if (ACPI_FAILURE(status)) { - goto exit; ---- a/drivers/acpi/acpica/hwxface.c -+++ b/drivers/acpi/acpica/hwxface.c -@@ -373,7 +373,7 @@ acpi_status acpi_write_bit_register(u32 - return_ACPI_STATUS(AE_BAD_PARAMETER); - } - -- lock_flags = acpi_os_acquire_lock(acpi_gbl_hardware_lock); -+ raw_spin_lock_irqsave(acpi_gbl_hardware_lock, lock_flags); - - /* - * At this point, we know that the parent register is one of the -@@ -434,7 +434,7 @@ acpi_status acpi_write_bit_register(u32 - - unlock_and_exit: - -- acpi_os_release_lock(acpi_gbl_hardware_lock, lock_flags); -+ raw_spin_unlock_irqrestore(acpi_gbl_hardware_lock, lock_flags); - return_ACPI_STATUS(status); - } - ---- a/drivers/acpi/acpica/utmutex.c -+++ b/drivers/acpi/acpica/utmutex.c -@@ -88,7 +88,7 @@ acpi_status acpi_ut_mutex_initialize(voi - return_ACPI_STATUS (status); - } - -- status = acpi_os_create_lock (&acpi_gbl_hardware_lock); -+ status = acpi_os_create_raw_lock (&acpi_gbl_hardware_lock); - if (ACPI_FAILURE (status)) { - return_ACPI_STATUS (status); - } -@@ -145,7 +145,7 @@ void acpi_ut_mutex_terminate(void) - /* Delete the spinlocks */ - - acpi_os_delete_lock(acpi_gbl_gpe_lock); -- acpi_os_delete_lock(acpi_gbl_hardware_lock); -+ acpi_os_delete_raw_lock(acpi_gbl_hardware_lock); - acpi_os_delete_lock(acpi_gbl_reference_count_lock); - - /* Delete the reader/writer lock */ ---- a/include/acpi/platform/aclinux.h -+++ b/include/acpi/platform/aclinux.h -@@ -134,6 +134,7 @@ - - #define acpi_cache_t struct kmem_cache - #define acpi_spinlock spinlock_t * -+#define acpi_raw_spinlock raw_spinlock_t * - #define acpi_cpu_flags unsigned long - - /* Use native linux version of acpi_os_allocate_zeroed */ -@@ -152,6 +153,20 @@ - #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id - #define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock - -+#define acpi_os_create_raw_lock(__handle) \ -+({ \ -+ raw_spinlock_t *lock = ACPI_ALLOCATE(sizeof(*lock)); \ -+ \ -+ if (lock) { \ -+ *(__handle) = lock; \ -+ raw_spin_lock_init(*(__handle)); \ -+ } \ -+ lock ? AE_OK : AE_NO_MEMORY; \ -+ }) -+ -+#define acpi_os_delete_raw_lock(__handle) kfree(__handle) -+ -+ - /* - * OSL interfaces used by debugger/disassembler - */ diff --git a/debian/patches/features/all/rt/add_migrate_disable.patch b/debian/patches/features/all/rt/add_migrate_disable.patch index d91dacb9b..4e6299c81 100644 --- a/debian/patches/features/all/rt/add_migrate_disable.patch +++ b/debian/patches/features/all/rt/add_migrate_disable.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Sat, 27 May 2017 19:02:06 +0200 Subject: kernel/sched/core: add migrate_disable() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz --- include/linux/preempt.h | 23 ++++++++ @@ -80,7 +79,7 @@ Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4 * boot command line: --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -1033,7 +1033,15 @@ void set_cpus_allowed_common(struct task +@@ -1034,7 +1034,15 @@ void set_cpus_allowed_common(struct task p->nr_cpus_allowed = cpumask_weight(new_mask); } @@ -97,7 +96,7 @@ Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4 { struct rq *rq = task_rq(p); bool queued, running; -@@ -1062,6 +1070,20 @@ void do_set_cpus_allowed(struct task_str +@@ -1063,6 +1071,20 @@ void do_set_cpus_allowed(struct task_str set_curr_task(rq, p); } @@ -118,7 +117,7 @@ Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4 /* * 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 -@@ -1120,9 +1142,16 @@ static int __set_cpus_allowed_ptr(struct +@@ -1121,9 +1143,16 @@ static int __set_cpus_allowed_ptr(struct } /* Can the task run on the task's current CPU? If so, we're done */ @@ -136,7 +135,7 @@ Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4 dest_cpu = cpumask_any_and(cpu_valid_mask, new_mask); if (task_running(rq, p) || p->state == TASK_WAKING) { struct migration_arg arg = { p, dest_cpu }; -@@ -7027,3 +7056,100 @@ const u32 sched_prio_to_wmult[40] = { +@@ -7032,3 +7061,100 @@ const u32 sched_prio_to_wmult[40] = { /* 10 */ 39045157, 49367440, 61356676, 76695844, 95443717, /* 15 */ 119304647, 148102320, 186737708, 238609294, 286331153, }; diff --git a/debian/patches/features/all/rt/alim15x3-move-irq-restore-before-pci_dev_put.patch b/debian/patches/features/all/rt/alim15x3-move-irq-restore-before-pci_dev_put.patch index 13328a6fc..909f8036e 100644 --- a/debian/patches/features/all/rt/alim15x3-move-irq-restore-before-pci_dev_put.patch +++ b/debian/patches/features/all/rt/alim15x3-move-irq-restore-before-pci_dev_put.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Tue, 3 Apr 2018 15:13:20 +0200 Subject: [PATCH] alim15x3: move irq-restore before pci_dev_put() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz init_chipset_ali15x3() initializes the chipset during init with disabled interrupts. There is no need to keep the interrupts disabled during diff --git a/debian/patches/features/all/rt/apparmor-use-a-locallock-instead-preempt_disable.patch b/debian/patches/features/all/rt/apparmor-use-a-locallock-instead-preempt_disable.patch index c4f1e466b..b3d8f2cca 100644 --- a/debian/patches/features/all/rt/apparmor-use-a-locallock-instead-preempt_disable.patch +++ b/debian/patches/features/all/rt/apparmor-use-a-locallock-instead-preempt_disable.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 11 Oct 2017 17:43:49 +0200 Subject: apparmor: use a locallock instead preempt_disable() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz get_buffers() disables preemption which acts as a lock for the per-CPU variable. Since we can't disable preemption here on RT, a local_lock is diff --git a/debian/patches/features/all/rt/arch-arm64-Add-lazy-preempt-support.patch b/debian/patches/features/all/rt/arch-arm64-Add-lazy-preempt-support.patch index 00bcf7001..cfb78fef8 100644 --- a/debian/patches/features/all/rt/arch-arm64-Add-lazy-preempt-support.patch +++ b/debian/patches/features/all/rt/arch-arm64-Add-lazy-preempt-support.patch @@ -1,7 +1,6 @@ From: Anders Roxell Date: Thu, 14 May 2015 17:52:17 +0200 Subject: arch/arm64: Add lazy preempt support -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz arm64 is missing support for PREEMPT_RT. The main feature which is lacking is support for lazy preemption. The arch-specific entry code, diff --git a/debian/patches/features/all/rt/arm-at91-pit-remove-irq-handler-when-clock-is-unused.patch b/debian/patches/features/all/rt/arm-at91-pit-remove-irq-handler-when-clock-is-unused.patch deleted file mode 100644 index f07dcb30e..000000000 --- a/debian/patches/features/all/rt/arm-at91-pit-remove-irq-handler-when-clock-is-unused.patch +++ /dev/null @@ -1,145 +0,0 @@ -From: Benedikt Spranger -Date: Sat, 6 Mar 2010 17:47:10 +0100 -Subject: ARM: AT91: PIT: Remove irq handler when clock event is unused -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Setup and remove the interrupt handler in clock event mode selection. -This avoids calling the (shared) interrupt handler when the device is -not used. - -Signed-off-by: Benedikt Spranger -Signed-off-by: Thomas Gleixner -[bigeasy: redo the patch with NR_IRQS_LEGACY which is probably required since -commit 8fe82a55 ("ARM: at91: sparse irq support") which is included since v3.6. -Patch based on what Sami Pietikäinen suggested]. -Signed-off-by: Sebastian Andrzej Siewior ---- - drivers/clocksource/timer-atmel-pit.c | 18 +++++++++--------- - drivers/clocksource/timer-atmel-st.c | 34 ++++++++++++++++++++++------------ - 2 files changed, 31 insertions(+), 21 deletions(-) - ---- a/drivers/clocksource/timer-atmel-pit.c -+++ b/drivers/clocksource/timer-atmel-pit.c -@@ -96,15 +96,24 @@ static int pit_clkevt_shutdown(struct cl - - /* disable irq, leaving the clocksource active */ - pit_write(data->base, AT91_PIT_MR, (data->cycle - 1) | AT91_PIT_PITEN); -+ free_irq(data->irq, data); - return 0; - } - -+static irqreturn_t at91sam926x_pit_interrupt(int irq, void *dev_id); - /* - * Clockevent device: interrupts every 1/HZ (== pit_cycles * MCK/16) - */ - static int pit_clkevt_set_periodic(struct clock_event_device *dev) - { - struct pit_data *data = clkevt_to_pit_data(dev); -+ int ret; -+ -+ ret = request_irq(data->irq, at91sam926x_pit_interrupt, -+ IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL, -+ "at91_tick", data); -+ if (ret) -+ panic(pr_fmt("Unable to setup IRQ\n")); - - /* update clocksource counter */ - data->cnt += data->cycle * PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR)); -@@ -230,15 +239,6 @@ static int __init at91sam926x_pit_dt_ini - return ret; - } - -- /* Set up irq handler */ -- ret = request_irq(data->irq, at91sam926x_pit_interrupt, -- IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL, -- "at91_tick", data); -- if (ret) { -- pr_err("Unable to setup IRQ\n"); -- return ret; -- } -- - /* Set up and register clockevents */ - data->clkevt.name = "pit"; - data->clkevt.features = CLOCK_EVT_FEAT_PERIODIC; ---- a/drivers/clocksource/timer-atmel-st.c -+++ b/drivers/clocksource/timer-atmel-st.c -@@ -115,18 +115,29 @@ static void clkdev32k_disable_and_flush_ - last_crtr = read_CRTR(); - } - -+static int atmel_st_irq; -+ - static int clkevt32k_shutdown(struct clock_event_device *evt) - { - clkdev32k_disable_and_flush_irq(); - irqmask = 0; - regmap_write(regmap_st, AT91_ST_IER, irqmask); -+ free_irq(atmel_st_irq, regmap_st); - return 0; - } - - static int clkevt32k_set_oneshot(struct clock_event_device *dev) - { -+ int ret; -+ - clkdev32k_disable_and_flush_irq(); - -+ ret = request_irq(atmel_st_irq, at91rm9200_timer_interrupt, -+ IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL, -+ "at91_tick", regmap_st); -+ if (ret) -+ panic(pr_fmt("Unable to setup IRQ\n")); -+ - /* - * ALM for oneshot irqs, set by next_event() - * before 32 seconds have passed. -@@ -139,8 +150,16 @@ static int clkevt32k_set_oneshot(struct - - static int clkevt32k_set_periodic(struct clock_event_device *dev) - { -+ int ret; -+ - clkdev32k_disable_and_flush_irq(); - -+ ret = request_irq(atmel_st_irq, at91rm9200_timer_interrupt, -+ IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL, -+ "at91_tick", regmap_st); -+ if (ret) -+ panic(pr_fmt("Unable to setup IRQ\n")); -+ - /* PIT for periodic irqs; fixed rate of 1/HZ */ - irqmask = AT91_ST_PITS; - regmap_write(regmap_st, AT91_ST_PIMR, timer_latch); -@@ -198,7 +217,7 @@ static int __init atmel_st_timer_init(st - { - struct clk *sclk; - unsigned int sclk_rate, val; -- int irq, ret; -+ int ret; - - regmap_st = syscon_node_to_regmap(node); - if (IS_ERR(regmap_st)) { -@@ -212,21 +231,12 @@ static int __init atmel_st_timer_init(st - regmap_read(regmap_st, AT91_ST_SR, &val); - - /* Get the interrupts property */ -- irq = irq_of_parse_and_map(node, 0); -- if (!irq) { -+ atmel_st_irq = irq_of_parse_and_map(node, 0); -+ if (!atmel_st_irq) { - pr_err("Unable to get IRQ from DT\n"); - return -EINVAL; - } - -- /* Make IRQs happen for the system timer */ -- ret = request_irq(irq, at91rm9200_timer_interrupt, -- IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL, -- "at91_tick", regmap_st); -- if (ret) { -- pr_err("Unable to setup IRQ\n"); -- return ret; -- } -- - sclk = of_clk_get(node, 0); - if (IS_ERR(sclk)) { - pr_err("Unable to get slow clock\n"); diff --git a/debian/patches/features/all/rt/arm-at91-tclib-default-to-tclib-timer-for-rt.patch b/debian/patches/features/all/rt/arm-at91-tclib-default-to-tclib-timer-for-rt.patch deleted file mode 100644 index c7ccebeec..000000000 --- a/debian/patches/features/all/rt/arm-at91-tclib-default-to-tclib-timer-for-rt.patch +++ /dev/null @@ -1,33 +0,0 @@ -From: Thomas Gleixner -Date: Sat, 1 May 2010 18:29:35 +0200 -Subject: ARM: at91: tclib: Default to tclib timer for RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -RT is not too happy about the shared timer interrupt in AT91 -devices. Default to tclib timer for RT. - -Signed-off-by: Thomas Gleixner - ---- - drivers/misc/Kconfig | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - ---- a/drivers/misc/Kconfig -+++ b/drivers/misc/Kconfig -@@ -54,6 +54,7 @@ config AD525X_DPOT_SPI - config ATMEL_TCLIB - bool "Atmel AT32/AT91 Timer/Counter Library" - depends on (AVR32 || ARCH_AT91) -+ default y if PREEMPT_RT_FULL - help - Select this if you want a library to allocate the Timer/Counter - blocks found on many Atmel processors. This facilitates using -@@ -86,7 +87,7 @@ config ATMEL_TCB_CLKSRC_BLOCK - config ATMEL_TCB_CLKSRC_USE_SLOW_CLOCK - bool "TC Block use 32 KiHz clock" - depends on ATMEL_TCB_CLKSRC -- default y -+ default y if !PREEMPT_RT_FULL - help - Select this to use 32 KiHz base clock rate as TC block clock - source for clock events. diff --git a/debian/patches/features/all/rt/arm-convert-boot-lock-to-raw.patch b/debian/patches/features/all/rt/arm-convert-boot-lock-to-raw.patch index 2c14c5359..4d1776214 100644 --- a/debian/patches/features/all/rt/arm-convert-boot-lock-to-raw.patch +++ b/debian/patches/features/all/rt/arm-convert-boot-lock-to-raw.patch @@ -1,7 +1,6 @@ From: Frank Rowand Date: Mon, 19 Sep 2011 14:51:14 -0700 Subject: arm: Convert arm boot_lock to raw -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The arm boot_lock is used by the secondary processor startup code. The locking task is the idle thread, which has idle->sched_class == &idle_sched_class. diff --git a/debian/patches/features/all/rt/arm-disable-NEON-in-kernel-mode.patch b/debian/patches/features/all/rt/arm-disable-NEON-in-kernel-mode.patch index b4a600483..626f61afc 100644 --- a/debian/patches/features/all/rt/arm-disable-NEON-in-kernel-mode.patch +++ b/debian/patches/features/all/rt/arm-disable-NEON-in-kernel-mode.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Fri, 1 Dec 2017 10:42:03 +0100 Subject: [PATCH] arm*: disable NEON in kernel mode -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz NEON in kernel mode is used by the crypto algorithms and raid6 code. While the raid6 code looks okay, the crypto algorithms do not: NEON diff --git a/debian/patches/features/all/rt/arm-enable-highmem-for-rt.patch b/debian/patches/features/all/rt/arm-enable-highmem-for-rt.patch index faad9b473..3891177cb 100644 --- a/debian/patches/features/all/rt/arm-enable-highmem-for-rt.patch +++ b/debian/patches/features/all/rt/arm-enable-highmem-for-rt.patch @@ -1,7 +1,6 @@ Subject: arm: Enable highmem for rt From: Thomas Gleixner Date: Wed, 13 Feb 2013 11:03:11 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz fixup highmem for ARM. diff --git a/debian/patches/features/all/rt/arm-highmem-flush-tlb-on-unmap.patch b/debian/patches/features/all/rt/arm-highmem-flush-tlb-on-unmap.patch index 48a7941d8..08e17cab7 100644 --- a/debian/patches/features/all/rt/arm-highmem-flush-tlb-on-unmap.patch +++ b/debian/patches/features/all/rt/arm-highmem-flush-tlb-on-unmap.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Mon, 11 Mar 2013 21:37:27 +0100 Subject: arm/highmem: Flush tlb on unmap -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The tlb should be flushed on unmap and thus make the mapping entry invalid. This is only done in the non-debug case which does not look diff --git a/debian/patches/features/all/rt/arm-include-definition-for-cpumask_t.patch b/debian/patches/features/all/rt/arm-include-definition-for-cpumask_t.patch index b641ac367..4bb2672be 100644 --- a/debian/patches/features/all/rt/arm-include-definition-for-cpumask_t.patch +++ b/debian/patches/features/all/rt/arm-include-definition-for-cpumask_t.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 22 Dec 2016 17:28:33 +0100 Subject: [PATCH] arm: include definition for cpumask_t -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz This definition gets pulled in by other files. With the (later) split of RCU and spinlock.h it won't compile anymore. diff --git a/debian/patches/features/all/rt/arm-kprobe-replace-patch_lock-to-raw-lock.patch b/debian/patches/features/all/rt/arm-kprobe-replace-patch_lock-to-raw-lock.patch index bcc218a9b..9a0fa6413 100644 --- a/debian/patches/features/all/rt/arm-kprobe-replace-patch_lock-to-raw-lock.patch +++ b/debian/patches/features/all/rt/arm-kprobe-replace-patch_lock-to-raw-lock.patch @@ -1,7 +1,6 @@ From: Yang Shi Date: Thu, 10 Nov 2016 16:17:55 -0800 Subject: [PATCH] arm: kprobe: replace patch_lock to raw lock -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz When running kprobe on -rt kernel, the below bug is caught: diff --git a/debian/patches/features/all/rt/arm-preempt-lazy-support.patch b/debian/patches/features/all/rt/arm-preempt-lazy-support.patch index 9e53d4765..5952dedd5 100644 --- a/debian/patches/features/all/rt/arm-preempt-lazy-support.patch +++ b/debian/patches/features/all/rt/arm-preempt-lazy-support.patch @@ -1,7 +1,6 @@ Subject: arm: Add support for lazy preemption From: Thomas Gleixner Date: Wed, 31 Oct 2012 12:04:11 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Implement the arm pieces for lazy preempt. diff --git a/debian/patches/features/all/rt/arm-unwind-use_raw_lock.patch b/debian/patches/features/all/rt/arm-unwind-use_raw_lock.patch index 24c907554..9c10dd91c 100644 --- a/debian/patches/features/all/rt/arm-unwind-use_raw_lock.patch +++ b/debian/patches/features/all/rt/arm-unwind-use_raw_lock.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Fri, 20 Sep 2013 14:31:54 +0200 Subject: arm/unwind: use a raw_spin_lock -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Mostly unwind is done with irqs enabled however SLUB may call it with irqs disabled while creating a new SLUB cache. diff --git a/debian/patches/features/all/rt/arm64-fpsimd-use-a-local_lock-instead-of-local_bh_di.patch b/debian/patches/features/all/rt/arm64-fpsimd-use-a-local_lock-instead-of-local_bh_di.patch index f60a7b822..30d81fb6f 100644 --- a/debian/patches/features/all/rt/arm64-fpsimd-use-a-local_lock-instead-of-local_bh_di.patch +++ b/debian/patches/features/all/rt/arm64-fpsimd-use-a-local_lock-instead-of-local_bh_di.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 17 May 2018 14:05:49 +0200 Subject: [PATCH] arm64: fpsimd: use a local_lock() in addition to local_bh_disable() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz In v4.16-RT I noticed a number of warnings from task_fpsimd_load(). The code disables BH and expects that it is not preemptible. On -RT the diff --git a/debian/patches/features/all/rt/arm64-xen--Make-XEN-depend-on-non-rt.patch b/debian/patches/features/all/rt/arm64-xen--Make-XEN-depend-on-non-rt.patch index dc2b7c98f..d6f0c3733 100644 --- a/debian/patches/features/all/rt/arm64-xen--Make-XEN-depend-on-non-rt.patch +++ b/debian/patches/features/all/rt/arm64-xen--Make-XEN-depend-on-non-rt.patch @@ -1,7 +1,6 @@ Subject: arm64/xen: Make XEN depend on !RT From: Thomas Gleixner Date: Mon, 12 Oct 2015 11:18:40 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz It's not ready and probably never will be, unless xen folks have a look at it. diff --git a/debian/patches/features/all/rt/at91_dont_enable_disable_clock.patch b/debian/patches/features/all/rt/at91_dont_enable_disable_clock.patch index 358a594ea..417e2e792 100644 --- a/debian/patches/features/all/rt/at91_dont_enable_disable_clock.patch +++ b/debian/patches/features/all/rt/at91_dont_enable_disable_clock.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 09 Mar 2016 10:51:06 +0100 Subject: arm: at91: do not disable/enable clocks in a row -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Currently the driver will disable the clock and enable it one line later if it is switching from periodic mode into one shot. diff --git a/debian/patches/features/all/rt/ata-disable-interrupts-if-non-rt.patch b/debian/patches/features/all/rt/ata-disable-interrupts-if-non-rt.patch deleted file mode 100644 index abc656bb2..000000000 --- a/debian/patches/features/all/rt/ata-disable-interrupts-if-non-rt.patch +++ /dev/null @@ -1,29 +0,0 @@ -From: Steven Rostedt -Date: Fri, 3 Jul 2009 08:44:29 -0500 -Subject: ata: Do not disable interrupts in ide code for preempt-rt -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Use the local_irq_*_nort variants. - -Signed-off-by: Steven Rostedt -Signed-off-by: Ingo Molnar -Signed-off-by: Thomas Gleixner - ---- - drivers/ata/libata-sff.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/drivers/ata/libata-sff.c -+++ b/drivers/ata/libata-sff.c -@@ -679,9 +679,9 @@ unsigned int ata_sff_data_xfer_noirq(str - unsigned long flags; - unsigned int consumed; - -- local_irq_save(flags); -+ local_irq_save_nort(flags); - consumed = ata_sff_data_xfer32(qc, buf, buflen, rw); -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - - return consumed; - } diff --git a/debian/patches/features/all/rt/block-Remove-redundant-WARN_ON.patch b/debian/patches/features/all/rt/block-Remove-redundant-WARN_ON.patch index cb6d06719..f3aa77909 100644 --- a/debian/patches/features/all/rt/block-Remove-redundant-WARN_ON.patch +++ b/debian/patches/features/all/rt/block-Remove-redundant-WARN_ON.patch @@ -1,7 +1,6 @@ From: Anna-Maria Gleixner Date: Wed, 11 Apr 2018 15:05:43 +0200 Subject: [PATCH] block: Remove redundant WARN_ON() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Commit 2fff8a924d4c ("block: Check locking assumptions at runtime") added a lockdep_assert_held(q->queue_lock) which makes the WARN_ON() redundant diff --git a/debian/patches/features/all/rt/block-avoid-disabling-interrupts-during-kmap_atomic.patch b/debian/patches/features/all/rt/block-avoid-disabling-interrupts-during-kmap_atomic.patch index 33d642184..aac6f0072 100644 --- a/debian/patches/features/all/rt/block-avoid-disabling-interrupts-during-kmap_atomic.patch +++ b/debian/patches/features/all/rt/block-avoid-disabling-interrupts-during-kmap_atomic.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Tue, 10 Apr 2018 17:32:57 +0200 Subject: [PATCH] block: don't disable interrupts during kmap_atomic() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz bounce_copy_vec() disables interrupts around kmap_atomic(). This is a leftover from the old kmap_atomic() implementation which relied on fixed diff --git a/debian/patches/features/all/rt/block-blk-mq-move-blk_queue_usage_counter_release-in.patch b/debian/patches/features/all/rt/block-blk-mq-move-blk_queue_usage_counter_release-in.patch index 92ec33822..963333d77 100644 --- a/debian/patches/features/all/rt/block-blk-mq-move-blk_queue_usage_counter_release-in.patch +++ b/debian/patches/features/all/rt/block-blk-mq-move-blk_queue_usage_counter_release-in.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Tue, 13 Mar 2018 13:49:16 +0100 Subject: [PATCH] block: blk-mq: move blk_queue_usage_counter_release() into process context -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz | BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:914 | in_atomic(): 1, irqs_disabled(): 0, pid: 255, name: kworker/u257:6 diff --git a/debian/patches/features/all/rt/block-blk-mq-use-swait.patch b/debian/patches/features/all/rt/block-blk-mq-use-swait.patch deleted file mode 100644 index 86ad4f9e3..000000000 --- a/debian/patches/features/all/rt/block-blk-mq-use-swait.patch +++ /dev/null @@ -1,123 +0,0 @@ -From: Sebastian Andrzej Siewior -Date: Fri, 13 Feb 2015 11:01:26 +0100 -Subject: block: blk-mq: Use swait -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -| BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:914 -| in_atomic(): 1, irqs_disabled(): 0, pid: 255, name: kworker/u257:6 -| 5 locks held by kworker/u257:6/255: -| #0: ("events_unbound"){.+.+.+}, at: [] process_one_work+0x171/0x5e0 -| #1: ((&entry->work)){+.+.+.}, at: [] process_one_work+0x171/0x5e0 -| #2: (&shost->scan_mutex){+.+.+.}, at: [] __scsi_add_device+0xa3/0x130 [scsi_mod] -| #3: (&set->tag_list_lock){+.+...}, at: [] blk_mq_init_queue+0x96a/0xa50 -| #4: (rcu_read_lock_sched){......}, at: [] percpu_ref_kill_and_confirm+0x1d/0x120 -| Preemption disabled at:[] blk_mq_freeze_queue_start+0x56/0x70 -| -| CPU: 2 PID: 255 Comm: kworker/u257:6 Not tainted 3.18.7-rt0+ #1 -| Workqueue: events_unbound async_run_entry_fn -| 0000000000000003 ffff8800bc29f998 ffffffff815b3a12 0000000000000000 -| 0000000000000000 ffff8800bc29f9b8 ffffffff8109aa16 ffff8800bc29fa28 -| ffff8800bc5d1bc8 ffff8800bc29f9e8 ffffffff815b8dd4 ffff880000000000 -| Call Trace: -| [] dump_stack+0x4f/0x7c -| [] __might_sleep+0x116/0x190 -| [] rt_spin_lock+0x24/0x60 -| [] __wake_up+0x29/0x60 -| [] blk_mq_usage_counter_release+0x1e/0x20 -| [] percpu_ref_kill_and_confirm+0x106/0x120 -| [] blk_mq_freeze_queue_start+0x56/0x70 -| [] blk_mq_update_tag_set_depth+0x40/0xd0 -| [] blk_mq_init_queue+0x98c/0xa50 -| [] scsi_mq_alloc_queue+0x20/0x60 [scsi_mod] -| [] scsi_alloc_sdev+0x2f5/0x370 [scsi_mod] -| [] scsi_probe_and_add_lun+0x9e4/0xdd0 [scsi_mod] -| [] __scsi_add_device+0x126/0x130 [scsi_mod] -| [] ata_scsi_scan_host+0xaf/0x200 [libata] -| [] async_port_probe+0x46/0x60 [libata] -| [] async_run_entry_fn+0x3b/0xf0 -| [] process_one_work+0x201/0x5e0 - -Signed-off-by: Sebastian Andrzej Siewior ---- - block/blk-core.c | 6 +++--- - block/blk-mq.c | 8 ++++---- - include/linux/blkdev.h | 2 +- - 3 files changed, 8 insertions(+), 8 deletions(-) - ---- a/block/blk-core.c -+++ b/block/blk-core.c -@@ -785,7 +785,7 @@ int blk_queue_enter(struct request_queue - */ - smp_rmb(); - -- ret = wait_event_interruptible(q->mq_freeze_wq, -+ ret = swait_event_interruptible(q->mq_freeze_wq, - !atomic_read(&q->mq_freeze_depth) || - blk_queue_dying(q)); - if (blk_queue_dying(q)) -@@ -805,7 +805,7 @@ static void blk_queue_usage_counter_rele - struct request_queue *q = - container_of(ref, struct request_queue, q_usage_counter); - -- wake_up_all(&q->mq_freeze_wq); -+ swake_up_all(&q->mq_freeze_wq); - } - - static void blk_rq_timed_out_timer(unsigned long data) -@@ -881,7 +881,7 @@ struct request_queue *blk_alloc_queue_no - q->bypass_depth = 1; - __set_bit(QUEUE_FLAG_BYPASS, &q->queue_flags); - -- init_waitqueue_head(&q->mq_freeze_wq); -+ init_swait_queue_head(&q->mq_freeze_wq); - - /* - * Init percpu_ref in atomic mode so that it's faster to shutdown. ---- a/block/blk-mq.c -+++ b/block/blk-mq.c -@@ -132,14 +132,14 @@ EXPORT_SYMBOL_GPL(blk_freeze_queue_start - - void blk_mq_freeze_queue_wait(struct request_queue *q) - { -- wait_event(q->mq_freeze_wq, percpu_ref_is_zero(&q->q_usage_counter)); -+ swait_event(q->mq_freeze_wq, percpu_ref_is_zero(&q->q_usage_counter)); - } - EXPORT_SYMBOL_GPL(blk_mq_freeze_queue_wait); - - int blk_mq_freeze_queue_wait_timeout(struct request_queue *q, - unsigned long timeout) - { -- return wait_event_timeout(q->mq_freeze_wq, -+ return swait_event_timeout(q->mq_freeze_wq, - percpu_ref_is_zero(&q->q_usage_counter), - timeout); - } -@@ -180,7 +180,7 @@ void blk_mq_unfreeze_queue(struct reques - WARN_ON_ONCE(freeze_depth < 0); - if (!freeze_depth) { - percpu_ref_reinit(&q->q_usage_counter); -- wake_up_all(&q->mq_freeze_wq); -+ swake_up_all(&q->mq_freeze_wq); - } - } - EXPORT_SYMBOL_GPL(blk_mq_unfreeze_queue); -@@ -261,7 +261,7 @@ void blk_mq_wake_waiters(struct request_ - * dying, we need to ensure that processes currently waiting on - * the queue are notified as well. - */ -- wake_up_all(&q->mq_freeze_wq); -+ swake_up_all(&q->mq_freeze_wq); - } - - bool blk_mq_can_queue(struct blk_mq_hw_ctx *hctx) ---- a/include/linux/blkdev.h -+++ b/include/linux/blkdev.h -@@ -598,7 +598,7 @@ struct request_queue { - struct throtl_data *td; - #endif - struct rcu_head rcu_head; -- wait_queue_head_t mq_freeze_wq; -+ struct swait_queue_head mq_freeze_wq; - struct percpu_ref q_usage_counter; - struct list_head all_q_node; - diff --git a/debian/patches/features/all/rt/block-mq-don-t-complete-requests-via-IPI.patch b/debian/patches/features/all/rt/block-mq-don-t-complete-requests-via-IPI.patch index 492fa4e65..e16614de3 100644 --- a/debian/patches/features/all/rt/block-mq-don-t-complete-requests-via-IPI.patch +++ b/debian/patches/features/all/rt/block-mq-don-t-complete-requests-via-IPI.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 29 Jan 2015 15:10:08 +0100 Subject: block/mq: don't complete requests via IPI -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The IPI runs in hardirq context and there are sleeping locks. This patch moves the completion into a workqueue. diff --git a/debian/patches/features/all/rt/block-mq-drop-preempt-disable.patch b/debian/patches/features/all/rt/block-mq-drop-preempt-disable.patch index 0255c02d7..2dd579702 100644 --- a/debian/patches/features/all/rt/block-mq-drop-preempt-disable.patch +++ b/debian/patches/features/all/rt/block-mq-drop-preempt-disable.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Tue, 14 Jul 2015 14:26:34 +0200 Subject: block/mq: do not invoke preempt_disable() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz preempt_disable() and get_cpu() don't play well together with the sleeping locks it tries to allocate later. diff --git a/debian/patches/features/all/rt/block-mq-use-cpu_light.patch b/debian/patches/features/all/rt/block-mq-use-cpu_light.patch index 11e1ec8b3..6ab793ece 100644 --- a/debian/patches/features/all/rt/block-mq-use-cpu_light.patch +++ b/debian/patches/features/all/rt/block-mq-use-cpu_light.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 9 Apr 2014 10:37:23 +0200 Subject: block: mq: use cpu_light() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz there is a might sleep splat because get_cpu() disables preemption and later we grab a lock. As a workaround for this we use get_cpu_light(). diff --git a/debian/patches/features/all/rt/block-shorten-interrupt-disabled-regions.patch b/debian/patches/features/all/rt/block-shorten-interrupt-disabled-regions.patch index d18e4e028..c2cad650a 100644 --- a/debian/patches/features/all/rt/block-shorten-interrupt-disabled-regions.patch +++ b/debian/patches/features/all/rt/block-shorten-interrupt-disabled-regions.patch @@ -1,7 +1,6 @@ Subject: block: Shorten interrupt disabled regions From: Thomas Gleixner Date: Wed, 22 Jun 2011 19:47:02 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Commit 9c40cef2b799 ("sched: Move blk_schedule_flush_plug() out of __schedule()") moved the blk_schedule_flush_plug() call out of the diff --git a/debian/patches/features/all/rt/block-use-cpu-chill.patch b/debian/patches/features/all/rt/block-use-cpu-chill.patch index b956ae2d9..83b2351bd 100644 --- a/debian/patches/features/all/rt/block-use-cpu-chill.patch +++ b/debian/patches/features/all/rt/block-use-cpu-chill.patch @@ -1,7 +1,6 @@ Subject: block: Use cpu_chill() for retry loops From: Thomas Gleixner Date: Thu, 20 Dec 2012 18:28:26 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Retry loops on RT might loop forever when the modifying side was preempted. Steven also observed a live lock when there was a diff --git a/debian/patches/features/all/rt/bug-rt-dependend-variants.patch b/debian/patches/features/all/rt/bug-rt-dependend-variants.patch deleted file mode 100644 index 424334211..000000000 --- a/debian/patches/features/all/rt/bug-rt-dependend-variants.patch +++ /dev/null @@ -1,37 +0,0 @@ -From: Ingo Molnar -Date: Fri, 3 Jul 2009 08:29:58 -0500 -Subject: bug: BUG_ON/WARN_ON variants dependend on RT/!RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Introduce RT/NON-RT WARN/BUG statements to avoid ifdefs in the code. - -Signed-off-by: Ingo Molnar -Signed-off-by: Thomas Gleixner - ---- - include/asm-generic/bug.h | 14 ++++++++++++++ - 1 file changed, 14 insertions(+) - ---- a/include/asm-generic/bug.h -+++ b/include/asm-generic/bug.h -@@ -233,6 +233,20 @@ void __warn(const char *file, int line, - # define WARN_ON_SMP(x) ({0;}) - #endif - -+#ifdef CONFIG_PREEMPT_RT_BASE -+# define BUG_ON_RT(c) BUG_ON(c) -+# define BUG_ON_NONRT(c) do { } while (0) -+# define WARN_ON_RT(condition) WARN_ON(condition) -+# define WARN_ON_NONRT(condition) do { } while (0) -+# define WARN_ON_ONCE_NONRT(condition) do { } while (0) -+#else -+# define BUG_ON_RT(c) do { } while (0) -+# define BUG_ON_NONRT(c) BUG_ON(c) -+# define WARN_ON_RT(condition) do { } while (0) -+# define WARN_ON_NONRT(condition) WARN_ON(condition) -+# define WARN_ON_ONCE_NONRT(condition) WARN_ON_ONCE(condition) -+#endif -+ - #endif /* __ASSEMBLY__ */ - - #endif diff --git a/debian/patches/features/all/rt/cgroups-scheduling-while-atomic-in-cgroup-code.patch b/debian/patches/features/all/rt/cgroups-scheduling-while-atomic-in-cgroup-code.patch deleted file mode 100644 index 399ff1bd9..000000000 --- a/debian/patches/features/all/rt/cgroups-scheduling-while-atomic-in-cgroup-code.patch +++ /dev/null @@ -1,105 +0,0 @@ -From: Mike Galbraith -Date: Sat, 21 Jun 2014 10:09:48 +0200 -Subject: memcontrol: Prevent scheduling while atomic in cgroup code -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -mm, memcg: make refill_stock() use get_cpu_light() - -Nikita reported the following memcg scheduling while atomic bug: - -Call Trace: -[e22d5a90] [c0007ea8] show_stack+0x4c/0x168 (unreliable) -[e22d5ad0] [c0618c04] __schedule_bug+0x94/0xb0 -[e22d5ae0] [c060b9ec] __schedule+0x530/0x550 -[e22d5bf0] [c060bacc] schedule+0x30/0xbc -[e22d5c00] [c060ca24] rt_spin_lock_slowlock+0x180/0x27c -[e22d5c70] [c00b39dc] res_counter_uncharge_until+0x40/0xc4 -[e22d5ca0] [c013ca88] drain_stock.isra.20+0x54/0x98 -[e22d5cc0] [c01402ac] __mem_cgroup_try_charge+0x2e8/0xbac -[e22d5d70] [c01410d4] mem_cgroup_charge_common+0x3c/0x70 -[e22d5d90] [c0117284] __do_fault+0x38c/0x510 -[e22d5df0] [c011a5f4] handle_pte_fault+0x98/0x858 -[e22d5e50] [c060ed08] do_page_fault+0x42c/0x6fc -[e22d5f40] [c000f5b4] handle_page_fault+0xc/0x80 - -What happens: - - refill_stock() - get_cpu_var() - drain_stock() - res_counter_uncharge() - res_counter_uncharge_until() - spin_lock() <== boom - -Fix it by replacing get/put_cpu_var() with get/put_cpu_light(). - -Reported-by: Nikita Yushchenko -Signed-off-by: Mike Galbraith -[bigeasy: use memcg_stock_ll as a locallock since it is now IRQ-off region] -Signed-off-by: Sebastian Andrzej Siewior ---- - mm/memcontrol.c | 13 +++++++------ - 1 file changed, 7 insertions(+), 6 deletions(-) - ---- a/mm/memcontrol.c -+++ b/mm/memcontrol.c -@@ -1723,6 +1723,7 @@ struct memcg_stock_pcp { - #define FLUSHING_CACHED_CHARGE 0 - }; - static DEFINE_PER_CPU(struct memcg_stock_pcp, memcg_stock); -+static DEFINE_LOCAL_IRQ_LOCK(memcg_stock_ll); - static DEFINE_MUTEX(percpu_charge_mutex); - - /** -@@ -1745,7 +1746,7 @@ static bool consume_stock(struct mem_cgr - if (nr_pages > CHARGE_BATCH) - return ret; - -- local_irq_save(flags); -+ local_lock_irqsave(memcg_stock_ll, flags); - - stock = this_cpu_ptr(&memcg_stock); - if (memcg == stock->cached && stock->nr_pages >= nr_pages) { -@@ -1753,7 +1754,7 @@ static bool consume_stock(struct mem_cgr - ret = true; - } - -- local_irq_restore(flags); -+ local_unlock_irqrestore(memcg_stock_ll, flags); - - return ret; - } -@@ -1784,13 +1785,13 @@ static void drain_local_stock(struct wor - * The only protection from memory hotplug vs. drain_stock races is - * that we always operate on local CPU stock here with IRQ disabled - */ -- local_irq_save(flags); -+ local_lock_irqsave(memcg_stock_ll, flags); - - stock = this_cpu_ptr(&memcg_stock); - drain_stock(stock); - clear_bit(FLUSHING_CACHED_CHARGE, &stock->flags); - -- local_irq_restore(flags); -+ local_unlock_irqrestore(memcg_stock_ll, flags); - } - - /* -@@ -1802,7 +1803,7 @@ static void refill_stock(struct mem_cgro - struct memcg_stock_pcp *stock; - unsigned long flags; - -- local_irq_save(flags); -+ local_lock_irqsave(memcg_stock_ll, flags); - - stock = this_cpu_ptr(&memcg_stock); - if (stock->cached != memcg) { /* reset if necessary */ -@@ -1814,7 +1815,7 @@ static void refill_stock(struct mem_cgro - if (stock->nr_pages > CHARGE_BATCH) - drain_stock(stock); - -- local_irq_restore(flags); -+ local_unlock_irqrestore(memcg_stock_ll, flags); - } - - /* diff --git a/debian/patches/features/all/rt/cgroups-use-simple-wait-in-css_release.patch b/debian/patches/features/all/rt/cgroups-use-simple-wait-in-css_release.patch index 86d19723a..788785dad 100644 --- a/debian/patches/features/all/rt/cgroups-use-simple-wait-in-css_release.patch +++ b/debian/patches/features/all/rt/cgroups-use-simple-wait-in-css_release.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Fri, 13 Feb 2015 15:52:24 +0100 Subject: cgroups: use simple wait in css_release() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz To avoid: |BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:914 diff --git a/debian/patches/features/all/rt/char-random-don-t-print-that-the-init-is-done.patch b/debian/patches/features/all/rt/char-random-don-t-print-that-the-init-is-done.patch deleted file mode 100644 index 0d623f637..000000000 --- a/debian/patches/features/all/rt/char-random-don-t-print-that-the-init-is-done.patch +++ /dev/null @@ -1,167 +0,0 @@ -From: Sebastian Andrzej Siewior -Date: Tue, 30 May 2017 16:39:01 +0200 -Subject: char/random: don't print that the init is done -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -On RT we run into circular locking with pendingb_lock (workqueue), -port_lock_key (uart) and the primary_crng (random): - - ====================================================== - [ INFO: possible circular locking dependency detected ] - ------------------------------------------------------- - irq/4-serial/512 is trying to acquire lock: - ((pendingb_lock).lock){+.+...}, at: [] queue_work_on+0x5d/0x190 - - but task is already holding lock: - (&port_lock_key){+.+...}, at: [] serial8250_handle_irq.part.27+0x16/0xb0 - - which lock already depends on the new lock. - - the existing dependency chain (in reverse order) is: - - -> #3 (&port_lock_key){+.+...}: - lock_acquire+0xac/0x240 - rt_spin_lock+0x46/0x50 - serial8250_console_write+0x211/0x220 - univ8250_console_write+0x1c/0x20 - console_unlock+0x563/0x5c0 - vprintk_emit+0x277/0x320 - vprintk_default+0x1a/0x20 - vprintk_func+0x20/0x80 - printk+0x3e/0x46 - crng_fast_load+0xde/0xe0 - add_interrupt_randomness+0x16c/0x1a0 - irq_thread+0x15c/0x1e0 - kthread+0x112/0x150 - ret_from_fork+0x31/0x40 - - -> #2 (primary_crng.lock){+.+...}: - lock_acquire+0xac/0x240 - rt_spin_lock+0x46/0x50 - _extract_crng+0x39/0xa0 - extract_crng+0x3a/0x40 - get_random_u32+0x120/0x190 - new_slab+0x1d6/0x7c0 - ___slab_alloc+0x30b/0x6f0 - __slab_alloc.isra.78+0x6c/0xc0 - __kmalloc+0x254/0x3a0 - pcpu_mem_zalloc+0x3a/0x70 - percpu_init_late+0x4f/0x8a - start_kernel+0x1ec/0x3b8 - x86_64_start_reservations+0x2a/0x2c - x86_64_start_kernel+0x13d/0x14c - verify_cpu+0x0/0xfc - - -> #1 ((batched_entropy_u32_lock).lock){+.+...}: - lock_acquire+0xac/0x240 - rt_spin_lock__no_mg+0x41/0x50 - get_random_u32+0x64/0x190 - new_slab+0x1d6/0x7c0 - ___slab_alloc+0x30b/0x6f0 - __slab_alloc.isra.78+0x6c/0xc0 - kmem_cache_alloc+0x26a/0x370 - __debug_object_init+0x325/0x460 - debug_object_activate+0x11c/0x1f0 - __queue_work+0x2c/0x770 - queue_work_on+0x12a/0x190 - serio_queue_event+0xd3/0x140 - __serio_register_port+0x17e/0x1a0 - i8042_probe+0x623/0x687 - platform_drv_probe+0x36/0x90 - driver_probe_device+0x1f8/0x2e0 - __driver_attach+0x96/0xa0 - bus_for_each_dev+0x5d/0x90 - driver_attach+0x19/0x20 - bus_add_driver+0x125/0x220 - driver_register+0x5b/0xd0 - __platform_driver_probe+0x5b/0x120 - __platform_create_bundle+0xaa/0xd0 - i8042_init+0x3f1/0x430 - do_one_initcall+0x3e/0x180 - kernel_init_freeable+0x212/0x295 - kernel_init+0x9/0x100 - ret_from_fork+0x31/0x40 - - -> #0 ((pendingb_lock).lock){+.+...}: - __lock_acquire+0x11b4/0x1320 - lock_acquire+0xac/0x240 - rt_spin_lock+0x46/0x50 - queue_work_on+0x5d/0x190 - tty_flip_buffer_push+0x26/0x30 - serial8250_rx_chars+0x120/0x1f0 - serial8250_handle_irq.part.27+0x58/0xb0 - serial8250_default_handle_irq+0x4b/0x60 - serial8250_interrupt+0x5f/0xd0 - irq_forced_thread_fn+0x1e/0x70 - irq_thread+0x137/0x1e0 - kthread+0x112/0x150 - ret_from_fork+0x31/0x40 - - other info that might help us debug this: - - Chain exists of: - (pendingb_lock).lock --> primary_crng.lock --> &port_lock_key - - Possible unsafe locking scenario: - - CPU0 CPU1 - ---- ---- - lock(&port_lock_key); - lock(primary_crng.lock); - lock(&port_lock_key); - lock((pendingb_lock).lock); - - *** DEADLOCK *** - - 2 locks held by irq/4-serial/512: - #0: (&i->lock){+.+...}, at: [] serial8250_interrupt+0x30/0xd0 - #1: (&port_lock_key){+.+...}, at: [] serial8250_handle_irq.part.27+0x16/0xb0 - - stack backtrace: - CPU: 4 PID: 512 Comm: irq/4-serial Not tainted 4.11.3-rt0+ #101 - Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.10.2-1 04/01/2014 - Call Trace: - dump_stack+0x86/0xc1 - print_circular_bug+0x1be/0x210 - __lock_acquire+0x11b4/0x1320 - lock_acquire+0xac/0x240 - rt_spin_lock+0x46/0x50 - queue_work_on+0x5d/0x190 - tty_flip_buffer_push+0x26/0x30 - serial8250_rx_chars+0x120/0x1f0 - serial8250_handle_irq.part.27+0x58/0xb0 - serial8250_default_handle_irq+0x4b/0x60 - serial8250_interrupt+0x5f/0xd0 - irq_forced_thread_fn+0x1e/0x70 - irq_thread+0x137/0x1e0 - kthread+0x112/0x150 - ret_from_fork+0x31/0x40 - -It should work if we delay that printk after dropping the lock but we -also could skip it. - -Signed-off-by: Sebastian Andrzej Siewior ---- - drivers/char/random.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/drivers/char/random.c -+++ b/drivers/char/random.c -@@ -809,7 +809,7 @@ static int crng_fast_load(const char *cp - invalidate_batched_entropy(); - crng_init = 1; - wake_up_interruptible(&crng_init_wait); -- pr_notice("random: fast init done\n"); -+ /* pr_notice("random: fast init done\n"); */ - } - return 1; - } -@@ -848,7 +848,7 @@ static void crng_reseed(struct crng_stat - crng_init = 2; - process_random_ready_list(); - wake_up_interruptible(&crng_init_wait); -- pr_notice("random: crng init done\n"); -+ /* pr_notice("random: crng init done\n"); */ - } - } - diff --git a/debian/patches/features/all/rt/clockevents-drivers-timer-atmel-pit-fix-double-free_.patch b/debian/patches/features/all/rt/clockevents-drivers-timer-atmel-pit-fix-double-free_.patch deleted file mode 100644 index e6d29326e..000000000 --- a/debian/patches/features/all/rt/clockevents-drivers-timer-atmel-pit-fix-double-free_.patch +++ /dev/null @@ -1,46 +0,0 @@ -From: Alexandre Belloni -Date: Thu, 17 Mar 2016 21:09:43 +0100 -Subject: [PATCH] clockevents/drivers/timer-atmel-pit: fix double free_irq -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -clockevents_exchange_device() changes the state from detached to shutdown -and so at that point the IRQ has not yet been requested. - -Acked-by: Nicolas Ferre -Signed-off-by: Alexandre Belloni -Signed-off-by: Sebastian Andrzej Siewior ---- - drivers/clocksource/timer-atmel-pit.c | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) - ---- a/drivers/clocksource/timer-atmel-pit.c -+++ b/drivers/clocksource/timer-atmel-pit.c -@@ -46,6 +46,7 @@ struct pit_data { - u32 cycle; - u32 cnt; - unsigned int irq; -+ bool irq_requested; - struct clk *mck; - }; - -@@ -96,7 +97,10 @@ static int pit_clkevt_shutdown(struct cl - - /* disable irq, leaving the clocksource active */ - pit_write(data->base, AT91_PIT_MR, (data->cycle - 1) | AT91_PIT_PITEN); -- free_irq(data->irq, data); -+ if (data->irq_requested) { -+ free_irq(data->irq, data); -+ data->irq_requested = false; -+ } - return 0; - } - -@@ -115,6 +119,8 @@ static int pit_clkevt_set_periodic(struc - if (ret) - panic(pr_fmt("Unable to setup IRQ\n")); - -+ data->irq_requested = true; -+ - /* update clocksource counter */ - data->cnt += data->cycle * PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR)); - pit_write(data->base, AT91_PIT_MR, diff --git a/debian/patches/features/all/rt/clocksource-tclib-allow-higher-clockrates.patch b/debian/patches/features/all/rt/clocksource-tclib-allow-higher-clockrates.patch index 0a9aacb91..891ab76ba 100644 --- a/debian/patches/features/all/rt/clocksource-tclib-allow-higher-clockrates.patch +++ b/debian/patches/features/all/rt/clocksource-tclib-allow-higher-clockrates.patch @@ -1,7 +1,6 @@ From: Benedikt Spranger Date: Mon, 8 Mar 2010 18:57:04 +0100 Subject: clocksource: TCLIB: Allow higher clock rates for clock events -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz As default the TCLIB uses the 32KiHz base clock rate for clock events. Add a compile time selection to allow higher clock resulution. diff --git a/debian/patches/features/all/rt/completion-use-simple-wait-queues.patch b/debian/patches/features/all/rt/completion-use-simple-wait-queues.patch index 2ba8572c9..88f8382d7 100644 --- a/debian/patches/features/all/rt/completion-use-simple-wait-queues.patch +++ b/debian/patches/features/all/rt/completion-use-simple-wait-queues.patch @@ -1,7 +1,6 @@ Subject: completion: Use simple wait queues From: Thomas Gleixner Date: Fri, 11 Jan 2013 11:23:51 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Completions have no long lasting callbacks and therefor do not need the complex waitqueue variant. Use simple waitqueues which reduces the @@ -35,7 +34,7 @@ Signed-off-by: Thomas Gleixner break; --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c -@@ -1608,7 +1608,7 @@ static void ffs_data_put(struct ffs_data +@@ -1612,7 +1612,7 @@ static void ffs_data_put(struct ffs_data pr_info("%s(): freeing\n", __func__); ffs_data_clear(ffs); BUG_ON(waitqueue_active(&ffs->ev.waitq) || @@ -159,7 +158,7 @@ Signed-off-by: Thomas Gleixner return error; --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c -@@ -593,6 +593,8 @@ static int enter_state(suspend_state_t s +@@ -594,6 +594,8 @@ static int enter_state(suspend_state_t s return error; } @@ -168,7 +167,7 @@ Signed-off-by: Thomas Gleixner /** * pm_suspend - Externally visible function for suspending the system. * @state: System sleep state to enter. -@@ -607,6 +609,7 @@ int pm_suspend(suspend_state_t state) +@@ -608,6 +610,7 @@ int pm_suspend(suspend_state_t state) if (state <= PM_SUSPEND_ON || state >= PM_SUSPEND_MAX) return -EINVAL; @@ -176,7 +175,7 @@ Signed-off-by: Thomas Gleixner pr_info("suspend entry (%s)\n", mem_sleep_labels[state]); error = enter_state(state); if (error) { -@@ -616,6 +619,7 @@ int pm_suspend(suspend_state_t state) +@@ -617,6 +620,7 @@ int pm_suspend(suspend_state_t state) suspend_stats.success++; } pr_info("suspend exit\n"); @@ -282,7 +281,7 @@ Signed-off-by: Thomas Gleixner EXPORT_SYMBOL(completion_done); --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -7075,7 +7075,10 @@ void migrate_disable(void) +@@ -7080,7 +7080,10 @@ void migrate_disable(void) return; } #ifdef CONFIG_SCHED_DEBUG @@ -294,7 +293,7 @@ Signed-off-by: Thomas Gleixner #endif if (p->migrate_disable) { -@@ -7105,7 +7108,10 @@ void migrate_enable(void) +@@ -7110,7 +7113,10 @@ void migrate_enable(void) } #ifdef CONFIG_SCHED_DEBUG diff --git a/debian/patches/features/all/rt/cond-resched-lock-rt-tweak.patch b/debian/patches/features/all/rt/cond-resched-lock-rt-tweak.patch index b9a80bf82..c3caef32f 100644 --- a/debian/patches/features/all/rt/cond-resched-lock-rt-tweak.patch +++ b/debian/patches/features/all/rt/cond-resched-lock-rt-tweak.patch @@ -1,7 +1,6 @@ Subject: sched: Use the proper LOCK_OFFSET for cond_resched() From: Thomas Gleixner Date: Sun, 17 Jul 2011 22:51:33 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz RT does not increment preempt count when a 'sleeping' spinlock is locked. Update PREEMPT_LOCK_OFFSET for that case. diff --git a/debian/patches/features/all/rt/cond-resched-softirq-rt.patch b/debian/patches/features/all/rt/cond-resched-softirq-rt.patch index 4f3df6aa4..7b09de750 100644 --- a/debian/patches/features/all/rt/cond-resched-softirq-rt.patch +++ b/debian/patches/features/all/rt/cond-resched-softirq-rt.patch @@ -1,7 +1,6 @@ Subject: sched: Take RT softirq semantics into account in cond_resched() From: Thomas Gleixner Date: Thu, 14 Jul 2011 09:56:44 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The softirq semantics work different on -RT. There is no SOFTIRQ_MASK in the preemption counter which leads to the BUG_ON() statement in @@ -16,7 +15,7 @@ Signed-off-by: Thomas Gleixner --- a/include/linux/sched.h +++ b/include/linux/sched.h -@@ -1625,12 +1625,16 @@ extern int __cond_resched_lock(spinlock_ +@@ -1633,12 +1633,16 @@ extern int __cond_resched_lock(spinlock_ __cond_resched_lock(lock); \ }) @@ -35,7 +34,7 @@ Signed-off-by: Thomas Gleixner { --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -5020,6 +5020,7 @@ int __cond_resched_lock(spinlock_t *lock +@@ -5021,6 +5021,7 @@ int __cond_resched_lock(spinlock_t *lock } EXPORT_SYMBOL(__cond_resched_lock); @@ -43,7 +42,7 @@ Signed-off-by: Thomas Gleixner int __sched __cond_resched_softirq(void) { BUG_ON(!in_softirq()); -@@ -5033,6 +5034,7 @@ int __sched __cond_resched_softirq(void) +@@ -5034,6 +5035,7 @@ int __sched __cond_resched_softirq(void) return 0; } EXPORT_SYMBOL(__cond_resched_softirq); diff --git a/debian/patches/features/all/rt/connector-cn_proc-Protect-send_msg-with-a-local-lock.patch b/debian/patches/features/all/rt/connector-cn_proc-Protect-send_msg-with-a-local-lock.patch index 6a6ad5a07..f91af26e9 100644 --- a/debian/patches/features/all/rt/connector-cn_proc-Protect-send_msg-with-a-local-lock.patch +++ b/debian/patches/features/all/rt/connector-cn_proc-Protect-send_msg-with-a-local-lock.patch @@ -2,7 +2,6 @@ From: Mike Galbraith Date: Sun, 16 Oct 2016 05:11:54 +0200 Subject: [PATCH] connector/cn_proc: Protect send_msg() with a local lock on RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz |BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:931 |in_atomic(): 1, irqs_disabled(): 0, pid: 31807, name: sleep diff --git a/debian/patches/features/all/rt/cpu-hotplug--Implement-CPU-pinning.patch b/debian/patches/features/all/rt/cpu-hotplug--Implement-CPU-pinning.patch index b1aa00ab4..feebdadd4 100644 --- a/debian/patches/features/all/rt/cpu-hotplug--Implement-CPU-pinning.patch +++ b/debian/patches/features/all/rt/cpu-hotplug--Implement-CPU-pinning.patch @@ -1,7 +1,6 @@ Subject: cpu/hotplug: Implement CPU pinning From: Thomas Gleixner Date: Wed, 19 Jul 2017 17:31:20 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Signed-off-by: Thomas Gleixner --- diff --git a/debian/patches/features/all/rt/cpu_chill-Add-a-UNINTERRUPTIBLE-hrtimer_nanosleep.patch b/debian/patches/features/all/rt/cpu_chill-Add-a-UNINTERRUPTIBLE-hrtimer_nanosleep.patch deleted file mode 100644 index c08f0087e..000000000 --- a/debian/patches/features/all/rt/cpu_chill-Add-a-UNINTERRUPTIBLE-hrtimer_nanosleep.patch +++ /dev/null @@ -1,103 +0,0 @@ -From: Steven Rostedt -Date: Tue, 4 Mar 2014 12:28:32 -0500 -Subject: cpu_chill: Add a UNINTERRUPTIBLE hrtimer_nanosleep -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -We hit another bug that was caused by switching cpu_chill() from -msleep() to hrtimer_nanosleep(). - -This time it is a livelock. The problem is that hrtimer_nanosleep() -calls schedule with the state == TASK_INTERRUPTIBLE. But these means -that if a signal is pending, the scheduler wont schedule, and will -simply change the current task state back to TASK_RUNNING. This -nullifies the whole point of cpu_chill() in the first place. That is, -if a task is spinning on a try_lock() and it preempted the owner of the -lock, if it has a signal pending, it will never give up the CPU to let -the owner of the lock run. - -I made a static function __hrtimer_nanosleep() that takes a fifth -parameter "state", which determines the task state of that the -nanosleep() will be in. The normal hrtimer_nanosleep() will act the -same, but cpu_chill() will call the __hrtimer_nanosleep() directly with -the TASK_UNINTERRUPTIBLE state. - -cpu_chill() only cares that the first sleep happens, and does not care -about the state of the restart schedule (in hrtimer_nanosleep_restart). - - -Reported-by: Ulrich Obergfell -Signed-off-by: Steven Rostedt -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/time/hrtimer.c | 24 +++++++++++++++++------- - 1 file changed, 17 insertions(+), 7 deletions(-) - ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -1742,12 +1742,13 @@ int nanosleep_copyout(struct restart_blo - return -ERESTART_RESTARTBLOCK; - } - --static int __sched do_nanosleep(struct hrtimer_sleeper *t, enum hrtimer_mode mode) -+static int __sched do_nanosleep(struct hrtimer_sleeper *t, enum hrtimer_mode mode, -+ unsigned long state) - { - struct restart_block *restart; - - do { -- set_current_state(TASK_INTERRUPTIBLE); -+ set_current_state(state); - hrtimer_start_expires(&t->timer, mode); - - if (likely(t->task)) -@@ -1785,13 +1786,15 @@ static long __sched hrtimer_nanosleep_re - hrtimer_init_sleeper_on_stack(&t, restart->nanosleep.clockid, - HRTIMER_MODE_ABS, current); - hrtimer_set_expires_tv64(&t.timer, restart->nanosleep.expires); -- ret = do_nanosleep(&t, HRTIMER_MODE_ABS); -+ /* cpu_chill() does not care about restart state. */ -+ ret = do_nanosleep(&t, HRTIMER_MODE_ABS, TASK_INTERRUPTIBLE); - destroy_hrtimer_on_stack(&t.timer); - return ret; - } - --long hrtimer_nanosleep(const struct timespec64 *rqtp, -- const enum hrtimer_mode mode, const clockid_t clockid) -+static long __hrtimer_nanosleep(const struct timespec64 *rqtp, -+ const enum hrtimer_mode mode, const clockid_t clockid, -+ unsigned long state) - { - struct restart_block *restart; - struct hrtimer_sleeper t; -@@ -1804,7 +1807,7 @@ long hrtimer_nanosleep(const struct time - - hrtimer_init_sleeper_on_stack(&t, clockid, mode, current); - hrtimer_set_expires_range_ns(&t.timer, timespec64_to_ktime(*rqtp), slack); -- ret = do_nanosleep(&t, mode); -+ ret = do_nanosleep(&t, mode, state); - if (ret != -ERESTART_RESTARTBLOCK) - goto out; - -@@ -1823,6 +1826,12 @@ long hrtimer_nanosleep(const struct time - return ret; - } - -+long hrtimer_nanosleep(const struct timespec64 *rqtp, -+ const enum hrtimer_mode mode, const clockid_t clockid) -+{ -+ return __hrtimer_nanosleep(rqtp, mode, clockid, TASK_INTERRUPTIBLE); -+} -+ - SYSCALL_DEFINE2(nanosleep, struct timespec __user *, rqtp, - struct timespec __user *, rmtp) - { -@@ -1870,7 +1879,8 @@ void cpu_chill(void) - unsigned int freeze_flag = current->flags & PF_NOFREEZE; - - current->flags |= PF_NOFREEZE; -- hrtimer_nanosleep(&tu, HRTIMER_MODE_REL_HARD, CLOCK_MONOTONIC); -+ __hrtimer_nanosleep(&tu, HRTIMER_MODE_REL_HARD, CLOCK_MONOTONIC, -+ TASK_UNINTERRUPTIBLE); - if (!freeze_flag) - current->flags &= ~PF_NOFREEZE; - } diff --git a/debian/patches/features/all/rt/cpufreq-drop-K8-s-driver-from-beeing-selected.patch b/debian/patches/features/all/rt/cpufreq-drop-K8-s-driver-from-beeing-selected.patch index 1f589e357..6b60722a5 100644 --- a/debian/patches/features/all/rt/cpufreq-drop-K8-s-driver-from-beeing-selected.patch +++ b/debian/patches/features/all/rt/cpufreq-drop-K8-s-driver-from-beeing-selected.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 9 Apr 2015 15:23:01 +0200 Subject: cpufreq: drop K8's driver from beeing selected -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Ralf posted a picture of a backtrace from diff --git a/debian/patches/features/all/rt/cpumask-disable-offstack-on-rt.patch b/debian/patches/features/all/rt/cpumask-disable-offstack-on-rt.patch index e1293a9bf..4bb76f0d0 100644 --- a/debian/patches/features/all/rt/cpumask-disable-offstack-on-rt.patch +++ b/debian/patches/features/all/rt/cpumask-disable-offstack-on-rt.patch @@ -1,7 +1,6 @@ Subject: cpumask: Disable CONFIG_CPUMASK_OFFSTACK for RT From: Thomas Gleixner Date: Wed, 14 Dec 2011 01:03:49 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz There are "valid" GFP_ATOMIC allocations such as diff --git a/debian/patches/features/all/rt/cpuset-Convert-callback_lock-to-raw_spinlock_t.patch b/debian/patches/features/all/rt/cpuset-Convert-callback_lock-to-raw_spinlock_t.patch index 94f16a7bd..c4c211bf4 100644 --- a/debian/patches/features/all/rt/cpuset-Convert-callback_lock-to-raw_spinlock_t.patch +++ b/debian/patches/features/all/rt/cpuset-Convert-callback_lock-to-raw_spinlock_t.patch @@ -1,7 +1,6 @@ From: Mike Galbraith Date: Sun, 8 Jan 2017 09:32:25 +0100 Subject: [PATCH] cpuset: Convert callback_lock to raw_spinlock_t -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The two commits below add up to a cpuset might_sleep() splat for RT: diff --git a/debian/patches/features/all/rt/crypto-Reduce-preempt-disabled-regions-more-algos.patch b/debian/patches/features/all/rt/crypto-Reduce-preempt-disabled-regions-more-algos.patch index f181fab7c..b48dac2e6 100644 --- a/debian/patches/features/all/rt/crypto-Reduce-preempt-disabled-regions-more-algos.patch +++ b/debian/patches/features/all/rt/crypto-Reduce-preempt-disabled-regions-more-algos.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Fri, 21 Feb 2014 17:24:04 +0100 Subject: crypto: Reduce preempt disabled regions, more algos -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Don Estabrook reported | kernel: WARNING: CPU: 2 PID: 858 at kernel/sched/core.c:2428 migrate_disable+0xed/0x100() diff --git a/debian/patches/features/all/rt/crypto-limit-more-FPU-enabled-sections.patch b/debian/patches/features/all/rt/crypto-limit-more-FPU-enabled-sections.patch index 683a0757b..561716bec 100644 --- a/debian/patches/features/all/rt/crypto-limit-more-FPU-enabled-sections.patch +++ b/debian/patches/features/all/rt/crypto-limit-more-FPU-enabled-sections.patch @@ -4,7 +4,6 @@ Subject: [PATCH] crypto: limit more FPU-enabled sections MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Those crypto drivers use SSE/AVX/… for their crypto work and in order to do so in kernel they need to enable the "FPU" in kernel mode which diff --git a/debian/patches/features/all/rt/d_delete-get-rid-of-trylock-loop.patch b/debian/patches/features/all/rt/d_delete-get-rid-of-trylock-loop.patch index 70eb85448..72bc28652 100644 --- a/debian/patches/features/all/rt/d_delete-get-rid-of-trylock-loop.patch +++ b/debian/patches/features/all/rt/d_delete-get-rid-of-trylock-loop.patch @@ -1,7 +1,6 @@ From: Al Viro Date: Fri, 23 Feb 2018 21:02:31 -0500 Subject: [PATCH] d_delete(): get rid of trylock loop -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit c19457f0aed7fae73bb40e68ffcc72f36e3966a5 diff --git a/debian/patches/features/all/rt/debugobjects-rt.patch b/debian/patches/features/all/rt/debugobjects-rt.patch index cde9ac45a..dd32133de 100644 --- a/debian/patches/features/all/rt/debugobjects-rt.patch +++ b/debian/patches/features/all/rt/debugobjects-rt.patch @@ -1,7 +1,6 @@ Subject: debugobjects: Make RT aware From: Thomas Gleixner Date: Sun, 17 Jul 2011 21:41:35 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Avoid filling the pool / allocating memory with irqs off(). diff --git a/debian/patches/features/all/rt/delayacct-use-raw_spinlocks.patch b/debian/patches/features/all/rt/delayacct-use-raw_spinlocks.patch index 753302a07..b52e5cdb0 100644 --- a/debian/patches/features/all/rt/delayacct-use-raw_spinlocks.patch +++ b/debian/patches/features/all/rt/delayacct-use-raw_spinlocks.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Sat, 20 May 2017 12:32:23 +0200 Subject: [PATCH] delayacct: use raw_spinlocks -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz upstream commit 02acc80d19edb0d5684c997b2004ad19f9f5236e diff --git a/debian/patches/features/all/rt/dm-make-rt-aware.patch b/debian/patches/features/all/rt/dm-make-rt-aware.patch deleted file mode 100644 index 4b0c2297a..000000000 --- a/debian/patches/features/all/rt/dm-make-rt-aware.patch +++ /dev/null @@ -1,27 +0,0 @@ -Subject: dm: Make rt aware -From: Thomas Gleixner -Date: Mon, 14 Nov 2011 23:06:09 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Use the BUG_ON_NORT variant for the irq_disabled() checks. RT has -interrupts legitimately enabled here as we cant deadlock against the -irq thread due to the "sleeping spinlocks" conversion. - -Reported-by: Luis Claudio R. Goncalves - -Signed-off-by: Thomas Gleixner ---- - drivers/md/dm-rq.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/drivers/md/dm-rq.c -+++ b/drivers/md/dm-rq.c -@@ -671,7 +671,7 @@ static void dm_old_request_fn(struct req - /* Establish tio->ti before queuing work (map_tio_request) */ - tio->ti = ti; - kthread_queue_work(&md->kworker, &tio->work); -- BUG_ON(!irqs_disabled()); -+ BUG_ON_NONRT(!irqs_disabled()); - } - } - diff --git a/debian/patches/features/all/rt/dm-rq-remove-BUG_ON-irqs_disabled-check.patch b/debian/patches/features/all/rt/dm-rq-remove-BUG_ON-irqs_disabled-check.patch index 7f81f94ea..c962ab317 100644 --- a/debian/patches/features/all/rt/dm-rq-remove-BUG_ON-irqs_disabled-check.patch +++ b/debian/patches/features/all/rt/dm-rq-remove-BUG_ON-irqs_disabled-check.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Tue, 27 Mar 2018 16:24:15 +0200 Subject: [PATCH] dm rq: remove BUG_ON(!irqs_disabled) check -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz In commit 052189a2ec95 ("dm: remove superfluous irq disablement in dm_request_fn") the spin_lock_irq() was replaced with spin_lock() + a diff --git a/debian/patches/features/all/rt/drivers-block-zram-Replace-bit-spinlocks-with-rtmute.patch b/debian/patches/features/all/rt/drivers-block-zram-Replace-bit-spinlocks-with-rtmute.patch index e72d55324..6006419d1 100644 --- a/debian/patches/features/all/rt/drivers-block-zram-Replace-bit-spinlocks-with-rtmute.patch +++ b/debian/patches/features/all/rt/drivers-block-zram-Replace-bit-spinlocks-with-rtmute.patch @@ -2,7 +2,6 @@ From: Mike Galbraith Date: Thu, 31 Mar 2016 04:08:28 +0200 Subject: [PATCH] drivers/block/zram: Replace bit spinlocks with rtmutex for -rt -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz They're nondeterministic, and lead to ___might_sleep() splats in -rt. OTOH, they're a lot less wasteful than an rtmutex per page. diff --git a/debian/patches/features/all/rt/drivers-net-vortex-fix-locking-issues.patch b/debian/patches/features/all/rt/drivers-net-vortex-fix-locking-issues.patch deleted file mode 100644 index 5d4f07012..000000000 --- a/debian/patches/features/all/rt/drivers-net-vortex-fix-locking-issues.patch +++ /dev/null @@ -1,49 +0,0 @@ -From: Steven Rostedt -Date: Fri, 3 Jul 2009 08:30:00 -0500 -Subject: drivers/net: vortex fix locking issues -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Argh, cut and paste wasn't enough... - -Use this patch instead. It needs an irq disable. But, believe it or not, -on SMP this is actually better. If the irq is shared (as it is in Mark's -case), we don't stop the irq of other devices from being handled on -another CPU (unfortunately for Mark, he pinned all interrupts to one CPU). - -Signed-off-by: Steven Rostedt -Signed-off-by: Thomas Gleixner - - drivers/net/ethernet/3com/3c59x.c | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - -Signed-off-by: Ingo Molnar - ---- a/drivers/net/ethernet/3com/3c59x.c -+++ b/drivers/net/ethernet/3com/3c59x.c -@@ -842,9 +842,9 @@ static void poll_vortex(struct net_devic - { - struct vortex_private *vp = netdev_priv(dev); - unsigned long flags; -- local_irq_save(flags); -+ local_irq_save_nort(flags); - (vp->full_bus_master_rx ? boomerang_interrupt:vortex_interrupt)(dev->irq,dev); -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - } - #endif - -@@ -1908,12 +1908,12 @@ static void vortex_tx_timeout(struct net - * Block interrupts because vortex_interrupt does a bare spin_lock() - */ - unsigned long flags; -- local_irq_save(flags); -+ local_irq_save_nort(flags); - if (vp->full_bus_master_tx) - boomerang_interrupt(dev->irq, dev); - else - vortex_interrupt(dev->irq, dev); -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - } - } - diff --git a/debian/patches/features/all/rt/drivers-random-reduce-preempt-disabled-region.patch b/debian/patches/features/all/rt/drivers-random-reduce-preempt-disabled-region.patch index 473498d82..292520e56 100644 --- a/debian/patches/features/all/rt/drivers-random-reduce-preempt-disabled-region.patch +++ b/debian/patches/features/all/rt/drivers-random-reduce-preempt-disabled-region.patch @@ -1,7 +1,6 @@ From: Ingo Molnar Date: Fri, 3 Jul 2009 08:29:30 -0500 Subject: drivers: random: Reduce preempt disabled region -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz No need to keep preemption disabled across the whole function. diff --git a/debian/patches/features/all/rt/drivers-tty-fix-omap-lock-crap.patch b/debian/patches/features/all/rt/drivers-tty-fix-omap-lock-crap.patch index 94145e544..f70e9198d 100644 --- a/debian/patches/features/all/rt/drivers-tty-fix-omap-lock-crap.patch +++ b/debian/patches/features/all/rt/drivers-tty-fix-omap-lock-crap.patch @@ -1,7 +1,6 @@ Subject: tty/serial/omap: Make the locking RT aware From: Thomas Gleixner Date: Thu, 28 Jul 2011 13:32:57 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The lock is a sleeping lock and local_irq_save() is not the optimsation we are looking for. Redo it to make it work on -RT and diff --git a/debian/patches/features/all/rt/drivers-tty-pl011-irq-disable-madness.patch b/debian/patches/features/all/rt/drivers-tty-pl011-irq-disable-madness.patch index 2daf46a14..ee04d95c6 100644 --- a/debian/patches/features/all/rt/drivers-tty-pl011-irq-disable-madness.patch +++ b/debian/patches/features/all/rt/drivers-tty-pl011-irq-disable-madness.patch @@ -1,7 +1,6 @@ Subject: tty/serial/pl011: Make the locking work on RT From: Thomas Gleixner Date: Tue, 08 Jan 2013 21:36:51 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The lock is a sleeping lock and local_irq_save() is not the optimsation we are looking for. Redo it to make it work on -RT and non-RT. diff --git a/debian/patches/features/all/rt/drivers-zram-Don-t-disable-preemption-in-zcomp_strea.patch b/debian/patches/features/all/rt/drivers-zram-Don-t-disable-preemption-in-zcomp_strea.patch index 11a501370..a5679db8b 100644 --- a/debian/patches/features/all/rt/drivers-zram-Don-t-disable-preemption-in-zcomp_strea.patch +++ b/debian/patches/features/all/rt/drivers-zram-Don-t-disable-preemption-in-zcomp_strea.patch @@ -2,7 +2,6 @@ From: Mike Galbraith Date: Thu, 20 Oct 2016 11:15:22 +0200 Subject: [PATCH] drivers/zram: Don't disable preemption in zcomp_stream_get/put() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz In v4.7, the driver switched to percpu compression streams, disabling preemption via get/put_cpu_ptr(). Use a per-zcomp_strm lock here. We diff --git a/debian/patches/features/all/rt/drivers-zram-fix-zcomp_stream_get-smp_processor_id-u.patch b/debian/patches/features/all/rt/drivers-zram-fix-zcomp_stream_get-smp_processor_id-u.patch index 23734f74b..fde000b05 100644 --- a/debian/patches/features/all/rt/drivers-zram-fix-zcomp_stream_get-smp_processor_id-u.patch +++ b/debian/patches/features/all/rt/drivers-zram-fix-zcomp_stream_get-smp_processor_id-u.patch @@ -2,7 +2,6 @@ From: Mike Galbraith Date: Wed, 23 Aug 2017 11:57:29 +0200 Subject: [PATCH] drivers/zram: fix zcomp_stream_get() smp_processor_id() use in preemptible code -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Use get_local_ptr() instead this_cpu_ptr() to avoid a warning regarding smp_processor_id() in preemptible code. diff --git a/debian/patches/features/all/rt/drm-i915-properly-init-lockdep-class.patch b/debian/patches/features/all/rt/drm-i915-properly-init-lockdep-class.patch deleted file mode 100644 index 790ccb5ea..000000000 --- a/debian/patches/features/all/rt/drm-i915-properly-init-lockdep-class.patch +++ /dev/null @@ -1,32 +0,0 @@ -From: Sebastian Andrzej Siewior -Date: Thu, 30 Nov 2017 16:06:13 +0100 -Subject: [PATCH] drm/i915: properly init lockdep class -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The code has an ifdef and uses two functions to either init the bare -spinlock or init it and set a lock-class. It is possible to do the same -thing without an ifdef. -With this patch (in debug case) we first use the "default" lock class -which is later overwritten to the supplied one. Without lockdep the set -name/class function vanishes. - -Signed-off-by: Sebastian Andrzej Siewior ---- - drivers/gpu/drm/i915/i915_gem_timeline.c | 5 +---- - 1 file changed, 1 insertion(+), 4 deletions(-) - ---- a/drivers/gpu/drm/i915/i915_gem_timeline.c -+++ b/drivers/gpu/drm/i915/i915_gem_timeline.c -@@ -33,11 +33,8 @@ static void __intel_timeline_init(struct - { - tl->fence_context = context; - tl->common = parent; --#ifdef CONFIG_DEBUG_SPINLOCK -- __raw_spin_lock_init(&tl->lock.rlock, lockname, lockclass); --#else - spin_lock_init(&tl->lock); --#endif -+ lockdep_set_class_and_name(&tl->lock, lockclass, lockname); - init_request_active(&tl->last_request, NULL); - INIT_LIST_HEAD(&tl->requests); - i915_syncmap_init(&tl->sync); diff --git a/debian/patches/features/all/rt/drmi915_Use_local_lockunlock_irq()_in_intel_pipe_update_startend().patch b/debian/patches/features/all/rt/drmi915_Use_local_lockunlock_irq()_in_intel_pipe_update_startend().patch index f4b0ede67..3434899bc 100644 --- a/debian/patches/features/all/rt/drmi915_Use_local_lockunlock_irq()_in_intel_pipe_update_startend().patch +++ b/debian/patches/features/all/rt/drmi915_Use_local_lockunlock_irq()_in_intel_pipe_update_startend().patch @@ -1,7 +1,6 @@ Subject: drm,i915: Use local_lock/unlock_irq() in intel_pipe_update_start/end() From: Mike Galbraith Date: Sat, 27 Feb 2016 09:01:42 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz [ 8.014039] BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:918 diff --git a/debian/patches/features/all/rt/drmradeoni915_Use_preempt_disableenable_rt()_where_recommended.patch b/debian/patches/features/all/rt/drmradeoni915_Use_preempt_disableenable_rt()_where_recommended.patch index 37fdbc5d5..077850622 100644 --- a/debian/patches/features/all/rt/drmradeoni915_Use_preempt_disableenable_rt()_where_recommended.patch +++ b/debian/patches/features/all/rt/drmradeoni915_Use_preempt_disableenable_rt()_where_recommended.patch @@ -1,7 +1,6 @@ Subject: drm,radeon,i915: Use preempt_disable/enable_rt() where recommended From: Mike Galbraith Date: Sat, 27 Feb 2016 08:09:11 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz DRM folks identified the spots, so use them. diff --git a/debian/patches/features/all/rt/epoll-use-get-cpu-light.patch b/debian/patches/features/all/rt/epoll-use-get-cpu-light.patch index 2b6dfab12..d7c97ec10 100644 --- a/debian/patches/features/all/rt/epoll-use-get-cpu-light.patch +++ b/debian/patches/features/all/rt/epoll-use-get-cpu-light.patch @@ -1,7 +1,6 @@ Subject: fs/epoll: Do not disable preemption on RT From: Thomas Gleixner Date: Fri, 08 Jul 2011 16:35:35 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz ep_call_nested() takes a sleeping lock so we can't disable preemption. The light version is enough since ep_call_nested() doesn't mind beeing diff --git a/debian/patches/features/all/rt/fs-aio-simple-simple-work.patch b/debian/patches/features/all/rt/fs-aio-simple-simple-work.patch index e769cb893..671f2032b 100644 --- a/debian/patches/features/all/rt/fs-aio-simple-simple-work.patch +++ b/debian/patches/features/all/rt/fs-aio-simple-simple-work.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Mon, 16 Feb 2015 18:49:10 +0100 Subject: fs/aio: simple simple work -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz |BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:768 |in_atomic(): 1, irqs_disabled(): 0, pid: 26, name: rcuos/2 diff --git a/debian/patches/features/all/rt/fs-block-rt-support.patch b/debian/patches/features/all/rt/fs-block-rt-support.patch deleted file mode 100644 index fdc54c170..000000000 --- a/debian/patches/features/all/rt/fs-block-rt-support.patch +++ /dev/null @@ -1,23 +0,0 @@ -Subject: block: Turn off warning which is bogus on RT -From: Thomas Gleixner -Date: Tue, 14 Jun 2011 17:05:09 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -On -RT the context is always with IRQs enabled. Ignore this warning on -RT. - -Signed-off-by: Thomas Gleixner ---- - block/blk-core.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/block/blk-core.c -+++ b/block/blk-core.c -@@ -280,7 +280,7 @@ EXPORT_SYMBOL(blk_start_queue_async); - void blk_start_queue(struct request_queue *q) - { - lockdep_assert_held(q->queue_lock); -- WARN_ON(!in_interrupt() && !irqs_disabled()); -+ WARN_ON_NONRT(!in_interrupt() && !irqs_disabled()); - WARN_ON_ONCE(q->mq_ops); - - queue_flag_clear(QUEUE_FLAG_STOPPED, q); diff --git a/debian/patches/features/all/rt/fs-dcache-Move-dentry_kill-below-lock_parent.patch b/debian/patches/features/all/rt/fs-dcache-Move-dentry_kill-below-lock_parent.patch index fa1084ceb..227780988 100644 --- a/debian/patches/features/all/rt/fs-dcache-Move-dentry_kill-below-lock_parent.patch +++ b/debian/patches/features/all/rt/fs-dcache-Move-dentry_kill-below-lock_parent.patch @@ -1,7 +1,6 @@ From: John Ogness Date: Fri, 23 Feb 2018 00:50:21 +0100 Subject: [PATCH] fs/dcache: Move dentry_kill() below lock_parent() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit c1d0c1a2b51e86124b7ba8ff9054698e2036d8e7 diff --git a/debian/patches/features/all/rt/fs-dcache-Remove-stale-comment-from-dentry_kill.patch b/debian/patches/features/all/rt/fs-dcache-Remove-stale-comment-from-dentry_kill.patch index 5da07ad6e..dda90d71d 100644 --- a/debian/patches/features/all/rt/fs-dcache-Remove-stale-comment-from-dentry_kill.patch +++ b/debian/patches/features/all/rt/fs-dcache-Remove-stale-comment-from-dentry_kill.patch @@ -1,7 +1,6 @@ From: John Ogness Date: Fri, 23 Feb 2018 00:50:20 +0100 Subject: [PATCH] fs/dcache: Remove stale comment from dentry_kill() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 06080d100d921848b35196850ec17310469e06ba diff --git a/debian/patches/features/all/rt/fs-dcache-bring-back-explicit-INIT_HLIST_BL_HEAD-in.patch b/debian/patches/features/all/rt/fs-dcache-bring-back-explicit-INIT_HLIST_BL_HEAD-in.patch index 98e400434..fce968e0a 100644 --- a/debian/patches/features/all/rt/fs-dcache-bring-back-explicit-INIT_HLIST_BL_HEAD-in.patch +++ b/debian/patches/features/all/rt/fs-dcache-bring-back-explicit-INIT_HLIST_BL_HEAD-in.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 13 Sep 2017 12:32:34 +0200 Subject: [PATCH] fs/dcache: bring back explicit INIT_HLIST_BL_HEAD init -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Commit 3d375d78593c ("mm: update callers to use HASH_ZERO flag") removed INIT_HLIST_BL_HEAD and uses the ZERO flag instead for the init. However diff --git a/debian/patches/features/all/rt/fs-dcache-bringt-back-explicit-INIT_HLIST_BL_HEAD-in.patch b/debian/patches/features/all/rt/fs-dcache-bringt-back-explicit-INIT_HLIST_BL_HEAD-in.patch deleted file mode 100644 index b5470bdee..000000000 --- a/debian/patches/features/all/rt/fs-dcache-bringt-back-explicit-INIT_HLIST_BL_HEAD-in.patch +++ /dev/null @@ -1,52 +0,0 @@ -From: Sebastian Andrzej Siewior -Date: Wed, 13 Sep 2017 12:32:34 +0200 -Subject: [PATCH] fs/dcache: bringt back explicit INIT_HLIST_BL_HEAD init -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Commit 3d375d78593c ("mm: update callers to use HASH_ZERO flag") removed -INIT_HLIST_BL_HEAD and uses the ZERO flag instead for the init. However -on RT we have also a spinlock which needs an init call so we can't use -that. - -Signed-off-by: Sebastian Andrzej Siewior ---- - fs/dcache.c | 10 ++++++++++ - 1 file changed, 10 insertions(+) - ---- a/fs/dcache.c -+++ b/fs/dcache.c -@@ -3578,6 +3578,8 @@ static int __init set_dhash_entries(char - - static void __init dcache_init_early(void) - { -+ unsigned int loop; -+ - /* If hashes are distributed across NUMA nodes, defer - * hash allocation until vmalloc space is available. - */ -@@ -3594,10 +3596,14 @@ static void __init dcache_init_early(voi - &d_hash_mask, - 0, - 0); -+ -+ for (loop = 0; loop < (1U << d_hash_shift); loop++) -+ INIT_HLIST_BL_HEAD(dentry_hashtable + loop); - } - - static void __init dcache_init(void) - { -+ unsigned int loop; - /* - * A constructor could be added for stable state like the lists, - * but it is probably not worth it because of the cache nature -@@ -3620,6 +3626,10 @@ static void __init dcache_init(void) - &d_hash_mask, - 0, - 0); -+ -+ for (loop = 0; loop < (1U << d_hash_shift); loop++) -+ INIT_HLIST_BL_HEAD(dentry_hashtable + loop); -+ - } - - /* SLAB cache for __getname() consumers */ diff --git a/debian/patches/features/all/rt/fs-dcache-disable-preemption-on-i_dir_seq-s-write-si.patch b/debian/patches/features/all/rt/fs-dcache-disable-preemption-on-i_dir_seq-s-write-si.patch index bde64cded..645c3a4e4 100644 --- a/debian/patches/features/all/rt/fs-dcache-disable-preemption-on-i_dir_seq-s-write-si.patch +++ b/debian/patches/features/all/rt/fs-dcache-disable-preemption-on-i_dir_seq-s-write-si.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Fri, 20 Oct 2017 11:29:53 +0200 Subject: [PATCH] fs/dcache: disable preemption on i_dir_seq's write side -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz i_dir_seq is an opencoded seqcounter. Based on the code it looks like we could have two writers in parallel despite the fact that the d_lock is diff --git a/debian/patches/features/all/rt/fs-dcache-use-cpu-chill-in-trylock-loops.patch b/debian/patches/features/all/rt/fs-dcache-use-cpu-chill-in-trylock-loops.patch index 640c780aa..fbbe12140 100644 --- a/debian/patches/features/all/rt/fs-dcache-use-cpu-chill-in-trylock-loops.patch +++ b/debian/patches/features/all/rt/fs-dcache-use-cpu-chill-in-trylock-loops.patch @@ -1,7 +1,6 @@ Subject: fs: dcache: Use cpu_chill() in trylock loops From: Thomas Gleixner Date: Wed, 07 Mar 2012 21:00:34 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Retry loops on RT might loop forever when the modifying side was preempted. Use cpu_chill() instead of cpu_relax() to let the system diff --git a/debian/patches/features/all/rt/fs-dcache-use-swait_queue-instead-of-waitqueue.patch b/debian/patches/features/all/rt/fs-dcache-use-swait_queue-instead-of-waitqueue.patch index 6e95e6853..f30fcc7c6 100644 --- a/debian/patches/features/all/rt/fs-dcache-use-swait_queue-instead-of-waitqueue.patch +++ b/debian/patches/features/all/rt/fs-dcache-use-swait_queue-instead-of-waitqueue.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 14 Sep 2016 14:35:49 +0200 Subject: [PATCH] fs/dcache: use swait_queue instead of waitqueue -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz __d_lookup_done() invokes wake_up_all() while holding a hlist_bl_lock() which disables preemption. As a workaround convert it to swait. diff --git a/debian/patches/features/all/rt/fs-jbd-replace-bh_state-lock.patch b/debian/patches/features/all/rt/fs-jbd-replace-bh_state-lock.patch index 202baffa2..a56bc6909 100644 --- a/debian/patches/features/all/rt/fs-jbd-replace-bh_state-lock.patch +++ b/debian/patches/features/all/rt/fs-jbd-replace-bh_state-lock.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Fri, 18 Mar 2011 10:11:25 +0100 Subject: fs: jbd/jbd2: Make state lock and journal head lock rt safe -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz bit_spin_locks break under RT. diff --git a/debian/patches/features/all/rt/fs-jbd2-pull-your-plug-when-waiting-for-space.patch b/debian/patches/features/all/rt/fs-jbd2-pull-your-plug-when-waiting-for-space.patch deleted file mode 100644 index 1bfe2b578..000000000 --- a/debian/patches/features/all/rt/fs-jbd2-pull-your-plug-when-waiting-for-space.patch +++ /dev/null @@ -1,32 +0,0 @@ -From: Sebastian Andrzej Siewior -Date: Mon, 17 Feb 2014 17:30:03 +0100 -Subject: fs: jbd2: pull your plug when waiting for space -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Two cps in parallel managed to stall the the ext4 fs. It seems that -journal code is either waiting for locks or sleeping waiting for -something to happen. This seems similar to what Mike observed on ext3, -here is his description: - -|With an -rt kernel, and a heavy sync IO load, tasks can jam -|up on journal locks without unplugging, which can lead to -|terminal IO starvation. Unplug and schedule when waiting -|for space. - - -Signed-off-by: Sebastian Andrzej Siewior ---- - fs/jbd2/checkpoint.c | 2 ++ - 1 file changed, 2 insertions(+) - ---- a/fs/jbd2/checkpoint.c -+++ b/fs/jbd2/checkpoint.c -@@ -116,6 +116,8 @@ void __jbd2_log_wait_for_space(journal_t - nblocks = jbd2_space_needed(journal); - while (jbd2_log_space_left(journal) < nblocks) { - write_unlock(&journal->j_state_lock); -+ if (current->plug) -+ io_schedule(); - mutex_lock(&journal->j_checkpoint_mutex); - - /* diff --git a/debian/patches/features/all/rt/fs-namespace-preemption-fix.patch b/debian/patches/features/all/rt/fs-namespace-preemption-fix.patch index 5500e0cc1..073038866 100644 --- a/debian/patches/features/all/rt/fs-namespace-preemption-fix.patch +++ b/debian/patches/features/all/rt/fs-namespace-preemption-fix.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Sun, 19 Jul 2009 08:44:27 -0500 Subject: fs: namespace preemption fix -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz On RT we cannot loop with preemption disabled here as mnt_make_readonly() might have been preempted. We can safely enable diff --git a/debian/patches/features/all/rt/fs-nfs-turn-rmdir_sem-into-a-semaphore.patch b/debian/patches/features/all/rt/fs-nfs-turn-rmdir_sem-into-a-semaphore.patch index 881afe8e9..9eb63d4aa 100644 --- a/debian/patches/features/all/rt/fs-nfs-turn-rmdir_sem-into-a-semaphore.patch +++ b/debian/patches/features/all/rt/fs-nfs-turn-rmdir_sem-into-a-semaphore.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 15 Sep 2016 10:51:27 +0200 Subject: [PATCH] fs/nfs: turn rmdir_sem into a semaphore -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The RW semaphore had a reader side which used the _non_owner version because it most likely took the reader lock in one thread and released it diff --git a/debian/patches/features/all/rt/fs-ntfs-disable-interrupt-non-rt.patch b/debian/patches/features/all/rt/fs-ntfs-disable-interrupt-non-rt.patch deleted file mode 100644 index 7d39ebfc1..000000000 --- a/debian/patches/features/all/rt/fs-ntfs-disable-interrupt-non-rt.patch +++ /dev/null @@ -1,76 +0,0 @@ -From: Mike Galbraith -Date: Fri, 3 Jul 2009 08:44:12 -0500 -Subject: fs: ntfs: disable interrupt only on !RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -On Sat, 2007-10-27 at 11:44 +0200, Ingo Molnar wrote: -> * Nick Piggin wrote: -> -> > > [10138.175796] [] show_trace+0x12/0x14 -> > > [10138.180291] [] dump_stack+0x16/0x18 -> > > [10138.184769] [] native_smp_call_function_mask+0x138/0x13d -> > > [10138.191117] [] smp_call_function+0x1e/0x24 -> > > [10138.196210] [] on_each_cpu+0x25/0x50 -> > > [10138.200807] [] flush_tlb_all+0x1e/0x20 -> > > [10138.205553] [] kmap_high+0x1b6/0x417 -> > > [10138.210118] [] kmap+0x4d/0x4f -> > > [10138.214102] [] ntfs_end_buffer_async_read+0x228/0x2f9 -> > > [10138.220163] [] end_bio_bh_io_sync+0x26/0x3f -> > > [10138.225352] [] bio_endio+0x42/0x6d -> > > [10138.229769] [] __end_that_request_first+0x115/0x4ac -> > > [10138.235682] [] end_that_request_chunk+0x8/0xa -> > > [10138.241052] [] ide_end_request+0x55/0x10a -> > > [10138.246058] [] ide_dma_intr+0x6f/0xac -> > > [10138.250727] [] ide_intr+0x93/0x1e0 -> > > [10138.255125] [] handle_IRQ_event+0x5c/0xc9 -> > -> > Looks like ntfs is kmap()ing from interrupt context. Should be using -> > kmap_atomic instead, I think. -> -> it's not atomic interrupt context but irq thread context - and -rt -> remaps kmap_atomic() to kmap() internally. - -Hm. Looking at the change to mm/bounce.c, perhaps I should do this -instead? - -Signed-off-by: Ingo Molnar -Signed-off-by: Thomas Gleixner - ---- - fs/ntfs/aops.c | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - ---- a/fs/ntfs/aops.c -+++ b/fs/ntfs/aops.c -@@ -93,13 +93,13 @@ static void ntfs_end_buffer_async_read(s - ofs = 0; - if (file_ofs < init_size) - ofs = init_size - file_ofs; -- local_irq_save(flags); -+ local_irq_save_nort(flags); - kaddr = kmap_atomic(page); - memset(kaddr + bh_offset(bh) + ofs, 0, - bh->b_size - ofs); - flush_dcache_page(page); - kunmap_atomic(kaddr); -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - } - } else { - clear_buffer_uptodate(bh); -@@ -144,13 +144,13 @@ static void ntfs_end_buffer_async_read(s - recs = PAGE_SIZE / rec_size; - /* Should have been verified before we got here... */ - BUG_ON(!recs); -- local_irq_save(flags); -+ local_irq_save_nort(flags); - kaddr = kmap_atomic(page); - for (i = 0; i < recs; i++) - post_read_mst_fixup((NTFS_RECORD*)(kaddr + - i * rec_size), rec_size); - kunmap_atomic(kaddr); -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - flush_dcache_page(page); - if (likely(page_uptodate && !PageError(page))) - SetPageUptodate(page); diff --git a/debian/patches/features/all/rt/fs-replace-bh_uptodate_lock-for-rt.patch b/debian/patches/features/all/rt/fs-replace-bh_uptodate_lock-for-rt.patch index 5c818350c..b9f24db4f 100644 --- a/debian/patches/features/all/rt/fs-replace-bh_uptodate_lock-for-rt.patch +++ b/debian/patches/features/all/rt/fs-replace-bh_uptodate_lock-for-rt.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Fri, 18 Mar 2011 09:18:52 +0100 Subject: buffer_head: Replace bh_uptodate_lock for -rt -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Wrap the bit_spin_lock calls into a separate inline and add the RT replacements with a real spinlock. diff --git a/debian/patches/features/all/rt/ftrace-Fix-trace-header-alignment.patch b/debian/patches/features/all/rt/ftrace-Fix-trace-header-alignment.patch index ea030e982..656a5b60c 100644 --- a/debian/patches/features/all/rt/ftrace-Fix-trace-header-alignment.patch +++ b/debian/patches/features/all/rt/ftrace-Fix-trace-header-alignment.patch @@ -1,7 +1,6 @@ From: Mike Galbraith Date: Sun, 16 Oct 2016 05:08:30 +0200 Subject: [PATCH] ftrace: Fix trace header alignment -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Line up helper arrows to the right column. diff --git a/debian/patches/features/all/rt/ftrace-migrate-disable-tracing.patch b/debian/patches/features/all/rt/ftrace-migrate-disable-tracing.patch index 49d311ac3..960656129 100644 --- a/debian/patches/features/all/rt/ftrace-migrate-disable-tracing.patch +++ b/debian/patches/features/all/rt/ftrace-migrate-disable-tracing.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Sun, 17 Jul 2011 21:56:42 +0200 Subject: trace: Add migrate-disabled counter to tracing output -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Signed-off-by: Thomas Gleixner --- diff --git a/debian/patches/features/all/rt/futex-Ensure-lock-unlock-symetry-versus-pi_lock-and-.patch b/debian/patches/features/all/rt/futex-Ensure-lock-unlock-symetry-versus-pi_lock-and-.patch index 53d51fa94..af6fd47d7 100644 --- a/debian/patches/features/all/rt/futex-Ensure-lock-unlock-symetry-versus-pi_lock-and-.patch +++ b/debian/patches/features/all/rt/futex-Ensure-lock-unlock-symetry-versus-pi_lock-and-.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Fri, 1 Mar 2013 11:17:42 +0100 Subject: futex: Ensure lock/unlock symetry versus pi_lock and hash bucket lock -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz In exit_pi_state_list() we have the following locking construct: diff --git a/debian/patches/features/all/rt/futex-requeue-pi-fix.patch b/debian/patches/features/all/rt/futex-requeue-pi-fix.patch index cd23e9d65..85cd319cb 100644 --- a/debian/patches/features/all/rt/futex-requeue-pi-fix.patch +++ b/debian/patches/features/all/rt/futex-requeue-pi-fix.patch @@ -1,7 +1,6 @@ From: Steven Rostedt Date: Tue, 14 Jul 2015 14:26:34 +0200 Subject: futex: Fix bug on when a requeued RT task times out -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Requeue with timeout causes a bug with PREEMPT_RT_FULL. diff --git a/debian/patches/features/all/rt/futex-workaround-migrate_disable-enable-in-different.patch b/debian/patches/features/all/rt/futex-workaround-migrate_disable-enable-in-different.patch index e89974c9b..2bc6412a7 100644 --- a/debian/patches/features/all/rt/futex-workaround-migrate_disable-enable-in-different.patch +++ b/debian/patches/features/all/rt/futex-workaround-migrate_disable-enable-in-different.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Wed, 8 Mar 2017 14:23:35 +0100 Subject: [PATCH] futex: workaround migrate_disable/enable in different context -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz migrate_disable()/migrate_enable() takes a different path in atomic() vs !atomic() context. These little hacks ensure that we don't underflow / overflow diff --git a/debian/patches/features/all/rt/genirq-disable-irqpoll-on-rt.patch b/debian/patches/features/all/rt/genirq-disable-irqpoll-on-rt.patch index a220b29f8..9aa92515d 100644 --- a/debian/patches/features/all/rt/genirq-disable-irqpoll-on-rt.patch +++ b/debian/patches/features/all/rt/genirq-disable-irqpoll-on-rt.patch @@ -1,7 +1,6 @@ From: Ingo Molnar Date: Fri, 3 Jul 2009 08:29:57 -0500 Subject: genirq: Disable irqpoll on -rt -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Creates long latencies for no value diff --git a/debian/patches/features/all/rt/genirq-do-not-invoke-the-affinity-callback-via-a-wor.patch b/debian/patches/features/all/rt/genirq-do-not-invoke-the-affinity-callback-via-a-wor.patch index 57123a041..4e4a2a2d2 100644 --- a/debian/patches/features/all/rt/genirq-do-not-invoke-the-affinity-callback-via-a-wor.patch +++ b/debian/patches/features/all/rt/genirq-do-not-invoke-the-affinity-callback-via-a-wor.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 21 Aug 2013 17:48:46 +0200 Subject: genirq: Do not invoke the affinity callback via a workqueue on RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Joe Korty reported, that __irq_set_affinity_locked() schedules a workqueue while holding a rawlock which results in a might_sleep() diff --git a/debian/patches/features/all/rt/genirq-force-threading.patch b/debian/patches/features/all/rt/genirq-force-threading.patch index ea5153e2d..a4322f281 100644 --- a/debian/patches/features/all/rt/genirq-force-threading.patch +++ b/debian/patches/features/all/rt/genirq-force-threading.patch @@ -1,7 +1,6 @@ Subject: genirq: Force interrupt thread on RT From: Thomas Gleixner Date: Sun, 03 Apr 2011 11:57:29 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Force threaded_irqs and optimize the code (force_irqthreads) in regard to this. diff --git a/debian/patches/features/all/rt/genirq-update-irq_set_irqchip_state-documentation.patch b/debian/patches/features/all/rt/genirq-update-irq_set_irqchip_state-documentation.patch index 520d06858..9f720bd56 100644 --- a/debian/patches/features/all/rt/genirq-update-irq_set_irqchip_state-documentation.patch +++ b/debian/patches/features/all/rt/genirq-update-irq_set_irqchip_state-documentation.patch @@ -1,7 +1,6 @@ From: Josh Cartwright Date: Thu, 11 Feb 2016 11:54:00 -0600 Subject: genirq: update irq_set_irqchip_state documentation -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz On -rt kernels, the use of migrate_disable()/migrate_enable() is sufficient to guarantee a task isn't moved to another CPU. Update the diff --git a/debian/patches/features/all/rt/genpatch.py b/debian/patches/features/all/rt/genpatch.py deleted file mode 100755 index eb3792d35..000000000 --- a/debian/patches/features/all/rt/genpatch.py +++ /dev/null @@ -1,139 +0,0 @@ -#!/usr/bin/python3 - -import codecs, errno, io, os, os.path, re, shutil, subprocess, sys, tempfile - -def main(source, version=None): - patch_dir = 'debian/patches' - rt_patch_dir = 'features/all/rt' - series_name = 'series-rt' - old_series = set() - new_series = set() - - try: - with open(os.path.join(patch_dir, series_name), 'r') as series_fh: - for line in series_fh: - name = line.strip() - if name != '' and name[0] != '#': - old_series.add(name) - except FileNotFoundError: - pass - - with open(os.path.join(patch_dir, series_name), 'w') as series_fh: - # Add directory prefix to all filenames. - # Add Origin to all patch headers. - def add_patch(name, source_patch, origin): - name = os.path.join(rt_patch_dir, name) - path = os.path.join(patch_dir, name) - try: - os.unlink(path) - except FileNotFoundError: - pass - with open(path, 'w') as patch: - in_header = True - for line in source_patch: - if in_header and re.match(r'^(\n|[^\w\s]|Index:)', line): - patch.write('Origin: %s\n' % origin) - if line != '\n': - patch.write('\n') - in_header = False - patch.write(line) - series_fh.write(name) - series_fh.write('\n') - new_series.add(name) - - if os.path.isdir(os.path.join(source, '.git')): - # Export rebased branch from stable-rt git as patch series - up_ver = re.sub(r'-rt\d+$', '', version) - env = os.environ.copy() - env['GIT_DIR'] = os.path.join(source, '.git') - env['DEBIAN_KERNEL_KEYRING'] = 'rt-signing-key.pgp' - - # Validate tag signature - gpg_wrapper = os.path.join(os.getcwd(), - "debian/bin/git-tag-gpg-wrapper") - verify_proc = subprocess.Popen(['git', - '-c', 'gpg.program=%s' % gpg_wrapper, - 'tag', '-v', 'v%s-rebase' % version], - env=env) - if verify_proc.wait(): - raise RuntimeError("GPG tag verification failed") - - args = ['git', 'format-patch', 'v%s..v%s-rebase' % (up_ver, version)] - format_proc = subprocess.Popen(args, - cwd=os.path.join(patch_dir, rt_patch_dir), - env=env, stdout=subprocess.PIPE) - with io.open(format_proc.stdout.fileno(), encoding='utf-8') as pipe: - for line in pipe: - name = line.strip('\n') - with open(os.path.join(patch_dir, rt_patch_dir, name)) as \ - source_patch: - patch_from = source_patch.readline() - match = re.match(r'From ([0-9a-f]{40}) ', patch_from) - assert match - origin = 'https://git.kernel.org/cgit/linux/kernel/git/rt/linux-stable-rt.git/commit?id=%s' % match.group(1) - add_patch(name, source_patch, origin) - - else: - # Get version and upstream version - if version is None: - match = re.search(r'(?:^|/)patches-(.+)\.tar\.[gx]z$', source) - assert match, 'no version specified or found in filename' - version = match.group(1) - match = re.match(r'^(\d+\.\d+)(?:\.\d+|-rc\d+)?-rt\d+$', version) - assert match, 'could not parse version string' - up_ver = match.group(1) - - # Expect an accompanying signature, and validate it - source_sig = re.sub(r'.[gx]z$', '.sign', source) - unxz_proc = subprocess.Popen(['xzcat', source], - stdout=subprocess.PIPE) - verify_output = subprocess.check_output( - ['gpgv', '--status-fd', '1', - '--keyring', 'debian/upstream/rt-signing-key.pgp', - '--ignore-time-conflict', source_sig, '-'], - stdin=unxz_proc.stdout) - if unxz_proc.wait() or \ - not re.search(r'^\[GNUPG:\]\s+VALIDSIG\s', - codecs.decode(verify_output), - re.MULTILINE): - os.write(2, verify_output) # bytes not str! - raise RuntimeError("GPG signature verification failed") - - temp_dir = tempfile.mkdtemp(prefix='rt-genpatch', dir='debian') - try: - # Unpack tarball - subprocess.check_call(['tar', '-C', temp_dir, '-xaf', source]) - source_dir = os.path.join(temp_dir, 'patches') - assert os.path.isdir(source_dir), 'tarball does not contain patches directory' - - # Copy patch series - origin = 'https://www.kernel.org/pub/linux/kernel/projects/rt/%s/older/patches-%s.tar.xz' % (up_ver, version) - with open(os.path.join(source_dir, 'series'), 'r') as \ - source_series_fh: - for line in source_series_fh: - name = line.strip() - if name != '' and name[0] != '#': - with open(os.path.join(source_dir, name)) as source_patch: - add_patch(name, source_patch, origin) - else: - # Leave comments and empty lines unchanged - series_fh.write(line) - finally: - shutil.rmtree(temp_dir) - - for name in new_series: - if name in old_series: - old_series.remove(name) - else: - print('Added patch', os.path.join(patch_dir, name)) - - for name in old_series: - print('Obsoleted patch', os.path.join(patch_dir, name)) - -if __name__ == '__main__': - if not (1 <= len(sys.argv) <= 3): - print('Usage: %s {TAR [RT-VERSION] | REPO RT-VERSION}' % sys.argv[0], file=sys.stderr) - print('TAR is a tarball of patches.', file=sys.stderr) - print('REPO is a git repo containing the given RT-VERSION.', file=sys.stderr) - sys.exit(2) - main(*sys.argv[1:]) diff --git a/debian/patches/features/all/rt/greybus-audio-don-t-inclide-rwlock.h-directly.patch b/debian/patches/features/all/rt/greybus-audio-don-t-inclide-rwlock.h-directly.patch deleted file mode 100644 index 0887cf36d..000000000 --- a/debian/patches/features/all/rt/greybus-audio-don-t-inclide-rwlock.h-directly.patch +++ /dev/null @@ -1,31 +0,0 @@ -From: Sebastian Andrzej Siewior -Date: Thu, 5 Oct 2017 14:38:52 +0200 -Subject: [PATCH] greybus: audio: don't inclide rwlock.h directly. -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -rwlock.h should not be included directly. Instead linux/splinlock.h -should be included. One thing it does is to break the RT build. - -Cc: Vaibhav Agarwal -Cc: Mark Greer -Cc: Johan Hovold -Cc: Alex Elder -Cc: Greg Kroah-Hartman -Cc: greybus-dev@lists.linaro.org -Cc: devel@driverdev.osuosl.org -Signed-off-by: Sebastian Andrzej Siewior ---- - drivers/staging/greybus/audio_manager.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/drivers/staging/greybus/audio_manager.c -+++ b/drivers/staging/greybus/audio_manager.c -@@ -10,7 +10,7 @@ - #include - #include - #include --#include -+#include - #include - - #include "audio_manager.h" diff --git a/debian/patches/features/all/rt/hotplug-duct-tape-RT-rwlock-usage-for-non-RT.patch b/debian/patches/features/all/rt/hotplug-duct-tape-RT-rwlock-usage-for-non-RT.patch index 12434a7cd..ad8ba4623 100644 --- a/debian/patches/features/all/rt/hotplug-duct-tape-RT-rwlock-usage-for-non-RT.patch +++ b/debian/patches/features/all/rt/hotplug-duct-tape-RT-rwlock-usage-for-non-RT.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Fri, 4 Aug 2017 18:31:00 +0200 Subject: [PATCH] hotplug: duct-tape RT-rwlock usage for non-RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz This type is only available on -RT. We need to craft something for non-RT. Since the only migrate_disable() user is -RT only, there is no diff --git a/debian/patches/features/all/rt/hotplug-light-get-online-cpus.patch b/debian/patches/features/all/rt/hotplug-light-get-online-cpus.patch index cf547c711..c1c36e438 100644 --- a/debian/patches/features/all/rt/hotplug-light-get-online-cpus.patch +++ b/debian/patches/features/all/rt/hotplug-light-get-online-cpus.patch @@ -1,7 +1,6 @@ Subject: hotplug: Lightweight get online cpus From: Thomas Gleixner Date: Wed, 15 Jun 2011 12:36:06 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz get_online_cpus() is a heavy weight function which involves a global mutex. migrate_disable() wants a simpler construct which prevents only @@ -20,7 +19,7 @@ Signed-off-by: Thomas Gleixner --- a/include/linux/cpu.h +++ b/include/linux/cpu.h -@@ -106,6 +106,8 @@ extern void cpu_hotplug_disable(void); +@@ -108,6 +108,8 @@ extern void cpu_hotplug_disable(void); extern void cpu_hotplug_enable(void); void clear_tasks_mm_cpumask(int cpu); int cpu_down(unsigned int cpu); @@ -29,7 +28,7 @@ Signed-off-by: Thomas Gleixner #else /* CONFIG_HOTPLUG_CPU */ -@@ -116,6 +118,9 @@ static inline void cpus_read_unlock(void +@@ -118,6 +120,9 @@ static inline void cpus_read_unlock(void static inline void lockdep_assert_cpus_held(void) { } static inline void cpu_hotplug_disable(void) { } static inline void cpu_hotplug_enable(void) { } @@ -65,7 +64,7 @@ Signed-off-by: Thomas Gleixner void cpus_read_lock(void) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -7173,6 +7173,7 @@ void migrate_disable(void) +@@ -7178,6 +7178,7 @@ void migrate_disable(void) } preempt_disable(); @@ -73,7 +72,7 @@ Signed-off-by: Thomas Gleixner migrate_disable_update_cpus_allowed(p); p->migrate_disable = 1; -@@ -7238,12 +7239,15 @@ void migrate_enable(void) +@@ -7243,12 +7244,15 @@ void migrate_enable(void) arg.task = p; arg.dest_cpu = dest_cpu; diff --git a/debian/patches/features/all/rt/hrtimer-Move-schedule_work-call-to-helper-thread.patch b/debian/patches/features/all/rt/hrtimer-Move-schedule_work-call-to-helper-thread.patch index 4fdf020d3..c287939d1 100644 --- a/debian/patches/features/all/rt/hrtimer-Move-schedule_work-call-to-helper-thread.patch +++ b/debian/patches/features/all/rt/hrtimer-Move-schedule_work-call-to-helper-thread.patch @@ -1,7 +1,6 @@ From: Yang Shi Date: Mon, 16 Sep 2013 14:09:19 -0700 Subject: hrtimer: Move schedule_work call to helper thread -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz When run ltp leapsec_timer test, the following call trace is caught: diff --git a/debian/patches/features/all/rt/hrtimer-account-for-migrated-timers.patch b/debian/patches/features/all/rt/hrtimer-account-for-migrated-timers.patch deleted file mode 100644 index ec2c83027..000000000 --- a/debian/patches/features/all/rt/hrtimer-account-for-migrated-timers.patch +++ /dev/null @@ -1,42 +0,0 @@ -From: Sebastian Andrzej Siewior -Date: Thu, 14 Dec 2017 11:31:40 +0100 -Subject: [PATCH] hrtimer: account for migrated timers -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.6-rt7.tar.xz - -if the timer is enqueud on CPUX and we run on CPUY then we have to -cpu_base bits of the correct CPU. Not sure if this accounts for all the -pieces but it might be okay with the check we have in -hrtimer_check_target() (that we have nothing to do but just wait). - -Reported-by: bert schulze -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/time/hrtimer.c | 12 +++++++----- - 1 file changed, 7 insertions(+), 5 deletions(-) - ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -775,16 +775,18 @@ static void hrtimer_reprogram(struct hrt - expires = 0; - - if (timer->is_soft) { -- if (cpu_base->softirq_activated) -+ struct hrtimer_cpu_base *timer_cpu_base = base->cpu_base; -+ -+ if (timer_cpu_base->softirq_activated) - return; - -- if (!ktime_before(expires, cpu_base->softirq_expires_next)) -+ if (!ktime_before(expires, timer_cpu_base->softirq_expires_next)) - return; - -- cpu_base->softirq_next_timer = timer; -- cpu_base->softirq_expires_next = expires; -+ timer_cpu_base->softirq_next_timer = timer; -+ timer_cpu_base->softirq_expires_next = expires; - -- if (!ktime_before(expires, cpu_base->expires_next) || -+ if (!ktime_before(expires, timer_cpu_base->expires_next) || - !reprogram) - return; - } diff --git a/debian/patches/features/all/rt/hrtimer-by-timers-by-default-into-the-softirq-context.patch b/debian/patches/features/all/rt/hrtimer-by-timers-by-default-into-the-softirq-context.patch index 94a5417b4..7efceebcf 100644 --- a/debian/patches/features/all/rt/hrtimer-by-timers-by-default-into-the-softirq-context.patch +++ b/debian/patches/features/all/rt/hrtimer-by-timers-by-default-into-the-softirq-context.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Fri, 3 Jul 2009 08:44:31 -0500 Subject: hrtimer: by timers by default into the softirq context -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz We can't have hrtimers callbacks running in hardirq context on RT. Therefore the timers are deferred to the softirq context by default. @@ -80,7 +79,7 @@ Signed-off-by: Sebastian Andrzej Siewior /* --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -343,7 +343,7 @@ static void init_rq_hrtick(struct rq *rq +@@ -344,7 +344,7 @@ static void init_rq_hrtick(struct rq *rq rq->hrtick_csd.info = rq; #endif diff --git a/debian/patches/features/all/rt/hrtimer-consolidate-hrtimer_init-hrtimer_init_sleepe.patch b/debian/patches/features/all/rt/hrtimer-consolidate-hrtimer_init-hrtimer_init_sleepe.patch index eb087964b..532e17973 100644 --- a/debian/patches/features/all/rt/hrtimer-consolidate-hrtimer_init-hrtimer_init_sleepe.patch +++ b/debian/patches/features/all/rt/hrtimer-consolidate-hrtimer_init-hrtimer_init_sleepe.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Mon, 4 Sep 2017 18:31:50 +0200 Subject: [PATCH] hrtimer: consolidate hrtimer_init() + hrtimer_init_sleeper() calls -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz hrtimer_init_sleeper() calls require a prior initialisation of the hrtimer object with hrtimer_init(). Lets make the initialisation of the diff --git a/debian/patches/features/all/rt/hrtimers-prepare-full-preemption.patch b/debian/patches/features/all/rt/hrtimers-prepare-full-preemption.patch index 01cacb7d7..dd0506ab4 100644 --- a/debian/patches/features/all/rt/hrtimers-prepare-full-preemption.patch +++ b/debian/patches/features/all/rt/hrtimers-prepare-full-preemption.patch @@ -1,7 +1,6 @@ From: Ingo Molnar Date: Fri, 3 Jul 2009 08:29:34 -0500 Subject: hrtimers: Prepare full preemption -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Make cancellation of a running callback in softirq context safe against preemption. diff --git a/debian/patches/features/all/rt/ide-don-t-disable-interrupts-during-kmap_atomic.patch b/debian/patches/features/all/rt/ide-don-t-disable-interrupts-during-kmap_atomic.patch index 5594706bb..8f9b639d0 100644 --- a/debian/patches/features/all/rt/ide-don-t-disable-interrupts-during-kmap_atomic.patch +++ b/debian/patches/features/all/rt/ide-don-t-disable-interrupts-during-kmap_atomic.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Tue, 10 Apr 2018 17:15:40 +0200 Subject: [PATCH] ide: don't disable interrupts during kmap_atomic() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz ide_pio_bytes() disables interrupts around kmap_atomic(). This is a leftover from the old kmap_atomic() implementation which relied on fixed diff --git a/debian/patches/features/all/rt/ide-don-t-disable-interrupts-if-they-are-already-dis.patch b/debian/patches/features/all/rt/ide-don-t-disable-interrupts-if-they-are-already-dis.patch index 839d315a7..965a23d44 100644 --- a/debian/patches/features/all/rt/ide-don-t-disable-interrupts-if-they-are-already-dis.patch +++ b/debian/patches/features/all/rt/ide-don-t-disable-interrupts-if-they-are-already-dis.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 4 Apr 2018 21:42:28 +0200 Subject: [PATCH] ide: Handle irq disabling consistently -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz ide_timer_expiry() disables interrupt at function entry when acquiring hwif->lock. Before disabling the device interrupt it unlocks hwif->lock, diff --git a/debian/patches/features/all/rt/ide-don-t-enable-disable-interrupts-in-force-threade.patch b/debian/patches/features/all/rt/ide-don-t-enable-disable-interrupts-in-force-threade.patch index 40f3c05bd..158646812 100644 --- a/debian/patches/features/all/rt/ide-don-t-enable-disable-interrupts-in-force-threade.patch +++ b/debian/patches/features/all/rt/ide-don-t-enable-disable-interrupts-in-force-threade.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 19 Apr 2018 11:22:55 +0200 Subject: [PATCH] ide: don't enable/disable interrupts in force threaded-IRQ mode -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The interrupts are enabled/disabled so the interrupt handler can run with enabled interrupts while serving the interrupt and not lose other diff --git a/debian/patches/features/all/rt/ide-use-nort-local-irq-variants.patch b/debian/patches/features/all/rt/ide-use-nort-local-irq-variants.patch deleted file mode 100644 index fbc120cbb..000000000 --- a/debian/patches/features/all/rt/ide-use-nort-local-irq-variants.patch +++ /dev/null @@ -1,170 +0,0 @@ -From: Ingo Molnar -Date: Fri, 3 Jul 2009 08:30:16 -0500 -Subject: ide: Do not disable interrupts for PREEMPT-RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Use the local_irq_*_nort variants. - -Signed-off-by: Ingo Molnar -Signed-off-by: Thomas Gleixner - ---- - drivers/ide/alim15x3.c | 4 ++-- - drivers/ide/hpt366.c | 4 ++-- - drivers/ide/ide-io-std.c | 8 ++++---- - drivers/ide/ide-io.c | 2 +- - drivers/ide/ide-iops.c | 4 ++-- - drivers/ide/ide-probe.c | 4 ++-- - drivers/ide/ide-taskfile.c | 6 +++--- - 7 files changed, 16 insertions(+), 16 deletions(-) - ---- a/drivers/ide/alim15x3.c -+++ b/drivers/ide/alim15x3.c -@@ -234,7 +234,7 @@ static int init_chipset_ali15x3(struct p - - isa_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); - -- local_irq_save(flags); -+ local_irq_save_nort(flags); - - if (m5229_revision < 0xC2) { - /* -@@ -325,7 +325,7 @@ static int init_chipset_ali15x3(struct p - } - pci_dev_put(north); - pci_dev_put(isa_dev); -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - return 0; - } - ---- a/drivers/ide/hpt366.c -+++ b/drivers/ide/hpt366.c -@@ -1236,7 +1236,7 @@ static int init_dma_hpt366(ide_hwif_t *h - - dma_old = inb(base + 2); - -- local_irq_save(flags); -+ local_irq_save_nort(flags); - - dma_new = dma_old; - pci_read_config_byte(dev, hwif->channel ? 0x4b : 0x43, &masterdma); -@@ -1247,7 +1247,7 @@ static int init_dma_hpt366(ide_hwif_t *h - if (dma_new != dma_old) - outb(dma_new, base + 2); - -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - - printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n", - hwif->name, base, base + 7); ---- a/drivers/ide/ide-io-std.c -+++ b/drivers/ide/ide-io-std.c -@@ -175,7 +175,7 @@ void ide_input_data(ide_drive_t *drive, - unsigned long uninitialized_var(flags); - - if ((io_32bit & 2) && !mmio) { -- local_irq_save(flags); -+ local_irq_save_nort(flags); - ata_vlb_sync(io_ports->nsect_addr); - } - -@@ -186,7 +186,7 @@ void ide_input_data(ide_drive_t *drive, - insl(data_addr, buf, words); - - if ((io_32bit & 2) && !mmio) -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - - if (((len + 1) & 3) < 2) - return; -@@ -219,7 +219,7 @@ void ide_output_data(ide_drive_t *drive, - unsigned long uninitialized_var(flags); - - if ((io_32bit & 2) && !mmio) { -- local_irq_save(flags); -+ local_irq_save_nort(flags); - ata_vlb_sync(io_ports->nsect_addr); - } - -@@ -230,7 +230,7 @@ void ide_output_data(ide_drive_t *drive, - outsl(data_addr, buf, words); - - if ((io_32bit & 2) && !mmio) -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - - if (((len + 1) & 3) < 2) - return; ---- a/drivers/ide/ide-io.c -+++ b/drivers/ide/ide-io.c -@@ -660,7 +660,7 @@ void ide_timer_expiry (unsigned long dat - /* disable_irq_nosync ?? */ - disable_irq(hwif->irq); - /* local CPU only, as if we were handling an interrupt */ -- local_irq_disable(); -+ local_irq_disable_nort(); - if (hwif->polling) { - startstop = handler(drive); - } else if (drive_is_ready(drive)) { ---- a/drivers/ide/ide-iops.c -+++ b/drivers/ide/ide-iops.c -@@ -129,12 +129,12 @@ int __ide_wait_stat(ide_drive_t *drive, - if ((stat & ATA_BUSY) == 0) - break; - -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - *rstat = stat; - return -EBUSY; - } - } -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - } - /* - * Allow status to settle, then read it again. ---- a/drivers/ide/ide-probe.c -+++ b/drivers/ide/ide-probe.c -@@ -196,10 +196,10 @@ static void do_identify(ide_drive_t *dri - int bswap = 1; - - /* local CPU only; some systems need this */ -- local_irq_save(flags); -+ local_irq_save_nort(flags); - /* read 512 bytes of id info */ - hwif->tp_ops->input_data(drive, NULL, id, SECTOR_SIZE); -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - - drive->dev_flags |= IDE_DFLAG_ID_READ; - #ifdef DEBUG ---- a/drivers/ide/ide-taskfile.c -+++ b/drivers/ide/ide-taskfile.c -@@ -251,7 +251,7 @@ void ide_pio_bytes(ide_drive_t *drive, s - - page_is_high = PageHighMem(page); - if (page_is_high) -- local_irq_save(flags); -+ local_irq_save_nort(flags); - - buf = kmap_atomic(page) + offset; - -@@ -272,7 +272,7 @@ void ide_pio_bytes(ide_drive_t *drive, s - kunmap_atomic(buf); - - if (page_is_high) -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - - len -= nr_bytes; - } -@@ -415,7 +415,7 @@ static ide_startstop_t pre_task_out_intr - } - - if ((drive->dev_flags & IDE_DFLAG_UNMASK) == 0) -- local_irq_disable(); -+ local_irq_disable_nort(); - - ide_set_handler(drive, &task_pio_intr, WAIT_WORSTCASE); - diff --git a/debian/patches/features/all/rt/include-linux-u64_stats_sync.h-Remove-functions-with.patch b/debian/patches/features/all/rt/include-linux-u64_stats_sync.h-Remove-functions-with.patch index d0260974f..f9ccf9eaf 100644 --- a/debian/patches/features/all/rt/include-linux-u64_stats_sync.h-Remove-functions-with.patch +++ b/debian/patches/features/all/rt/include-linux-u64_stats_sync.h-Remove-functions-with.patch @@ -1,7 +1,6 @@ From: Anna-Maria Gleixner Date: Wed, 4 Apr 2018 11:44:00 +0200 Subject: [PATCH] net: u64_stats_sync: Remove functions without user -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Commit 67db3e4bfbc9 ("tcp: no longer hold ehash lock while calling tcp_get_info()") removes the only users of u64_stats_update_end/begin_raw() diff --git a/debian/patches/features/all/rt/infiniband-mellanox-ib-use-nort-irq.patch b/debian/patches/features/all/rt/infiniband-mellanox-ib-use-nort-irq.patch deleted file mode 100644 index 1af664c68..000000000 --- a/debian/patches/features/all/rt/infiniband-mellanox-ib-use-nort-irq.patch +++ /dev/null @@ -1,41 +0,0 @@ -From: Sven-Thorsten Dietrich -Date: Fri, 3 Jul 2009 08:30:35 -0500 -Subject: infiniband: Mellanox IB driver patch use _nort() primitives -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Fixes in_atomic stack-dump, when Mellanox module is loaded into the RT -Kernel. - -Michael S. Tsirkin sayeth: -"Basically, if you just make spin_lock_irqsave (and spin_lock_irq) not disable -interrupts for non-raw spinlocks, I think all of infiniband will be fine without -changes." - -Signed-off-by: Sven-Thorsten Dietrich -Signed-off-by: Ingo Molnar -Signed-off-by: Thomas Gleixner - ---- - drivers/infiniband/ulp/ipoib/ipoib_multicast.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c -+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c -@@ -895,7 +895,7 @@ void ipoib_mcast_restart_task(struct wor - - ipoib_dbg_mcast(priv, "restarting multicast task\n"); - -- local_irq_save(flags); -+ local_irq_save_nort(flags); - netif_addr_lock(dev); - spin_lock(&priv->lock); - -@@ -977,7 +977,7 @@ void ipoib_mcast_restart_task(struct wor - - spin_unlock(&priv->lock); - netif_addr_unlock(dev); -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - - ipoib_mcast_remove_list(&remove_list); - diff --git a/debian/patches/features/all/rt/inpt-gameport-use-local-irq-nort.patch b/debian/patches/features/all/rt/inpt-gameport-use-local-irq-nort.patch deleted file mode 100644 index 319518495..000000000 --- a/debian/patches/features/all/rt/inpt-gameport-use-local-irq-nort.patch +++ /dev/null @@ -1,61 +0,0 @@ -From: Ingo Molnar -Date: Fri, 3 Jul 2009 08:30:16 -0500 -Subject: input: gameport: Do not disable interrupts on PREEMPT_RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Use the _nort() primitives. - -Signed-off-by: Ingo Molnar -Signed-off-by: Thomas Gleixner - ---- - drivers/input/gameport/gameport.c | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - ---- a/drivers/input/gameport/gameport.c -+++ b/drivers/input/gameport/gameport.c -@@ -91,13 +91,13 @@ static int gameport_measure_speed(struct - tx = ~0; - - for (i = 0; i < 50; i++) { -- local_irq_save(flags); -+ local_irq_save_nort(flags); - t1 = ktime_get_ns(); - for (t = 0; t < 50; t++) - gameport_read(gameport); - t2 = ktime_get_ns(); - t3 = ktime_get_ns(); -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - udelay(i * 10); - t = (t2 - t1) - (t3 - t2); - if (t < tx) -@@ -124,12 +124,12 @@ static int old_gameport_measure_speed(st - tx = 1 << 30; - - for(i = 0; i < 50; i++) { -- local_irq_save(flags); -+ local_irq_save_nort(flags); - GET_TIME(t1); - for (t = 0; t < 50; t++) gameport_read(gameport); - GET_TIME(t2); - GET_TIME(t3); -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - udelay(i * 10); - if ((t = DELTA(t2,t1) - DELTA(t3,t2)) < tx) tx = t; - } -@@ -148,11 +148,11 @@ static int old_gameport_measure_speed(st - tx = 1 << 30; - - for(i = 0; i < 50; i++) { -- local_irq_save(flags); -+ local_irq_save_nort(flags); - t1 = rdtsc(); - for (t = 0; t < 50; t++) gameport_read(gameport); - t2 = rdtsc(); -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - udelay(i * 10); - if (t2 - t1 < tx) tx = t2 - t1; - } diff --git a/debian/patches/features/all/rt/iommu-amd--Use-WARN_ON_NORT.patch b/debian/patches/features/all/rt/iommu-amd--Use-WARN_ON_NORT.patch deleted file mode 100644 index d8f46deb5..000000000 --- a/debian/patches/features/all/rt/iommu-amd--Use-WARN_ON_NORT.patch +++ /dev/null @@ -1,47 +0,0 @@ -Subject: iommu/amd: Use WARN_ON_NORT in __attach_device() -From: Thomas Gleixner -Date: Sat, 27 Feb 2016 10:22:23 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -RT does not disable interrupts here, but the protection is still -correct. Fixup the WARN_ON so it won't yell on RT. - -Note: This WARN_ON is bogus anyway. The real thing this needs to check is that -amd_iommu_devtable_lock is held. - -Reported-by: DIXLOR -Signed-off-by: Thomas Gleixner ---- - drivers/iommu/amd_iommu.c | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - ---- a/drivers/iommu/amd_iommu.c -+++ b/drivers/iommu/amd_iommu.c -@@ -1944,10 +1944,10 @@ static int __attach_device(struct iommu_ - int ret; - - /* -- * Must be called with IRQs disabled. Warn here to detect early -- * when its not. -+ * Must be called with IRQs disabled on a non RT kernel. Warn here to -+ * detect early when its not. - */ -- WARN_ON(!irqs_disabled()); -+ WARN_ON_NONRT(!irqs_disabled()); - - /* lock domain */ - spin_lock(&domain->lock); -@@ -2115,10 +2115,10 @@ static void __detach_device(struct iommu - struct protection_domain *domain; - - /* -- * Must be called with IRQs disabled. Warn here to detect early -- * when its not. -+ * Must be called with IRQs disabled on a non RT kernel. Warn here to -+ * detect early when its not. - */ -- WARN_ON(!irqs_disabled()); -+ WARN_ON_NONRT(!irqs_disabled()); - - if (WARN_ON(!dev_data->domain)) - return; diff --git a/debian/patches/features/all/rt/iommu-amd-Cleanup-locking-in-__attach-detach_device.patch b/debian/patches/features/all/rt/iommu-amd-Cleanup-locking-in-__attach-detach_device.patch index 6fdac7420..680986d8d 100644 --- a/debian/patches/features/all/rt/iommu-amd-Cleanup-locking-in-__attach-detach_device.patch +++ b/debian/patches/features/all/rt/iommu-amd-Cleanup-locking-in-__attach-detach_device.patch @@ -1,7 +1,6 @@ From: Anna-Maria Gleixner Date: Mon, 16 Apr 2018 16:15:24 +0200 Subject: [PATCH] iommu/amd: Cleanup locking in __attach/detach_device() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Since introduction of the pd_bitmap_lock in commit 2bc001808904 ("iommu/amd: Split domain id out of amd_iommu_devtable_lock") diff --git a/debian/patches/features/all/rt/iommu-amd-Do-not-flush-when-device-is-busy.patch b/debian/patches/features/all/rt/iommu-amd-Do-not-flush-when-device-is-busy.patch index 962aa910c..368d46780 100644 --- a/debian/patches/features/all/rt/iommu-amd-Do-not-flush-when-device-is-busy.patch +++ b/debian/patches/features/all/rt/iommu-amd-Do-not-flush-when-device-is-busy.patch @@ -1,7 +1,6 @@ From: Anna-Maria Gleixner Date: Mon, 16 Apr 2018 16:15:25 +0200 Subject: [PATCH] iommu/amd: Do not flush when device is busy -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz When device is already attached to a domain, there is no need to execute the domain_flush_tlb_pde(). Therefore move the check if the domain is set diff --git a/debian/patches/features/all/rt/iommu-amd-Prevent-possible-null-pointer-dereference-.patch b/debian/patches/features/all/rt/iommu-amd-Prevent-possible-null-pointer-dereference-.patch index ee8bb8e83..8d2c445fd 100644 --- a/debian/patches/features/all/rt/iommu-amd-Prevent-possible-null-pointer-dereference-.patch +++ b/debian/patches/features/all/rt/iommu-amd-Prevent-possible-null-pointer-dereference-.patch @@ -2,7 +2,6 @@ From: Anna-Maria Gleixner Date: Mon, 16 Apr 2018 16:15:23 +0200 Subject: [PATCH] iommu/amd: Prevent possible null pointer dereference and infinite loop -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The check for !dev_data->domain in __detach_device() emits a warning and returns. The calling code in detach_device() dereferences dev_data->domain diff --git a/debian/patches/features/all/rt/iommu-amd-hide-unused-iommu_table_lock.patch b/debian/patches/features/all/rt/iommu-amd-hide-unused-iommu_table_lock.patch index 600af68b8..78bbb0de4 100644 --- a/debian/patches/features/all/rt/iommu-amd-hide-unused-iommu_table_lock.patch +++ b/debian/patches/features/all/rt/iommu-amd-hide-unused-iommu_table_lock.patch @@ -1,7 +1,6 @@ From: Arnd Bergmann Date: Wed, 4 Apr 2018 12:56:59 +0200 Subject: [PATCH] iommu: amd: hide unused iommu_table_lock -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The newly introduced lock is only used when CONFIG_IRQ_REMAP is enabled: diff --git a/debian/patches/features/all/rt/iommu-iova-Use-raw_cpu_ptr-instead-of-get_cpu_ptr-fo.patch b/debian/patches/features/all/rt/iommu-iova-Use-raw_cpu_ptr-instead-of-get_cpu_ptr-fo.patch deleted file mode 100644 index c6ec62d42..000000000 --- a/debian/patches/features/all/rt/iommu-iova-Use-raw_cpu_ptr-instead-of-get_cpu_ptr-fo.patch +++ /dev/null @@ -1,43 +0,0 @@ -From: Sebastian Andrzej Siewior -Date: Thu, 21 Sep 2017 17:21:40 +0200 -Subject: [PATCH] iommu/iova: Use raw_cpu_ptr() instead of get_cpu_ptr() for - ->fq -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -get_cpu_ptr() disabled preemption and returns the ->fq object of the -current CPU. raw_cpu_ptr() does the same except that it not disable -preemption which means the scheduler can move it to another CPU after it -obtained the per-CPU object. -In this case this is not bad because the data structure itself is -protected with a spin_lock. This change shouldn't matter however on RT -it does because the sleeping lock can't be accessed with disabled -preemption. - -Cc: Joerg Roedel -Cc: iommu@lists.linux-foundation.org -Reported-by: vinadhy@gmail.com -Signed-off-by: Sebastian Andrzej Siewior ---- - drivers/iommu/iova.c | 4 +--- - 1 file changed, 1 insertion(+), 3 deletions(-) - ---- a/drivers/iommu/iova.c -+++ b/drivers/iommu/iova.c -@@ -570,7 +570,7 @@ void queue_iova(struct iova_domain *iova - unsigned long pfn, unsigned long pages, - unsigned long data) - { -- struct iova_fq *fq = get_cpu_ptr(iovad->fq); -+ struct iova_fq *fq = raw_cpu_ptr(iovad->fq); - unsigned long flags; - unsigned idx; - -@@ -600,8 +600,6 @@ void queue_iova(struct iova_domain *iova - if (atomic_cmpxchg(&iovad->fq_timer_on, 0, 1) == 0) - mod_timer(&iovad->fq_timer, - jiffies + msecs_to_jiffies(IOVA_FQ_TIMEOUT)); -- -- put_cpu_ptr(iovad->fq); - } - EXPORT_SYMBOL_GPL(queue_iova); - diff --git a/debian/patches/features/all/rt/irq-allow-disabling-of-softirq-processing-in-irq-thread-context.patch b/debian/patches/features/all/rt/irq-allow-disabling-of-softirq-processing-in-irq-thread-context.patch index 364266e64..44c056af3 100644 --- a/debian/patches/features/all/rt/irq-allow-disabling-of-softirq-processing-in-irq-thread-context.patch +++ b/debian/patches/features/all/rt/irq-allow-disabling-of-softirq-processing-in-irq-thread-context.patch @@ -1,7 +1,6 @@ Subject: genirq: Allow disabling of softirq processing in irq thread context From: Thomas Gleixner Date: Tue, 31 Jan 2012 13:01:27 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The processing of softirqs in irq thread context is a performance gain for the non-rt workloads of a system, but it's counterproductive for diff --git a/debian/patches/features/all/rt/irqwork-Move-irq-safe-work-to-irq-context.patch b/debian/patches/features/all/rt/irqwork-Move-irq-safe-work-to-irq-context.patch index 781f61d92..813d778e2 100644 --- a/debian/patches/features/all/rt/irqwork-Move-irq-safe-work-to-irq-context.patch +++ b/debian/patches/features/all/rt/irqwork-Move-irq-safe-work-to-irq-context.patch @@ -1,7 +1,6 @@ Subject: irqwork: Move irq safe work to irq context From: Thomas Gleixner Date: Sun, 15 Nov 2015 18:40:17 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz On architectures where arch_irq_work_has_interrupt() returns false, we end up running the irq safe work from the softirq context. That diff --git a/debian/patches/features/all/rt/irqwork-push_most_work_into_softirq_context.patch b/debian/patches/features/all/rt/irqwork-push_most_work_into_softirq_context.patch index e407bfe89..5df75fe7c 100644 --- a/debian/patches/features/all/rt/irqwork-push_most_work_into_softirq_context.patch +++ b/debian/patches/features/all/rt/irqwork-push_most_work_into_softirq_context.patch @@ -1,7 +1,6 @@ Subject: irqwork: push most work into softirq context From: Sebastian Andrzej Siewior Date: Tue, 23 Jun 2015 15:32:51 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Initially we defered all irqwork into softirq because we didn't want the latency spikes if perf or another user was busy and delayed the RT task. diff --git a/debian/patches/features/all/rt/jump-label-rt.patch b/debian/patches/features/all/rt/jump-label-rt.patch index d6714f0cd..49c6437e5 100644 --- a/debian/patches/features/all/rt/jump-label-rt.patch +++ b/debian/patches/features/all/rt/jump-label-rt.patch @@ -1,7 +1,6 @@ Subject: jump-label: disable if stop_machine() is used From: Thomas Gleixner Date: Wed, 08 Jul 2015 17:14:48 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Some architectures are using stop_machine() while switching the opcode which leads to latency spikes. diff --git a/debian/patches/features/all/rt/kconfig-disable-a-few-options-rt.patch b/debian/patches/features/all/rt/kconfig-disable-a-few-options-rt.patch index 8e6abf343..eecb81a33 100644 --- a/debian/patches/features/all/rt/kconfig-disable-a-few-options-rt.patch +++ b/debian/patches/features/all/rt/kconfig-disable-a-few-options-rt.patch @@ -1,7 +1,6 @@ Subject: kconfig: Disable config options which are not RT compatible From: Thomas Gleixner Date: Sun, 24 Jul 2011 12:11:43 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Disable stuff which is known to have issues on RT diff --git a/debian/patches/features/all/rt/kconfig-preempt-rt-full.patch b/debian/patches/features/all/rt/kconfig-preempt-rt-full.patch index 8a0f654e7..c868452cd 100644 --- a/debian/patches/features/all/rt/kconfig-preempt-rt-full.patch +++ b/debian/patches/features/all/rt/kconfig-preempt-rt-full.patch @@ -1,7 +1,6 @@ Subject: kconfig: Add PREEMPT_RT_FULL From: Thomas Gleixner Date: Wed, 29 Jun 2011 14:58:57 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Introduce the final symbol for PREEMPT_RT_FULL. diff --git a/debian/patches/features/all/rt/kernel-SRCU-provide-a-static-initializer.patch b/debian/patches/features/all/rt/kernel-SRCU-provide-a-static-initializer.patch index d3f8cc2c0..02d0851be 100644 --- a/debian/patches/features/all/rt/kernel-SRCU-provide-a-static-initializer.patch +++ b/debian/patches/features/all/rt/kernel-SRCU-provide-a-static-initializer.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Tue, 19 Mar 2013 14:44:30 +0100 Subject: kernel/SRCU: provide a static initializer -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz There are macros for static initializer for the three out of four possible notifier types, that are: diff --git a/debian/patches/features/all/rt/kernel-printk-Don-t-try-to-print-from-IRQ-NMI-region.patch b/debian/patches/features/all/rt/kernel-printk-Don-t-try-to-print-from-IRQ-NMI-region.patch index cf3e0113e..18ecb2590 100644 --- a/debian/patches/features/all/rt/kernel-printk-Don-t-try-to-print-from-IRQ-NMI-region.patch +++ b/debian/patches/features/all/rt/kernel-printk-Don-t-try-to-print-from-IRQ-NMI-region.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 19 May 2016 17:45:27 +0200 Subject: [PATCH] kernel/printk: Don't try to print from IRQ/NMI region -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz On -RT we try to acquire sleeping locks which might lead to warnings from lockdep or a warn_on() from spin_try_lock() (which is a rtmutex on diff --git a/debian/patches/features/all/rt/kernel-sched-Provide-a-pointer-to-the-valid-CPU-mask.patch b/debian/patches/features/all/rt/kernel-sched-Provide-a-pointer-to-the-valid-CPU-mask.patch index e92307edf..d85ac6827 100644 --- a/debian/patches/features/all/rt/kernel-sched-Provide-a-pointer-to-the-valid-CPU-mask.patch +++ b/debian/patches/features/all/rt/kernel-sched-Provide-a-pointer-to-the-valid-CPU-mask.patch @@ -4,7 +4,6 @@ Subject: [PATCH] kernel: sched: Provide a pointer to the valid CPU mask MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz In commit 4b53a3412d66 ("sched/core: Remove the tsk_nr_cpus_allowed() wrapper") the tsk_nr_cpus_allowed() wrapper was removed. There was not @@ -275,7 +274,7 @@ Signed-off-by: Sebastian Andrzej Siewior if (!find_hca(cpu, &unit) && unit >= 0) --- a/fs/proc/array.c +++ b/fs/proc/array.c -@@ -361,9 +361,9 @@ static inline void task_context_switch_c +@@ -386,9 +386,9 @@ static inline void task_context_switch_c static void task_cpus_allowed(struct seq_file *m, struct task_struct *task) { seq_printf(m, "Cpus_allowed:\t%*pb\n", @@ -345,7 +344,7 @@ Signed-off-by: Sebastian Andrzej Siewior * parent) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -970,7 +970,7 @@ static struct rq *__migrate_task(struct +@@ -971,7 +971,7 @@ static struct rq *__migrate_task(struct } /* Affinity changed (again). */ @@ -354,7 +353,7 @@ Signed-off-by: Sebastian Andrzej Siewior return rq; update_rq_clock(rq); -@@ -998,7 +998,7 @@ static int migration_cpu_stop(void *data +@@ -999,7 +999,7 @@ static int migration_cpu_stop(void *data local_irq_disable(); /* * We need to explicitly wake pending tasks before running @@ -363,7 +362,7 @@ Signed-off-by: Sebastian Andrzej Siewior * during wakeups, see set_cpus_allowed_ptr()'s TASK_WAKING test. */ sched_ttwu_pending(); -@@ -1029,7 +1029,7 @@ static int migration_cpu_stop(void *data +@@ -1030,7 +1030,7 @@ static int migration_cpu_stop(void *data */ void set_cpus_allowed_common(struct task_struct *p, const struct cpumask *new_mask) { @@ -372,7 +371,7 @@ Signed-off-by: Sebastian Andrzej Siewior p->nr_cpus_allowed = cpumask_weight(new_mask); } -@@ -1099,7 +1099,7 @@ static int __set_cpus_allowed_ptr(struct +@@ -1100,7 +1100,7 @@ static int __set_cpus_allowed_ptr(struct goto out; } @@ -381,7 +380,7 @@ Signed-off-by: Sebastian Andrzej Siewior goto out; if (!cpumask_intersects(new_mask, cpu_valid_mask)) { -@@ -1260,10 +1260,10 @@ static int migrate_swap_stop(void *data) +@@ -1261,10 +1261,10 @@ static int migrate_swap_stop(void *data) if (task_cpu(arg->src_task) != arg->src_cpu) goto unlock; @@ -394,7 +393,7 @@ Signed-off-by: Sebastian Andrzej Siewior goto unlock; __migrate_swap_task(arg->src_task, arg->dst_cpu); -@@ -1304,10 +1304,10 @@ int migrate_swap(struct task_struct *cur +@@ -1305,10 +1305,10 @@ int migrate_swap(struct task_struct *cur if (!cpu_active(arg.src_cpu) || !cpu_active(arg.dst_cpu)) goto out; @@ -407,7 +406,7 @@ Signed-off-by: Sebastian Andrzej Siewior goto out; trace_sched_swap_numa(cur, arg.src_cpu, p, arg.dst_cpu); -@@ -1451,7 +1451,7 @@ void kick_process(struct task_struct *p) +@@ -1452,7 +1452,7 @@ void kick_process(struct task_struct *p) EXPORT_SYMBOL_GPL(kick_process); /* @@ -416,7 +415,7 @@ Signed-off-by: Sebastian Andrzej Siewior * * A few notes on cpu_active vs cpu_online: * -@@ -1491,14 +1491,14 @@ static int select_fallback_rq(int cpu, s +@@ -1492,14 +1492,14 @@ static int select_fallback_rq(int cpu, s for_each_cpu(dest_cpu, nodemask) { if (!cpu_active(dest_cpu)) continue; @@ -433,7 +432,7 @@ Signed-off-by: Sebastian Andrzej Siewior if (!(p->flags & PF_KTHREAD) && !cpu_active(dest_cpu)) continue; if (!cpu_online(dest_cpu)) -@@ -1543,7 +1543,7 @@ static int select_fallback_rq(int cpu, s +@@ -1544,7 +1544,7 @@ static int select_fallback_rq(int cpu, s } /* @@ -442,7 +441,7 @@ Signed-off-by: Sebastian Andrzej Siewior */ static inline int select_task_rq(struct task_struct *p, int cpu, int sd_flags, int wake_flags) -@@ -1553,11 +1553,11 @@ int select_task_rq(struct task_struct *p +@@ -1554,11 +1554,11 @@ int select_task_rq(struct task_struct *p if (p->nr_cpus_allowed > 1) cpu = p->sched_class->select_task_rq(p, cpu, sd_flags, wake_flags); else @@ -456,7 +455,7 @@ Signed-off-by: Sebastian Andrzej Siewior * CPU. * * Since this is common to all placement strategies, this lives here. -@@ -1565,7 +1565,7 @@ int select_task_rq(struct task_struct *p +@@ -1566,7 +1566,7 @@ int select_task_rq(struct task_struct *p * [ this allows ->select_task() to simply return task_cpu(p) and * not worry about this generic constraint ] */ @@ -465,7 +464,7 @@ Signed-off-by: Sebastian Andrzej Siewior !cpu_online(cpu))) cpu = select_fallback_rq(task_cpu(p), p); -@@ -2455,7 +2455,7 @@ void wake_up_new_task(struct task_struct +@@ -2456,7 +2456,7 @@ void wake_up_new_task(struct task_struct #ifdef CONFIG_SMP /* * Fork balancing, do it here and not earlier because: @@ -474,7 +473,7 @@ Signed-off-by: Sebastian Andrzej Siewior * - any previously selected CPU might disappear through hotplug * * Use __set_task_cpu() to avoid calling sched_class::migrate_task_rq, -@@ -4239,7 +4239,7 @@ static int __sched_setscheduler(struct t +@@ -4240,7 +4240,7 @@ static int __sched_setscheduler(struct t * the entire root_domain to become SCHED_DEADLINE. We * will also fail if there's no bandwidth available. */ @@ -483,7 +482,7 @@ Signed-off-by: Sebastian Andrzej Siewior rq->rd->dl_bw.bw == 0) { task_rq_unlock(rq, p, &rf); return -EPERM; -@@ -4838,7 +4838,7 @@ long sched_getaffinity(pid_t pid, struct +@@ -4839,7 +4839,7 @@ long sched_getaffinity(pid_t pid, struct goto out_unlock; raw_spin_lock_irqsave(&p->pi_lock, flags); @@ -492,7 +491,7 @@ Signed-off-by: Sebastian Andrzej Siewior raw_spin_unlock_irqrestore(&p->pi_lock, flags); out_unlock: -@@ -5428,7 +5428,7 @@ int task_can_attach(struct task_struct * +@@ -5429,7 +5429,7 @@ int task_can_attach(struct task_struct * * allowed nodes is unnecessary. Thus, cpusets are not * applicable for such threads. This prevents checking for * success of set_cpus_allowed_ptr() on all attached tasks @@ -501,7 +500,7 @@ Signed-off-by: Sebastian Andrzej Siewior */ if (p->flags & PF_NO_SETAFFINITY) { ret = -EINVAL; -@@ -5455,7 +5455,7 @@ int migrate_task_to(struct task_struct * +@@ -5456,7 +5456,7 @@ int migrate_task_to(struct task_struct * if (curr_cpu == target_cpu) return 0; @@ -510,7 +509,7 @@ Signed-off-by: Sebastian Andrzej Siewior return -EINVAL; /* TODO: This is not properly updating schedstats */ -@@ -5592,7 +5592,7 @@ static void migrate_tasks(struct rq *dea +@@ -5593,7 +5593,7 @@ static void migrate_tasks(struct rq *dea put_prev_task(rq, next); /* diff --git a/debian/patches/features/all/rt/kernel-sched-move-stack-kprobe-clean-up-to-__put_tas.patch b/debian/patches/features/all/rt/kernel-sched-move-stack-kprobe-clean-up-to-__put_tas.patch index 867db4598..27f8b35f0 100644 --- a/debian/patches/features/all/rt/kernel-sched-move-stack-kprobe-clean-up-to-__put_tas.patch +++ b/debian/patches/features/all/rt/kernel-sched-move-stack-kprobe-clean-up-to-__put_tas.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Mon, 21 Nov 2016 19:31:08 +0100 Subject: [PATCH] kernel/sched: move stack + kprobe clean up to __put_task_struct() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz There is no need to free the stack before the task struct. This also comes handy on -RT because we can't free memory in preempt disabled @@ -43,7 +42,7 @@ Signed-off-by: Sebastian Andrzej Siewior security_task_free(tsk); --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -2778,15 +2778,6 @@ static struct rq *finish_task_switch(str +@@ -2779,15 +2779,6 @@ static struct rq *finish_task_switch(str if (prev->sched_class->task_dead) prev->sched_class->task_dead(prev); diff --git a/debian/patches/features/all/rt/kernel-signal-Remove-no-longer-required-irqsave-rest.patch b/debian/patches/features/all/rt/kernel-signal-Remove-no-longer-required-irqsave-rest.patch index 8994d3b81..de01dbc6b 100644 --- a/debian/patches/features/all/rt/kernel-signal-Remove-no-longer-required-irqsave-rest.patch +++ b/debian/patches/features/all/rt/kernel-signal-Remove-no-longer-required-irqsave-rest.patch @@ -1,7 +1,6 @@ From: Anna-Maria Gleixner Date: Wed, 4 Apr 2018 11:44:01 +0200 Subject: [PATCH] kernel/signal: Remove no longer required irqsave/restore -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Commit a841796f11c9 ("signal: align __lock_task_sighand() irq disabling and RCU") introduced a rcu read side critical section with interrupts diff --git a/debian/patches/features/all/rt/kernel-softirq-unlock-with-irqs-on.patch b/debian/patches/features/all/rt/kernel-softirq-unlock-with-irqs-on.patch index 4e715644d..238ed299a 100644 --- a/debian/patches/features/all/rt/kernel-softirq-unlock-with-irqs-on.patch +++ b/debian/patches/features/all/rt/kernel-softirq-unlock-with-irqs-on.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Tue, 9 Feb 2016 18:17:18 +0100 Subject: kernel: softirq: unlock with irqs on -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz We unlock the lock while the interrupts are off. This isn't a problem now but will get because the migrate_disable() + enable are not diff --git a/debian/patches/features/all/rt/kgb-serial-hackaround.patch b/debian/patches/features/all/rt/kgb-serial-hackaround.patch index 375e840cb..b205dd54c 100644 --- a/debian/patches/features/all/rt/kgb-serial-hackaround.patch +++ b/debian/patches/features/all/rt/kgb-serial-hackaround.patch @@ -1,7 +1,6 @@ From: Jason Wessel Date: Thu, 28 Jul 2011 12:42:23 -0500 Subject: kgdb/serial: Short term workaround -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz On 07/27/2011 04:37 PM, Thomas Gleixner wrote: > - KGDB (not yet disabled) is reportedly unusable on -rt right now due @@ -34,7 +33,7 @@ Jason. #include #include #include -@@ -3219,6 +3220,8 @@ void serial8250_console_write(struct uar +@@ -3220,6 +3221,8 @@ void serial8250_console_write(struct uar if (port->sysrq || oops_in_progress) locked = 0; diff --git a/debian/patches/features/all/rt/leds-trigger-disable-CPU-trigger-on-RT.patch b/debian/patches/features/all/rt/leds-trigger-disable-CPU-trigger-on-RT.patch index 7f45f231b..e59b96299 100644 --- a/debian/patches/features/all/rt/leds-trigger-disable-CPU-trigger-on-RT.patch +++ b/debian/patches/features/all/rt/leds-trigger-disable-CPU-trigger-on-RT.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 23 Jan 2014 14:45:59 +0100 Subject: leds: trigger: disable CPU trigger on -RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz as it triggers: |CPU: 0 PID: 0 Comm: swapper Not tainted 3.12.8-rt10 #141 diff --git a/debian/patches/features/all/rt/lib-percpu_ida.c-don-t-do-alloc-from-per-CPU-list-if.patch b/debian/patches/features/all/rt/lib-percpu_ida.c-don-t-do-alloc-from-per-CPU-list-if.patch new file mode 100644 index 000000000..11064152c --- /dev/null +++ b/debian/patches/features/all/rt/lib-percpu_ida.c-don-t-do-alloc-from-per-CPU-list-if.patch @@ -0,0 +1,34 @@ +From: Sebastian Andrzej Siewior +Date: Wed, 13 Jun 2018 09:58:30 +0200 +Subject: [PATCH] lib/percpu_ida.c: don't do alloc from per-CPU list if there + is none + +In commit 804209d8a009 ("lib/percpu_ida.c: use _irqsave() instead of +local_irq_save() + spin_lock") I inlined alloc_local_tag() and mixed up +the >= check from percpu_ida_alloc() with the one in alloc_local_tag(). + +Don't alloc from per-CPU freelist if ->nr_free is zero. + +Fixes: 804209d8a009 ("lib/percpu_ida.c: use _irqsave() instead of local_irq_save() + spin_lock") +Reported-by: David Disseldorp +Signed-off-by: Sebastian Andrzej Siewior +--- + lib/percpu_ida.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/percpu_ida.c b/lib/percpu_ida.c +index 9bbd9c5d375a..beb14839b41a 100644 +--- a/lib/percpu_ida.c ++++ b/lib/percpu_ida.c +@@ -141,7 +141,7 @@ int percpu_ida_alloc(struct percpu_ida *pool, int state) + spin_lock_irqsave(&tags->lock, flags); + + /* Fastpath */ +- if (likely(tags->nr_free >= 0)) { ++ if (likely(tags->nr_free)) { + tag = tags->freelist[--tags->nr_free]; + spin_unlock_irqrestore(&tags->lock, flags); + return tag; +-- +2.17.1 + diff --git a/debian/patches/features/all/rt/libata-remove-ata_sff_data_xfer_noirq.patch b/debian/patches/features/all/rt/libata-remove-ata_sff_data_xfer_noirq.patch index 2939392e0..390e39b68 100644 --- a/debian/patches/features/all/rt/libata-remove-ata_sff_data_xfer_noirq.patch +++ b/debian/patches/features/all/rt/libata-remove-ata_sff_data_xfer_noirq.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 19 Apr 2018 12:55:14 +0200 Subject: [PATCH] libata: remove ata_sff_data_xfer_noirq() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz ata_sff_data_xfer_noirq() is invoked via the ->sff_data_xfer hook. The latter is invoked by ata_pio_sector(), atapi_send_cdb() and diff --git a/debian/patches/features/all/rt/list_bl-fixup-bogus-lockdep-warning.patch b/debian/patches/features/all/rt/list_bl-fixup-bogus-lockdep-warning.patch index 1c3044d8e..43ebad4b9 100644 --- a/debian/patches/features/all/rt/list_bl-fixup-bogus-lockdep-warning.patch +++ b/debian/patches/features/all/rt/list_bl-fixup-bogus-lockdep-warning.patch @@ -1,7 +1,6 @@ From: Josh Cartwright Date: Thu, 31 Mar 2016 00:04:25 -0500 Subject: [PATCH] list_bl: fixup bogus lockdep warning -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz At first glance, the use of 'static inline' seems appropriate for INIT_HLIST_BL_HEAD(). diff --git a/debian/patches/features/all/rt/list_bl.h-make-list-head-locking-RT-safe.patch b/debian/patches/features/all/rt/list_bl.h-make-list-head-locking-RT-safe.patch index 82f14cd08..9ea1a600d 100644 --- a/debian/patches/features/all/rt/list_bl.h-make-list-head-locking-RT-safe.patch +++ b/debian/patches/features/all/rt/list_bl.h-make-list-head-locking-RT-safe.patch @@ -1,7 +1,6 @@ From: Paul Gortmaker Date: Fri, 21 Jun 2013 15:07:25 -0400 Subject: list_bl: Make list head locking RT safe -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz As per changes in include/linux/jbd_common.h for avoiding the bit_spin_locks on RT ("fs: jbd/jbd2: Make state lock and journal diff --git a/debian/patches/features/all/rt/local-irq-rt-depending-variants.patch b/debian/patches/features/all/rt/local-irq-rt-depending-variants.patch deleted file mode 100644 index 1ea96a575..000000000 --- a/debian/patches/features/all/rt/local-irq-rt-depending-variants.patch +++ /dev/null @@ -1,53 +0,0 @@ -From: Thomas Gleixner -Date: Tue, 21 Jul 2009 22:34:14 +0200 -Subject: rt: local_irq_* variants depending on RT/!RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Add local_irq_*_(no)rt variant which are mainly used to break -interrupt disabled sections on PREEMPT_RT or to explicitely disable -interrupts on PREEMPT_RT. - -Signed-off-by: Thomas Gleixner - ---- - include/linux/interrupt.h | 2 +- - include/linux/irqflags.h | 19 +++++++++++++++++++ - 2 files changed, 20 insertions(+), 1 deletion(-) - ---- a/include/linux/interrupt.h -+++ b/include/linux/interrupt.h -@@ -207,7 +207,7 @@ extern void devm_free_irq(struct device - #ifdef CONFIG_LOCKDEP - # define local_irq_enable_in_hardirq() do { } while (0) - #else --# define local_irq_enable_in_hardirq() local_irq_enable() -+# define local_irq_enable_in_hardirq() local_irq_enable_nort() - #endif - - extern void disable_irq_nosync(unsigned int irq); ---- a/include/linux/irqflags.h -+++ b/include/linux/irqflags.h -@@ -165,4 +165,23 @@ do { \ - - #define irqs_disabled_flags(flags) raw_irqs_disabled_flags(flags) - -+/* -+ * local_irq* variants depending on RT/!RT -+ */ -+#ifdef CONFIG_PREEMPT_RT_FULL -+# define local_irq_disable_nort() do { } while (0) -+# define local_irq_enable_nort() do { } while (0) -+# define local_irq_save_nort(flags) local_save_flags(flags) -+# define local_irq_restore_nort(flags) (void)(flags) -+# define local_irq_disable_rt() local_irq_disable() -+# define local_irq_enable_rt() local_irq_enable() -+#else -+# define local_irq_disable_nort() local_irq_disable() -+# define local_irq_enable_nort() local_irq_enable() -+# define local_irq_save_nort(flags) local_irq_save(flags) -+# define local_irq_restore_nort(flags) local_irq_restore(flags) -+# define local_irq_disable_rt() do { } while (0) -+# define local_irq_enable_rt() do { } while (0) -+#endif -+ - #endif diff --git a/debian/patches/features/all/rt/locallock-provide-get-put-_locked_ptr-variants.patch b/debian/patches/features/all/rt/locallock-provide-get-put-_locked_ptr-variants.patch index 6cc9d0694..14b1bf7ab 100644 --- a/debian/patches/features/all/rt/locallock-provide-get-put-_locked_ptr-variants.patch +++ b/debian/patches/features/all/rt/locallock-provide-get-put-_locked_ptr-variants.patch @@ -1,7 +1,6 @@ From: Julia Cartwright Date: Mon, 7 May 2018 08:58:56 -0500 Subject: [PATCH] locallock: provide {get,put}_locked_ptr() variants -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Provide a set of locallocked accessors for pointers to per-CPU data; this is useful for dynamically-allocated per-CPU regions, for example. diff --git a/debian/patches/features/all/rt/localversion.patch b/debian/patches/features/all/rt/localversion.patch index a268efce4..bbb083308 100644 --- a/debian/patches/features/all/rt/localversion.patch +++ b/debian/patches/features/all/rt/localversion.patch @@ -1,7 +1,6 @@ Subject: Add localversion for -RT release From: Thomas Gleixner Date: Fri, 08 Jul 2011 20:25:16 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Signed-off-by: Thomas Gleixner --- @@ -11,4 +10,4 @@ Signed-off-by: Thomas Gleixner --- /dev/null +++ b/localversion-rt @@ -0,0 +1 @@ -+-rt3 ++-rt7 diff --git a/debian/patches/features/all/rt/lockdep-Add-a-assert_in_softirq.patch b/debian/patches/features/all/rt/lockdep-Add-a-assert_in_softirq.patch deleted file mode 100644 index 8fc822fd6..000000000 --- a/debian/patches/features/all/rt/lockdep-Add-a-assert_in_softirq.patch +++ /dev/null @@ -1,34 +0,0 @@ -From: Anna-Maria Gleixner -Date: Tue, 10 Apr 2018 11:37:11 +0200 -Subject: [PATCH] lockdep: Add a assert_in_softirq() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz - -Instead of directly warn on wrong context, check if softirq context is -set. This check could be a nop on RT. - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - include/linux/lockdep.h | 6 ++++++ - 1 file changed, 6 insertions(+) - ---- a/include/linux/lockdep.h -+++ b/include/linux/lockdep.h -@@ -608,11 +608,17 @@ do { \ - "IRQs not disabled as expected\n"); \ - } while (0) - -+#define lockdep_assert_in_softirq() do { \ -+ WARN_ONCE(debug_locks && !current->lockdep_recursion && \ -+ !current->softirq_context, \ -+ "Not in softirq context as expected\n"); \ -+ } while (0) - #else - # define might_lock(lock) do { } while (0) - # define might_lock_read(lock) do { } while (0) - # define lockdep_assert_irqs_enabled() do { } while (0) - # define lockdep_assert_irqs_disabled() do { } while (0) -+# define lockdep_assert_in_softirq() do { } while (0) - #endif - - #ifdef CONFIG_LOCKDEP diff --git a/debian/patches/features/all/rt/lockdep-disable-self-test.patch b/debian/patches/features/all/rt/lockdep-disable-self-test.patch index 43d125198..034add368 100644 --- a/debian/patches/features/all/rt/lockdep-disable-self-test.patch +++ b/debian/patches/features/all/rt/lockdep-disable-self-test.patch @@ -4,7 +4,6 @@ Subject: [PATCH] lockdep: disable self-test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The self-test wasn't always 100% accurate for RT. We disabled a few tests which failed because they had a different semantic for RT. Some diff --git a/debian/patches/features/all/rt/lockdep-no-softirq-accounting-on-rt.patch b/debian/patches/features/all/rt/lockdep-no-softirq-accounting-on-rt.patch index dc1025a74..99adf2fd0 100644 --- a/debian/patches/features/all/rt/lockdep-no-softirq-accounting-on-rt.patch +++ b/debian/patches/features/all/rt/lockdep-no-softirq-accounting-on-rt.patch @@ -1,16 +1,14 @@ Subject: lockdep: Make it RT aware From: Thomas Gleixner Date: Sun, 17 Jul 2011 18:51:23 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz teach lockdep that we don't really do softirqs on -RT. Signed-off-by: Thomas Gleixner --- include/linux/irqflags.h | 23 +++++++++++++++-------- - include/linux/lockdep.h | 7 ++++++- kernel/locking/lockdep.c | 2 ++ - 3 files changed, 23 insertions(+), 9 deletions(-) + 2 files changed, 17 insertions(+), 8 deletions(-) --- a/include/linux/irqflags.h +++ b/include/linux/irqflags.h @@ -51,26 +49,6 @@ Signed-off-by: Thomas Gleixner #if defined(CONFIG_IRQSOFF_TRACER) || \ defined(CONFIG_PREEMPT_TRACER) ---- a/include/linux/lockdep.h -+++ b/include/linux/lockdep.h -@@ -608,11 +608,16 @@ do { \ - "IRQs not disabled as expected\n"); \ - } while (0) - --#define lockdep_assert_in_softirq() do { \ -+#ifdef CONFIG_PREEMPT_RT_FULL -+# define lockdep_assert_in_softirq() do { } while (0) -+#else -+# define lockdep_assert_in_softirq() do { \ - WARN_ONCE(debug_locks && !current->lockdep_recursion && \ - !current->softirq_context, \ - "Not in softirq context as expected\n"); \ - } while (0) -+#endif -+ - #else - # define might_lock(lock) do { } while (0) - # define might_lock_read(lock) do { } while (0) --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -3843,6 +3843,7 @@ static void check_flags(unsigned long fl diff --git a/debian/patches/features/all/rt/lockdep-selftest-fix-warnings-due-to-missing-PREEMPT.patch b/debian/patches/features/all/rt/lockdep-selftest-fix-warnings-due-to-missing-PREEMPT.patch index 3e21c52aa..01cc757dd 100644 --- a/debian/patches/features/all/rt/lockdep-selftest-fix-warnings-due-to-missing-PREEMPT.patch +++ b/debian/patches/features/all/rt/lockdep-selftest-fix-warnings-due-to-missing-PREEMPT.patch @@ -1,7 +1,6 @@ From: Josh Cartwright Date: Wed, 28 Jan 2015 13:08:45 -0600 Subject: lockdep: selftest: fix warnings due to missing PREEMPT_RT conditionals -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz "lockdep: Selftest: Only do hardirq context test for raw spinlock" disabled the execution of certain tests with PREEMPT_RT_FULL, but did diff --git a/debian/patches/features/all/rt/lockdep-selftest-only-do-hardirq-context-test-for-raw-spinlock.patch b/debian/patches/features/all/rt/lockdep-selftest-only-do-hardirq-context-test-for-raw-spinlock.patch index 48bb60880..6162cd2da 100644 --- a/debian/patches/features/all/rt/lockdep-selftest-only-do-hardirq-context-test-for-raw-spinlock.patch +++ b/debian/patches/features/all/rt/lockdep-selftest-only-do-hardirq-context-test-for-raw-spinlock.patch @@ -1,7 +1,6 @@ Subject: lockdep: selftest: Only do hardirq context test for raw spinlock From: Yong Zhang Date: Mon, 16 Apr 2012 15:01:56 +0800 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz From: Yong Zhang diff --git a/debian/patches/features/all/rt/locking-don-t-check-for-__LINUX_SPINLOCK_TYPES_H-on-.patch b/debian/patches/features/all/rt/locking-don-t-check-for-__LINUX_SPINLOCK_TYPES_H-on-.patch index ec96274bb..336a73567 100644 --- a/debian/patches/features/all/rt/locking-don-t-check-for-__LINUX_SPINLOCK_TYPES_H-on-.patch +++ b/debian/patches/features/all/rt/locking-don-t-check-for-__LINUX_SPINLOCK_TYPES_H-on-.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Fri, 4 Aug 2017 17:40:42 +0200 Subject: [PATCH 1/2] locking: don't check for __LINUX_SPINLOCK_TYPES_H on -RT archs -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream uses arch_spinlock_t within spinlock_t and requests that spinlock_types.h header file is included first. diff --git a/debian/patches/features/all/rt/locking-locktorture-Do-NOT-include-rwlock.h-directly.patch b/debian/patches/features/all/rt/locking-locktorture-Do-NOT-include-rwlock.h-directly.patch index 084ee0ed4..f825a7f49 100644 --- a/debian/patches/features/all/rt/locking-locktorture-Do-NOT-include-rwlock.h-directly.patch +++ b/debian/patches/features/all/rt/locking-locktorture-Do-NOT-include-rwlock.h-directly.patch @@ -1,7 +1,6 @@ From: "Wolfgang M. Reimer" Date: Tue, 21 Jul 2015 16:20:07 +0200 Subject: locking: locktorture: Do NOT include rwlock.h directly -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Including rwlock.h directly will cause kernel builds to fail if CONFIG_PREEMPT_RT_FULL is defined. The correct header file diff --git a/debian/patches/features/all/rt/locking-rt-mutex-fix-deadlock-in-device-mapper-block.patch b/debian/patches/features/all/rt/locking-rt-mutex-fix-deadlock-in-device-mapper-block.patch index 3ebc19e24..2148ff6b5 100644 --- a/debian/patches/features/all/rt/locking-rt-mutex-fix-deadlock-in-device-mapper-block.patch +++ b/debian/patches/features/all/rt/locking-rt-mutex-fix-deadlock-in-device-mapper-block.patch @@ -1,7 +1,6 @@ From: Mikulas Patocka Date: Mon, 13 Nov 2017 12:56:53 -0500 Subject: [PATCH] locking/rt-mutex: fix deadlock in device mapper / block-IO -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz When some block device driver creates a bio and submits it to another block device driver, the bio is added to current->bio_list (in order to diff --git a/debian/patches/features/all/rt/locking-rtmutex-Handle-non-enqueued-waiters-graceful.patch b/debian/patches/features/all/rt/locking-rtmutex-Handle-non-enqueued-waiters-graceful.patch index 667368577..f93e0f509 100644 --- a/debian/patches/features/all/rt/locking-rtmutex-Handle-non-enqueued-waiters-graceful.patch +++ b/debian/patches/features/all/rt/locking-rtmutex-Handle-non-enqueued-waiters-graceful.patch @@ -2,7 +2,6 @@ From: Peter Zijlstra Date: Tue, 27 Mar 2018 14:14:38 +0200 Subject: [PATCH] locking/rtmutex: Handle non enqueued waiters gracefully in remove_waiter() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit c28d62cf52d791ba5f6db7ce525ed06b86291c82 diff --git a/debian/patches/features/all/rt/locking-rtmutex-don-t-drop-the-wait_lock-twice.patch b/debian/patches/features/all/rt/locking-rtmutex-don-t-drop-the-wait_lock-twice.patch index 20d14b59a..3cbe9b669 100644 --- a/debian/patches/features/all/rt/locking-rtmutex-don-t-drop-the-wait_lock-twice.patch +++ b/debian/patches/features/all/rt/locking-rtmutex-don-t-drop-the-wait_lock-twice.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 7 Sep 2017 12:38:47 +0200 Subject: locking/rtmutex: don't drop the wait_lock twice -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Since the futex rework, __rt_mutex_start_proxy_lock() does no longer acquire the wait_lock so it must not drop it. Otherwise the lock is not diff --git a/debian/patches/features/all/rt/locking-rtmutex-re-init-the-wait_lock-in-rt_mutex_in.patch b/debian/patches/features/all/rt/locking-rtmutex-re-init-the-wait_lock-in-rt_mutex_in.patch index 66aaf9fe4..5b3a6679f 100644 --- a/debian/patches/features/all/rt/locking-rtmutex-re-init-the-wait_lock-in-rt_mutex_in.patch +++ b/debian/patches/features/all/rt/locking-rtmutex-re-init-the-wait_lock-in-rt_mutex_in.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 16 Nov 2017 16:48:48 +0100 Subject: [PATCH] locking/rtmutex: re-init the wait_lock in rt_mutex_init_proxy_locked() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz We could provide a key-class for the lockdep (and fixup all callers) or move the init to all callers (like it was) in order to avoid lockdep diff --git a/debian/patches/features/all/rt/md-disable-bcache.patch b/debian/patches/features/all/rt/md-disable-bcache.patch index 2350c07c9..fdfe59336 100644 --- a/debian/patches/features/all/rt/md-disable-bcache.patch +++ b/debian/patches/features/all/rt/md-disable-bcache.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 29 Aug 2013 11:48:57 +0200 Subject: md: disable bcache -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz It uses anon semaphores |drivers/md/bcache/request.c: In function ‘cached_dev_write_complete’: diff --git a/debian/patches/features/all/rt/md-raid5-do-not-disable-interrupts.patch b/debian/patches/features/all/rt/md-raid5-do-not-disable-interrupts.patch deleted file mode 100644 index 0dfc996e8..000000000 --- a/debian/patches/features/all/rt/md-raid5-do-not-disable-interrupts.patch +++ /dev/null @@ -1,55 +0,0 @@ -From: Sebastian Andrzej Siewior -Date: Fri, 17 Nov 2017 16:21:00 +0100 -Subject: [PATCH] md/raid5: do not disable interrupts -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -|BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:974 -|in_atomic(): 0, irqs_disabled(): 1, pid: 2992, name: lvm -|CPU: 2 PID: 2992 Comm: lvm Not tainted 4.13.10-rt3+ #54 -|Call Trace: -| dump_stack+0x4f/0x65 -| ___might_sleep+0xfc/0x150 -| atomic_dec_and_spin_lock+0x3c/0x80 -| raid5_release_stripe+0x73/0x110 -| grow_one_stripe+0xce/0xf0 -| setup_conf+0x841/0xaa0 -| raid5_run+0x7e7/0xa40 -| md_run+0x515/0xaf0 -| raid_ctr+0x147d/0x25e0 -| dm_table_add_target+0x155/0x320 -| table_load+0x103/0x320 -| ctl_ioctl+0x1d9/0x510 -| dm_ctl_ioctl+0x9/0x10 -| do_vfs_ioctl+0x8e/0x670 -| SyS_ioctl+0x3c/0x70 -| entry_SYSCALL_64_fastpath+0x17/0x98 - -The interrupts were disabled because ->device_lock is taken with -interrupts disabled. - -Cc: stable-rt@vger.kernel.org -Signed-off-by: Sebastian Andrzej Siewior ---- - drivers/md/raid5.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/drivers/md/raid5.c -+++ b/drivers/md/raid5.c -@@ -410,7 +410,7 @@ void raid5_release_stripe(struct stripe_ - md_wakeup_thread(conf->mddev->thread); - return; - slow_path: -- local_irq_save(flags); -+ local_irq_save_nort(flags); - /* we are ok here if STRIPE_ON_RELEASE_LIST is set or not */ - if (atomic_dec_and_lock(&sh->count, &conf->device_lock)) { - INIT_LIST_HEAD(&list); -@@ -419,7 +419,7 @@ void raid5_release_stripe(struct stripe_ - spin_unlock(&conf->device_lock); - release_inactive_stripe_list(conf, &list, hash); - } -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - } - - static inline void remove_hash(struct stripe_head *sh) diff --git a/debian/patches/features/all/rt/md-raid5-percpu-handling-rt-aware.patch b/debian/patches/features/all/rt/md-raid5-percpu-handling-rt-aware.patch index 26839354f..df0c39443 100644 --- a/debian/patches/features/all/rt/md-raid5-percpu-handling-rt-aware.patch +++ b/debian/patches/features/all/rt/md-raid5-percpu-handling-rt-aware.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Tue, 6 Apr 2010 16:51:31 +0200 Subject: md: raid5: Make raid5_percpu handling RT aware -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz __raid_run_ops() disables preemption with get_cpu() around the access to the raid5_percpu variables. That causes scheduling while atomic @@ -42,7 +41,7 @@ Tested-by: Udo van den Heuvel } static void free_stripe(struct kmem_cache *sc, struct stripe_head *sh) -@@ -6789,6 +6791,7 @@ static int raid456_cpu_up_prepare(unsign +@@ -6788,6 +6790,7 @@ static int raid456_cpu_up_prepare(unsign __func__, cpu); return -ENOMEM; } @@ -50,7 +49,7 @@ Tested-by: Udo van den Heuvel return 0; } -@@ -6799,7 +6802,6 @@ static int raid5_alloc_percpu(struct r5c +@@ -6798,7 +6801,6 @@ static int raid5_alloc_percpu(struct r5c conf->percpu = alloc_percpu(struct raid5_percpu); if (!conf->percpu) return -ENOMEM; diff --git a/debian/patches/features/all/rt/mfd-syscon-atmel-smc-include-string.h.patch b/debian/patches/features/all/rt/mfd-syscon-atmel-smc-include-string.h.patch index f983e50f2..db4e313e6 100644 --- a/debian/patches/features/all/rt/mfd-syscon-atmel-smc-include-string.h.patch +++ b/debian/patches/features/all/rt/mfd-syscon-atmel-smc-include-string.h.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 4 Oct 2017 09:55:58 +0200 Subject: [PATCH] mfd: syscon: atmel-smc: include string.h -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The string.h header file is needed for the memset() definition. The RT build fails because it is not pulled in via other header files. diff --git a/debian/patches/features/all/rt/mips-disable-highmem-on-rt.patch b/debian/patches/features/all/rt/mips-disable-highmem-on-rt.patch index da10a61e1..0ff1fe530 100644 --- a/debian/patches/features/all/rt/mips-disable-highmem-on-rt.patch +++ b/debian/patches/features/all/rt/mips-disable-highmem-on-rt.patch @@ -1,7 +1,6 @@ Subject: mips: Disable highmem on RT From: Thomas Gleixner Date: Mon, 18 Jul 2011 17:10:12 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The current highmem handling on -RT is not compatible and needs fixups. diff --git a/debian/patches/features/all/rt/mm--rt--Fix-generic-kmap_atomic-for-RT.patch b/debian/patches/features/all/rt/mm--rt--Fix-generic-kmap_atomic-for-RT.patch index 2782ff24c..3549e58fd 100644 --- a/debian/patches/features/all/rt/mm--rt--Fix-generic-kmap_atomic-for-RT.patch +++ b/debian/patches/features/all/rt/mm--rt--Fix-generic-kmap_atomic-for-RT.patch @@ -1,7 +1,6 @@ Subject: mm: rt: Fix generic kmap_atomic for RT From: Thomas Gleixner Date: Sat, 19 Sep 2015 10:15:00 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The update to 4.1 brought in the mainline variant of the pagefault disable distangling from preempt count. That introduced a diff --git a/debian/patches/features/all/rt/mm-backing-dev-don-t-disable-IRQs-in-wb_congested_pu.patch b/debian/patches/features/all/rt/mm-backing-dev-don-t-disable-IRQs-in-wb_congested_pu.patch deleted file mode 100644 index 06c410eaa..000000000 --- a/debian/patches/features/all/rt/mm-backing-dev-don-t-disable-IRQs-in-wb_congested_pu.patch +++ /dev/null @@ -1,42 +0,0 @@ -From: Sebastian Andrzej Siewior -Date: Fri, 5 Feb 2016 12:17:14 +0100 -Subject: mm: backing-dev: don't disable IRQs in wb_congested_put() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -it triggers: -|BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:930 -|in_atomic(): 0, irqs_disabled(): 1, pid: 12, name: rcuc/0 -|1 lock held by rcuc/0/12: -| #0: (rcu_callback){......}, at: [] rcu_cpu_kthread+0x376/0xb10 -|irq event stamp: 23636 -|hardirqs last enabled at (23635): [] _raw_spin_unlock_irqrestore+0x6c/0x80 -|hardirqs last disabled at (23636): [] wb_congested_put+0x18/0x90 -| [] rt_spin_lock+0x24/0x60 -| [] atomic_dec_and_spin_lock+0x52/0x90 -| [] wb_congested_put+0x28/0x90 -| [] __blkg_release_rcu+0x5e/0x1e0 -| [] ? __blkg_release_rcu+0x87/0x1e0 -| [] ? blkg_conf_finish+0x90/0x90 -| [] rcu_cpu_kthread+0x3b7/0xb10 - -due to cgwb_lock beeing taken with spin_lock_irqsave() usually. - -Signed-off-by: Sebastian Andrzej Siewior ---- - mm/backing-dev.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/mm/backing-dev.c -+++ b/mm/backing-dev.c -@@ -482,9 +482,9 @@ void wb_congested_put(struct bdi_writeba - { - unsigned long flags; - -- local_irq_save(flags); -+ local_irq_save_nort(flags); - if (!atomic_dec_and_lock(&congested->refcnt, &cgwb_lock)) { -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - return; - } - diff --git a/debian/patches/features/all/rt/mm-bounce-local-irq-save-nort.patch b/debian/patches/features/all/rt/mm-bounce-local-irq-save-nort.patch deleted file mode 100644 index 1c292aac9..000000000 --- a/debian/patches/features/all/rt/mm-bounce-local-irq-save-nort.patch +++ /dev/null @@ -1,28 +0,0 @@ -Subject: mm: bounce: Use local_irq_save_nort -From: Thomas Gleixner -Date: Wed, 09 Jan 2013 10:33:09 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -kmap_atomic() is preemptible on RT. - -Signed-off-by: Thomas Gleixner ---- - block/bounce.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/block/bounce.c -+++ b/block/bounce.c -@@ -66,11 +66,11 @@ static void bounce_copy_vec(struct bio_v - unsigned long flags; - unsigned char *vto; - -- local_irq_save(flags); -+ local_irq_save_nort(flags); - vto = kmap_atomic(to->bv_page); - memcpy(vto + to->bv_offset, vfrom, to->bv_len); - kunmap_atomic(vto); -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - } - - #else /* CONFIG_HIGHMEM */ diff --git a/debian/patches/features/all/rt/mm-convert-swap-to-percpu-locked.patch b/debian/patches/features/all/rt/mm-convert-swap-to-percpu-locked.patch index 493962571..0af58aae0 100644 --- a/debian/patches/features/all/rt/mm-convert-swap-to-percpu-locked.patch +++ b/debian/patches/features/all/rt/mm-convert-swap-to-percpu-locked.patch @@ -1,7 +1,6 @@ From: Ingo Molnar Date: Fri, 3 Jul 2009 08:29:51 -0500 Subject: mm/swap: Convert to percpu locked -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Replace global locks (get_cpu + local_irq_save) with "local_locks()". Currently there is one of for "rotate" and one for "swap". diff --git a/debian/patches/features/all/rt/mm-disable-sloub-rt.patch b/debian/patches/features/all/rt/mm-disable-sloub-rt.patch index 2b7cc0fc6..ab1a8b638 100644 --- a/debian/patches/features/all/rt/mm-disable-sloub-rt.patch +++ b/debian/patches/features/all/rt/mm-disable-sloub-rt.patch @@ -1,7 +1,6 @@ From: Ingo Molnar Date: Fri, 3 Jul 2009 08:44:03 -0500 Subject: mm: Allow only slub on RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Disable SLAB and SLOB on -RT. Only SLUB is adopted to -RT needs. diff --git a/debian/patches/features/all/rt/mm-enable-slub.patch b/debian/patches/features/all/rt/mm-enable-slub.patch index 3299f5ca1..c307ea59d 100644 --- a/debian/patches/features/all/rt/mm-enable-slub.patch +++ b/debian/patches/features/all/rt/mm-enable-slub.patch @@ -1,7 +1,6 @@ Subject: mm: Enable SLUB for RT From: Thomas Gleixner Date: Thu, 25 Oct 2012 10:32:35 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Make SLUB RT aware by converting locks to raw and using free lists to move the freeing out of the lock held region. diff --git a/debian/patches/features/all/rt/mm-make-vmstat-rt-aware.patch b/debian/patches/features/all/rt/mm-make-vmstat-rt-aware.patch index 35978435a..78d52653a 100644 --- a/debian/patches/features/all/rt/mm-make-vmstat-rt-aware.patch +++ b/debian/patches/features/all/rt/mm-make-vmstat-rt-aware.patch @@ -1,7 +1,6 @@ From: Ingo Molnar Date: Fri, 3 Jul 2009 08:30:13 -0500 Subject: mm/vmstat: Protect per cpu variables with preempt disable on RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Disable preemption on -RT for the vmstat code. On vanila the code runs in IRQ-off regions while on -RT it is not. "preempt_disable" ensures that the diff --git a/debian/patches/features/all/rt/mm-memcontrol-Don-t-call-schedule_work_on-in-preempt.patch b/debian/patches/features/all/rt/mm-memcontrol-Don-t-call-schedule_work_on-in-preempt.patch index 5a0b5db45..52ddca411 100644 --- a/debian/patches/features/all/rt/mm-memcontrol-Don-t-call-schedule_work_on-in-preempt.patch +++ b/debian/patches/features/all/rt/mm-memcontrol-Don-t-call-schedule_work_on-in-preempt.patch @@ -1,7 +1,6 @@ From: Yang Shi Subject: mm/memcontrol: Don't call schedule_work_on in preemption disabled context Date: Wed, 30 Oct 2013 11:48:33 -0700 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz The following trace is triggered when running ltp oom test cases: diff --git a/debian/patches/features/all/rt/mm-memcontrol-do_not_disable_irq.patch b/debian/patches/features/all/rt/mm-memcontrol-do_not_disable_irq.patch index f936851b2..b87b62475 100644 --- a/debian/patches/features/all/rt/mm-memcontrol-do_not_disable_irq.patch +++ b/debian/patches/features/all/rt/mm-memcontrol-do_not_disable_irq.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Subject: mm/memcontrol: Replace local_irq_disable with local locks Date: Wed, 28 Jan 2015 17:14:16 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz There are a few local_irq_disable() which then take sleeping locks. This patch converts them local locks. @@ -30,7 +29,7 @@ Signed-off-by: Sebastian Andrzej Siewior /* Whether legacy memory+swap accounting is active */ static bool do_memsw_account(void) { -@@ -4540,12 +4543,12 @@ static int mem_cgroup_move_account(struc +@@ -4543,12 +4546,12 @@ static int mem_cgroup_move_account(struc ret = 0; @@ -45,7 +44,7 @@ Signed-off-by: Sebastian Andrzej Siewior out_unlock: unlock_page(page); out: -@@ -5488,10 +5491,10 @@ void mem_cgroup_commit_charge(struct pag +@@ -5491,10 +5494,10 @@ void mem_cgroup_commit_charge(struct pag commit_charge(page, memcg, lrucare); @@ -58,7 +57,7 @@ Signed-off-by: Sebastian Andrzej Siewior if (do_memsw_account() && PageSwapCache(page)) { swp_entry_t entry = { .val = page_private(page) }; -@@ -5560,7 +5563,7 @@ static void uncharge_batch(const struct +@@ -5563,7 +5566,7 @@ static void uncharge_batch(const struct memcg_oom_recover(ug->memcg); } @@ -67,7 +66,7 @@ Signed-off-by: Sebastian Andrzej Siewior __mod_memcg_state(ug->memcg, MEMCG_RSS, -ug->nr_anon); __mod_memcg_state(ug->memcg, MEMCG_CACHE, -ug->nr_file); __mod_memcg_state(ug->memcg, MEMCG_RSS_HUGE, -ug->nr_huge); -@@ -5568,7 +5571,7 @@ static void uncharge_batch(const struct +@@ -5571,7 +5574,7 @@ static void uncharge_batch(const struct __count_memcg_events(ug->memcg, PGPGOUT, ug->pgpgout); __this_cpu_add(ug->memcg->stat_cpu->nr_page_events, nr_pages); memcg_check_events(ug->memcg, ug->dummy_page); @@ -76,7 +75,7 @@ Signed-off-by: Sebastian Andrzej Siewior if (!mem_cgroup_is_root(ug->memcg)) css_put_many(&ug->memcg->css, nr_pages); -@@ -5731,10 +5734,10 @@ void mem_cgroup_migrate(struct page *old +@@ -5734,10 +5737,10 @@ void mem_cgroup_migrate(struct page *old commit_charge(newpage, memcg, false); @@ -89,7 +88,7 @@ Signed-off-by: Sebastian Andrzej Siewior } DEFINE_STATIC_KEY_FALSE(memcg_sockets_enabled_key); -@@ -5926,6 +5929,7 @@ void mem_cgroup_swapout(struct page *pag +@@ -5929,6 +5932,7 @@ void mem_cgroup_swapout(struct page *pag struct mem_cgroup *memcg, *swap_memcg; unsigned int nr_entries; unsigned short oldid; @@ -97,7 +96,7 @@ Signed-off-by: Sebastian Andrzej Siewior VM_BUG_ON_PAGE(PageLRU(page), page); VM_BUG_ON_PAGE(page_count(page), page); -@@ -5971,13 +5975,17 @@ void mem_cgroup_swapout(struct page *pag +@@ -5974,13 +5978,17 @@ void mem_cgroup_swapout(struct page *pag * important here to have the interrupts disabled because it is the * only synchronisation we have for udpating the per-CPU variables. */ diff --git a/debian/patches/features/all/rt/mm-page-alloc-use-local-lock-on-target-cpu.patch b/debian/patches/features/all/rt/mm-page-alloc-use-local-lock-on-target-cpu.patch index 735e89319..b05b0552d 100644 --- a/debian/patches/features/all/rt/mm-page-alloc-use-local-lock-on-target-cpu.patch +++ b/debian/patches/features/all/rt/mm-page-alloc-use-local-lock-on-target-cpu.patch @@ -1,7 +1,6 @@ Subject: mm: page_alloc: Use local_lock_on() instead of plain spinlock From: Thomas Gleixner Date: Thu, 27 Sep 2012 11:11:46 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The plain spinlock while sufficient does not update the local_lock internals. Use a proper local_lock function instead to ease debugging. diff --git a/debian/patches/features/all/rt/mm-page_alloc-reduce-lock-sections-further.patch b/debian/patches/features/all/rt/mm-page_alloc-reduce-lock-sections-further.patch index 5fdf4b97b..def1f9eb2 100644 --- a/debian/patches/features/all/rt/mm-page_alloc-reduce-lock-sections-further.patch +++ b/debian/patches/features/all/rt/mm-page_alloc-reduce-lock-sections-further.patch @@ -1,7 +1,6 @@ From: Peter Zijlstra Date: Fri Jul 3 08:44:37 2009 -0500 Subject: mm: page_alloc: Reduce lock sections further -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Split out the pages which are to be freed into a separate list and call free_pages_bulk() outside of the percpu page allocator locks. diff --git a/debian/patches/features/all/rt/mm-page_alloc-rt-friendly-per-cpu-pages.patch b/debian/patches/features/all/rt/mm-page_alloc-rt-friendly-per-cpu-pages.patch index a9db60520..cec60ff75 100644 --- a/debian/patches/features/all/rt/mm-page_alloc-rt-friendly-per-cpu-pages.patch +++ b/debian/patches/features/all/rt/mm-page_alloc-rt-friendly-per-cpu-pages.patch @@ -1,7 +1,6 @@ From: Ingo Molnar Date: Fri, 3 Jul 2009 08:29:37 -0500 Subject: mm: page_alloc: rt-friendly per-cpu pages -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz rt-friendly per-cpu pages: convert the irqs-off per-cpu locking method into a preemptible, explicit-per-cpu-locks method. diff --git a/debian/patches/features/all/rt/mm-perform-lru_add_drain_all-remotely.patch b/debian/patches/features/all/rt/mm-perform-lru_add_drain_all-remotely.patch index fe59d719f..638e0ce4f 100644 --- a/debian/patches/features/all/rt/mm-perform-lru_add_drain_all-remotely.patch +++ b/debian/patches/features/all/rt/mm-perform-lru_add_drain_all-remotely.patch @@ -1,7 +1,6 @@ From: Luiz Capitulino Date: Fri, 27 May 2016 15:03:28 +0200 Subject: [PATCH] mm: perform lru_add_drain_all() remotely -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz lru_add_drain_all() works by scheduling lru_add_drain_cpu() to run on all CPUs that have non-empty LRU pagevecs and then waiting for diff --git a/debian/patches/features/all/rt/mm-protect-activate-switch-mm.patch b/debian/patches/features/all/rt/mm-protect-activate-switch-mm.patch index 3db9a2afe..16cc40ca0 100644 --- a/debian/patches/features/all/rt/mm-protect-activate-switch-mm.patch +++ b/debian/patches/features/all/rt/mm-protect-activate-switch-mm.patch @@ -1,7 +1,6 @@ From: Yong Zhang Date: Tue, 15 May 2012 13:53:56 +0800 Subject: mm: Protect activate_mm() by preempt_[disable&enable]_rt() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz User preempt_*_rt instead of local_irq_*_rt or otherwise there will be warning on ARM like below: diff --git a/debian/patches/features/all/rt/mm-rt-kmap-atomic-scheduling.patch b/debian/patches/features/all/rt/mm-rt-kmap-atomic-scheduling.patch index dd179eb6b..5e40984ec 100644 --- a/debian/patches/features/all/rt/mm-rt-kmap-atomic-scheduling.patch +++ b/debian/patches/features/all/rt/mm-rt-kmap-atomic-scheduling.patch @@ -1,7 +1,6 @@ Subject: mm, rt: kmap_atomic scheduling From: Peter Zijlstra Date: Thu, 28 Jul 2011 10:43:51 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz In fact, with migrate_disable() existing one could play games with kmap_atomic. You could save/restore the kmap_atomic slots on context diff --git a/debian/patches/features/all/rt/mm-scatterlist-dont-disable-irqs-on-RT.patch b/debian/patches/features/all/rt/mm-scatterlist-dont-disable-irqs-on-RT.patch index ea5bf1acd..cbb3bafa4 100644 --- a/debian/patches/features/all/rt/mm-scatterlist-dont-disable-irqs-on-RT.patch +++ b/debian/patches/features/all/rt/mm-scatterlist-dont-disable-irqs-on-RT.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Fri, 3 Jul 2009 08:44:34 -0500 Subject: mm/scatterlist: Do not disable irqs on RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz For -RT it is enough to keep pagefault disabled (which is currently handled by kmap_atomic()). diff --git a/debian/patches/features/all/rt/mm-slub-close-possible-memory-leak-in-kmem_cache_all.patch b/debian/patches/features/all/rt/mm-slub-close-possible-memory-leak-in-kmem_cache_all.patch deleted file mode 100644 index bb49f2269..000000000 --- a/debian/patches/features/all/rt/mm-slub-close-possible-memory-leak-in-kmem_cache_all.patch +++ /dev/null @@ -1,26 +0,0 @@ -From: Sebastian Andrzej Siewior -Date: Wed, 13 Dec 2017 12:44:14 +0100 -Subject: [PATCH] mm/slub: close possible memory-leak in - kmem_cache_alloc_bulk() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Under certain circumstances we could leak elements which were moved to -the local "to_free" list. The damage is limited since I can't find -any users here. - -Cc: stable-rt@vger.kernel.org -Signed-off-by: Sebastian Andrzej Siewior ---- - mm/slub.c | 1 + - 1 file changed, 1 insertion(+) - ---- a/mm/slub.c -+++ b/mm/slub.c -@@ -3241,6 +3241,7 @@ int kmem_cache_alloc_bulk(struct kmem_ca - return i; - error: - local_irq_enable(); -+ free_delayed(&to_free); - slab_post_alloc_hook(s, flags, i, p); - __kmem_cache_free_bulk(s, i, p); - return 0; diff --git a/debian/patches/features/all/rt/mm-vmalloc-use-get-cpu-light.patch b/debian/patches/features/all/rt/mm-vmalloc-use-get-cpu-light.patch index cfb4a56d0..0690a5e46 100644 --- a/debian/patches/features/all/rt/mm-vmalloc-use-get-cpu-light.patch +++ b/debian/patches/features/all/rt/mm-vmalloc-use-get-cpu-light.patch @@ -1,7 +1,6 @@ Subject: mm/vmalloc: Another preempt disable region which sucks From: Thomas Gleixner Date: Tue, 12 Jul 2011 11:39:36 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Avoid the preempt disable version of get_cpu_var(). The inner-lock should provide enough serialisation. diff --git a/debian/patches/features/all/rt/mm-workingset-do-not-protect-workingset_shadow_nodes.patch b/debian/patches/features/all/rt/mm-workingset-do-not-protect-workingset_shadow_nodes.patch index 57276a12c..2de3bb2f6 100644 --- a/debian/patches/features/all/rt/mm-workingset-do-not-protect-workingset_shadow_nodes.patch +++ b/debian/patches/features/all/rt/mm-workingset-do-not-protect-workingset_shadow_nodes.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 29 Jan 2015 17:19:44 +0100 Subject: mm/workingset: Do not protect workingset_shadow_nodes with irq off -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz workingset_shadow_nodes is protected by local_irq_disable(). Some users use spin_lock_irq(). diff --git a/debian/patches/features/all/rt/mm_zsmalloc_copy_with_get_cpu_var_and_locking.patch b/debian/patches/features/all/rt/mm_zsmalloc_copy_with_get_cpu_var_and_locking.patch index 59930a34c..f6217ec02 100644 --- a/debian/patches/features/all/rt/mm_zsmalloc_copy_with_get_cpu_var_and_locking.patch +++ b/debian/patches/features/all/rt/mm_zsmalloc_copy_with_get_cpu_var_and_locking.patch @@ -1,7 +1,6 @@ From: Mike Galbraith Date: Tue, 22 Mar 2016 11:16:09 +0100 Subject: [PATCH] mm/zsmalloc: copy with get_cpu_var() and locking -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz get_cpu_var() disables preemption and triggers a might_sleep() splat later. This is replaced with get_locked_var(). diff --git a/debian/patches/features/all/rt/mmci-remove-bogus-irq-save.patch b/debian/patches/features/all/rt/mmci-remove-bogus-irq-save.patch index 012a4ea18..8854042b6 100644 --- a/debian/patches/features/all/rt/mmci-remove-bogus-irq-save.patch +++ b/debian/patches/features/all/rt/mmci-remove-bogus-irq-save.patch @@ -1,7 +1,6 @@ Subject: mmci: Remove bogus local_irq_save() From: Thomas Gleixner Date: Wed, 09 Jan 2013 12:11:12 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz upstream commit 99d02d6cd5610711d91f286bb67a57142028e9e6 diff --git a/debian/patches/features/all/rt/move_sched_delayed_work_to_helper.patch b/debian/patches/features/all/rt/move_sched_delayed_work_to_helper.patch deleted file mode 100644 index 62ea199ae..000000000 --- a/debian/patches/features/all/rt/move_sched_delayed_work_to_helper.patch +++ /dev/null @@ -1,73 +0,0 @@ -Date: Wed, 26 Jun 2013 15:28:11 -0400 -From: Steven Rostedt -Subject: rt,ntp: Move call to schedule_delayed_work() to helper thread -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The ntp code for notify_cmos_timer() is called from a hard interrupt -context. schedule_delayed_work() under PREEMPT_RT_FULL calls spinlocks -that have been converted to mutexes, thus calling schedule_delayed_work() -from interrupt is not safe. - -Add a helper thread that does the call to schedule_delayed_work and wake -up that thread instead of calling schedule_delayed_work() directly. -This is only for CONFIG_PREEMPT_RT_FULL, otherwise the code still calls -schedule_delayed_work() directly in irq context. - -Note: There's a few places in the kernel that do this. Perhaps the RT -code should have a dedicated thread that does the checks. Just register -a notifier on boot up for your check and wake up the thread when -needed. This will be a todo. - -Signed-off-by: Steven Rostedt -[bigeasy: use swork_queue() instead a helper thread] -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/time/ntp.c | 26 ++++++++++++++++++++++++++ - 1 file changed, 26 insertions(+) - ---- a/kernel/time/ntp.c -+++ b/kernel/time/ntp.c -@@ -18,6 +18,7 @@ - #include - #include - #include -+#include - - #include "ntp_internal.h" - #include "timekeeping_internal.h" -@@ -569,10 +570,35 @@ static void sync_cmos_clock(struct work_ - &sync_cmos_work, timespec64_to_jiffies(&next)); - } - -+#ifdef CONFIG_PREEMPT_RT_FULL -+ -+static void run_clock_set_delay(struct swork_event *event) -+{ -+ queue_delayed_work(system_power_efficient_wq, &sync_cmos_work, 0); -+} -+ -+static struct swork_event ntp_cmos_swork; -+ -+void ntp_notify_cmos_timer(void) -+{ -+ swork_queue(&ntp_cmos_swork); -+} -+ -+static __init int create_cmos_delay_thread(void) -+{ -+ WARN_ON(swork_get()); -+ INIT_SWORK(&ntp_cmos_swork, run_clock_set_delay); -+ return 0; -+} -+early_initcall(create_cmos_delay_thread); -+ -+#else -+ - void ntp_notify_cmos_timer(void) - { - queue_delayed_work(system_power_efficient_wq, &sync_cmos_work, 0); - } -+#endif /* CONFIG_PREEMPT_RT_FULL */ - - #else - void ntp_notify_cmos_timer(void) { } diff --git a/debian/patches/features/all/rt/mutex-no-spin-on-rt.patch b/debian/patches/features/all/rt/mutex-no-spin-on-rt.patch index 4f04e3645..6f7ca0e2e 100644 --- a/debian/patches/features/all/rt/mutex-no-spin-on-rt.patch +++ b/debian/patches/features/all/rt/mutex-no-spin-on-rt.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Sun, 17 Jul 2011 21:51:45 +0200 Subject: locking: Disable spin on owner for RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Drop spin on owner for mutex / rwsem. We are most likely not using it but… diff --git a/debian/patches/features/all/rt/net-3com-3c59x-Move-boomerang-vortex-conditional-int.patch b/debian/patches/features/all/rt/net-3com-3c59x-Move-boomerang-vortex-conditional-int.patch index 6c112ce96..09d5fe769 100644 --- a/debian/patches/features/all/rt/net-3com-3c59x-Move-boomerang-vortex-conditional-int.patch +++ b/debian/patches/features/all/rt/net-3com-3c59x-Move-boomerang-vortex-conditional-int.patch @@ -2,7 +2,6 @@ From: Anna-Maria Gleixner Date: Thu, 12 Apr 2018 18:36:14 +0200 Subject: [PATCH] net: 3com: 3c59x: Move boomerang/vortex conditional into function -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz If vp->full_bus_master_tx is set, vp->full_bus_master_rx is set as well (see vortex_probe1()). Therefore the conditionals for the decision if @@ -44,7 +43,7 @@ Signed-off-by: Sebastian Andrzej Siewior local_irq_restore(flags); } #endif -@@ -1729,8 +1729,7 @@ vortex_open(struct net_device *dev) +@@ -1728,8 +1728,7 @@ vortex_open(struct net_device *dev) dma_addr_t dma; /* Use the now-standard shared IRQ implementation. */ @@ -54,7 +53,7 @@ Signed-off-by: Sebastian Andrzej Siewior pr_err("%s: Could not reserve IRQ %d\n", dev->name, dev->irq); goto err; } -@@ -1911,10 +1910,7 @@ static void vortex_tx_timeout(struct net +@@ -1910,10 +1909,7 @@ static void vortex_tx_timeout(struct net */ unsigned long flags; local_irq_save(flags); @@ -66,7 +65,7 @@ Signed-off-by: Sebastian Andrzej Siewior local_irq_restore(flags); } } -@@ -2267,9 +2263,8 @@ boomerang_start_xmit(struct sk_buff *skb +@@ -2266,9 +2262,8 @@ boomerang_start_xmit(struct sk_buff *skb */ static irqreturn_t @@ -77,7 +76,7 @@ Signed-off-by: Sebastian Andrzej Siewior struct vortex_private *vp = netdev_priv(dev); void __iomem *ioaddr; int status; -@@ -2386,9 +2381,8 @@ vortex_interrupt(int irq, void *dev_id) +@@ -2385,9 +2380,8 @@ vortex_interrupt(int irq, void *dev_id) */ static irqreturn_t @@ -88,7 +87,7 @@ Signed-off-by: Sebastian Andrzej Siewior struct vortex_private *vp = netdev_priv(dev); void __iomem *ioaddr; int status; -@@ -2526,6 +2520,18 @@ boomerang_interrupt(int irq, void *dev_i +@@ -2525,6 +2519,18 @@ boomerang_interrupt(int irq, void *dev_i return IRQ_RETVAL(handled); } diff --git a/debian/patches/features/all/rt/net-3com-3c59x-Pull-locking-out-of-ISR.patch b/debian/patches/features/all/rt/net-3com-3c59x-Pull-locking-out-of-ISR.patch index 5c25ac629..ac59d2e1f 100644 --- a/debian/patches/features/all/rt/net-3com-3c59x-Pull-locking-out-of-ISR.patch +++ b/debian/patches/features/all/rt/net-3com-3c59x-Pull-locking-out-of-ISR.patch @@ -1,7 +1,6 @@ From: Anna-Maria Gleixner Date: Thu, 12 Apr 2018 18:36:15 +0200 Subject: [PATCH] net: 3com: 3c59x: Pull locking out of ISR -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Locking is done in the same way in _vortex_interrupt() and _boomerang_interrupt(). To prevent duplication, move the locking into the @@ -17,7 +16,7 @@ Signed-off-by: Sebastian Andrzej Siewior --- a/drivers/net/ethernet/3com/3c59x.c +++ b/drivers/net/ethernet/3com/3c59x.c -@@ -2273,7 +2273,6 @@ static irqreturn_t +@@ -2272,7 +2272,6 @@ static irqreturn_t unsigned int bytes_compl = 0, pkts_compl = 0; ioaddr = vp->ioaddr; @@ -25,7 +24,7 @@ Signed-off-by: Sebastian Andrzej Siewior status = ioread16(ioaddr + EL3_STATUS); -@@ -2371,7 +2370,6 @@ static irqreturn_t +@@ -2370,7 +2369,6 @@ static irqreturn_t pr_debug("%s: exiting interrupt, status %4.4x.\n", dev->name, status); handler_exit: @@ -33,7 +32,7 @@ Signed-off-by: Sebastian Andrzej Siewior return IRQ_RETVAL(handled); } -@@ -2392,12 +2390,6 @@ static irqreturn_t +@@ -2391,12 +2389,6 @@ static irqreturn_t ioaddr = vp->ioaddr; @@ -46,7 +45,7 @@ Signed-off-by: Sebastian Andrzej Siewior vp->handling_irq = 1; status = ioread16(ioaddr + EL3_STATUS); -@@ -2516,7 +2508,6 @@ static irqreturn_t +@@ -2515,7 +2507,6 @@ static irqreturn_t dev->name, status); handler_exit: vp->handling_irq = 0; @@ -54,7 +53,7 @@ Signed-off-by: Sebastian Andrzej Siewior return IRQ_RETVAL(handled); } -@@ -2525,11 +2516,18 @@ vortex_boomerang_interrupt(int irq, void +@@ -2524,11 +2515,18 @@ vortex_boomerang_interrupt(int irq, void { struct net_device *dev = dev_id; struct vortex_private *vp = netdev_priv(dev); diff --git a/debian/patches/features/all/rt/net-3com-3c59x-irq-save-variant-of-ISR.patch b/debian/patches/features/all/rt/net-3com-3c59x-irq-save-variant-of-ISR.patch index 4155d4f42..376eee4be 100644 --- a/debian/patches/features/all/rt/net-3com-3c59x-irq-save-variant-of-ISR.patch +++ b/debian/patches/features/all/rt/net-3com-3c59x-irq-save-variant-of-ISR.patch @@ -1,7 +1,6 @@ From: Anna-Maria Gleixner Date: Thu, 12 Apr 2018 18:36:16 +0200 Subject: [PATCH] net: 3com: 3c59x: irq save variant of ISR -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz When vortex_boomerang_interrupt() is invoked from vortex_tx_timeout() or poll_vortex() interrupts must be disabled. This detaches the interrupt @@ -30,7 +29,7 @@ Signed-off-by: Sebastian Andrzej Siewior } #endif -@@ -1904,15 +1901,7 @@ static void vortex_tx_timeout(struct net +@@ -1903,15 +1900,7 @@ static void vortex_tx_timeout(struct net pr_err("%s: Interrupt posted but not delivered --" " IRQ blocked by another device?\n", dev->name); /* Bad idea here.. but we might as well handle a few events. */ @@ -47,7 +46,7 @@ Signed-off-by: Sebastian Andrzej Siewior } if (vortex_debug > 0) -@@ -2516,16 +2505,17 @@ vortex_boomerang_interrupt(int irq, void +@@ -2515,16 +2504,17 @@ vortex_boomerang_interrupt(int irq, void { struct net_device *dev = dev_id; struct vortex_private *vp = netdev_priv(dev); diff --git a/debian/patches/features/all/rt/net-Have-__napi_schedule_irqoff-disable-interrupts-o.patch b/debian/patches/features/all/rt/net-Have-__napi_schedule_irqoff-disable-interrupts-o.patch index 365c85108..6ca9dafba 100644 --- a/debian/patches/features/all/rt/net-Have-__napi_schedule_irqoff-disable-interrupts-o.patch +++ b/debian/patches/features/all/rt/net-Have-__napi_schedule_irqoff-disable-interrupts-o.patch @@ -2,7 +2,6 @@ From: Steven Rostedt Date: Tue, 6 Dec 2016 17:50:30 -0500 Subject: [PATCH] net: Have __napi_schedule_irqoff() disable interrupts on RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz A customer hit a crash where the napi sd->poll_list became corrupted. The customer had the bnx2x driver, which does a @@ -51,7 +50,7 @@ Signed-off-by: Sebastian Andrzej Siewior { --- a/net/core/dev.c +++ b/net/core/dev.c -@@ -5407,6 +5407,7 @@ bool napi_schedule_prep(struct napi_stru +@@ -5404,6 +5404,7 @@ bool napi_schedule_prep(struct napi_stru } EXPORT_SYMBOL(napi_schedule_prep); @@ -59,7 +58,7 @@ Signed-off-by: Sebastian Andrzej Siewior /** * __napi_schedule_irqoff - schedule for receive * @n: entry to schedule -@@ -5418,6 +5419,7 @@ void __napi_schedule_irqoff(struct napi_ +@@ -5415,6 +5416,7 @@ void __napi_schedule_irqoff(struct napi_ ____napi_schedule(this_cpu_ptr(&softnet_data), n); } EXPORT_SYMBOL(__napi_schedule_irqoff); diff --git a/debian/patches/features/all/rt/net-Qdisc-use-a-seqlock-instead-seqcount.patch b/debian/patches/features/all/rt/net-Qdisc-use-a-seqlock-instead-seqcount.patch index 1d252ca34..da0d599f6 100644 --- a/debian/patches/features/all/rt/net-Qdisc-use-a-seqlock-instead-seqcount.patch +++ b/debian/patches/features/all/rt/net-Qdisc-use-a-seqlock-instead-seqcount.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 14 Sep 2016 17:36:35 +0200 Subject: [PATCH] net/Qdisc: use a seqlock instead seqcount -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The seqcount disables preemption on -RT while it is held which can't remove. Also we don't want the reader to spin for ages if the writer is @@ -23,7 +22,7 @@ Signed-off-by: Sebastian Andrzej Siewior --- a/include/linux/seqlock.h +++ b/include/linux/seqlock.h -@@ -481,6 +481,15 @@ static inline void write_seqlock(seqlock +@@ -482,6 +482,15 @@ static inline void write_seqlock(seqlock __raw_write_seqcount_begin(&sl->seqcount); } diff --git a/debian/patches/features/all/rt/net-add-a-lock-around-icmp_sk.patch b/debian/patches/features/all/rt/net-add-a-lock-around-icmp_sk.patch index 9c5f5f5fa..4d552af76 100644 --- a/debian/patches/features/all/rt/net-add-a-lock-around-icmp_sk.patch +++ b/debian/patches/features/all/rt/net-add-a-lock-around-icmp_sk.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 31 Aug 2016 17:54:09 +0200 Subject: [PATCH] net: add a lock around icmp_sk() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz It looks like the this_cpu_ptr() access in icmp_sk() is protected with local_bh_disable(). To avoid missing serialization in -RT I am adding diff --git a/debian/patches/features/all/rt/net-add-back-the-missing-serialization-in-ip_send_un.patch b/debian/patches/features/all/rt/net-add-back-the-missing-serialization-in-ip_send_un.patch index f0e0fb16a..b4985f206 100644 --- a/debian/patches/features/all/rt/net-add-back-the-missing-serialization-in-ip_send_un.patch +++ b/debian/patches/features/all/rt/net-add-back-the-missing-serialization-in-ip_send_un.patch @@ -5,7 +5,6 @@ Subject: [PATCH] net: add back the missing serialization in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Some time ago Sami Pietikäinen reported a crash on -RT in ip_send_unicast_reply() which was later fixed by Nicholas Mc Guire diff --git a/debian/patches/features/all/rt/net-another-local-irq-disable-alloc-atomic-headache.patch b/debian/patches/features/all/rt/net-another-local-irq-disable-alloc-atomic-headache.patch index 1e0d4d02b..0e4e345c8 100644 --- a/debian/patches/features/all/rt/net-another-local-irq-disable-alloc-atomic-headache.patch +++ b/debian/patches/features/all/rt/net-another-local-irq-disable-alloc-atomic-headache.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Wed, 26 Sep 2012 16:21:08 +0200 Subject: net: Another local_irq_disable/kmalloc headache -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Replace it by a local lock. Though that's pretty inefficient :( diff --git a/debian/patches/features/all/rt/net-core-cpuhotplug-drain-input_pkt_queue-lockless.patch b/debian/patches/features/all/rt/net-core-cpuhotplug-drain-input_pkt_queue-lockless.patch index d51f65ad9..1d57360b8 100644 --- a/debian/patches/features/all/rt/net-core-cpuhotplug-drain-input_pkt_queue-lockless.patch +++ b/debian/patches/features/all/rt/net-core-cpuhotplug-drain-input_pkt_queue-lockless.patch @@ -1,7 +1,6 @@ Subject: net/core/cpuhotplug: Drain input_pkt_queue lockless From: Grygorii Strashko Date: Fri, 9 Oct 2015 09:25:49 -0500 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz I can constantly see below error report with 4.1 RT-kernel on TI ARM dra7-evm if I'm trying to unplug cpu1: @@ -36,7 +35,7 @@ Cc: stable-rt@vger.kernel.org --- a/net/core/dev.c +++ b/net/core/dev.c -@@ -8708,7 +8708,7 @@ static int dev_cpu_dead(unsigned int old +@@ -8705,7 +8705,7 @@ static int dev_cpu_dead(unsigned int old netif_rx_ni(skb); input_queue_head_incr(oldsd); } diff --git a/debian/patches/features/all/rt/net-core-protect-users-of-napi_alloc_cache-against-r.patch b/debian/patches/features/all/rt/net-core-protect-users-of-napi_alloc_cache-against-r.patch index a4bd89fac..9bb65bdaa 100644 --- a/debian/patches/features/all/rt/net-core-protect-users-of-napi_alloc_cache-against-r.patch +++ b/debian/patches/features/all/rt/net-core-protect-users-of-napi_alloc_cache-against-r.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Fri, 15 Jan 2016 16:33:34 +0100 Subject: net/core: protect users of napi_alloc_cache against reentrance -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz On -RT the code running in BH can not be moved to another CPU so CPU local variable remain local. However the code can be preempted diff --git a/debian/patches/features/all/rt/net-core-use-local_bh_disable-in-netif_rx_ni.patch b/debian/patches/features/all/rt/net-core-use-local_bh_disable-in-netif_rx_ni.patch index 695ba2014..7916f69ea 100644 --- a/debian/patches/features/all/rt/net-core-use-local_bh_disable-in-netif_rx_ni.patch +++ b/debian/patches/features/all/rt/net-core-use-local_bh_disable-in-netif_rx_ni.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Fri, 16 Jun 2017 19:03:16 +0200 Subject: [PATCH] net/core: use local_bh_disable() in netif_rx_ni() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz In 2004 netif_rx_ni() gained a preempt_disable() section around netif_rx() and its do_softirq() + testing for it. The do_softirq() part diff --git a/debian/patches/features/all/rt/net-dev-always-take-qdisc-s-busylock-in-__dev_xmit_s.patch b/debian/patches/features/all/rt/net-dev-always-take-qdisc-s-busylock-in-__dev_xmit_s.patch index ef66e3ac3..6bcdbb081 100644 --- a/debian/patches/features/all/rt/net-dev-always-take-qdisc-s-busylock-in-__dev_xmit_s.patch +++ b/debian/patches/features/all/rt/net-dev-always-take-qdisc-s-busylock-in-__dev_xmit_s.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 30 Mar 2016 13:36:29 +0200 Subject: [PATCH] net: dev: always take qdisc's busylock in __dev_xmit_skb() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The root-lock is dropped before dev_hard_start_xmit() is invoked and after setting the __QDISC___STATE_RUNNING bit. If this task is now pushed away diff --git a/debian/patches/features/all/rt/net-fix-iptable-xt-write-recseq-begin-rt-fallout.patch b/debian/patches/features/all/rt/net-fix-iptable-xt-write-recseq-begin-rt-fallout.patch index 7f04ca73c..675f1676b 100644 --- a/debian/patches/features/all/rt/net-fix-iptable-xt-write-recseq-begin-rt-fallout.patch +++ b/debian/patches/features/all/rt/net-fix-iptable-xt-write-recseq-begin-rt-fallout.patch @@ -1,7 +1,6 @@ Subject: net: netfilter: Serialize xt_write_recseq sections on RT From: Thomas Gleixner Date: Sun, 28 Oct 2012 11:18:08 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The netfilter code relies only on the implicit semantics of local_bh_disable() for serializing wt_write_recseq sections. RT breaks diff --git a/debian/patches/features/all/rt/net-mac808211-rc-warn_on.patch b/debian/patches/features/all/rt/net-mac808211-rc-warn_on.patch deleted file mode 100644 index d7eaee059..000000000 --- a/debian/patches/features/all/rt/net-mac808211-rc-warn_on.patch +++ /dev/null @@ -1,54 +0,0 @@ -From: Anna-Maria Gleixner -Date: Tue, 10 Apr 2018 11:37:12 +0200 -Subject: [PATCH] net: mac808211: mac802154: use lockdep_assert_in_softirq() instead own warning -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz - -The warning in ieee802154_rx() and ieee80211_rx_napi() is there to ensure -the softirq context for the subsequent netif_receive_skb() call. The check -could be moved into the netif_receive_skb() function to prevent all calling -functions implement the checks on their own. Use the lockdep variant for -softirq context check. While at it, add a lockdep based check for irq -enabled as mentioned in the comment above netif_receive_skb(). - -Signed-off-by: Anna-Maria Gleixner -Signed-off-by: Sebastian Andrzej Siewior ---- - net/core/dev.c | 3 +++ - net/mac80211/rx.c | 2 -- - net/mac802154/rx.c | 2 -- - 3 files changed, 3 insertions(+), 4 deletions(-) - ---- a/net/core/dev.c -+++ b/net/core/dev.c -@@ -4720,6 +4720,9 @@ static int netif_receive_skb_internal(st - */ - int netif_receive_skb(struct sk_buff *skb) - { -+ lockdep_assert_irqs_enabled(); -+ lockdep_assert_in_softirq(); -+ - trace_netif_receive_skb_entry(skb); - - return netif_receive_skb_internal(skb); ---- a/net/mac80211/rx.c -+++ b/net/mac80211/rx.c -@@ -4245,8 +4245,6 @@ void ieee80211_rx_napi(struct ieee80211_ - struct ieee80211_supported_band *sband; - struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); - -- WARN_ON_ONCE(softirq_count() == 0); -- - if (WARN_ON(status->band >= NUM_NL80211_BANDS)) - goto drop; - ---- a/net/mac802154/rx.c -+++ b/net/mac802154/rx.c -@@ -258,8 +258,6 @@ void ieee802154_rx(struct ieee802154_loc - { - u16 crc; - -- WARN_ON_ONCE(softirq_count() == 0); -- - if (local->suspended) - goto drop; - diff --git a/debian/patches/features/all/rt/net-make-devnet_rename_seq-a-mutex.patch b/debian/patches/features/all/rt/net-make-devnet_rename_seq-a-mutex.patch index affa1a65c..eaa99a6b2 100644 --- a/debian/patches/features/all/rt/net-make-devnet_rename_seq-a-mutex.patch +++ b/debian/patches/features/all/rt/net-make-devnet_rename_seq-a-mutex.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 20 Mar 2013 18:06:20 +0100 Subject: net: Add a mutex around devnet_rename_seq -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz On RT write_seqcount_begin() disables preemption and device_rename() allocates memory with GFP_KERNEL and grabs later the sysfs_mutex diff --git a/debian/patches/features/all/rt/net-move-xmit_recursion-to-per-task-variable-on-RT.patch b/debian/patches/features/all/rt/net-move-xmit_recursion-to-per-task-variable-on-RT.patch index 2039a9b08..f30f930ef 100644 --- a/debian/patches/features/all/rt/net-move-xmit_recursion-to-per-task-variable-on-RT.patch +++ b/debian/patches/features/all/rt/net-move-xmit_recursion-to-per-task-variable-on-RT.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 13 Jan 2016 15:55:02 +0100 Subject: net: move xmit_recursion to per-task variable on -RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz A softirq on -RT can be preempted. That means one task is in __dev_queue_xmit(), gets preempted and another task may enter diff --git a/debian/patches/features/all/rt/net-prevent-abba-deadlock.patch b/debian/patches/features/all/rt/net-prevent-abba-deadlock.patch deleted file mode 100644 index 7b560f70b..000000000 --- a/debian/patches/features/all/rt/net-prevent-abba-deadlock.patch +++ /dev/null @@ -1,112 +0,0 @@ -Subject: net-flip-lock-dep-thingy.patch -From: Thomas Gleixner -Date: Tue, 28 Jun 2011 10:59:58 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -======================================================= -[ INFO: possible circular locking dependency detected ] -3.0.0-rc3+ #26 -------------------------------------------------------- -ip/1104 is trying to acquire lock: - (local_softirq_lock){+.+...}, at: [] __local_lock+0x25/0x68 - -but task is already holding lock: - (sk_lock-AF_INET){+.+...}, at: [] lock_sock+0x10/0x12 - -which lock already depends on the new lock. - - -the existing dependency chain (in reverse order) is: - --> #1 (sk_lock-AF_INET){+.+...}: - [] lock_acquire+0x103/0x12e - [] lock_sock_nested+0x82/0x92 - [] lock_sock+0x10/0x12 - [] tcp_close+0x1b/0x355 - [] inet_release+0xc3/0xcd - [] sock_release+0x1f/0x74 - [] sock_close+0x27/0x2b - [] fput+0x11d/0x1e3 - [] filp_close+0x70/0x7b - [] sys_close+0xf8/0x13d - [] system_call_fastpath+0x16/0x1b - --> #0 (local_softirq_lock){+.+...}: - [] __lock_acquire+0xacc/0xdc8 - [] lock_acquire+0x103/0x12e - [] _raw_spin_lock+0x3b/0x4a - [] __local_lock+0x25/0x68 - [] local_bh_disable+0x36/0x3b - [] _raw_write_lock_bh+0x16/0x4f - [] tcp_close+0x159/0x355 - [] inet_release+0xc3/0xcd - [] sock_release+0x1f/0x74 - [] sock_close+0x27/0x2b - [] fput+0x11d/0x1e3 - [] filp_close+0x70/0x7b - [] sys_close+0xf8/0x13d - [] system_call_fastpath+0x16/0x1b - -other info that might help us debug this: - - Possible unsafe locking scenario: - - CPU0 CPU1 - ---- ---- - lock(sk_lock-AF_INET); - lock(local_softirq_lock); - lock(sk_lock-AF_INET); - lock(local_softirq_lock); - - *** DEADLOCK *** - -1 lock held by ip/1104: - #0: (sk_lock-AF_INET){+.+...}, at: [] lock_sock+0x10/0x12 - -stack backtrace: -Pid: 1104, comm: ip Not tainted 3.0.0-rc3+ #26 -Call Trace: - [] print_circular_bug+0x1f8/0x209 - [] __lock_acquire+0xacc/0xdc8 - [] ? __local_lock+0x25/0x68 - [] lock_acquire+0x103/0x12e - [] ? __local_lock+0x25/0x68 - [] ? get_parent_ip+0x11/0x41 - [] _raw_spin_lock+0x3b/0x4a - [] ? __local_lock+0x25/0x68 - [] ? get_parent_ip+0x28/0x41 - [] __local_lock+0x25/0x68 - [] local_bh_disable+0x36/0x3b - [] ? lock_sock+0x10/0x12 - [] _raw_write_lock_bh+0x16/0x4f - [] tcp_close+0x159/0x355 - [] inet_release+0xc3/0xcd - [] sock_release+0x1f/0x74 - [] sock_close+0x27/0x2b - [] fput+0x11d/0x1e3 - [] filp_close+0x70/0x7b - [] sys_close+0xf8/0x13d - [] system_call_fastpath+0x16/0x1b - - -Signed-off-by: Thomas Gleixner ---- - net/core/sock.c | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - ---- a/net/core/sock.c -+++ b/net/core/sock.c -@@ -2762,12 +2762,11 @@ void lock_sock_nested(struct sock *sk, i - if (sk->sk_lock.owned) - __lock_sock(sk); - sk->sk_lock.owned = 1; -- spin_unlock(&sk->sk_lock.slock); -+ spin_unlock_bh(&sk->sk_lock.slock); - /* - * The sk_lock has mutex_lock() semantics here: - */ - mutex_acquire(&sk->sk_lock.dep_map, subclass, 0, _RET_IP_); -- local_bh_enable(); - } - EXPORT_SYMBOL(lock_sock_nested); - diff --git a/debian/patches/features/all/rt/net-provide-a-way-to-delegate-processing-a-softirq-t.patch b/debian/patches/features/all/rt/net-provide-a-way-to-delegate-processing-a-softirq-t.patch index c44e6bb18..4f808cc86 100644 --- a/debian/patches/features/all/rt/net-provide-a-way-to-delegate-processing-a-softirq-t.patch +++ b/debian/patches/features/all/rt/net-provide-a-way-to-delegate-processing-a-softirq-t.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 20 Jan 2016 15:39:05 +0100 Subject: net: provide a way to delegate processing a softirq to ksoftirqd -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz If the NET_RX uses up all of his budget it moves the following NAPI invocations into the `ksoftirqd`. On -RT it does not do so. Instead it @@ -68,7 +67,7 @@ Signed-off-by: Sebastian Andrzej Siewior void raise_softirq_irqoff(unsigned int nr) --- a/net/core/dev.c +++ b/net/core/dev.c -@@ -5812,7 +5812,7 @@ static __latent_entropy void net_rx_acti +@@ -5809,7 +5809,7 @@ static __latent_entropy void net_rx_acti list_splice_tail(&repoll, &list); list_splice(&list, &sd->poll_list); if (!list_empty(&sd->poll_list)) diff --git a/debian/patches/features/all/rt/net-sched-dev_deactivate_many-use-msleep-1-instead-o.patch b/debian/patches/features/all/rt/net-sched-dev_deactivate_many-use-msleep-1-instead-o.patch index e0c2bf63d..625a7b43b 100644 --- a/debian/patches/features/all/rt/net-sched-dev_deactivate_many-use-msleep-1-instead-o.patch +++ b/debian/patches/features/all/rt/net-sched-dev_deactivate_many-use-msleep-1-instead-o.patch @@ -1,7 +1,6 @@ From: Marc Kleine-Budde Date: Wed, 5 Mar 2014 00:49:47 +0100 Subject: net: sched: Use msleep() instead of yield() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz On PREEMPT_RT enabled systems the interrupt handler run as threads at prio 50 (by default). If a high priority userspace process tries to shut down a busy diff --git a/debian/patches/features/all/rt/net-take-the-tcp_sk_lock-lock-with-BH-disabled.patch b/debian/patches/features/all/rt/net-take-the-tcp_sk_lock-lock-with-BH-disabled.patch index 2a4e7dca6..db46aa22e 100644 --- a/debian/patches/features/all/rt/net-take-the-tcp_sk_lock-lock-with-BH-disabled.patch +++ b/debian/patches/features/all/rt/net-take-the-tcp_sk_lock-lock-with-BH-disabled.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Mon, 21 Aug 2017 15:09:13 +0200 Subject: [PATCH] net: take the tcp_sk_lock lock with BH disabled -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Lockdep may complain about an unsafe locking scenario: | CPU0 CPU1 diff --git a/debian/patches/features/all/rt/net-use-cpu-chill.patch b/debian/patches/features/all/rt/net-use-cpu-chill.patch index ae7cf1d96..a111f2aca 100644 --- a/debian/patches/features/all/rt/net-use-cpu-chill.patch +++ b/debian/patches/features/all/rt/net-use-cpu-chill.patch @@ -1,7 +1,6 @@ Subject: net: Use cpu_chill() instead of cpu_relax() From: Thomas Gleixner Date: Wed, 07 Mar 2012 21:10:04 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Retry loops on RT might loop forever when the modifying side was preempted. Use cpu_chill() instead of cpu_relax() to let the system diff --git a/debian/patches/features/all/rt/net-use-task_struct-instead-of-CPU-number-as-the-que.patch b/debian/patches/features/all/rt/net-use-task_struct-instead-of-CPU-number-as-the-que.patch index 347e4cc6f..c2ed1137b 100644 --- a/debian/patches/features/all/rt/net-use-task_struct-instead-of-CPU-number-as-the-que.patch +++ b/debian/patches/features/all/rt/net-use-task_struct-instead-of-CPU-number-as-the-que.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 21 Feb 2018 10:39:54 +0100 Subject: [PATCH] net: use task_struct instead of CPU number as the queue owner on -RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz In commit ("net: move xmit_recursion to per-task variable on -RT") the recursion level was changed to be per-task since we can get preempted in @@ -135,7 +134,7 @@ Signed-off-by: Sebastian Andrzej Siewior if (unlikely(xmit_rec_read() > XMIT_RECURSION_LIMIT)) goto recursion_alert; -@@ -7762,7 +7766,7 @@ static void netdev_init_one_queue(struct +@@ -7759,7 +7763,7 @@ static void netdev_init_one_queue(struct /* Initialize queue lock */ spin_lock_init(&queue->_xmit_lock); netdev_set_xmit_lockdep_class(&queue->_xmit_lock, dev->type); diff --git a/debian/patches/features/all/rt/net-use-trylock-in-icmp_sk.patch b/debian/patches/features/all/rt/net-use-trylock-in-icmp_sk.patch index 6d4a9b593..509c71aa8 100644 --- a/debian/patches/features/all/rt/net-use-trylock-in-icmp_sk.patch +++ b/debian/patches/features/all/rt/net-use-trylock-in-icmp_sk.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 21 Sep 2017 14:42:04 +0200 Subject: net: use trylock in icmp_sk -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The locking path can be recursive (same as for sk->sk_lock.slock) and therefore we need a trylock version for the locallock, too. diff --git a/debian/patches/features/all/rt/net-wireless-warn-nort.patch b/debian/patches/features/all/rt/net-wireless-warn-nort.patch deleted file mode 100644 index 508c4eea7..000000000 --- a/debian/patches/features/all/rt/net-wireless-warn-nort.patch +++ /dev/null @@ -1,24 +0,0 @@ -Subject: net/wireless: Use WARN_ON_NORT() -From: Thomas Gleixner -Date: Thu, 21 Jul 2011 21:05:33 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The softirq counter is meaningless on RT, so the check triggers a -false positive. - -Signed-off-by: Thomas Gleixner ---- - net/mac80211/rx.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/net/mac80211/rx.c -+++ b/net/mac80211/rx.c -@@ -4250,7 +4250,7 @@ void ieee80211_rx_napi(struct ieee80211_ - struct ieee80211_supported_band *sband; - struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); - -- WARN_ON_ONCE(softirq_count() == 0); -+ WARN_ON_ONCE_NONRT(softirq_count() == 0); - - if (WARN_ON(status->band >= NUM_NL80211_BANDS)) - goto drop; diff --git a/debian/patches/features/all/rt/net_disable_NET_RX_BUSY_POLL.patch b/debian/patches/features/all/rt/net_disable_NET_RX_BUSY_POLL.patch index f339b7684..75bf42ac7 100644 --- a/debian/patches/features/all/rt/net_disable_NET_RX_BUSY_POLL.patch +++ b/debian/patches/features/all/rt/net_disable_NET_RX_BUSY_POLL.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Sat, 27 May 2017 19:02:06 +0200 Subject: net/core: disable NET_RX_BUSY_POLL -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz sk_busy_loop() does preempt_disable() followed by a few operations which can take sleeping locks and may get long. diff --git a/debian/patches/features/all/rt/nohz-Prevent-erroneous-tick-stop-invocations.patch b/debian/patches/features/all/rt/nohz-Prevent-erroneous-tick-stop-invocations.patch index b140aac20..dcc1460b5 100644 --- a/debian/patches/features/all/rt/nohz-Prevent-erroneous-tick-stop-invocations.patch +++ b/debian/patches/features/all/rt/nohz-Prevent-erroneous-tick-stop-invocations.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Fri, 22 Dec 2017 15:51:13 +0100 Subject: [PATCH 2/4] nohz: Prevent erroneous tick stop invocations -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The conditions in irq_exit() to invoke tick_nohz_irq_exit() are: diff --git a/debian/patches/features/all/rt/ntfs-avoid-disabling-interrupts-during-kmap_atomic.patch b/debian/patches/features/all/rt/ntfs-avoid-disabling-interrupts-during-kmap_atomic.patch index 4c1124c11..c42c6098e 100644 --- a/debian/patches/features/all/rt/ntfs-avoid-disabling-interrupts-during-kmap_atomic.patch +++ b/debian/patches/features/all/rt/ntfs-avoid-disabling-interrupts-during-kmap_atomic.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Tue, 10 Apr 2018 17:54:32 +0200 Subject: [PATCH] ntfs: don't disable interrupts during kmap_atomic() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz ntfs_end_buffer_async_read() disables interrupts around kmap_atomic(). This is a leftover from the old kmap_atomic() implementation which relied on fixed diff --git a/debian/patches/features/all/rt/oleg-signal-rt-fix.patch b/debian/patches/features/all/rt/oleg-signal-rt-fix.patch index 377513425..a32e9c752 100644 --- a/debian/patches/features/all/rt/oleg-signal-rt-fix.patch +++ b/debian/patches/features/all/rt/oleg-signal-rt-fix.patch @@ -1,7 +1,6 @@ From: Oleg Nesterov Date: Tue, 14 Jul 2015 14:26:34 +0200 Subject: signal/x86: Delay calling signals in atomic -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz On x86_64 we must disable preemption before we enable interrupts for stack faults, int3 and debugging, because the current task is using diff --git a/debian/patches/features/all/rt/panic-disable-random-on-rt.patch b/debian/patches/features/all/rt/panic-disable-random-on-rt.patch index c2226095a..abf40a8b7 100644 --- a/debian/patches/features/all/rt/panic-disable-random-on-rt.patch +++ b/debian/patches/features/all/rt/panic-disable-random-on-rt.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Tue, 14 Jul 2015 14:26:34 +0200 Subject: panic: skip get_random_bytes for RT_FULL in init_oops_id -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Disable on -RT. If this is invoked from irq-context we will have problems to acquire the sleeping lock. diff --git a/debian/patches/features/all/rt/patch-to-introduce-rcu-bh-qs-where-safe-from-softirq.patch b/debian/patches/features/all/rt/patch-to-introduce-rcu-bh-qs-where-safe-from-softirq.patch index efbb97441..ee8b9c957 100644 --- a/debian/patches/features/all/rt/patch-to-introduce-rcu-bh-qs-where-safe-from-softirq.patch +++ b/debian/patches/features/all/rt/patch-to-introduce-rcu-bh-qs-where-safe-from-softirq.patch @@ -1,7 +1,6 @@ Subject: rcu: Make ksoftirqd do RCU quiescent states From: "Paul E. McKenney" Date: Wed, 5 Oct 2011 11:45:18 -0700 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Implementing RCU-bh in terms of RCU-preempt makes the system vulnerable to network-based denial-of-service attacks. This patch therefore diff --git a/debian/patches/features/all/rt/pci-switchtec-Don-t-use-completion-s-wait-queue.patch b/debian/patches/features/all/rt/pci-switchtec-Don-t-use-completion-s-wait-queue.patch index 83b990f57..3054d40f5 100644 --- a/debian/patches/features/all/rt/pci-switchtec-Don-t-use-completion-s-wait-queue.patch +++ b/debian/patches/features/all/rt/pci-switchtec-Don-t-use-completion-s-wait-queue.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 4 Oct 2017 10:24:23 +0200 Subject: [PATCH] pci/switchtec: Don't use completion's wait queue -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The poll callback is using completion's wait_queue_head_t member and puts it in poll_wait() so the poll() caller gets a wakeup after command diff --git a/debian/patches/features/all/rt/percpu_ida-Use-_irqsave-instead-of-local_irq_save-sp.patch b/debian/patches/features/all/rt/percpu_ida-Use-_irqsave-instead-of-local_irq_save-sp.patch index 9b5c2f747..b8a8e7a4f 100644 --- a/debian/patches/features/all/rt/percpu_ida-Use-_irqsave-instead-of-local_irq_save-sp.patch +++ b/debian/patches/features/all/rt/percpu_ida-Use-_irqsave-instead-of-local_irq_save-sp.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Mon, 23 Apr 2018 16:42:39 +0200 Subject: [PATCH] percpu_ida: Use _irqsave() instead of local_irq_save() + spin_lock -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz percpu_ida() decouples disabling interrupts from the locking operations. This breaks some assumptions if the locking operations are replaced like diff --git a/debian/patches/features/all/rt/percpu_ida-use-locklocks.patch b/debian/patches/features/all/rt/percpu_ida-use-locklocks.patch deleted file mode 100644 index a99d102f6..000000000 --- a/debian/patches/features/all/rt/percpu_ida-use-locklocks.patch +++ /dev/null @@ -1,102 +0,0 @@ -From: Sebastian Andrzej Siewior -Date: Wed, 9 Apr 2014 11:58:17 +0200 -Subject: percpu_ida: Use local locks -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -the local_irq_save() + spin_lock() does not work that well on -RT - -Signed-off-by: Sebastian Andrzej Siewior ---- - lib/percpu_ida.c | 20 ++++++++++++-------- - 1 file changed, 12 insertions(+), 8 deletions(-) - ---- a/lib/percpu_ida.c -+++ b/lib/percpu_ida.c -@@ -27,6 +27,9 @@ - #include - #include - #include -+#include -+ -+static DEFINE_LOCAL_IRQ_LOCK(irq_off_lock); - - struct percpu_ida_cpu { - /* -@@ -149,13 +152,13 @@ int percpu_ida_alloc(struct percpu_ida * - unsigned long flags; - int tag; - -- local_irq_save(flags); -+ local_lock_irqsave(irq_off_lock, flags); - tags = this_cpu_ptr(pool->tag_cpu); - - /* Fastpath */ - tag = alloc_local_tag(tags); - if (likely(tag >= 0)) { -- local_irq_restore(flags); -+ local_unlock_irqrestore(irq_off_lock, flags); - return tag; - } - -@@ -174,6 +177,7 @@ int percpu_ida_alloc(struct percpu_ida * - - if (!tags->nr_free) - alloc_global_tags(pool, tags); -+ - if (!tags->nr_free) - steal_tags(pool, tags); - -@@ -185,7 +189,7 @@ int percpu_ida_alloc(struct percpu_ida * - } - - spin_unlock(&pool->lock); -- local_irq_restore(flags); -+ local_unlock_irqrestore(irq_off_lock, flags); - - if (tag >= 0 || state == TASK_RUNNING) - break; -@@ -197,7 +201,7 @@ int percpu_ida_alloc(struct percpu_ida * - - schedule(); - -- local_irq_save(flags); -+ local_lock_irqsave(irq_off_lock, flags); - tags = this_cpu_ptr(pool->tag_cpu); - } - if (state != TASK_RUNNING) -@@ -222,7 +226,7 @@ void percpu_ida_free(struct percpu_ida * - - BUG_ON(tag >= pool->nr_tags); - -- local_irq_save(flags); -+ local_lock_irqsave(irq_off_lock, flags); - tags = this_cpu_ptr(pool->tag_cpu); - - spin_lock(&tags->lock); -@@ -254,7 +258,7 @@ void percpu_ida_free(struct percpu_ida * - spin_unlock(&pool->lock); - } - -- local_irq_restore(flags); -+ local_unlock_irqrestore(irq_off_lock, flags); - } - EXPORT_SYMBOL_GPL(percpu_ida_free); - -@@ -346,7 +350,7 @@ int percpu_ida_for_each_free(struct perc - struct percpu_ida_cpu *remote; - unsigned cpu, i, err = 0; - -- local_irq_save(flags); -+ local_lock_irqsave(irq_off_lock, flags); - for_each_possible_cpu(cpu) { - remote = per_cpu_ptr(pool->tag_cpu, cpu); - spin_lock(&remote->lock); -@@ -368,7 +372,7 @@ int percpu_ida_for_each_free(struct perc - } - spin_unlock(&pool->lock); - out: -- local_irq_restore(flags); -+ local_unlock_irqrestore(irq_off_lock, flags); - return err; - } - EXPORT_SYMBOL_GPL(percpu_ida_for_each_free); diff --git a/debian/patches/features/all/rt/peter_zijlstra-frob-rcu.patch b/debian/patches/features/all/rt/peter_zijlstra-frob-rcu.patch index 795a72193..5ea9c7ab8 100644 --- a/debian/patches/features/all/rt/peter_zijlstra-frob-rcu.patch +++ b/debian/patches/features/all/rt/peter_zijlstra-frob-rcu.patch @@ -1,7 +1,6 @@ Subject: rcu: Frob softirq test From: Peter Zijlstra Date: Sat Aug 13 00:23:17 CEST 2011 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz With RT_FULL we get the below wreckage: diff --git a/debian/patches/features/all/rt/peterz-percpu-rwsem-rt.patch b/debian/patches/features/all/rt/peterz-percpu-rwsem-rt.patch index 074a0d9c6..211864b4a 100644 --- a/debian/patches/features/all/rt/peterz-percpu-rwsem-rt.patch +++ b/debian/patches/features/all/rt/peterz-percpu-rwsem-rt.patch @@ -1,7 +1,6 @@ Subject: locking/percpu-rwsem: Remove preempt_disable variants From: Peter Zijlstra Date: Wed Nov 23 16:29:32 CET 2016 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Effective revert commit: diff --git a/debian/patches/features/all/rt/peterz-srcu-crypto-chain.patch b/debian/patches/features/all/rt/peterz-srcu-crypto-chain.patch index 057897778..8f5be48a3 100644 --- a/debian/patches/features/all/rt/peterz-srcu-crypto-chain.patch +++ b/debian/patches/features/all/rt/peterz-srcu-crypto-chain.patch @@ -1,7 +1,6 @@ Subject: crypto: Convert crypto notifier chain to SRCU From: Peter Zijlstra Date: Fri, 05 Oct 2012 09:03:24 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The crypto notifier deadlocks on RT. Though this can be a real deadlock on mainline as well due to fifo fair rwsems. diff --git a/debian/patches/features/all/rt/pid.h-include-atomic.h.patch b/debian/patches/features/all/rt/pid.h-include-atomic.h.patch index 7d2de172d..9510164b0 100644 --- a/debian/patches/features/all/rt/pid.h-include-atomic.h.patch +++ b/debian/patches/features/all/rt/pid.h-include-atomic.h.patch @@ -1,7 +1,6 @@ From: Grygorii Strashko Date: Tue, 21 Jul 2015 19:43:56 +0300 Subject: pid.h: include atomic.h -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz This patch fixes build error: CC kernel/pid_namespace.o diff --git a/debian/patches/features/all/rt/posix-cpu-timers-remove-lockdep_assert_irqs_disabled.patch b/debian/patches/features/all/rt/posix-cpu-timers-remove-lockdep_assert_irqs_disabled.patch index d05e9f099..6881961c9 100644 --- a/debian/patches/features/all/rt/posix-cpu-timers-remove-lockdep_assert_irqs_disabled.patch +++ b/debian/patches/features/all/rt/posix-cpu-timers-remove-lockdep_assert_irqs_disabled.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 12 Apr 2018 17:37:17 +0200 Subject: [PATCH] posix-cpu-timers: remove lockdep_assert_irqs_disabled() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The lockdep_assert_irqs_disabled() was a BUG_ON() statement in the beginning and it was added just before the "spin_lock(siglock)" diff --git a/debian/patches/features/all/rt/posix-timers-move-the-rcu-head-out-of-the-union.patch b/debian/patches/features/all/rt/posix-timers-move-the-rcu-head-out-of-the-union.patch index 37b8200b9..ff765451e 100644 --- a/debian/patches/features/all/rt/posix-timers-move-the-rcu-head-out-of-the-union.patch +++ b/debian/patches/features/all/rt/posix-timers-move-the-rcu-head-out-of-the-union.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 28 Mar 2018 11:15:19 +0200 Subject: [PATCH 3/3] posix-timers: move the rcu head out of the union -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz On RT the timer can be preempted while running and therefore we wait with timer_wait_for_callback() for the timer to complete (instead of diff --git a/debian/patches/features/all/rt/posix-timers-no-broadcast.patch b/debian/patches/features/all/rt/posix-timers-no-broadcast.patch index bf4f5122f..2ebea3a70 100644 --- a/debian/patches/features/all/rt/posix-timers-no-broadcast.patch +++ b/debian/patches/features/all/rt/posix-timers-no-broadcast.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Fri, 3 Jul 2009 08:29:20 -0500 Subject: posix-timers: Prevent broadcast signals -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Posix timers should not send broadcast signals and kernel only signals. Prevent it. diff --git a/debian/patches/features/all/rt/posix-timers-thread-posix-cpu-timers-on-rt.patch b/debian/patches/features/all/rt/posix-timers-thread-posix-cpu-timers-on-rt.patch index d467b4544..a4af55386 100644 --- a/debian/patches/features/all/rt/posix-timers-thread-posix-cpu-timers-on-rt.patch +++ b/debian/patches/features/all/rt/posix-timers-thread-posix-cpu-timers-on-rt.patch @@ -1,7 +1,6 @@ From: John Stultz Date: Fri, 3 Jul 2009 08:29:58 -0500 Subject: posix-timers: Thread posix-cpu-timers on -rt -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz posix-cpu-timer code takes non -rt safe locks in hard irq context. Move it to a thread. diff --git a/debian/patches/features/all/rt/power-disable-highmem-on-rt.patch b/debian/patches/features/all/rt/power-disable-highmem-on-rt.patch index 0dc955a97..eb2e5bbc4 100644 --- a/debian/patches/features/all/rt/power-disable-highmem-on-rt.patch +++ b/debian/patches/features/all/rt/power-disable-highmem-on-rt.patch @@ -1,7 +1,6 @@ Subject: powerpc: Disable highmem on RT From: Thomas Gleixner Date: Mon, 18 Jul 2011 17:08:34 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The current highmem handling on -RT is not compatible and needs fixups. diff --git a/debian/patches/features/all/rt/power-use-generic-rwsem-on-rt.patch b/debian/patches/features/all/rt/power-use-generic-rwsem-on-rt.patch index 9703a668b..d1d414f54 100644 --- a/debian/patches/features/all/rt/power-use-generic-rwsem-on-rt.patch +++ b/debian/patches/features/all/rt/power-use-generic-rwsem-on-rt.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Tue, 14 Jul 2015 14:26:34 +0200 Subject: powerpc: Use generic rwsem on RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Use generic code which uses rtmutex diff --git a/debian/patches/features/all/rt/powerpc-kvm-Disable-in-kernel-MPIC-emulation-for-PRE.patch b/debian/patches/features/all/rt/powerpc-kvm-Disable-in-kernel-MPIC-emulation-for-PRE.patch index ecec8f4fc..ddf890e5c 100644 --- a/debian/patches/features/all/rt/powerpc-kvm-Disable-in-kernel-MPIC-emulation-for-PRE.patch +++ b/debian/patches/features/all/rt/powerpc-kvm-Disable-in-kernel-MPIC-emulation-for-PRE.patch @@ -1,7 +1,6 @@ From: Bogdan Purcareata Date: Fri, 24 Apr 2015 15:53:13 +0000 Subject: powerpc/kvm: Disable in-kernel MPIC emulation for PREEMPT_RT_FULL -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz While converting the openpic emulation code to use a raw_spinlock_t enables guests to run on RT, there's still a performance issue. For interrupts sent in diff --git a/debian/patches/features/all/rt/powerpc-preempt-lazy-support.patch b/debian/patches/features/all/rt/powerpc-preempt-lazy-support.patch index 284aec9c4..9f84a8921 100644 --- a/debian/patches/features/all/rt/powerpc-preempt-lazy-support.patch +++ b/debian/patches/features/all/rt/powerpc-preempt-lazy-support.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Thu, 1 Nov 2012 10:14:11 +0100 Subject: powerpc: Add support for lazy preemption -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Implement the powerpc pieces for lazy preempt. diff --git a/debian/patches/features/all/rt/powerpc-ps3-device-init.c-adapt-to-completions-using.patch b/debian/patches/features/all/rt/powerpc-ps3-device-init.c-adapt-to-completions-using.patch index 71aa317df..a153e1cf0 100644 --- a/debian/patches/features/all/rt/powerpc-ps3-device-init.c-adapt-to-completions-using.patch +++ b/debian/patches/features/all/rt/powerpc-ps3-device-init.c-adapt-to-completions-using.patch @@ -1,7 +1,6 @@ From: Paul Gortmaker Date: Sun, 31 May 2015 14:44:42 -0400 Subject: powerpc: ps3/device-init.c - adapt to completions using swait vs wait -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz To fix: diff --git a/debian/patches/features/all/rt/preempt-lazy-support.patch b/debian/patches/features/all/rt/preempt-lazy-support.patch index affd2bb51..124128c89 100644 --- a/debian/patches/features/all/rt/preempt-lazy-support.patch +++ b/debian/patches/features/all/rt/preempt-lazy-support.patch @@ -1,7 +1,6 @@ Subject: sched: Add support for lazy preemption From: Thomas Gleixner Date: Fri, 26 Oct 2012 18:50:54 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz It has become an obsession to mitigate the determinism vs. throughput loss of RT. Looking at the mainline semantics of preemption points @@ -141,7 +140,7 @@ Signed-off-by: Thomas Gleixner --- a/include/linux/sched.h +++ b/include/linux/sched.h -@@ -1628,6 +1628,44 @@ static inline int test_tsk_need_resched( +@@ -1636,6 +1636,44 @@ static inline int test_tsk_need_resched( return unlikely(test_tsk_thread_flag(tsk,TIF_NEED_RESCHED)); } @@ -234,7 +233,7 @@ Signed-off-by: Thomas Gleixner default PREEMPT_NONE --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -520,6 +520,48 @@ void resched_curr(struct rq *rq) +@@ -521,6 +521,48 @@ void resched_curr(struct rq *rq) trace_sched_wake_idle_without_ipi(cpu); } @@ -283,7 +282,7 @@ Signed-off-by: Thomas Gleixner void resched_cpu(int cpu) { struct rq *rq = cpu_rq(cpu); -@@ -2455,6 +2497,9 @@ int sched_fork(unsigned long clone_flags +@@ -2456,6 +2498,9 @@ int sched_fork(unsigned long clone_flags p->on_cpu = 0; #endif init_task_preempt_count(p); @@ -293,7 +292,7 @@ Signed-off-by: Thomas Gleixner #ifdef CONFIG_SMP plist_node_init(&p->pushable_tasks, MAX_PRIO); RB_CLEAR_NODE(&p->pushable_dl_tasks); -@@ -3437,6 +3482,7 @@ static void __sched notrace __schedule(b +@@ -3438,6 +3483,7 @@ static void __sched notrace __schedule(b next = pick_next_task(rq, prev, &rf); clear_tsk_need_resched(prev); @@ -301,7 +300,7 @@ Signed-off-by: Thomas Gleixner clear_preempt_need_resched(); if (likely(prev != next)) { -@@ -3626,6 +3672,30 @@ static void __sched notrace preempt_sche +@@ -3627,6 +3673,30 @@ static void __sched notrace preempt_sche } while (need_resched()); } @@ -332,7 +331,7 @@ Signed-off-by: Thomas Gleixner #ifdef CONFIG_PREEMPT /* * this is the entry point to schedule() from in-kernel preemption -@@ -3640,7 +3710,8 @@ asmlinkage __visible void __sched notrac +@@ -3641,7 +3711,8 @@ asmlinkage __visible void __sched notrac */ if (likely(!preemptible())) return; @@ -342,7 +341,7 @@ Signed-off-by: Thomas Gleixner preempt_schedule_common(); } NOKPROBE_SYMBOL(preempt_schedule); -@@ -3667,6 +3738,9 @@ asmlinkage __visible void __sched notrac +@@ -3668,6 +3739,9 @@ asmlinkage __visible void __sched notrac if (likely(!preemptible())) return; @@ -352,7 +351,7 @@ Signed-off-by: Thomas Gleixner do { /* * Because the function tracer can trace preempt_count_sub() -@@ -5430,7 +5504,9 @@ void init_idle(struct task_struct *idle, +@@ -5431,7 +5505,9 @@ void init_idle(struct task_struct *idle, /* Set the preempt count _outside_ the spinlocks! */ init_idle_preempt_count(idle, cpu); @@ -363,7 +362,7 @@ Signed-off-by: Thomas Gleixner /* * The idle tasks have their own, simple scheduling class: */ -@@ -7146,6 +7222,7 @@ void migrate_disable(void) +@@ -7151,6 +7227,7 @@ void migrate_disable(void) } preempt_disable(); @@ -371,7 +370,7 @@ Signed-off-by: Thomas Gleixner pin_current_cpu(); migrate_disable_update_cpus_allowed(p); -@@ -7213,6 +7290,7 @@ void migrate_enable(void) +@@ -7218,6 +7295,7 @@ void migrate_enable(void) arg.dest_cpu = dest_cpu; unpin_current_cpu(); @@ -379,7 +378,7 @@ Signed-off-by: Thomas Gleixner preempt_enable(); stop_one_cpu(task_cpu(p), migration_cpu_stop, &arg); tlb_migrate_finish(p->mm); -@@ -7221,6 +7299,7 @@ void migrate_enable(void) +@@ -7226,6 +7304,7 @@ void migrate_enable(void) } } unpin_current_cpu(); diff --git a/debian/patches/features/all/rt/preempt-nort-rt-variants.patch b/debian/patches/features/all/rt/preempt-nort-rt-variants.patch index 9825fb2b9..c9a87c546 100644 --- a/debian/patches/features/all/rt/preempt-nort-rt-variants.patch +++ b/debian/patches/features/all/rt/preempt-nort-rt-variants.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Fri, 24 Jul 2009 12:38:56 +0200 Subject: preempt: Provide preempt_*_(no)rt variants -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz RT needs a few preempt_disable/enable points which are not necessary otherwise. Implement variants to avoid #ifdeffery. diff --git a/debian/patches/features/all/rt/printk-27force_early_printk-27-boot-param-to-help-with-debugging.patch b/debian/patches/features/all/rt/printk-27force_early_printk-27-boot-param-to-help-with-debugging.patch index b1e4a6738..db295c916 100644 --- a/debian/patches/features/all/rt/printk-27force_early_printk-27-boot-param-to-help-with-debugging.patch +++ b/debian/patches/features/all/rt/printk-27force_early_printk-27-boot-param-to-help-with-debugging.patch @@ -1,7 +1,6 @@ Subject: printk: Add "force_early_printk" boot param to help with debugging From: Peter Zijlstra Date: Fri, 02 Sep 2011 14:41:29 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Gives me an option to screw printk and actually see what the machine says. diff --git a/debian/patches/features/all/rt/printk-kill.patch b/debian/patches/features/all/rt/printk-kill.patch index 3a82e9126..f3482d235 100644 --- a/debian/patches/features/all/rt/printk-kill.patch +++ b/debian/patches/features/all/rt/printk-kill.patch @@ -1,7 +1,6 @@ Subject: printk: Add a printk kill switch From: Ingo Molnar Date: Fri, 22 Jul 2011 17:58:40 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Add a prinkt-kill-switch. This is used from (NMI) watchdog to ensure that it does not dead-lock with the early printk code. diff --git a/debian/patches/features/all/rt/printk-rt-aware.patch b/debian/patches/features/all/rt/printk-rt-aware.patch index f425c1c45..521568fb8 100644 --- a/debian/patches/features/all/rt/printk-rt-aware.patch +++ b/debian/patches/features/all/rt/printk-rt-aware.patch @@ -1,7 +1,6 @@ Subject: printk: Make rt aware From: Thomas Gleixner Date: Wed, 19 Sep 2012 14:50:37 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Drop the lock before calling the console driver and do not disable interrupts while printing to a serial console. diff --git a/debian/patches/features/all/rt/ptrace-fix-ptrace-vs-tasklist_lock-race.patch b/debian/patches/features/all/rt/ptrace-fix-ptrace-vs-tasklist_lock-race.patch index f66f62e7f..7f6978e62 100644 --- a/debian/patches/features/all/rt/ptrace-fix-ptrace-vs-tasklist_lock-race.patch +++ b/debian/patches/features/all/rt/ptrace-fix-ptrace-vs-tasklist_lock-race.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 29 Aug 2013 18:21:04 +0200 Subject: ptrace: fix ptrace vs tasklist_lock race -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz As explained by Alexander Fyodorov : @@ -44,7 +43,7 @@ Signed-off-by: Sebastian Andrzej Siewior #define task_contributes_to_load(task) ((task->state & TASK_UNINTERRUPTIBLE) != 0 && \ (task->flags & PF_FROZEN) == 0 && \ (task->state & TASK_NOLOAD) == 0) -@@ -1612,6 +1608,51 @@ static inline int test_tsk_need_resched( +@@ -1620,6 +1616,51 @@ static inline int test_tsk_need_resched( return unlikely(test_tsk_thread_flag(tsk,TIF_NEED_RESCHED)); } @@ -116,7 +115,7 @@ Signed-off-by: Sebastian Andrzej Siewior spin_unlock_irq(&task->sighand->siglock); --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -1369,6 +1369,18 @@ int migrate_swap(struct task_struct *cur +@@ -1370,6 +1370,18 @@ int migrate_swap(struct task_struct *cur return ret; } @@ -135,7 +134,7 @@ Signed-off-by: Sebastian Andrzej Siewior /* * wait_task_inactive - wait for a thread to unschedule. * -@@ -1413,7 +1425,7 @@ unsigned long wait_task_inactive(struct +@@ -1414,7 +1426,7 @@ unsigned long wait_task_inactive(struct * is actually now running somewhere else! */ while (task_running(rq, p)) { @@ -144,7 +143,7 @@ Signed-off-by: Sebastian Andrzej Siewior return 0; cpu_relax(); } -@@ -1428,7 +1440,8 @@ unsigned long wait_task_inactive(struct +@@ -1429,7 +1441,8 @@ unsigned long wait_task_inactive(struct running = task_running(rq, p); queued = task_on_rq_queued(p); ncsw = 0; diff --git a/debian/patches/features/all/rt/radix-tree-use-local-locks.patch b/debian/patches/features/all/rt/radix-tree-use-local-locks.patch index dcbc7a611..562982d81 100644 --- a/debian/patches/features/all/rt/radix-tree-use-local-locks.patch +++ b/debian/patches/features/all/rt/radix-tree-use-local-locks.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 25 Jan 2017 16:34:27 +0100 Subject: [PATCH] radix-tree: use local locks -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The preload functionality uses per-CPU variables and preempt-disable to ensure that it does not switch CPUs during its usage. This patch adds @@ -137,7 +136,7 @@ Signed-off-by: Sebastian Andrzej Siewior static unsigned radix_tree_load_root(const struct radix_tree_root *root, struct radix_tree_node **nodep, unsigned long *maxindex) { -@@ -2102,10 +2110,16 @@ EXPORT_SYMBOL(radix_tree_tagged); +@@ -2100,10 +2108,16 @@ EXPORT_SYMBOL(radix_tree_tagged); void idr_preload(gfp_t gfp_mask) { if (__radix_tree_preload(gfp_mask, IDR_PRELOAD_SIZE)) @@ -155,7 +154,7 @@ Signed-off-by: Sebastian Andrzej Siewior /** * ida_pre_get - reserve resources for ida allocation * @ida: ida handle -@@ -2122,7 +2136,7 @@ int ida_pre_get(struct ida *ida, gfp_t g +@@ -2120,7 +2134,7 @@ int ida_pre_get(struct ida *ida, gfp_t g * to return to the ida_pre_get() step. */ if (!__radix_tree_preload(gfp, IDA_PRELOAD_SIZE)) diff --git a/debian/patches/features/all/rt/random-avoid-preempt_disable-ed-section.patch b/debian/patches/features/all/rt/random-avoid-preempt_disable-ed-section.patch index c4cf28941..179a589af 100644 --- a/debian/patches/features/all/rt/random-avoid-preempt_disable-ed-section.patch +++ b/debian/patches/features/all/rt/random-avoid-preempt_disable-ed-section.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Fri, 12 May 2017 15:46:17 +0200 Subject: [PATCH] random: avoid preempt_disable()ed section -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz extract_crng() will use sleeping locks while in a preempt_disable() section due to get_cpu_var(). diff --git a/debian/patches/features/all/rt/random-make-it-work-on-rt.patch b/debian/patches/features/all/rt/random-make-it-work-on-rt.patch index 37a4362f1..e86369e0e 100644 --- a/debian/patches/features/all/rt/random-make-it-work-on-rt.patch +++ b/debian/patches/features/all/rt/random-make-it-work-on-rt.patch @@ -1,7 +1,6 @@ Subject: random: Make it work on rt From: Thomas Gleixner Date: Tue, 21 Aug 2012 20:38:50 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Delegate the random insertion to the forced threaded interrupt handler. Store the return IP of the hard interrupt handler in the irq diff --git a/debian/patches/features/all/rt/rbtree-include-rcu.h-because-we-use-it.patch b/debian/patches/features/all/rt/rbtree-include-rcu.h-because-we-use-it.patch index 83eca0beb..3070854de 100644 --- a/debian/patches/features/all/rt/rbtree-include-rcu.h-because-we-use-it.patch +++ b/debian/patches/features/all/rt/rbtree-include-rcu.h-because-we-use-it.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 14 Sep 2016 11:52:17 +0200 Subject: rbtree: include rcu.h because we use it -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Since commit c1adf20052d8 ("Introduce rb_replace_node_rcu()") rbtree_augmented.h uses RCU related data structures but does not include diff --git a/debian/patches/features/all/rt/rcu-Eliminate-softirq-processing-from-rcutree.patch b/debian/patches/features/all/rt/rcu-Eliminate-softirq-processing-from-rcutree.patch index 26464229d..27107c3f6 100644 --- a/debian/patches/features/all/rt/rcu-Eliminate-softirq-processing-from-rcutree.patch +++ b/debian/patches/features/all/rt/rcu-Eliminate-softirq-processing-from-rcutree.patch @@ -1,7 +1,6 @@ From: "Paul E. McKenney" Date: Mon, 4 Nov 2013 13:21:10 -0800 Subject: rcu: Eliminate softirq processing from rcutree -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Running RCU out of softirq is a problem for some workloads that would like to manage RCU core processing independently of other softirq work, diff --git a/debian/patches/features/all/rt/rcu-Suppress-lockdep-false-positive-boost_mtx-compla.patch b/debian/patches/features/all/rt/rcu-Suppress-lockdep-false-positive-boost_mtx-compla.patch deleted file mode 100644 index 3f4142350..000000000 --- a/debian/patches/features/all/rt/rcu-Suppress-lockdep-false-positive-boost_mtx-compla.patch +++ /dev/null @@ -1,50 +0,0 @@ -From: "Paul E. McKenney" -Date: Tue, 19 Sep 2017 15:36:42 -0700 -Subject: [PATCH] rcu: Suppress lockdep false-positive ->boost_mtx complaints -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Upstream commit bcda31a2659497df39d6bedfbdf17498b4f4ac89 - -RCU priority boosting uses rt_mutex_init_proxy_locked() to initialize an -rt_mutex structure in locked state held by some other task. When that -other task releases it, lockdep complains (quite accurately, but a bit -uselessly) that the other task never acquired it. This complaint can -suppress other, more helpful, lockdep complaints, and in any case it is -a false positive. - -This commit therefore switches from rt_mutex_unlock() to -rt_mutex_futex_unlock(), thereby avoiding the lockdep annotations. -Of course, if lockdep ever learns about rt_mutex_init_proxy_locked(), -addtional adjustments will be required. - -Suggested-by: Peter Zijlstra -Signed-off-by: Paul E. McKenney -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/rcu/tree_plugin.h | 5 ++--- - 1 file changed, 2 insertions(+), 3 deletions(-) - ---- a/kernel/rcu/tree_plugin.h -+++ b/kernel/rcu/tree_plugin.h -@@ -31,11 +31,10 @@ - #include - #include - #include "../time/tick-internal.h" -+#include "../locking/rtmutex_common.h" - - #ifdef CONFIG_RCU_BOOST - --#include "../locking/rtmutex_common.h" -- - /* - * Control variables for per-CPU and per-rcu_node kthreads. These - * handle all flavors of RCU. -@@ -530,7 +529,7 @@ void rcu_read_unlock_special(struct task - - /* Unboost if we were boosted. */ - if (IS_ENABLED(CONFIG_RCU_BOOST) && drop_boost_mutex) -- rt_mutex_unlock(&rnp->boost_mtx); -+ rt_mutex_futex_unlock(&rnp->boost_mtx); - - /* - * If this was the last task on the expedited lists, diff --git a/debian/patches/features/all/rt/rcu-disable-rcu-fast-no-hz-on-rt.patch b/debian/patches/features/all/rt/rcu-disable-rcu-fast-no-hz-on-rt.patch index 8e67be2bc..13b4e6beb 100644 --- a/debian/patches/features/all/rt/rcu-disable-rcu-fast-no-hz-on-rt.patch +++ b/debian/patches/features/all/rt/rcu-disable-rcu-fast-no-hz-on-rt.patch @@ -1,7 +1,6 @@ Subject: rcu: Disable RCU_FAST_NO_HZ on RT From: Thomas Gleixner Date: Sun, 28 Oct 2012 13:26:09 +0000 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz This uses a timer_list timer from the irq disabled guts of the idle code. Disable it for now to prevent wreckage. diff --git a/debian/patches/features/all/rt/rcu-enable-rcu_normal_after_boot-by-default-for-RT.patch b/debian/patches/features/all/rt/rcu-enable-rcu_normal_after_boot-by-default-for-RT.patch index 3539e7a05..caeb52ab9 100644 --- a/debian/patches/features/all/rt/rcu-enable-rcu_normal_after_boot-by-default-for-RT.patch +++ b/debian/patches/features/all/rt/rcu-enable-rcu_normal_after_boot-by-default-for-RT.patch @@ -1,7 +1,6 @@ From: Julia Cartwright Date: Wed, 12 Oct 2016 11:21:14 -0500 Subject: [PATCH] rcu: enable rcu_normal_after_boot by default for RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The forcing of an expedited grace period is an expensive and very RT-application unfriendly operation, as it forcibly preempts all running diff --git a/debian/patches/features/all/rt/rcu-make-RCU_BOOST-default-on-RT.patch b/debian/patches/features/all/rt/rcu-make-RCU_BOOST-default-on-RT.patch index cecda0772..bda5c6289 100644 --- a/debian/patches/features/all/rt/rcu-make-RCU_BOOST-default-on-RT.patch +++ b/debian/patches/features/all/rt/rcu-make-RCU_BOOST-default-on-RT.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Fri, 21 Mar 2014 20:19:05 +0100 Subject: rcu: make RCU_BOOST default on RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Since it is no longer invoked from the softirq people run into OOM more often if the priority of the RCU thread is too low. Making boosting diff --git a/debian/patches/features/all/rt/rcu-merge-rcu-bh-into-rcu-preempt-for-rt.patch b/debian/patches/features/all/rt/rcu-merge-rcu-bh-into-rcu-preempt-for-rt.patch index 1081797c5..3a6fef25e 100644 --- a/debian/patches/features/all/rt/rcu-merge-rcu-bh-into-rcu-preempt-for-rt.patch +++ b/debian/patches/features/all/rt/rcu-merge-rcu-bh-into-rcu-preempt-for-rt.patch @@ -1,7 +1,6 @@ Subject: rcu: Merge RCU-bh into RCU-preempt Date: Wed, 5 Oct 2011 11:59:38 -0700 From: Thomas Gleixner -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The Linux kernel has long RCU-bh read-side critical sections that intolerably increase scheduling latency under mainline's RCU-bh rules, diff --git a/debian/patches/features/all/rt/rcu-segcblist-include-rcupdate.h.patch b/debian/patches/features/all/rt/rcu-segcblist-include-rcupdate.h.patch deleted file mode 100644 index ffc4029ab..000000000 --- a/debian/patches/features/all/rt/rcu-segcblist-include-rcupdate.h.patch +++ /dev/null @@ -1,23 +0,0 @@ -From: Sebastian Andrzej Siewior -Date: Fri, 22 Sep 2017 15:01:46 +0200 -Subject: [PATCH] rcu/segcblist: include rcupdate.h -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The RT build on ARM complains about non-existing ULONG_CMP_LT. Since -rcu_segcblist.c uses that macro it should include the header file. - -Signed-off-by: Sebastian Andrzej Siewior ---- - kernel/rcu/rcu_segcblist.c | 1 + - 1 file changed, 1 insertion(+) - ---- a/kernel/rcu/rcu_segcblist.c -+++ b/kernel/rcu/rcu_segcblist.c -@@ -23,6 +23,7 @@ - #include - #include - #include -+#include - - #include "rcu_segcblist.h" - diff --git a/debian/patches/features/all/rt/rcutree-rcu_bh_qs-disable-irq-while-calling-rcu_pree.patch b/debian/patches/features/all/rt/rcutree-rcu_bh_qs-disable-irq-while-calling-rcu_pree.patch index 6c7572abe..a781890ab 100644 --- a/debian/patches/features/all/rt/rcutree-rcu_bh_qs-disable-irq-while-calling-rcu_pree.patch +++ b/debian/patches/features/all/rt/rcutree-rcu_bh_qs-disable-irq-while-calling-rcu_pree.patch @@ -1,7 +1,6 @@ From: Tiejun Chen Date: Wed, 18 Dec 2013 17:51:49 +0800 Subject: rcutree/rcu_bh_qs: Disable irq while calling rcu_preempt_qs() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Any callers to the function rcu_preempt_qs() must disable irqs in order to protect the assignment to ->rcu_read_unlock_special. In diff --git a/debian/patches/features/all/rt/re-preempt_rt_full-arm-coredump-fails-for-cpu-3e-3d-4.patch b/debian/patches/features/all/rt/re-preempt_rt_full-arm-coredump-fails-for-cpu-3e-3d-4.patch index e84b9007d..293ef2d04 100644 --- a/debian/patches/features/all/rt/re-preempt_rt_full-arm-coredump-fails-for-cpu-3e-3d-4.patch +++ b/debian/patches/features/all/rt/re-preempt_rt_full-arm-coredump-fails-for-cpu-3e-3d-4.patch @@ -1,7 +1,6 @@ Subject: ARM: Initialize split page table locks for vector page From: Frank Rowand Date: Sat, 1 Oct 2011 18:58:13 -0700 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Without this patch, ARM can not use SPLIT_PTLOCK_CPUS if PREEMPT_RT_FULL=y because vectors_user_mapping() creates a diff --git a/debian/patches/features/all/rt/rfc-arm-smp-__cpu_disable-fix-sleeping-function-called-from-invalid-context.patch b/debian/patches/features/all/rt/rfc-arm-smp-__cpu_disable-fix-sleeping-function-called-from-invalid-context.patch index 2652853db..325a7c0a2 100644 --- a/debian/patches/features/all/rt/rfc-arm-smp-__cpu_disable-fix-sleeping-function-called-from-invalid-context.patch +++ b/debian/patches/features/all/rt/rfc-arm-smp-__cpu_disable-fix-sleeping-function-called-from-invalid-context.patch @@ -1,7 +1,6 @@ Subject: ARM: smp: Move clear_tasks_mm_cpumask() call to __cpu_die() From: Grygorii Strashko Date: Fri, 11 Sep 2015 21:21:23 +0300 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz When running with the RT-kernel (4.1.5-rt5) on TI OMAP dra7-evm and trying to do Suspend to RAM, the following backtrace occurs: diff --git a/debian/patches/features/all/rt/rt-Increase-decrease-the-nr-of-migratory-tasks-when-.patch b/debian/patches/features/all/rt/rt-Increase-decrease-the-nr-of-migratory-tasks-when-.patch index 14f5c8ce3..cfd8647de 100644 --- a/debian/patches/features/all/rt/rt-Increase-decrease-the-nr-of-migratory-tasks-when-.patch +++ b/debian/patches/features/all/rt/rt-Increase-decrease-the-nr-of-migratory-tasks-when-.patch @@ -1,7 +1,6 @@ From: Daniel Bristot de Oliveira Date: Mon, 26 Jun 2017 17:07:15 +0200 Subject: rt: Increase/decrease the nr of migratory tasks when enabling/disabling migration -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz There is a problem in the migrate_disable()/enable() implementation regarding the number of migratory tasks in the rt/dl RQs. The problem @@ -81,7 +80,7 @@ Signed-off-by: Sebastian Andrzej Siewior --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -7109,6 +7109,47 @@ const u32 sched_prio_to_wmult[40] = { +@@ -7114,6 +7114,47 @@ const u32 sched_prio_to_wmult[40] = { #if defined(CONFIG_PREEMPT_COUNT) && defined(CONFIG_SMP) @@ -129,7 +128,7 @@ Signed-off-by: Sebastian Andrzej Siewior void migrate_disable(void) { struct task_struct *p = current; -@@ -7132,10 +7173,9 @@ void migrate_disable(void) +@@ -7137,10 +7178,9 @@ void migrate_disable(void) } preempt_disable(); @@ -142,7 +141,7 @@ Signed-off-by: Sebastian Andrzej Siewior preempt_enable(); } -@@ -7167,9 +7207,8 @@ void migrate_enable(void) +@@ -7172,9 +7212,8 @@ void migrate_enable(void) preempt_disable(); diff --git a/debian/patches/features/all/rt/rt-introduce-cpu-chill.patch b/debian/patches/features/all/rt/rt-introduce-cpu-chill.patch index a44b4bfc7..2b414bcba 100644 --- a/debian/patches/features/all/rt/rt-introduce-cpu-chill.patch +++ b/debian/patches/features/all/rt/rt-introduce-cpu-chill.patch @@ -1,7 +1,6 @@ Subject: rt: Introduce cpu_chill() From: Thomas Gleixner Date: Wed, 07 Mar 2012 20:51:03 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Retry loops on RT might loop forever when the modifying side was preempted. Add cpu_chill() to replace cpu_relax(). cpu_chill() diff --git a/debian/patches/features/all/rt/rt-local-irq-lock.patch b/debian/patches/features/all/rt/rt-local-irq-lock.patch index 21a867520..c27d96204 100644 --- a/debian/patches/features/all/rt/rt-local-irq-lock.patch +++ b/debian/patches/features/all/rt/rt-local-irq-lock.patch @@ -1,7 +1,6 @@ Subject: rt: Add local irq locks From: Thomas Gleixner Date: Mon, 20 Jun 2011 09:03:47 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Introduce locallock. For !RT this maps to preempt_disable()/ local_irq_disable() so there is not much that changes. For RT this will diff --git a/debian/patches/features/all/rt/rt-preempt-base-config.patch b/debian/patches/features/all/rt/rt-preempt-base-config.patch index 50ae1b55a..3f962fb74 100644 --- a/debian/patches/features/all/rt/rt-preempt-base-config.patch +++ b/debian/patches/features/all/rt/rt-preempt-base-config.patch @@ -1,7 +1,6 @@ Subject: rt: Provide PREEMPT_RT_BASE config switch From: Thomas Gleixner Date: Fri, 17 Jun 2011 12:39:57 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Introduce PREEMPT_RT_BASE which enables parts of PREEMPT_RT_FULL. Forces interrupt threading and enables some of the RT diff --git a/debian/patches/features/all/rt/rt-serial-warn-fix.patch b/debian/patches/features/all/rt/rt-serial-warn-fix.patch index c39ef819e..9119b686b 100644 --- a/debian/patches/features/all/rt/rt-serial-warn-fix.patch +++ b/debian/patches/features/all/rt/rt-serial-warn-fix.patch @@ -1,7 +1,6 @@ Subject: rt: Improve the serial console PASS_LIMIT From: Ingo Molnar Date: Wed Dec 14 13:05:54 CET 2011 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Beyond the warning: diff --git a/debian/patches/features/all/rt/rtmutex--Handle-non-enqueued-waiters-gracefully.patch b/debian/patches/features/all/rt/rtmutex--Handle-non-enqueued-waiters-gracefully.patch deleted file mode 100644 index 6f352c44a..000000000 --- a/debian/patches/features/all/rt/rtmutex--Handle-non-enqueued-waiters-gracefully.patch +++ /dev/null @@ -1,33 +0,0 @@ -Subject: rtmutex: Handle non enqueued waiters gracefully -From: Thomas Gleixner -Date: Fri, 06 Nov 2015 18:51:03 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Yimin debugged that in case of a PI wakeup in progress when -rt_mutex_start_proxy_lock() calls task_blocks_on_rt_mutex() the latter -returns -EAGAIN and in consequence the remove_waiter() call runs into -a BUG_ON() because there is nothing to remove. - -Guard it with rt_mutex_has_waiters(). This is a quick fix which is -easy to backport. The proper fix is to have a central check in -remove_waiter() so we can call it unconditionally. - -Reported-and-debugged-by: Yimin Deng -Signed-off-by: Thomas Gleixner -Cc: stable-rt@vger.kernel.org - ---- - kernel/locking/rtmutex.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/kernel/locking/rtmutex.c -+++ b/kernel/locking/rtmutex.c -@@ -1728,7 +1728,7 @@ int __rt_mutex_start_proxy_lock(struct r - ret = 0; - } - -- if (unlikely(ret)) -+ if (ret && rt_mutex_has_waiters(lock)) - remove_waiter(lock, waiter); - - debug_rt_mutex_print_deadlock(waiter); diff --git a/debian/patches/features/all/rt/rtmutex-Make-lock_killable-work.patch b/debian/patches/features/all/rt/rtmutex-Make-lock_killable-work.patch index 8aa8f52fc..cc50d7ea5 100644 --- a/debian/patches/features/all/rt/rtmutex-Make-lock_killable-work.patch +++ b/debian/patches/features/all/rt/rtmutex-Make-lock_killable-work.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Sat, 1 Apr 2017 12:50:59 +0200 Subject: [PATCH] rtmutex: Make lock_killable work -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Locking an rt mutex killable does not work because signal handling is restricted to TASK_INTERRUPTIBLE. diff --git a/debian/patches/features/all/rt/rtmutex-Provide-rt_mutex_slowlock_locked.patch b/debian/patches/features/all/rt/rtmutex-Provide-rt_mutex_slowlock_locked.patch index 26e849eed..13e80368b 100644 --- a/debian/patches/features/all/rt/rtmutex-Provide-rt_mutex_slowlock_locked.patch +++ b/debian/patches/features/all/rt/rtmutex-Provide-rt_mutex_slowlock_locked.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Thu, 12 Oct 2017 16:14:22 +0200 Subject: rtmutex: Provide rt_mutex_slowlock_locked() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz This is the inner-part of rt_mutex_slowlock(), required for rwsem-rt. diff --git a/debian/patches/features/all/rt/rtmutex-add-mutex-implementation-based-on-rtmutex.patch b/debian/patches/features/all/rt/rtmutex-add-mutex-implementation-based-on-rtmutex.patch index 8cfd93471..783831268 100644 --- a/debian/patches/features/all/rt/rtmutex-add-mutex-implementation-based-on-rtmutex.patch +++ b/debian/patches/features/all/rt/rtmutex-add-mutex-implementation-based-on-rtmutex.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Thu, 12 Oct 2017 17:17:03 +0200 Subject: rtmutex: add mutex implementation based on rtmutex -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Signed-off-by: Thomas Gleixner Signed-off-by: Sebastian Andrzej Siewior diff --git a/debian/patches/features/all/rt/rtmutex-add-rwlock-implementation-based-on-rtmutex.patch b/debian/patches/features/all/rt/rtmutex-add-rwlock-implementation-based-on-rtmutex.patch index f8c84fc42..35ac0af12 100644 --- a/debian/patches/features/all/rt/rtmutex-add-rwlock-implementation-based-on-rtmutex.patch +++ b/debian/patches/features/all/rt/rtmutex-add-rwlock-implementation-based-on-rtmutex.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Thu, 12 Oct 2017 17:18:06 +0200 Subject: rtmutex: add rwlock implementation based on rtmutex -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The implementation is bias-based, similar to the rwsem implementation. diff --git a/debian/patches/features/all/rt/rtmutex-add-rwsem-implementation-based-on-rtmutex.patch b/debian/patches/features/all/rt/rtmutex-add-rwsem-implementation-based-on-rtmutex.patch index 69b9d59d3..21d1c44da 100644 --- a/debian/patches/features/all/rt/rtmutex-add-rwsem-implementation-based-on-rtmutex.patch +++ b/debian/patches/features/all/rt/rtmutex-add-rwsem-implementation-based-on-rtmutex.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Thu, 12 Oct 2017 17:28:34 +0200 Subject: rtmutex: add rwsem implementation based on rtmutex -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The RT specific R/W semaphore implementation restricts the number of readers to one because a writer cannot block on multiple readers and inherit its diff --git a/debian/patches/features/all/rt/rtmutex-add-sleeping-lock-implementation.patch b/debian/patches/features/all/rt/rtmutex-add-sleeping-lock-implementation.patch index 1b0764ec7..5394076f2 100644 --- a/debian/patches/features/all/rt/rtmutex-add-sleeping-lock-implementation.patch +++ b/debian/patches/features/all/rt/rtmutex-add-sleeping-lock-implementation.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Thu, 12 Oct 2017 17:11:19 +0200 Subject: rtmutex: add sleeping lock implementation -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Signed-off-by: Thomas Gleixner Signed-off-by: Sebastian Andrzej Siewior @@ -1124,7 +1123,7 @@ Signed-off-by: Sebastian Andrzej Siewior # include "rtmutex-debug.h" --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -429,9 +429,15 @@ static bool set_nr_if_polling(struct tas +@@ -430,9 +430,15 @@ static bool set_nr_if_polling(struct tas #endif #endif @@ -1142,7 +1141,7 @@ Signed-off-by: Sebastian Andrzej Siewior /* * Atomically grab the task, if ->wake_q is !nil already it means -@@ -453,24 +459,32 @@ void wake_q_add(struct wake_q_head *head +@@ -454,24 +460,32 @@ void wake_q_add(struct wake_q_head *head head->lastp = &node->next; } diff --git a/debian/patches/features/all/rt/rtmutex-add-ww_mutex-addon-for-mutex-rt.patch b/debian/patches/features/all/rt/rtmutex-add-ww_mutex-addon-for-mutex-rt.patch index 5acb53f53..702e04182 100644 --- a/debian/patches/features/all/rt/rtmutex-add-ww_mutex-addon-for-mutex-rt.patch +++ b/debian/patches/features/all/rt/rtmutex-add-ww_mutex-addon-for-mutex-rt.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 12 Oct 2017 17:34:38 +0200 Subject: rtmutex: add ww_mutex addon for mutex-rt -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Signed-off-by: Sebastian Andrzej Siewior --- diff --git a/debian/patches/features/all/rt/rtmutex-annotate-sleeping-lock-context.patch b/debian/patches/features/all/rt/rtmutex-annotate-sleeping-lock-context.patch index 012197bd5..6e69c13f5 100644 --- a/debian/patches/features/all/rt/rtmutex-annotate-sleeping-lock-context.patch +++ b/debian/patches/features/all/rt/rtmutex-annotate-sleeping-lock-context.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Fri, 20 Apr 2018 18:13:11 +0200 Subject: [PATCH] rtmutex: annotate sleeping lock context -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The RCU code complains on schedule() within a rcu_readlock() section. The valid scenario on -RT is if a sleeping is held. In order to suppress @@ -42,7 +41,7 @@ Signed-off-by: Sebastian Andrzej Siewior #ifdef CONFIG_PREEMPT_RCU int rcu_read_lock_nesting; -@@ -1723,6 +1726,23 @@ static __always_inline bool need_resched +@@ -1731,6 +1734,23 @@ static __always_inline bool need_resched return unlikely(tif_need_resched()); } diff --git a/debian/patches/features/all/rt/rtmutex-avoid-include-hell.patch b/debian/patches/features/all/rt/rtmutex-avoid-include-hell.patch index 9b47fcd46..a3b55f5b7 100644 --- a/debian/patches/features/all/rt/rtmutex-avoid-include-hell.patch +++ b/debian/patches/features/all/rt/rtmutex-avoid-include-hell.patch @@ -1,7 +1,6 @@ Subject: rtmutex: Avoid include hell From: Thomas Gleixner Date: Wed, 29 Jun 2011 20:06:39 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Include only the required raw types. This avoids pulling in the complete spinlock header which in turn requires rtmutex.h at some point. diff --git a/debian/patches/features/all/rt/rtmutex-export-lockdep-less-version-of-rt_mutex-s-lo.patch b/debian/patches/features/all/rt/rtmutex-export-lockdep-less-version-of-rt_mutex-s-lo.patch index 5b8821383..1477b3aa2 100644 --- a/debian/patches/features/all/rt/rtmutex-export-lockdep-less-version-of-rt_mutex-s-lo.patch +++ b/debian/patches/features/all/rt/rtmutex-export-lockdep-less-version-of-rt_mutex-s-lo.patch @@ -2,7 +2,6 @@ From: Thomas Gleixner Date: Thu, 12 Oct 2017 16:36:39 +0200 Subject: rtmutex: export lockdep-less version of rt_mutex's lock, trylock and unlock -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Required for lock implementation ontop of rtmutex. diff --git a/debian/patches/features/all/rt/rtmutex-futex-prepare-rt.patch b/debian/patches/features/all/rt/rtmutex-futex-prepare-rt.patch index 4fbdbc3e2..23479b660 100644 --- a/debian/patches/features/all/rt/rtmutex-futex-prepare-rt.patch +++ b/debian/patches/features/all/rt/rtmutex-futex-prepare-rt.patch @@ -1,7 +1,6 @@ Subject: rtmutex: Handle the various new futex race conditions From: Thomas Gleixner Date: Fri, 10 Jun 2011 11:04:15 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz RT opens a few new interesting race conditions in the rtmutex/futex combo due to futex hash bucket lock being a 'sleeping' spinlock and diff --git a/debian/patches/features/all/rt/rtmutex-lock-killable.patch b/debian/patches/features/all/rt/rtmutex-lock-killable.patch index c0f01e39c..d25ce7809 100644 --- a/debian/patches/features/all/rt/rtmutex-lock-killable.patch +++ b/debian/patches/features/all/rt/rtmutex-lock-killable.patch @@ -1,7 +1,6 @@ Subject: rtmutex: Add rtmutex_lock_killable() From: Thomas Gleixner Date: Thu, 09 Jun 2011 11:43:52 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Add "killable" type to rtmutex. We need this since rtmutex are used as "normal" mutexes which do use this type. diff --git a/debian/patches/features/all/rt/rtmutex-trylock-is-okay-on-RT.patch b/debian/patches/features/all/rt/rtmutex-trylock-is-okay-on-RT.patch index dd1dbb7b0..276a4be30 100644 --- a/debian/patches/features/all/rt/rtmutex-trylock-is-okay-on-RT.patch +++ b/debian/patches/features/all/rt/rtmutex-trylock-is-okay-on-RT.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed 02 Dec 2015 11:34:07 +0100 Subject: rtmutex: trylock is okay on -RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz non-RT kernel could deadlock on rt_mutex_trylock() in softirq context. On -RT we don't run softirqs in IRQ context but in thread context so it is diff --git a/debian/patches/features/all/rt/rtmutex-wire-up-RT-s-locking.patch b/debian/patches/features/all/rt/rtmutex-wire-up-RT-s-locking.patch index d7c351ffd..462ad6b45 100644 --- a/debian/patches/features/all/rt/rtmutex-wire-up-RT-s-locking.patch +++ b/debian/patches/features/all/rt/rtmutex-wire-up-RT-s-locking.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Thu, 12 Oct 2017 17:31:14 +0200 Subject: rtmutex: wire up RT's locking -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Signed-off-by: Thomas Gleixner Signed-off-by: Sebastian Andrzej Siewior diff --git a/debian/patches/features/all/rt/rtmutex_dont_include_rcu.patch b/debian/patches/features/all/rt/rtmutex_dont_include_rcu.patch index 7865ff22e..d63e678a0 100644 --- a/debian/patches/features/all/rt/rtmutex_dont_include_rcu.patch +++ b/debian/patches/features/all/rt/rtmutex_dont_include_rcu.patch @@ -1,6 +1,5 @@ From: Sebastian Andrzej Siewior Subject: rbtree: don't include the rcu header -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The RCU header pulls in spinlock.h and fails due not yet defined types: diff --git a/debian/patches/features/all/rt/rxrpc-remove-unused-static-variables.patch b/debian/patches/features/all/rt/rxrpc-remove-unused-static-variables.patch index 2cc65d6c4..812d3047f 100644 --- a/debian/patches/features/all/rt/rxrpc-remove-unused-static-variables.patch +++ b/debian/patches/features/all/rt/rxrpc-remove-unused-static-variables.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Fri, 21 Oct 2016 10:54:50 +0200 Subject: [PATCH] rxrpc: remove unused static variables -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz upstream commit edb63e2b271752a9424a3d33cfcd4f434a020f9b diff --git a/debian/patches/features/all/rt/sas-ata-isci-dont-t-disable-interrupts-in-qc_issue-h.patch b/debian/patches/features/all/rt/sas-ata-isci-dont-t-disable-interrupts-in-qc_issue-h.patch deleted file mode 100644 index 6a4eb7785..000000000 --- a/debian/patches/features/all/rt/sas-ata-isci-dont-t-disable-interrupts-in-qc_issue-h.patch +++ /dev/null @@ -1,79 +0,0 @@ -From: Paul Gortmaker -Date: Sat, 14 Feb 2015 11:01:16 -0500 -Subject: sas-ata/isci: dont't disable interrupts in qc_issue handler -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -On 3.14-rt we see the following trace on Canoe Pass for -SCSI_ISCI "Intel(R) C600 Series Chipset SAS Controller" -when the sas qc_issue handler is run: - - BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:905 - in_atomic(): 0, irqs_disabled(): 1, pid: 432, name: udevd - CPU: 11 PID: 432 Comm: udevd Not tainted 3.14.28-rt22 #2 - Hardware name: Intel Corporation S2600CP/S2600CP, BIOS SE5C600.86B.02.01.0002.082220131453 08/22/2013 - ffff880fab500000 ffff880fa9f239c0 ffffffff81a2d273 0000000000000000 - ffff880fa9f239d8 ffffffff8107f023 ffff880faac23dc0 ffff880fa9f239f0 - ffffffff81a33cc0 ffff880faaeb1400 ffff880fa9f23a40 ffffffff815de891 - Call Trace: - [] dump_stack+0x4e/0x7a - [] __might_sleep+0xe3/0x160 - [] rt_spin_lock+0x20/0x50 - [] isci_task_execute_task+0x171/0x2f0 <----- - [] sas_ata_qc_issue+0x25b/0x2a0 - [] ata_qc_issue+0x1f3/0x370 - [] ? ata_scsi_invalid_field+0x40/0x40 - [] ata_scsi_translate+0xa5/0x1b0 - [] ata_sas_queuecmd+0x86/0x280 - [] sas_queuecommand+0x196/0x230 - [] ? get_parent_ip+0xd/0x50 - [] scsi_dispatch_cmd+0xb4/0x210 - [] scsi_request_fn+0x314/0x530 - -and gdb shows: - -(gdb) list * isci_task_execute_task+0x171 -0xffffffff815ddfb1 is in isci_task_execute_task (drivers/scsi/isci/task.c:138). -133 dev_dbg(&ihost->pdev->dev, "%s: num=%d\n", __func__, num); -134 -135 for_each_sas_task(num, task) { -136 enum sci_status status = SCI_FAILURE; -137 -138 spin_lock_irqsave(&ihost->scic_lock, flags); <----- -139 idev = isci_lookup_device(task->dev); -140 io_ready = isci_device_io_ready(idev, task); -141 tag = isci_alloc_tag(ihost); -142 spin_unlock_irqrestore(&ihost->scic_lock, flags); -(gdb) - -In addition to the scic_lock, the function also contains locking of -the task_state_lock -- which is clearly not a candidate for raw lock -conversion. As can be seen by the comment nearby, we really should -be running the qc_issue code with interrupts enabled anyway. - - -Signed-off-by: Paul Gortmaker -Signed-off-by: Sebastian Andrzej Siewior ---- - drivers/scsi/libsas/sas_ata.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/drivers/scsi/libsas/sas_ata.c -+++ b/drivers/scsi/libsas/sas_ata.c -@@ -190,7 +190,7 @@ static unsigned int sas_ata_qc_issue(str - /* TODO: audit callers to ensure they are ready for qc_issue to - * unconditionally re-enable interrupts - */ -- local_irq_save(flags); -+ local_irq_save_nort(flags); - spin_unlock(ap->lock); - - /* If the device fell off, no sense in issuing commands */ -@@ -252,7 +252,7 @@ static unsigned int sas_ata_qc_issue(str - - out: - spin_lock(ap->lock); -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - return ret; - } - diff --git a/debian/patches/features/all/rt/sched-Prevent-task-state-corruption-by-spurious-lock.patch b/debian/patches/features/all/rt/sched-Prevent-task-state-corruption-by-spurious-lock.patch index c3c823d9e..f2cbcd6c6 100644 --- a/debian/patches/features/all/rt/sched-Prevent-task-state-corruption-by-spurious-lock.patch +++ b/debian/patches/features/all/rt/sched-Prevent-task-state-corruption-by-spurious-lock.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Tue, 6 Jun 2017 14:20:37 +0200 Subject: sched: Prevent task state corruption by spurious lock wakeup -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Mathias and others reported GDB failures on RT. @@ -67,7 +66,7 @@ Signed-off-by: Sebastian Andrzej Siewior --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -2217,7 +2217,7 @@ EXPORT_SYMBOL(wake_up_process); +@@ -2218,7 +2218,7 @@ EXPORT_SYMBOL(wake_up_process); */ int wake_up_lock_sleeper(struct task_struct *p) { diff --git a/debian/patches/features/all/rt/sched-Remove-TASK_ALL.patch b/debian/patches/features/all/rt/sched-Remove-TASK_ALL.patch index 9a29d7d56..4844fb7e9 100644 --- a/debian/patches/features/all/rt/sched-Remove-TASK_ALL.patch +++ b/debian/patches/features/all/rt/sched-Remove-TASK_ALL.patch @@ -1,7 +1,6 @@ From: Peter Zijlstra Date: Wed, 7 Jun 2017 10:12:45 +0200 Subject: [PATCH] sched: Remove TASK_ALL -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz It's unused: diff --git a/debian/patches/features/all/rt/sched-delay-put-task.patch b/debian/patches/features/all/rt/sched-delay-put-task.patch index 9ad305055..82b37de15 100644 --- a/debian/patches/features/all/rt/sched-delay-put-task.patch +++ b/debian/patches/features/all/rt/sched-delay-put-task.patch @@ -1,7 +1,6 @@ Subject: sched: Move task_struct cleanup to RCU From: Thomas Gleixner Date: Tue, 31 May 2011 16:59:16 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz __put_task_struct() does quite some expensive work. We don't want to burden random tasks with that. diff --git a/debian/patches/features/all/rt/sched-disable-rt-group-sched-on-rt.patch b/debian/patches/features/all/rt/sched-disable-rt-group-sched-on-rt.patch index 57562693d..612f517ff 100644 --- a/debian/patches/features/all/rt/sched-disable-rt-group-sched-on-rt.patch +++ b/debian/patches/features/all/rt/sched-disable-rt-group-sched-on-rt.patch @@ -1,7 +1,6 @@ Subject: sched: Disable CONFIG_RT_GROUP_SCHED on RT From: Thomas Gleixner Date: Mon, 18 Jul 2011 17:03:52 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Carsten reported problems when running: diff --git a/debian/patches/features/all/rt/sched-disable-ttwu-queue.patch b/debian/patches/features/all/rt/sched-disable-ttwu-queue.patch index ab414df32..95221e680 100644 --- a/debian/patches/features/all/rt/sched-disable-ttwu-queue.patch +++ b/debian/patches/features/all/rt/sched-disable-ttwu-queue.patch @@ -1,7 +1,6 @@ Subject: sched: Disable TTWU_QUEUE on RT From: Thomas Gleixner Date: Tue, 13 Sep 2011 16:42:35 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The queued remote wakeup mechanism can introduce rather large latencies if the number of migrated tasks is high. Disable it for RT. diff --git a/debian/patches/features/all/rt/sched-fair-Fix-CFS-bandwidth-control-lockdep-DEADLOC.patch b/debian/patches/features/all/rt/sched-fair-Fix-CFS-bandwidth-control-lockdep-DEADLOC.patch index e423508f4..a1eb5fa9a 100644 --- a/debian/patches/features/all/rt/sched-fair-Fix-CFS-bandwidth-control-lockdep-DEADLOC.patch +++ b/debian/patches/features/all/rt/sched-fair-Fix-CFS-bandwidth-control-lockdep-DEADLOC.patch @@ -1,7 +1,6 @@ From: Mike Galbraith Date: Fri, 4 May 2018 08:14:38 +0200 Subject: [PATCH] sched/fair: Fix CFS bandwidth control lockdep DEADLOCK report -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz CFS bandwidth control yields the inversion gripe below, moving handling quells it. diff --git a/debian/patches/features/all/rt/sched-let-softirq_count-return-0-if-inside-local_bh_.patch b/debian/patches/features/all/rt/sched-let-softirq_count-return-0-if-inside-local_bh_.patch index d2aaef7a1..9df3b3e94 100644 --- a/debian/patches/features/all/rt/sched-let-softirq_count-return-0-if-inside-local_bh_.patch +++ b/debian/patches/features/all/rt/sched-let-softirq_count-return-0-if-inside-local_bh_.patch @@ -2,7 +2,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 17 May 2018 11:47:24 +0200 Subject: [PATCH] sched: let softirq_count() return !0 if inside local_bh_disable()ed section -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz I don't see a reason why softirq_count() shouldn't reflect the fact that we are within a local_bh_disable() section. I *think* it was done @@ -12,6 +11,7 @@ I don't see any fallout with this change. Furthermore, all checks like "WARN_ON(!softirq_count())" will work and we can drop the workaround we currently have in the queue. +Acked-by: Steven Rostedt (VMware) Signed-off-by: Sebastian Andrzej Siewior --- include/linux/preempt.h | 2 +- diff --git a/debian/patches/features/all/rt/sched-limit-nr-migrate.patch b/debian/patches/features/all/rt/sched-limit-nr-migrate.patch index a8af322dc..821b0de23 100644 --- a/debian/patches/features/all/rt/sched-limit-nr-migrate.patch +++ b/debian/patches/features/all/rt/sched-limit-nr-migrate.patch @@ -1,7 +1,6 @@ Subject: sched: Limit the number of task migrations per batch From: Thomas Gleixner Date: Mon, 06 Jun 2011 12:12:51 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Put an upper limit on the number of tasks which are migrated per batch to avoid large latencies. @@ -13,7 +12,7 @@ Signed-off-by: Thomas Gleixner --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -64,7 +64,11 @@ const_debug unsigned int sysctl_sched_fe +@@ -65,7 +65,11 @@ const_debug unsigned int sysctl_sched_fe * Number of tasks to iterate in a single balance run. * Limited because this is done with IRQs disabled. */ diff --git a/debian/patches/features/all/rt/sched-might-sleep-do-not-account-rcu-depth.patch b/debian/patches/features/all/rt/sched-might-sleep-do-not-account-rcu-depth.patch index 5d9437d58..c488ef7bd 100644 --- a/debian/patches/features/all/rt/sched-might-sleep-do-not-account-rcu-depth.patch +++ b/debian/patches/features/all/rt/sched-might-sleep-do-not-account-rcu-depth.patch @@ -1,7 +1,6 @@ Subject: sched: Do not account rcu_preempt_depth on RT in might_sleep() From: Thomas Gleixner Date: Tue, 07 Jun 2011 09:19:06 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz RT changes the rcu_preempt_depth semantics, so we cannot check for it in might_sleep(). @@ -37,7 +36,7 @@ Signed-off-by: Thomas Gleixner /* Internal to kernel */ --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -6137,7 +6137,7 @@ void __init sched_init(void) +@@ -6138,7 +6138,7 @@ void __init sched_init(void) #ifdef CONFIG_DEBUG_ATOMIC_SLEEP static inline int preempt_count_equals(int preempt_offset) { diff --git a/debian/patches/features/all/rt/sched-mmdrop-delayed.patch b/debian/patches/features/all/rt/sched-mmdrop-delayed.patch index 85de0bfdc..870344eb8 100644 --- a/debian/patches/features/all/rt/sched-mmdrop-delayed.patch +++ b/debian/patches/features/all/rt/sched-mmdrop-delayed.patch @@ -1,7 +1,6 @@ Subject: sched: Move mmdrop to RCU on RT From: Thomas Gleixner Date: Mon, 06 Jun 2011 12:20:33 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Takes sleeping locks and calls into the memory allocator, so nothing we want to do in task switch and oder atomic contexts. @@ -78,7 +77,7 @@ Signed-off-by: Thomas Gleixner struct mm_struct *mm; --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -2766,9 +2766,13 @@ static struct rq *finish_task_switch(str +@@ -2767,9 +2767,13 @@ static struct rq *finish_task_switch(str * provided by mmdrop(), * - a sync_core for SYNC_CORE. */ @@ -93,7 +92,7 @@ Signed-off-by: Thomas Gleixner } if (unlikely(prev_state == TASK_DEAD)) { if (prev->sched_class->task_dead) -@@ -5532,6 +5536,8 @@ void sched_setnuma(struct task_struct *p +@@ -5533,6 +5537,8 @@ void sched_setnuma(struct task_struct *p #endif /* CONFIG_NUMA_BALANCING */ #ifdef CONFIG_HOTPLUG_CPU @@ -102,7 +101,7 @@ Signed-off-by: Thomas Gleixner /* * Ensure that the idle task is using init_mm right before its CPU goes * offline. -@@ -5546,7 +5552,12 @@ void idle_task_exit(void) +@@ -5547,7 +5553,12 @@ void idle_task_exit(void) switch_mm(mm, &init_mm, current); finish_arch_post_lock_switch(); } @@ -116,7 +115,7 @@ Signed-off-by: Thomas Gleixner } /* -@@ -5849,6 +5860,10 @@ int sched_cpu_dying(unsigned int cpu) +@@ -5850,6 +5861,10 @@ int sched_cpu_dying(unsigned int cpu) update_max_interval(); nohz_balance_exit_idle(cpu); hrtick_clear(rq); diff --git a/debian/patches/features/all/rt/sched-rt-mutex-wakeup.patch b/debian/patches/features/all/rt/sched-rt-mutex-wakeup.patch index ab3902e22..0a72478a2 100644 --- a/debian/patches/features/all/rt/sched-rt-mutex-wakeup.patch +++ b/debian/patches/features/all/rt/sched-rt-mutex-wakeup.patch @@ -1,7 +1,6 @@ Subject: sched: Add saved_state for tasks blocked on sleeping locks From: Thomas Gleixner Date: Sat, 25 Jun 2011 09:21:04 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Spinlocks are state preserving in !RT. RT changes the state when a task gets blocked on a lock. So we need to remember the state before @@ -27,7 +26,7 @@ Signed-off-by: Thomas Gleixner /* * This begins the randomizable portion of task_struct. Only -@@ -1521,6 +1523,7 @@ extern struct task_struct *find_get_task +@@ -1529,6 +1531,7 @@ extern struct task_struct *find_get_task extern int wake_up_state(struct task_struct *tsk, unsigned int state); extern int wake_up_process(struct task_struct *tsk); @@ -37,7 +36,7 @@ Signed-off-by: Thomas Gleixner #ifdef CONFIG_SMP --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -2026,8 +2026,25 @@ try_to_wake_up(struct task_struct *p, un +@@ -2027,8 +2027,25 @@ try_to_wake_up(struct task_struct *p, un */ raw_spin_lock_irqsave(&p->pi_lock, flags); smp_mb__after_spinlock(); @@ -64,7 +63,7 @@ Signed-off-by: Thomas Gleixner trace_sched_waking(p); -@@ -2191,6 +2208,18 @@ int wake_up_process(struct task_struct * +@@ -2192,6 +2209,18 @@ int wake_up_process(struct task_struct * } EXPORT_SYMBOL(wake_up_process); diff --git a/debian/patches/features/all/rt/sched-swait-include-wait.h.patch b/debian/patches/features/all/rt/sched-swait-include-wait.h.patch index b7afb27f8..33e80727a 100644 --- a/debian/patches/features/all/rt/sched-swait-include-wait.h.patch +++ b/debian/patches/features/all/rt/sched-swait-include-wait.h.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Mon, 4 Dec 2017 13:11:10 +0100 Subject: [PATCH] sched/swait: include wait.h -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz kbuild bot reported against an intermediate RT patch that the build fails with: diff --git a/debian/patches/features/all/rt/sched-tracing-Fix-trace_sched_pi_setprio-for-deboost.patch b/debian/patches/features/all/rt/sched-tracing-Fix-trace_sched_pi_setprio-for-deboost.patch new file mode 100644 index 000000000..ba4257778 --- /dev/null +++ b/debian/patches/features/all/rt/sched-tracing-Fix-trace_sched_pi_setprio-for-deboost.patch @@ -0,0 +1,52 @@ +From: Sebastian Andrzej Siewior +Date: Thu, 24 May 2018 15:26:48 +0200 +Subject: [PATCH] sched, tracing: Fix trace_sched_pi_setprio() for deboosting +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Since the following commit: + + b91473ff6e97 ("sched,tracing: Update trace_sched_pi_setprio()") + +the sched_pi_setprio trace point shows the "newprio" during a deboost: + + |futex sched_pi_setprio: comm=futex_requeue_p pid"34 oldprio˜ newprio=3D98 + |futex sched_switch: prev_comm=futex_requeue_p prev_pid"34 prev_prio=120 + +This patch open codes __rt_effective_prio() in the tracepoint as the +'newprio' to get the old behaviour back / the correct priority: + + |futex sched_pi_setprio: comm=futex_requeue_p pid"20 oldprio˜ newprio=3D120 + |futex sched_switch: prev_comm=futex_requeue_p prev_pid"20 prev_prio=120 + +Peter suggested to open code the new priority so people using tracehook +could get the deadline data out. + +Reported-by: Mansky Christian +Signed-off-by: Sebastian Andrzej Siewior +Signed-off-by: Peter Zijlstra (Intel) +Cc: Linus Torvalds +Cc: Peter Zijlstra +Cc: Steven Rostedt +Cc: Thomas Gleixner +Fixes: b91473ff6e97 ("sched,tracing: Update trace_sched_pi_setprio()") +Link: http://lkml.kernel.org/r/20180524132647.gg6ziuogczdmjjzu@linutronix.de +Signed-off-by: Ingo Molnar +--- + include/trace/events/sched.h | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/include/trace/events/sched.h ++++ b/include/trace/events/sched.h +@@ -435,7 +435,9 @@ TRACE_EVENT(sched_pi_setprio, + memcpy(__entry->comm, tsk->comm, TASK_COMM_LEN); + __entry->pid = tsk->pid; + __entry->oldprio = tsk->prio; +- __entry->newprio = pi_task ? pi_task->prio : tsk->prio; ++ __entry->newprio = pi_task ? ++ min(tsk->normal_prio, pi_task->prio) : ++ tsk->normal_prio; + /* XXX SCHED_DEADLINE bits missing */ + ), + diff --git a/debian/patches/features/all/rt/sched-ttwu-ensure-success-return-is-correct.patch b/debian/patches/features/all/rt/sched-ttwu-ensure-success-return-is-correct.patch index 5abba3873..027fd3ae2 100644 --- a/debian/patches/features/all/rt/sched-ttwu-ensure-success-return-is-correct.patch +++ b/debian/patches/features/all/rt/sched-ttwu-ensure-success-return-is-correct.patch @@ -1,7 +1,6 @@ Subject: sched: ttwu: Return success when only changing the saved_state value From: Thomas Gleixner Date: Tue, 13 Dec 2011 21:42:19 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz When a task blocks on a rt lock, it saves the current state in p->saved_state, so a lock related wake up will not destroy the @@ -21,7 +20,7 @@ Signed-off-by: Thomas Gleixner --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -2033,8 +2033,10 @@ try_to_wake_up(struct task_struct *p, un +@@ -2034,8 +2034,10 @@ try_to_wake_up(struct task_struct *p, un * if the wakeup condition is true. */ if (!(wake_flags & WF_LOCK_SLEEPER)) { diff --git a/debian/patches/features/all/rt/sched-workqueue-Only-wake-up-idle-workers-if-not-blo.patch b/debian/patches/features/all/rt/sched-workqueue-Only-wake-up-idle-workers-if-not-blo.patch index ac23c04bd..f7395c9d4 100644 --- a/debian/patches/features/all/rt/sched-workqueue-Only-wake-up-idle-workers-if-not-blo.patch +++ b/debian/patches/features/all/rt/sched-workqueue-Only-wake-up-idle-workers-if-not-blo.patch @@ -1,7 +1,6 @@ From: Steven Rostedt Date: Mon, 18 Mar 2013 15:12:49 -0400 Subject: sched/workqueue: Only wake up idle workers if not blocked on sleeping spin lock -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz In -rt, most spin_locks() turn into mutexes. One of these spin_lock conversions is performed on the workqueue gcwq->lock. When the idle @@ -24,7 +23,7 @@ Signed-off-by: Sebastian Andrzej Siewior --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -3463,8 +3463,10 @@ static void __sched notrace __schedule(b +@@ -3464,8 +3464,10 @@ static void __sched notrace __schedule(b * If a worker went to sleep, notify and ask workqueue * whether it wants to wake up a task to maintain * concurrency. diff --git a/debian/patches/features/all/rt/scsi-fcoe-rt-aware.patch b/debian/patches/features/all/rt/scsi-fcoe-rt-aware.patch index 4ae5886b9..6b3ca2c3b 100644 --- a/debian/patches/features/all/rt/scsi-fcoe-rt-aware.patch +++ b/debian/patches/features/all/rt/scsi-fcoe-rt-aware.patch @@ -1,7 +1,6 @@ Subject: scsi/fcoe: Make RT aware. From: Thomas Gleixner Date: Sat, 12 Nov 2011 14:00:48 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Do not disable preemption while taking sleeping locks. All user look safe for migrate_diable() only. diff --git a/debian/patches/features/all/rt/scsi-qla2xxx-fix-bug-sleeping-function-called-from-invalid-context.patch b/debian/patches/features/all/rt/scsi-qla2xxx-fix-bug-sleeping-function-called-from-invalid-context.patch deleted file mode 100644 index 16b989f2f..000000000 --- a/debian/patches/features/all/rt/scsi-qla2xxx-fix-bug-sleeping-function-called-from-invalid-context.patch +++ /dev/null @@ -1,48 +0,0 @@ -Subject: scsi: qla2xxx: Use local_irq_save_nort() in qla2x00_poll -From: John Kacur -Date: Fri, 27 Apr 2012 12:48:46 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -RT triggers the following: - -[ 11.307652] [] __might_sleep+0xe7/0x110 -[ 11.307663] [] rt_spin_lock+0x24/0x60 -[ 11.307670] [] ? rt_spin_lock_slowunlock+0x78/0x90 -[ 11.307703] [] qla24xx_intr_handler+0x63/0x2d0 [qla2xxx] -[ 11.307736] [] qla2x00_poll+0x67/0x90 [qla2xxx] - -Function qla2x00_poll does local_irq_save() before calling qla24xx_intr_handler -which has a spinlock. Since spinlocks are sleepable on rt, it is not allowed -to call them with interrupts disabled. Therefore we use local_irq_save_nort() -instead which saves flags without disabling interrupts. - -This fix needs to be applied to v3.0-rt, v3.2-rt and v3.4-rt - -Suggested-by: Thomas Gleixner -Signed-off-by: John Kacur -Cc: Steven Rostedt -Cc: David Sommerseth -Link: http://lkml.kernel.org/r/1335523726-10024-1-git-send-email-jkacur@redhat.com - -Signed-off-by: Thomas Gleixner ---- - drivers/scsi/qla2xxx/qla_inline.h | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/drivers/scsi/qla2xxx/qla_inline.h -+++ b/drivers/scsi/qla2xxx/qla_inline.h -@@ -59,12 +59,12 @@ qla2x00_poll(struct rsp_que *rsp) - { - unsigned long flags; - struct qla_hw_data *ha = rsp->hw; -- local_irq_save(flags); -+ local_irq_save_nort(flags); - if (IS_P3P_TYPE(ha)) - qla82xx_poll(0, rsp); - else - ha->isp_ops->intr_handler(0, rsp); -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - } - - static inline uint8_t * diff --git a/debian/patches/features/all/rt/seqlock-prevent-rt-starvation.patch b/debian/patches/features/all/rt/seqlock-prevent-rt-starvation.patch index 6028ce201..93df53717 100644 --- a/debian/patches/features/all/rt/seqlock-prevent-rt-starvation.patch +++ b/debian/patches/features/all/rt/seqlock-prevent-rt-starvation.patch @@ -1,7 +1,6 @@ Subject: seqlock: Prevent rt starvation From: Thomas Gleixner Date: Wed, 22 Feb 2012 12:03:30 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz If a low prio writer gets preempted while holding the seqlock write locked, a high prio reader spins forever on RT. diff --git a/debian/patches/features/all/rt/seqlock-provide-the-same-ordering-semantics-as-mainl.patch b/debian/patches/features/all/rt/seqlock-provide-the-same-ordering-semantics-as-mainl.patch new file mode 100644 index 000000000..0b00532d1 --- /dev/null +++ b/debian/patches/features/all/rt/seqlock-provide-the-same-ordering-semantics-as-mainl.patch @@ -0,0 +1,29 @@ +From: Julia Cartwright +Date: Thu, 26 Apr 2018 15:02:03 -0500 +Subject: [PATCH] seqlock: provide the same ordering semantics as mainline + +The mainline implementation of read_seqbegin() orders prior loads w.r.t. +the read-side critical section. Fixup the RT writer-boosting +implementation to provide the same guarantee. + +Also, while we're here, update the usage of ACCESS_ONCE() to use +READ_ONCE(). + +Fixes: e69f15cf77c23 ("seqlock: Prevent rt starvation") +Cc: stable-rt@vger.kernel.org +Signed-off-by: Julia Cartwright +Signed-off-by: Sebastian Andrzej Siewior +--- + include/linux/seqlock.h | 1 + + 1 file changed, 1 insertion(+) + +--- a/include/linux/seqlock.h ++++ b/include/linux/seqlock.h +@@ -461,6 +461,7 @@ static inline unsigned read_seqbegin(seq + spin_unlock_wait(&sl->lock); + goto repeat; + } ++ smp_rmb(); + return ret; + } + #endif diff --git a/debian/patches/features/all/rt/signal-fix-up-rcu-wreckage.patch b/debian/patches/features/all/rt/signal-fix-up-rcu-wreckage.patch deleted file mode 100644 index f1d95f85e..000000000 --- a/debian/patches/features/all/rt/signal-fix-up-rcu-wreckage.patch +++ /dev/null @@ -1,39 +0,0 @@ -Subject: signal: Make __lock_task_sighand() RT aware -From: Thomas Gleixner -Date: Fri, 22 Jul 2011 08:07:08 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -local_irq_save() + spin_lock(&sighand->siglock) does not work on --RT. Use the nort variants. - -Signed-off-by: Thomas Gleixner ---- - kernel/signal.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - ---- a/kernel/signal.c -+++ b/kernel/signal.c -@@ -1302,12 +1302,12 @@ struct sighand_struct *__lock_task_sigha - * Disable interrupts early to avoid deadlocks. - * See rcu_read_unlock() comment header for details. - */ -- local_irq_save(*flags); -+ local_irq_save_nort(*flags); - rcu_read_lock(); - sighand = rcu_dereference(tsk->sighand); - if (unlikely(sighand == NULL)) { - rcu_read_unlock(); -- local_irq_restore(*flags); -+ local_irq_restore_nort(*flags); - break; - } - /* -@@ -1328,7 +1328,7 @@ struct sighand_struct *__lock_task_sigha - } - spin_unlock(&sighand->siglock); - rcu_read_unlock(); -- local_irq_restore(*flags); -+ local_irq_restore_nort(*flags); - } - - return sighand; diff --git a/debian/patches/features/all/rt/signal-revert-ptrace-preempt-magic.patch b/debian/patches/features/all/rt/signal-revert-ptrace-preempt-magic.patch index f91a20fba..f409b6625 100644 --- a/debian/patches/features/all/rt/signal-revert-ptrace-preempt-magic.patch +++ b/debian/patches/features/all/rt/signal-revert-ptrace-preempt-magic.patch @@ -1,7 +1,6 @@ Subject: signal: Revert ptrace preempt magic From: Thomas Gleixner Date: Wed, 21 Sep 2011 19:57:12 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit '53da1d9456fe7f8 fix ptrace slowness' is nothing more than a bandaid around the ptrace design trainwreck. It's not a diff --git a/debian/patches/features/all/rt/signals-allow-rt-tasks-to-cache-one-sigqueue-struct.patch b/debian/patches/features/all/rt/signals-allow-rt-tasks-to-cache-one-sigqueue-struct.patch index 2739eb95f..a8dbebfa3 100644 --- a/debian/patches/features/all/rt/signals-allow-rt-tasks-to-cache-one-sigqueue-struct.patch +++ b/debian/patches/features/all/rt/signals-allow-rt-tasks-to-cache-one-sigqueue-struct.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Fri, 3 Jul 2009 08:44:56 -0500 Subject: signals: Allow rt tasks to cache one sigqueue struct -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz To avoid allocation allow rt tasks to cache one sigqueue struct in task struct. diff --git a/debian/patches/features/all/rt/skbufhead-raw-lock.patch b/debian/patches/features/all/rt/skbufhead-raw-lock.patch index bef1e36d4..adaf26c99 100644 --- a/debian/patches/features/all/rt/skbufhead-raw-lock.patch +++ b/debian/patches/features/all/rt/skbufhead-raw-lock.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Tue, 12 Jul 2011 15:38:34 +0200 Subject: net: Use skbufhead with raw lock -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Use the rps lock as rawlock so we can keep irq-off regions. It looks low latency. However we can't kfree() from this context therefore we defer this @@ -66,7 +65,7 @@ Signed-off-by: Thomas Gleixner #endif } -@@ -4746,7 +4746,7 @@ static void flush_backlog(struct work_st +@@ -4743,7 +4743,7 @@ static void flush_backlog(struct work_st skb_queue_walk_safe(&sd->input_pkt_queue, skb, tmp) { if (skb->dev->reg_state == NETREG_UNREGISTERING) { __skb_unlink(skb, &sd->input_pkt_queue); @@ -75,7 +74,7 @@ Signed-off-by: Thomas Gleixner input_queue_head_incr(sd); } } -@@ -4756,11 +4756,14 @@ static void flush_backlog(struct work_st +@@ -4753,11 +4753,14 @@ static void flush_backlog(struct work_st skb_queue_walk_safe(&sd->process_queue, skb, tmp) { if (skb->dev->reg_state == NETREG_UNREGISTERING) { __skb_unlink(skb, &sd->process_queue); @@ -91,7 +90,7 @@ Signed-off-by: Thomas Gleixner } static void flush_all_backlogs(void) -@@ -5308,7 +5311,9 @@ static int process_backlog(struct napi_s +@@ -5305,7 +5308,9 @@ static int process_backlog(struct napi_s while (again) { struct sk_buff *skb; @@ -101,7 +100,7 @@ Signed-off-by: Thomas Gleixner rcu_read_lock(); __netif_receive_skb(skb); rcu_read_unlock(); -@@ -5316,9 +5321,9 @@ static int process_backlog(struct napi_s +@@ -5313,9 +5318,9 @@ static int process_backlog(struct napi_s if (++work >= quota) return work; @@ -112,7 +111,7 @@ Signed-off-by: Thomas Gleixner rps_lock(sd); if (skb_queue_empty(&sd->input_pkt_queue)) { /* -@@ -5758,13 +5763,21 @@ static __latent_entropy void net_rx_acti +@@ -5755,13 +5760,21 @@ static __latent_entropy void net_rx_acti unsigned long time_limit = jiffies + usecs_to_jiffies(netdev_budget_usecs); int budget = netdev_budget; @@ -134,7 +133,7 @@ Signed-off-by: Thomas Gleixner for (;;) { struct napi_struct *n; -@@ -8699,6 +8712,9 @@ static int dev_cpu_dead(unsigned int old +@@ -8696,6 +8709,9 @@ static int dev_cpu_dead(unsigned int old netif_rx_ni(skb); input_queue_head_incr(oldsd); } @@ -144,7 +143,7 @@ Signed-off-by: Thomas Gleixner return 0; } -@@ -9004,8 +9020,9 @@ static int __init net_dev_init(void) +@@ -9001,8 +9017,9 @@ static int __init net_dev_init(void) INIT_WORK(flush, flush_backlog); diff --git a/debian/patches/features/all/rt/slub-disable-SLUB_CPU_PARTIAL.patch b/debian/patches/features/all/rt/slub-disable-SLUB_CPU_PARTIAL.patch index 530198bf3..c5a2f066f 100644 --- a/debian/patches/features/all/rt/slub-disable-SLUB_CPU_PARTIAL.patch +++ b/debian/patches/features/all/rt/slub-disable-SLUB_CPU_PARTIAL.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 15 Apr 2015 19:00:47 +0200 Subject: slub: Disable SLUB_CPU_PARTIAL -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz |BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:915 |in_atomic(): 1, irqs_disabled(): 0, pid: 87, name: rcuop/7 diff --git a/debian/patches/features/all/rt/slub-enable-irqs-for-no-wait.patch b/debian/patches/features/all/rt/slub-enable-irqs-for-no-wait.patch index 954bf7a7a..8780791d0 100644 --- a/debian/patches/features/all/rt/slub-enable-irqs-for-no-wait.patch +++ b/debian/patches/features/all/rt/slub-enable-irqs-for-no-wait.patch @@ -1,7 +1,6 @@ Subject: slub: Enable irqs for __GFP_WAIT From: Thomas Gleixner Date: Wed, 09 Jan 2013 12:08:15 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz SYSTEM_RUNNING might be too late for enabling interrupts. Allocations with GFP_WAIT can happen before that. So use this as an indicator. diff --git a/debian/patches/features/all/rt/snd-pcm-fix-snd_pcm_stream_lock-irqs_disabled-splats.patch b/debian/patches/features/all/rt/snd-pcm-fix-snd_pcm_stream_lock-irqs_disabled-splats.patch deleted file mode 100644 index d08092a1d..000000000 --- a/debian/patches/features/all/rt/snd-pcm-fix-snd_pcm_stream_lock-irqs_disabled-splats.patch +++ /dev/null @@ -1,70 +0,0 @@ -From: Mike Galbraith -Date: Wed, 18 Feb 2015 15:09:23 +0100 -Subject: snd/pcm: fix snd_pcm_stream_lock*() irqs_disabled() splats -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Locking functions previously using read_lock_irq()/read_lock_irqsave() were -changed to local_irq_disable/save(), leading to gripes. Use nort variants. - -|BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:915 -|in_atomic(): 0, irqs_disabled(): 1, pid: 5947, name: alsa-sink-ALC88 -|CPU: 5 PID: 5947 Comm: alsa-sink-ALC88 Not tainted 3.18.7-rt1 #9 -|Hardware name: MEDION MS-7848/MS-7848, BIOS M7848W08.404 11/06/2014 -| ffff880409316240 ffff88040866fa38 ffffffff815bdeb5 0000000000000002 -| 0000000000000000 ffff88040866fa58 ffffffff81073c86 ffffffffa03b2640 -| ffff88040239ec00 ffff88040866fa78 ffffffff815c3d34 ffffffffa03b2640 -|Call Trace: -| [] dump_stack+0x4f/0x9e -| [] __might_sleep+0xe6/0x150 -| [] __rt_spin_lock+0x24/0x50 -| [] rt_read_lock+0x34/0x40 -| [] snd_pcm_stream_lock+0x29/0x70 [snd_pcm] -| [] snd_pcm_playback_poll+0x5d/0x120 [snd_pcm] -| [] do_sys_poll+0x322/0x5b0 -| [] SyS_ppoll+0x1a8/0x1c0 -| [] system_call_fastpath+0x16/0x1b - -Signed-off-by: Mike Galbraith -Signed-off-by: Sebastian Andrzej Siewior ---- - sound/core/pcm_native.c | 8 ++++---- - 1 file changed, 4 insertions(+), 4 deletions(-) - ---- a/sound/core/pcm_native.c -+++ b/sound/core/pcm_native.c -@@ -148,7 +148,7 @@ EXPORT_SYMBOL_GPL(snd_pcm_stream_unlock) - void snd_pcm_stream_lock_irq(struct snd_pcm_substream *substream) - { - if (!substream->pcm->nonatomic) -- local_irq_disable(); -+ local_irq_disable_nort(); - snd_pcm_stream_lock(substream); - } - EXPORT_SYMBOL_GPL(snd_pcm_stream_lock_irq); -@@ -163,7 +163,7 @@ void snd_pcm_stream_unlock_irq(struct sn - { - snd_pcm_stream_unlock(substream); - if (!substream->pcm->nonatomic) -- local_irq_enable(); -+ local_irq_enable_nort(); - } - EXPORT_SYMBOL_GPL(snd_pcm_stream_unlock_irq); - -@@ -171,7 +171,7 @@ unsigned long _snd_pcm_stream_lock_irqsa - { - unsigned long flags = 0; - if (!substream->pcm->nonatomic) -- local_irq_save(flags); -+ local_irq_save_nort(flags); - snd_pcm_stream_lock(substream); - return flags; - } -@@ -189,7 +189,7 @@ void snd_pcm_stream_unlock_irqrestore(st - { - snd_pcm_stream_unlock(substream); - if (!substream->pcm->nonatomic) -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - } - EXPORT_SYMBOL_GPL(snd_pcm_stream_unlock_irqrestore); - diff --git a/debian/patches/features/all/rt/softirq-disable-softirq-stacks-for-rt.patch b/debian/patches/features/all/rt/softirq-disable-softirq-stacks-for-rt.patch index 2d9dfa141..51d400db7 100644 --- a/debian/patches/features/all/rt/softirq-disable-softirq-stacks-for-rt.patch +++ b/debian/patches/features/all/rt/softirq-disable-softirq-stacks-for-rt.patch @@ -1,7 +1,6 @@ Subject: softirq: Disable softirq stacks for RT From: Thomas Gleixner Date: Mon, 18 Jul 2011 13:59:17 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Disable extra stacks for softirqs. We want to preempt softirqs and having them on special IRQ-stack does not make this easier. diff --git a/debian/patches/features/all/rt/softirq-preempt-fix-3-re.patch b/debian/patches/features/all/rt/softirq-preempt-fix-3-re.patch index 0d35ab2e7..9bdb430b8 100644 --- a/debian/patches/features/all/rt/softirq-preempt-fix-3-re.patch +++ b/debian/patches/features/all/rt/softirq-preempt-fix-3-re.patch @@ -1,7 +1,6 @@ Subject: softirq: Check preemption after reenabling interrupts From: Thomas Gleixner Date: Sun, 13 Nov 2011 17:17:09 +0100 (CET) -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz raise_softirq_irqoff() disables interrupts and wakes the softirq daemon, but after reenabling interrupts there is no preemption check, @@ -136,7 +135,7 @@ Signed-off-by: Thomas Gleixner atomic_long_inc(&skb->dev->rx_dropped); kfree_skb(skb); -@@ -5270,12 +5273,14 @@ static void net_rps_action_and_irq_enabl +@@ -5267,12 +5270,14 @@ static void net_rps_action_and_irq_enabl sd->rps_ipi_list = NULL; local_irq_enable(); @@ -151,7 +150,7 @@ Signed-off-by: Thomas Gleixner } static bool sd_has_rps_ipi_waiting(struct softnet_data *sd) -@@ -5353,6 +5358,7 @@ void __napi_schedule(struct napi_struct +@@ -5350,6 +5355,7 @@ void __napi_schedule(struct napi_struct local_irq_save(flags); ____napi_schedule(this_cpu_ptr(&softnet_data), n); local_irq_restore(flags); @@ -159,7 +158,7 @@ Signed-off-by: Thomas Gleixner } EXPORT_SYMBOL(__napi_schedule); -@@ -8677,6 +8683,7 @@ static int dev_cpu_dead(unsigned int old +@@ -8674,6 +8680,7 @@ static int dev_cpu_dead(unsigned int old raise_softirq_irqoff(NET_TX_SOFTIRQ); local_irq_enable(); diff --git a/debian/patches/features/all/rt/softirq-split-locks.patch b/debian/patches/features/all/rt/softirq-split-locks.patch index a79c8003c..60f00dd63 100644 --- a/debian/patches/features/all/rt/softirq-split-locks.patch +++ b/debian/patches/features/all/rt/softirq-split-locks.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Thu, 04 Oct 2012 14:20:47 +0100 Subject: softirq: Split softirq locks -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The 3.x RT series removed the split softirq implementation in favour of pushing softirq processing into the context of the thread which diff --git a/debian/patches/features/all/rt/softirq-split-timer-softirqs-out-of-ksoftirqd.patch b/debian/patches/features/all/rt/softirq-split-timer-softirqs-out-of-ksoftirqd.patch index 79f36ba99..e29f7a436 100644 --- a/debian/patches/features/all/rt/softirq-split-timer-softirqs-out-of-ksoftirqd.patch +++ b/debian/patches/features/all/rt/softirq-split-timer-softirqs-out-of-ksoftirqd.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 20 Jan 2016 16:34:17 +0100 Subject: softirq: split timer softirqs out of ksoftirqd -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The softirqd runs in -RT with SCHED_FIFO (prio 1) and deals mostly with timer wakeup which can not happen in hardirq context. The prio has been diff --git a/debian/patches/features/all/rt/softirq-wake-the-timer-softirq-if-needed.patch b/debian/patches/features/all/rt/softirq-wake-the-timer-softirq-if-needed.patch index 0532b9484..7712e007e 100644 --- a/debian/patches/features/all/rt/softirq-wake-the-timer-softirq-if-needed.patch +++ b/debian/patches/features/all/rt/softirq-wake-the-timer-softirq-if-needed.patch @@ -1,7 +1,6 @@ From: Mike Galbraith Date: Fri, 20 Jan 2017 18:10:20 +0100 Subject: [PATCH] softirq: wake the timer softirq if needed -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The irq-exit path only checks the "normal"-softirq thread if it is running and ignores the state of the "timer"-softirq thread. It is possible diff --git a/debian/patches/features/all/rt/sparc64-use-generic-rwsem-spinlocks-rt.patch b/debian/patches/features/all/rt/sparc64-use-generic-rwsem-spinlocks-rt.patch deleted file mode 100644 index edfd49036..000000000 --- a/debian/patches/features/all/rt/sparc64-use-generic-rwsem-spinlocks-rt.patch +++ /dev/null @@ -1,28 +0,0 @@ -From: Allen Pais -Date: Fri, 13 Dec 2013 09:44:41 +0530 -Subject: sparc64: use generic rwsem spinlocks rt -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Signed-off-by: Allen Pais -Signed-off-by: Sebastian Andrzej Siewior ---- - arch/sparc/Kconfig | 6 ++---- - 1 file changed, 2 insertions(+), 4 deletions(-) - ---- a/arch/sparc/Kconfig -+++ b/arch/sparc/Kconfig -@@ -206,12 +206,10 @@ config NR_CPUS - source kernel/Kconfig.hz - - config RWSEM_GENERIC_SPINLOCK -- bool -- default y if SPARC32 -+ def_bool PREEMPT_RT_FULL - - config RWSEM_XCHGADD_ALGORITHM -- bool -- default y if SPARC64 -+ def_bool !RWSEM_GENERIC_SPINLOCK && !PREEMPT_RT_FULL - - config GENERIC_HWEIGHT - bool diff --git a/debian/patches/features/all/rt/spinlock-types-separate-raw.patch b/debian/patches/features/all/rt/spinlock-types-separate-raw.patch index 94a8b1f6d..e2291eac0 100644 --- a/debian/patches/features/all/rt/spinlock-types-separate-raw.patch +++ b/debian/patches/features/all/rt/spinlock-types-separate-raw.patch @@ -1,7 +1,6 @@ Subject: spinlock: Split the lock types header From: Thomas Gleixner Date: Wed, 29 Jun 2011 19:34:01 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Split raw_spinlock into its own file and the remaining spinlock_t into its own non-RT header. The non-RT header will be replaced later by sleeping diff --git a/debian/patches/features/all/rt/squashfs-make-use-of-local-lock-in-multi_cpu-decompr.patch b/debian/patches/features/all/rt/squashfs-make-use-of-local-lock-in-multi_cpu-decompr.patch index fa8b780d7..9265989bb 100644 --- a/debian/patches/features/all/rt/squashfs-make-use-of-local-lock-in-multi_cpu-decompr.patch +++ b/debian/patches/features/all/rt/squashfs-make-use-of-local-lock-in-multi_cpu-decompr.patch @@ -2,7 +2,6 @@ From: Julia Cartwright Date: Mon, 7 May 2018 08:58:57 -0500 Subject: [PATCH] squashfs: make use of local lock in multi_cpu decompressor -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Currently, the squashfs multi_cpu decompressor makes use of get_cpu_ptr()/put_cpu_ptr(), which unconditionally disable preemption diff --git a/debian/patches/features/all/rt/srcu-Prohibit-call_srcu-use-under-raw-spinlocks.patch b/debian/patches/features/all/rt/srcu-Prohibit-call_srcu-use-under-raw-spinlocks.patch deleted file mode 100644 index a2b7e1288..000000000 --- a/debian/patches/features/all/rt/srcu-Prohibit-call_srcu-use-under-raw-spinlocks.patch +++ /dev/null @@ -1,403 +0,0 @@ -From: "Paul E. McKenney" -Date: Tue, 10 Oct 2017 13:52:30 -0700 -Subject: srcu: Prohibit call_srcu() use under raw spinlocks -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Upstream commit 08265b8f1a139c1cff052b35ab7cf929528f88bb - -Invoking queue_delayed_work() while holding a raw spinlock is forbidden -in -rt kernels, which is exactly what __call_srcu() does, indirectly via -srcu_funnel_gp_start(). This commit therefore downgrades Tree SRCU's -locking from raw to non-raw spinlocks, which works because call_srcu() -is not ever called while holding a raw spinlock. - -Reported-by: Sebastian Andrzej Siewior -Signed-off-by: Paul E. McKenney ---- - include/linux/srcutree.h | 8 +-- - kernel/rcu/srcutree.c | 109 +++++++++++++++++++++++++++++------------------ - 2 files changed, 72 insertions(+), 45 deletions(-) - ---- a/include/linux/srcutree.h -+++ b/include/linux/srcutree.h -@@ -40,7 +40,7 @@ struct srcu_data { - unsigned long srcu_unlock_count[2]; /* Unlocks per CPU. */ - - /* Update-side state. */ -- raw_spinlock_t __private lock ____cacheline_internodealigned_in_smp; -+ spinlock_t __private lock ____cacheline_internodealigned_in_smp; - struct rcu_segcblist srcu_cblist; /* List of callbacks.*/ - unsigned long srcu_gp_seq_needed; /* Furthest future GP needed. */ - unsigned long srcu_gp_seq_needed_exp; /* Furthest future exp GP. */ -@@ -58,7 +58,7 @@ struct srcu_data { - * Node in SRCU combining tree, similar in function to rcu_data. - */ - struct srcu_node { -- raw_spinlock_t __private lock; -+ spinlock_t __private lock; - unsigned long srcu_have_cbs[4]; /* GP seq for children */ - /* having CBs, but only */ - /* is > ->srcu_gq_seq. */ -@@ -78,7 +78,7 @@ struct srcu_struct { - struct srcu_node *level[RCU_NUM_LVLS + 1]; - /* First node at each level. */ - struct mutex srcu_cb_mutex; /* Serialize CB preparation. */ -- raw_spinlock_t __private lock; /* Protect counters */ -+ spinlock_t __private lock; /* Protect counters */ - struct mutex srcu_gp_mutex; /* Serialize GP work. */ - unsigned int srcu_idx; /* Current rdr array element. */ - unsigned long srcu_gp_seq; /* Grace-period seq #. */ -@@ -107,7 +107,7 @@ struct srcu_struct { - #define __SRCU_STRUCT_INIT(name, pcpu_name) \ - { \ - .sda = &pcpu_name, \ -- .lock = __RAW_SPIN_LOCK_UNLOCKED(name.lock), \ -+ .lock = __SPIN_LOCK_UNLOCKED(name.lock), \ - .srcu_gp_seq_needed = 0 - 1, \ - __SRCU_DEP_MAP_INIT(name) \ - } ---- a/kernel/rcu/srcutree.c -+++ b/kernel/rcu/srcutree.c -@@ -54,6 +54,33 @@ static void srcu_invoke_callbacks(struct - static void srcu_reschedule(struct srcu_struct *sp, unsigned long delay); - static void process_srcu(struct work_struct *work); - -+/* Wrappers for lock acquisition and release, see raw_spin_lock_rcu_node(). */ -+#define spin_lock_rcu_node(p) \ -+do { \ -+ spin_lock(&ACCESS_PRIVATE(p, lock)); \ -+ smp_mb__after_unlock_lock(); \ -+} while (0) -+ -+#define spin_unlock_rcu_node(p) spin_unlock(&ACCESS_PRIVATE(p, lock)) -+ -+#define spin_lock_irq_rcu_node(p) \ -+do { \ -+ spin_lock_irq(&ACCESS_PRIVATE(p, lock)); \ -+ smp_mb__after_unlock_lock(); \ -+} while (0) -+ -+#define spin_unlock_irq_rcu_node(p) \ -+ spin_unlock_irq(&ACCESS_PRIVATE(p, lock)) -+ -+#define spin_lock_irqsave_rcu_node(p, flags) \ -+do { \ -+ spin_lock_irqsave(&ACCESS_PRIVATE(p, lock), flags); \ -+ smp_mb__after_unlock_lock(); \ -+} while (0) -+ -+#define spin_unlock_irqrestore_rcu_node(p, flags) \ -+ spin_unlock_irqrestore(&ACCESS_PRIVATE(p, lock), flags) \ -+ - /* - * Initialize SRCU combining tree. Note that statically allocated - * srcu_struct structures might already have srcu_read_lock() and -@@ -78,7 +105,7 @@ static void init_srcu_struct_nodes(struc - - /* Each pass through this loop initializes one srcu_node structure. */ - rcu_for_each_node_breadth_first(sp, snp) { -- raw_spin_lock_init(&ACCESS_PRIVATE(snp, lock)); -+ spin_lock_init(&ACCESS_PRIVATE(snp, lock)); - WARN_ON_ONCE(ARRAY_SIZE(snp->srcu_have_cbs) != - ARRAY_SIZE(snp->srcu_data_have_cbs)); - for (i = 0; i < ARRAY_SIZE(snp->srcu_have_cbs); i++) { -@@ -112,7 +139,7 @@ static void init_srcu_struct_nodes(struc - snp_first = sp->level[level]; - for_each_possible_cpu(cpu) { - sdp = per_cpu_ptr(sp->sda, cpu); -- raw_spin_lock_init(&ACCESS_PRIVATE(sdp, lock)); -+ spin_lock_init(&ACCESS_PRIVATE(sdp, lock)); - rcu_segcblist_init(&sdp->srcu_cblist); - sdp->srcu_cblist_invoking = false; - sdp->srcu_gp_seq_needed = sp->srcu_gp_seq; -@@ -171,7 +198,7 @@ int __init_srcu_struct(struct srcu_struc - /* Don't re-initialize a lock while it is held. */ - debug_check_no_locks_freed((void *)sp, sizeof(*sp)); - lockdep_init_map(&sp->dep_map, name, key, 0); -- raw_spin_lock_init(&ACCESS_PRIVATE(sp, lock)); -+ spin_lock_init(&ACCESS_PRIVATE(sp, lock)); - return init_srcu_struct_fields(sp, false); - } - EXPORT_SYMBOL_GPL(__init_srcu_struct); -@@ -188,7 +215,7 @@ EXPORT_SYMBOL_GPL(__init_srcu_struct); - */ - int init_srcu_struct(struct srcu_struct *sp) - { -- raw_spin_lock_init(&ACCESS_PRIVATE(sp, lock)); -+ spin_lock_init(&ACCESS_PRIVATE(sp, lock)); - return init_srcu_struct_fields(sp, false); - } - EXPORT_SYMBOL_GPL(init_srcu_struct); -@@ -211,13 +238,13 @@ static void check_init_srcu_struct(struc - /* The smp_load_acquire() pairs with the smp_store_release(). */ - if (!rcu_seq_state(smp_load_acquire(&sp->srcu_gp_seq_needed))) /*^^^*/ - return; /* Already initialized. */ -- raw_spin_lock_irqsave_rcu_node(sp, flags); -+ spin_lock_irqsave_rcu_node(sp, flags); - if (!rcu_seq_state(sp->srcu_gp_seq_needed)) { -- raw_spin_unlock_irqrestore_rcu_node(sp, flags); -+ spin_unlock_irqrestore_rcu_node(sp, flags); - return; - } - init_srcu_struct_fields(sp, true); -- raw_spin_unlock_irqrestore_rcu_node(sp, flags); -+ spin_unlock_irqrestore_rcu_node(sp, flags); - } - - /* -@@ -499,7 +526,7 @@ static void srcu_gp_end(struct srcu_stru - mutex_lock(&sp->srcu_cb_mutex); - - /* End the current grace period. */ -- raw_spin_lock_irq_rcu_node(sp); -+ spin_lock_irq_rcu_node(sp); - idx = rcu_seq_state(sp->srcu_gp_seq); - WARN_ON_ONCE(idx != SRCU_STATE_SCAN2); - cbdelay = srcu_get_delay(sp); -@@ -508,7 +535,7 @@ static void srcu_gp_end(struct srcu_stru - gpseq = rcu_seq_current(&sp->srcu_gp_seq); - if (ULONG_CMP_LT(sp->srcu_gp_seq_needed_exp, gpseq)) - sp->srcu_gp_seq_needed_exp = gpseq; -- raw_spin_unlock_irq_rcu_node(sp); -+ spin_unlock_irq_rcu_node(sp); - mutex_unlock(&sp->srcu_gp_mutex); - /* A new grace period can start at this point. But only one. */ - -@@ -516,7 +543,7 @@ static void srcu_gp_end(struct srcu_stru - idx = rcu_seq_ctr(gpseq) % ARRAY_SIZE(snp->srcu_have_cbs); - idxnext = (idx + 1) % ARRAY_SIZE(snp->srcu_have_cbs); - rcu_for_each_node_breadth_first(sp, snp) { -- raw_spin_lock_irq_rcu_node(snp); -+ spin_lock_irq_rcu_node(snp); - cbs = false; - if (snp >= sp->level[rcu_num_lvls - 1]) - cbs = snp->srcu_have_cbs[idx] == gpseq; -@@ -526,7 +553,7 @@ static void srcu_gp_end(struct srcu_stru - snp->srcu_gp_seq_needed_exp = gpseq; - mask = snp->srcu_data_have_cbs[idx]; - snp->srcu_data_have_cbs[idx] = 0; -- raw_spin_unlock_irq_rcu_node(snp); -+ spin_unlock_irq_rcu_node(snp); - if (cbs) - srcu_schedule_cbs_snp(sp, snp, mask, cbdelay); - -@@ -534,11 +561,11 @@ static void srcu_gp_end(struct srcu_stru - if (!(gpseq & counter_wrap_check)) - for (cpu = snp->grplo; cpu <= snp->grphi; cpu++) { - sdp = per_cpu_ptr(sp->sda, cpu); -- raw_spin_lock_irqsave_rcu_node(sdp, flags); -+ spin_lock_irqsave_rcu_node(sdp, flags); - if (ULONG_CMP_GE(gpseq, - sdp->srcu_gp_seq_needed + 100)) - sdp->srcu_gp_seq_needed = gpseq; -- raw_spin_unlock_irqrestore_rcu_node(sdp, flags); -+ spin_unlock_irqrestore_rcu_node(sdp, flags); - } - } - -@@ -546,17 +573,17 @@ static void srcu_gp_end(struct srcu_stru - mutex_unlock(&sp->srcu_cb_mutex); - - /* Start a new grace period if needed. */ -- raw_spin_lock_irq_rcu_node(sp); -+ spin_lock_irq_rcu_node(sp); - gpseq = rcu_seq_current(&sp->srcu_gp_seq); - if (!rcu_seq_state(gpseq) && - ULONG_CMP_LT(gpseq, sp->srcu_gp_seq_needed)) { - srcu_gp_start(sp); -- raw_spin_unlock_irq_rcu_node(sp); -+ spin_unlock_irq_rcu_node(sp); - /* Throttle expedited grace periods: Should be rare! */ - srcu_reschedule(sp, rcu_seq_ctr(gpseq) & 0x3ff - ? 0 : SRCU_INTERVAL); - } else { -- raw_spin_unlock_irq_rcu_node(sp); -+ spin_unlock_irq_rcu_node(sp); - } - } - -@@ -576,18 +603,18 @@ static void srcu_funnel_exp_start(struct - if (rcu_seq_done(&sp->srcu_gp_seq, s) || - ULONG_CMP_GE(READ_ONCE(snp->srcu_gp_seq_needed_exp), s)) - return; -- raw_spin_lock_irqsave_rcu_node(snp, flags); -+ spin_lock_irqsave_rcu_node(snp, flags); - if (ULONG_CMP_GE(snp->srcu_gp_seq_needed_exp, s)) { -- raw_spin_unlock_irqrestore_rcu_node(snp, flags); -+ spin_unlock_irqrestore_rcu_node(snp, flags); - return; - } - WRITE_ONCE(snp->srcu_gp_seq_needed_exp, s); -- raw_spin_unlock_irqrestore_rcu_node(snp, flags); -+ spin_unlock_irqrestore_rcu_node(snp, flags); - } -- raw_spin_lock_irqsave_rcu_node(sp, flags); -+ spin_lock_irqsave_rcu_node(sp, flags); - if (!ULONG_CMP_LT(sp->srcu_gp_seq_needed_exp, s)) - sp->srcu_gp_seq_needed_exp = s; -- raw_spin_unlock_irqrestore_rcu_node(sp, flags); -+ spin_unlock_irqrestore_rcu_node(sp, flags); - } - - /* -@@ -609,12 +636,12 @@ static void srcu_funnel_gp_start(struct - for (; snp != NULL; snp = snp->srcu_parent) { - if (rcu_seq_done(&sp->srcu_gp_seq, s) && snp != sdp->mynode) - return; /* GP already done and CBs recorded. */ -- raw_spin_lock_irqsave_rcu_node(snp, flags); -+ spin_lock_irqsave_rcu_node(snp, flags); - if (ULONG_CMP_GE(snp->srcu_have_cbs[idx], s)) { - snp_seq = snp->srcu_have_cbs[idx]; - if (snp == sdp->mynode && snp_seq == s) - snp->srcu_data_have_cbs[idx] |= sdp->grpmask; -- raw_spin_unlock_irqrestore_rcu_node(snp, flags); -+ spin_unlock_irqrestore_rcu_node(snp, flags); - if (snp == sdp->mynode && snp_seq != s) { - srcu_schedule_cbs_sdp(sdp, do_norm - ? SRCU_INTERVAL -@@ -630,11 +657,11 @@ static void srcu_funnel_gp_start(struct - snp->srcu_data_have_cbs[idx] |= sdp->grpmask; - if (!do_norm && ULONG_CMP_LT(snp->srcu_gp_seq_needed_exp, s)) - snp->srcu_gp_seq_needed_exp = s; -- raw_spin_unlock_irqrestore_rcu_node(snp, flags); -+ spin_unlock_irqrestore_rcu_node(snp, flags); - } - - /* Top of tree, must ensure the grace period will be started. */ -- raw_spin_lock_irqsave_rcu_node(sp, flags); -+ spin_lock_irqsave_rcu_node(sp, flags); - if (ULONG_CMP_LT(sp->srcu_gp_seq_needed, s)) { - /* - * Record need for grace period s. Pair with load -@@ -653,7 +680,7 @@ static void srcu_funnel_gp_start(struct - queue_delayed_work(system_power_efficient_wq, &sp->work, - srcu_get_delay(sp)); - } -- raw_spin_unlock_irqrestore_rcu_node(sp, flags); -+ spin_unlock_irqrestore_rcu_node(sp, flags); - } - - /* -@@ -816,7 +843,7 @@ void __call_srcu(struct srcu_struct *sp, - rhp->func = func; - local_irq_save(flags); - sdp = this_cpu_ptr(sp->sda); -- raw_spin_lock_rcu_node(sdp); -+ spin_lock_rcu_node(sdp); - rcu_segcblist_enqueue(&sdp->srcu_cblist, rhp, false); - rcu_segcblist_advance(&sdp->srcu_cblist, - rcu_seq_current(&sp->srcu_gp_seq)); -@@ -830,7 +857,7 @@ void __call_srcu(struct srcu_struct *sp, - sdp->srcu_gp_seq_needed_exp = s; - needexp = true; - } -- raw_spin_unlock_irqrestore_rcu_node(sdp, flags); -+ spin_unlock_irqrestore_rcu_node(sdp, flags); - if (needgp) - srcu_funnel_gp_start(sp, sdp, s, do_norm); - else if (needexp) -@@ -886,7 +913,7 @@ static void __synchronize_srcu(struct sr - - /* - * Make sure that later code is ordered after the SRCU grace -- * period. This pairs with the raw_spin_lock_irq_rcu_node() -+ * period. This pairs with the spin_lock_irq_rcu_node() - * in srcu_invoke_callbacks(). Unlike Tree RCU, this is needed - * because the current CPU might have been totally uninvolved with - * (and thus unordered against) that grace period. -@@ -1010,7 +1037,7 @@ void srcu_barrier(struct srcu_struct *sp - */ - for_each_possible_cpu(cpu) { - sdp = per_cpu_ptr(sp->sda, cpu); -- raw_spin_lock_irq_rcu_node(sdp); -+ spin_lock_irq_rcu_node(sdp); - atomic_inc(&sp->srcu_barrier_cpu_cnt); - sdp->srcu_barrier_head.func = srcu_barrier_cb; - debug_rcu_head_queue(&sdp->srcu_barrier_head); -@@ -1019,7 +1046,7 @@ void srcu_barrier(struct srcu_struct *sp - debug_rcu_head_unqueue(&sdp->srcu_barrier_head); - atomic_dec(&sp->srcu_barrier_cpu_cnt); - } -- raw_spin_unlock_irq_rcu_node(sdp); -+ spin_unlock_irq_rcu_node(sdp); - } - - /* Remove the initial count, at which point reaching zero can happen. */ -@@ -1068,17 +1095,17 @@ static void srcu_advance_state(struct sr - */ - idx = rcu_seq_state(smp_load_acquire(&sp->srcu_gp_seq)); /* ^^^ */ - if (idx == SRCU_STATE_IDLE) { -- raw_spin_lock_irq_rcu_node(sp); -+ spin_lock_irq_rcu_node(sp); - if (ULONG_CMP_GE(sp->srcu_gp_seq, sp->srcu_gp_seq_needed)) { - WARN_ON_ONCE(rcu_seq_state(sp->srcu_gp_seq)); -- raw_spin_unlock_irq_rcu_node(sp); -+ spin_unlock_irq_rcu_node(sp); - mutex_unlock(&sp->srcu_gp_mutex); - return; - } - idx = rcu_seq_state(READ_ONCE(sp->srcu_gp_seq)); - if (idx == SRCU_STATE_IDLE) - srcu_gp_start(sp); -- raw_spin_unlock_irq_rcu_node(sp); -+ spin_unlock_irq_rcu_node(sp); - if (idx != SRCU_STATE_IDLE) { - mutex_unlock(&sp->srcu_gp_mutex); - return; /* Someone else started the grace period. */ -@@ -1127,19 +1154,19 @@ static void srcu_invoke_callbacks(struct - sdp = container_of(work, struct srcu_data, work.work); - sp = sdp->sp; - rcu_cblist_init(&ready_cbs); -- raw_spin_lock_irq_rcu_node(sdp); -+ spin_lock_irq_rcu_node(sdp); - rcu_segcblist_advance(&sdp->srcu_cblist, - rcu_seq_current(&sp->srcu_gp_seq)); - if (sdp->srcu_cblist_invoking || - !rcu_segcblist_ready_cbs(&sdp->srcu_cblist)) { -- raw_spin_unlock_irq_rcu_node(sdp); -+ spin_unlock_irq_rcu_node(sdp); - return; /* Someone else on the job or nothing to do. */ - } - - /* We are on the job! Extract and invoke ready callbacks. */ - sdp->srcu_cblist_invoking = true; - rcu_segcblist_extract_done_cbs(&sdp->srcu_cblist, &ready_cbs); -- raw_spin_unlock_irq_rcu_node(sdp); -+ spin_unlock_irq_rcu_node(sdp); - rhp = rcu_cblist_dequeue(&ready_cbs); - for (; rhp != NULL; rhp = rcu_cblist_dequeue(&ready_cbs)) { - debug_rcu_head_unqueue(rhp); -@@ -1152,13 +1179,13 @@ static void srcu_invoke_callbacks(struct - * Update counts, accelerate new callbacks, and if needed, - * schedule another round of callback invocation. - */ -- raw_spin_lock_irq_rcu_node(sdp); -+ spin_lock_irq_rcu_node(sdp); - rcu_segcblist_insert_count(&sdp->srcu_cblist, &ready_cbs); - (void)rcu_segcblist_accelerate(&sdp->srcu_cblist, - rcu_seq_snap(&sp->srcu_gp_seq)); - sdp->srcu_cblist_invoking = false; - more = rcu_segcblist_ready_cbs(&sdp->srcu_cblist); -- raw_spin_unlock_irq_rcu_node(sdp); -+ spin_unlock_irq_rcu_node(sdp); - if (more) - srcu_schedule_cbs_sdp(sdp, 0); - } -@@ -1171,7 +1198,7 @@ static void srcu_reschedule(struct srcu_ - { - bool pushgp = true; - -- raw_spin_lock_irq_rcu_node(sp); -+ spin_lock_irq_rcu_node(sp); - if (ULONG_CMP_GE(sp->srcu_gp_seq, sp->srcu_gp_seq_needed)) { - if (!WARN_ON_ONCE(rcu_seq_state(sp->srcu_gp_seq))) { - /* All requests fulfilled, time to go idle. */ -@@ -1181,7 +1208,7 @@ static void srcu_reschedule(struct srcu_ - /* Outstanding request and no GP. Start one. */ - srcu_gp_start(sp); - } -- raw_spin_unlock_irq_rcu_node(sp); -+ spin_unlock_irq_rcu_node(sp); - - if (pushgp) - queue_delayed_work(system_power_efficient_wq, &sp->work, delay); diff --git a/debian/patches/features/all/rt/srcu-replace-local_irqsave-with-a-locallock.patch b/debian/patches/features/all/rt/srcu-replace-local_irqsave-with-a-locallock.patch index a05229313..086c46783 100644 --- a/debian/patches/features/all/rt/srcu-replace-local_irqsave-with-a-locallock.patch +++ b/debian/patches/features/all/rt/srcu-replace-local_irqsave-with-a-locallock.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 12 Oct 2017 18:37:12 +0200 Subject: [PATCH] srcu: replace local_irqsave() with a locallock -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz There are two instances which disable interrupts in order to become a stable this_cpu_ptr() pointer. The restore part is coupled with diff --git a/debian/patches/features/all/rt/srcu-use-cpu_online-instead-custom-check.patch b/debian/patches/features/all/rt/srcu-use-cpu_online-instead-custom-check.patch index 073bc485f..76004fd3b 100644 --- a/debian/patches/features/all/rt/srcu-use-cpu_online-instead-custom-check.patch +++ b/debian/patches/features/all/rt/srcu-use-cpu_online-instead-custom-check.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 13 Sep 2017 14:43:41 +0200 Subject: [PATCH] srcu: use cpu_online() instead custom check -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The current check via srcu_online is slightly racy because after looking at srcu_online there could be an interrupt that interrupted us long diff --git a/debian/patches/features/all/rt/stop-machine-raw-lock.patch b/debian/patches/features/all/rt/stop-machine-raw-lock.patch index bbb998655..0c2f153d3 100644 --- a/debian/patches/features/all/rt/stop-machine-raw-lock.patch +++ b/debian/patches/features/all/rt/stop-machine-raw-lock.patch @@ -1,7 +1,6 @@ Subject: stop_machine: Use raw spinlocks From: Thomas Gleixner Date: Wed, 29 Jun 2011 11:01:51 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz upstream commit de5b55c1d4e30740009864eb35ce4ed856aac01d diff --git a/debian/patches/features/all/rt/stop_machine-convert-stop_machine_run-to-PREEMPT_RT.patch b/debian/patches/features/all/rt/stop_machine-convert-stop_machine_run-to-PREEMPT_RT.patch deleted file mode 100644 index 96e1aa3a1..000000000 --- a/debian/patches/features/all/rt/stop_machine-convert-stop_machine_run-to-PREEMPT_RT.patch +++ /dev/null @@ -1,35 +0,0 @@ -From: Ingo Molnar -Date: Fri, 3 Jul 2009 08:30:27 -0500 -Subject: stop_machine: convert stop_machine_run() to PREEMPT_RT -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Instead of playing with non-preemption, introduce explicit -startup serialization. This is more robust and cleaner as -well. - -Signed-off-by: Ingo Molnar -Signed-off-by: Thomas Gleixner -[bigeasy: XXX: stopper_lock -> stop_cpus_lock] ---- - kernel/stop_machine.c | 10 ++++++++++ - 1 file changed, 10 insertions(+) - ---- a/kernel/stop_machine.c -+++ b/kernel/stop_machine.c -@@ -475,6 +475,16 @@ static void cpu_stopper_thread(unsigned - struct cpu_stop_done *done = work->done; - int ret; - -+ /* -+ * Wait until the stopper finished scheduling on all -+ * cpus -+ */ -+ lg_global_lock(&stop_cpus_lock); -+ /* -+ * Let other cpu threads continue as well -+ */ -+ lg_global_unlock(&stop_cpus_lock); -+ - /* cpu stop callbacks must not sleep, make in_atomic() == T */ - preempt_count_inc(); - ret = fn(arg); diff --git a/debian/patches/features/all/rt/sunrpc-make-svc_xprt_do_enqueue-use-get_cpu_light.patch b/debian/patches/features/all/rt/sunrpc-make-svc_xprt_do_enqueue-use-get_cpu_light.patch index 8662bd8ef..18c039b6b 100644 --- a/debian/patches/features/all/rt/sunrpc-make-svc_xprt_do_enqueue-use-get_cpu_light.patch +++ b/debian/patches/features/all/rt/sunrpc-make-svc_xprt_do_enqueue-use-get_cpu_light.patch @@ -1,7 +1,6 @@ From: Mike Galbraith Date: Wed, 18 Feb 2015 16:05:28 +0100 Subject: sunrpc: Make svc_xprt_do_enqueue() use get_cpu_light() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz |BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:915 |in_atomic(): 1, irqs_disabled(): 0, pid: 3194, name: rpc.nfsd diff --git a/debian/patches/features/all/rt/sysfs-realtime-entry.patch b/debian/patches/features/all/rt/sysfs-realtime-entry.patch index 6fa166c89..85c90149d 100644 --- a/debian/patches/features/all/rt/sysfs-realtime-entry.patch +++ b/debian/patches/features/all/rt/sysfs-realtime-entry.patch @@ -1,7 +1,6 @@ Subject: sysfs: Add /sys/kernel/realtime entry From: Clark Williams Date: Sat Jul 30 21:55:53 2011 -0500 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Add a /sys/kernel entry to indicate that the kernel is a realtime kernel. diff --git a/debian/patches/features/all/rt/take-write_seqcount_invalidate-into-__d_drop.patch b/debian/patches/features/all/rt/take-write_seqcount_invalidate-into-__d_drop.patch index 140480810..8640f74b2 100644 --- a/debian/patches/features/all/rt/take-write_seqcount_invalidate-into-__d_drop.patch +++ b/debian/patches/features/all/rt/take-write_seqcount_invalidate-into-__d_drop.patch @@ -1,7 +1,6 @@ From: Al Viro Date: Wed, 7 Mar 2018 00:49:10 -0500 Subject: [PATCH] take write_seqcount_invalidate() into __d_drop() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Upstream commit 0632a9ac7bc0a32f8251a53b3925775f0a7c4da6 diff --git a/debian/patches/features/all/rt/tasklet-rt-prevent-tasklets-from-going-into-infinite-spin-in-rt.patch b/debian/patches/features/all/rt/tasklet-rt-prevent-tasklets-from-going-into-infinite-spin-in-rt.patch index ab6ce7560..32817a480 100644 --- a/debian/patches/features/all/rt/tasklet-rt-prevent-tasklets-from-going-into-infinite-spin-in-rt.patch +++ b/debian/patches/features/all/rt/tasklet-rt-prevent-tasklets-from-going-into-infinite-spin-in-rt.patch @@ -1,7 +1,6 @@ Subject: tasklet: Prevent tasklets from going into infinite spin in RT From: Ingo Molnar Date: Tue Nov 29 20:18:22 2011 -0500 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz When CONFIG_PREEMPT_RT_FULL is enabled, tasklets run as threads, and spinlocks turn are mutexes. But this can cause issues with diff --git a/debian/patches/features/all/rt/thermal-Defer-thermal-wakups-to-threads.patch b/debian/patches/features/all/rt/thermal-Defer-thermal-wakups-to-threads.patch index 57c1fd654..72faa3db2 100644 --- a/debian/patches/features/all/rt/thermal-Defer-thermal-wakups-to-threads.patch +++ b/debian/patches/features/all/rt/thermal-Defer-thermal-wakups-to-threads.patch @@ -1,7 +1,6 @@ From: Daniel Wagner Date: Tue, 17 Feb 2015 09:37:44 +0100 Subject: thermal: Defer thermal wakups to threads -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz On RT the spin lock in pkg_temp_thermal_platfrom_thermal_notify will call schedule while we run in irq context. diff --git a/debian/patches/features/all/rt/time-hrtimer-avoid-schedule_work-with-interrupts-dis.patch b/debian/patches/features/all/rt/time-hrtimer-avoid-schedule_work-with-interrupts-dis.patch index b56c69993..e108d70f7 100644 --- a/debian/patches/features/all/rt/time-hrtimer-avoid-schedule_work-with-interrupts-dis.patch +++ b/debian/patches/features/all/rt/time-hrtimer-avoid-schedule_work-with-interrupts-dis.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Wed, 15 Nov 2017 17:29:51 +0100 Subject: [PATCH] time/hrtimer: avoid schedule_work() with interrupts disabled -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz The NOHZ code tries to schedule a workqueue with interrupts disabled. Since this does not work -RT I am switching it to swork instead. diff --git a/debian/patches/features/all/rt/timekeeping-split-jiffies-lock.patch b/debian/patches/features/all/rt/timekeeping-split-jiffies-lock.patch index 7c644f6be..5ca4f5f43 100644 --- a/debian/patches/features/all/rt/timekeeping-split-jiffies-lock.patch +++ b/debian/patches/features/all/rt/timekeeping-split-jiffies-lock.patch @@ -1,7 +1,6 @@ Subject: timekeeping: Split jiffies seqlock From: Thomas Gleixner Date: Thu, 14 Feb 2013 22:36:59 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Replace jiffies_lock seqlock with a simple seqcounter and a rawlock so it can be taken in atomic context on RT. diff --git a/debian/patches/features/all/rt/timer-delay-waking-softirqs-from-the-jiffy-tick.patch b/debian/patches/features/all/rt/timer-delay-waking-softirqs-from-the-jiffy-tick.patch index 2359b3dd2..d6d596e4c 100644 --- a/debian/patches/features/all/rt/timer-delay-waking-softirqs-from-the-jiffy-tick.patch +++ b/debian/patches/features/all/rt/timer-delay-waking-softirqs-from-the-jiffy-tick.patch @@ -1,7 +1,6 @@ From: Peter Zijlstra Date: Fri, 21 Aug 2009 11:56:45 +0200 Subject: timer: delay waking softirqs from the jiffy tick -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz People were complaining about broken balancing with the recent -rt series. diff --git a/debian/patches/features/all/rt/timer-fd-avoid-live-lock.patch b/debian/patches/features/all/rt/timer-fd-avoid-live-lock.patch index b739494b2..31a9b1b5e 100644 --- a/debian/patches/features/all/rt/timer-fd-avoid-live-lock.patch +++ b/debian/patches/features/all/rt/timer-fd-avoid-live-lock.patch @@ -1,7 +1,6 @@ Subject: timer-fd: Prevent live lock From: Thomas Gleixner Date: Wed, 25 Jan 2012 11:08:40 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz If hrtimer_try_to_cancel() requires a retry, then depending on the priority setting te retry loop might prevent timer callback completion diff --git a/debian/patches/features/all/rt/timerqueue-Document-return-values-of-timerqueue_add-.patch b/debian/patches/features/all/rt/timerqueue-Document-return-values-of-timerqueue_add-.patch deleted file mode 100644 index f52731c82..000000000 --- a/debian/patches/features/all/rt/timerqueue-Document-return-values-of-timerqueue_add-.patch +++ /dev/null @@ -1,40 +0,0 @@ -From: Thomas Gleixner -Date: Fri, 22 Dec 2017 15:51:15 +0100 -Subject: [PATCH 4/4] timerqueue: Document return values of - timerqueue_add/del() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The return values of timerqueue_add/del() are not documented in the kernel doc -comment. Add proper documentation. - -Signed-off-by: Thomas Gleixner -Cc: rt@linutronix.de -Signed-off-by: Sebastian Andrzej Siewior ---- - lib/timerqueue.c | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - ---- a/lib/timerqueue.c -+++ b/lib/timerqueue.c -@@ -33,8 +33,9 @@ - * @head: head of timerqueue - * @node: timer node to be added - * -- * Adds the timer node to the timerqueue, sorted by the -- * node's expires value. -+ * Adds the timer node to the timerqueue, sorted by the node's expires -+ * value. Returns true if the newly added timer is the first expiring timer in -+ * the queue. - */ - bool timerqueue_add(struct timerqueue_head *head, struct timerqueue_node *node) - { -@@ -70,7 +71,8 @@ EXPORT_SYMBOL_GPL(timerqueue_add); - * @head: head of timerqueue - * @node: timer node to be removed - * -- * Removes the timer node from the timerqueue. -+ * Removes the timer node from the timerqueue. Returns true if the queue is -+ * not empty after the remove. - */ - bool timerqueue_del(struct timerqueue_head *head, struct timerqueue_node *node) - { diff --git a/debian/patches/features/all/rt/timers-prepare-for-full-preemption.patch b/debian/patches/features/all/rt/timers-prepare-for-full-preemption.patch index 1beded364..bf325b85a 100644 --- a/debian/patches/features/all/rt/timers-prepare-for-full-preemption.patch +++ b/debian/patches/features/all/rt/timers-prepare-for-full-preemption.patch @@ -1,7 +1,6 @@ From: Ingo Molnar Date: Fri, 3 Jul 2009 08:29:34 -0500 Subject: timers: Prepare for full preemption -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz When softirqs can be preempted we need to make sure that cancelling the timer from the active thread can not deadlock vs. a running timer @@ -29,7 +28,7 @@ Signed-off-by: Thomas Gleixner # define del_timer_sync(t) del_timer(t) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -525,11 +525,14 @@ void resched_cpu(int cpu) +@@ -526,11 +526,14 @@ void resched_cpu(int cpu) */ int get_nohz_timer_target(void) { @@ -46,7 +45,7 @@ Signed-off-by: Thomas Gleixner rcu_read_lock(); for_each_domain(cpu, sd) { -@@ -548,6 +551,8 @@ int get_nohz_timer_target(void) +@@ -549,6 +552,8 @@ int get_nohz_timer_target(void) cpu = housekeeping_any_cpu(HK_FLAG_TIMER); unlock: rcu_read_unlock(); diff --git a/debian/patches/features/all/rt/tpm_tis-fix-stall-after-iowrite-s.patch b/debian/patches/features/all/rt/tpm_tis-fix-stall-after-iowrite-s.patch index e5f0a922a..012162724 100644 --- a/debian/patches/features/all/rt/tpm_tis-fix-stall-after-iowrite-s.patch +++ b/debian/patches/features/all/rt/tpm_tis-fix-stall-after-iowrite-s.patch @@ -1,7 +1,6 @@ From: Haris Okanovic Date: Tue, 15 Aug 2017 15:13:08 -0500 Subject: [PATCH] tpm_tis: fix stall after iowrite*()s -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz ioread8() operations to TPM MMIO addresses can stall the cpu when immediately following a sequence of iowrite*()'s to the same region. diff --git a/debian/patches/features/all/rt/tracing-Fix-display-of-hist-trigger-expressions-cont.patch b/debian/patches/features/all/rt/tracing-Fix-display-of-hist-trigger-expressions-cont.patch index 65ad9fb87..94711d2f4 100644 --- a/debian/patches/features/all/rt/tracing-Fix-display-of-hist-trigger-expressions-cont.patch +++ b/debian/patches/features/all/rt/tracing-Fix-display-of-hist-trigger-expressions-cont.patch @@ -2,7 +2,6 @@ From: Tom Zanussi Date: Wed, 28 Mar 2018 15:10:53 -0500 Subject: [PATCH] tracing: Fix display of hist trigger expressions containing timestamps -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz [ commit 0ae7961e75c3fe3383796323d5342cbda8f82536 ] diff --git a/debian/patches/features/all/rt/tracing-account-for-preempt-off-in-preempt_schedule.patch b/debian/patches/features/all/rt/tracing-account-for-preempt-off-in-preempt_schedule.patch deleted file mode 100644 index 64d99f240..000000000 --- a/debian/patches/features/all/rt/tracing-account-for-preempt-off-in-preempt_schedule.patch +++ /dev/null @@ -1,47 +0,0 @@ -From: Steven Rostedt -Date: Thu, 29 Sep 2011 12:24:30 -0500 -Subject: tracing: Account for preempt off in preempt_schedule() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -The preempt_schedule() uses the preempt_disable_notrace() version -because it can cause infinite recursion by the function tracer as -the function tracer uses preempt_enable_notrace() which may call -back into the preempt_schedule() code as the NEED_RESCHED is still -set and the PREEMPT_ACTIVE has not been set yet. - -See commit: d1f74e20b5b064a130cd0743a256c2d3cfe84010 that made this -change. - -The preemptoff and preemptirqsoff latency tracers require the first -and last preempt count modifiers to enable tracing. But this skips -the checks. Since we can not convert them back to the non notrace -version, we can use the idle() hooks for the latency tracers here. -That is, the start/stop_critical_timings() works well to manually -start and stop the latency tracer for preempt off timings. - -Signed-off-by: Steven Rostedt -Signed-off-by: Clark Williams -Signed-off-by: Thomas Gleixner ---- - kernel/sched/core.c | 9 +++++++++ - 1 file changed, 9 insertions(+) - ---- a/kernel/sched/core.c -+++ b/kernel/sched/core.c -@@ -3604,7 +3604,16 @@ asmlinkage __visible void __sched notrac - * an infinite recursion. - */ - prev_ctx = exception_enter(); -+ /* -+ * The add/subtract must not be traced by the function -+ * tracer. But we still want to account for the -+ * preempt off latency tracer. Since the _notrace versions -+ * of add/subtract skip the accounting for latency tracer -+ * we must force it manually. -+ */ -+ start_critical_timings(); - __schedule(true); -+ stop_critical_timings(); - exception_exit(prev_ctx); - - preempt_latency_stop(1); diff --git a/debian/patches/features/all/rt/tty-goldfish-Enable-earlycon-only-if-built-in.patch b/debian/patches/features/all/rt/tty-goldfish-Enable-earlycon-only-if-built-in.patch deleted file mode 100644 index 3d5da3e03..000000000 --- a/debian/patches/features/all/rt/tty-goldfish-Enable-earlycon-only-if-built-in.patch +++ /dev/null @@ -1,66 +0,0 @@ -From: Sebastian Andrzej Siewior -Date: Wed, 29 Nov 2017 16:32:20 +0100 -Subject: [PATCH] tty: goldfish: Enable 'earlycon' only if built-in -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Commit 3840ed9548f7 ("tty: goldfish: Implement support for kernel -'earlycon' parameter") breaks an allmodconfig config on x86: -| LD vmlinux.o -| MODPOST vmlinux.o -|drivers/tty/serial/earlycon.o: In function `parse_options': -|drivers/tty/serial/earlycon.c:97: undefined reference to `uart_parse_earlycon' -|Makefile:1005: recipe for target 'vmlinux' failed - -earlycon.c::parse_options() invokes uart_parse_earlycon() from serial_core.c -which is compiled=m because GOLDFISH_TTY itself (and most others) are =m. -To avoid that, I'm adding the _CONSOLE config option which is selected if the -GOLDFISH module itself is =y since it doesn't need the early bits for the =m -case (other drivers do the same dance). -The alternative would be to move uart_parse_earlycon() from -serial_core.c to earlycon.c (we don't have that many users of that -function). - -Fixes: 3840ed9548f7 ("tty: goldfish: Implement support for kernel - 'earlycon' parameter") -Signed-off-by: Sebastian Andrzej Siewior ---- - drivers/tty/Kconfig | 6 +++++- - drivers/tty/goldfish.c | 2 ++ - 2 files changed, 7 insertions(+), 1 deletion(-) - ---- a/drivers/tty/Kconfig -+++ b/drivers/tty/Kconfig -@@ -394,10 +394,14 @@ config GOLDFISH_TTY - depends on GOLDFISH - select SERIAL_CORE - select SERIAL_CORE_CONSOLE -- select SERIAL_EARLYCON - help - Console and system TTY driver for the Goldfish virtual platform. - -+config GOLDFISH_TTY_EARLY_CONSOLE -+ bool -+ default y if GOLDFISH_TTY=y -+ select SERIAL_EARLYCON -+ - config DA_TTY - bool "DA TTY" - depends on METAG_DA ---- a/drivers/tty/goldfish.c -+++ b/drivers/tty/goldfish.c -@@ -442,6 +442,7 @@ static int goldfish_tty_remove(struct pl - return 0; - } - -+#ifdef CONFIG_GOLDFISH_TTY_EARLY_CONSOLE - static void gf_early_console_putchar(struct uart_port *port, int ch) - { - __raw_writel(ch, port->membase); -@@ -465,6 +466,7 @@ static int __init gf_earlycon_setup(stru - } - - OF_EARLYCON_DECLARE(early_gf_tty, "google,goldfish-tty", gf_earlycon_setup); -+#endif - - static const struct of_device_id goldfish_tty_of_match[] = { - { .compatible = "google,goldfish-tty", }, diff --git a/debian/patches/features/all/rt/tty-serial-8250-don-t-take-the-trylock-during-oops.patch b/debian/patches/features/all/rt/tty-serial-8250-don-t-take-the-trylock-during-oops.patch index d08a2488e..6b5d7dea7 100644 --- a/debian/patches/features/all/rt/tty-serial-8250-don-t-take-the-trylock-during-oops.patch +++ b/debian/patches/features/all/rt/tty-serial-8250-don-t-take-the-trylock-during-oops.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Mon, 11 Apr 2016 16:55:02 +0200 Subject: [PATCH] tty: serial: 8250: don't take the trylock during oops -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz An oops with irqs off (panic() from irqsafe hrtimer like the watchdog timer) will lead to a lockdep warning on each invocation and as such @@ -15,7 +14,7 @@ Signed-off-by: Sebastian Andrzej Siewior --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c -@@ -3217,10 +3217,8 @@ void serial8250_console_write(struct uar +@@ -3218,10 +3218,8 @@ void serial8250_console_write(struct uar serial8250_rpm_get(up); diff --git a/debian/patches/features/all/rt/tty-serial-atmel-use-port-name-as-name-in-request_ir.patch b/debian/patches/features/all/rt/tty-serial-atmel-use-port-name-as-name-in-request_ir.patch deleted file mode 100644 index d989ad058..000000000 --- a/debian/patches/features/all/rt/tty-serial-atmel-use-port-name-as-name-in-request_ir.patch +++ /dev/null @@ -1,56 +0,0 @@ -From: Sebastian Andrzej Siewior -Date: Thu, 26 Apr 2018 16:42:24 +0200 -Subject: [PATCH] tty/serial: atmel: use port->name as name in request_irq() -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz - -I was puzzled while looking at /proc/interrupts and random things showed -up between reboots. This occurred more often but I realised it later. The -"correct" output should be: -|38: 11861 atmel-aic5 2 Level ttyS0 - -but I saw sometimes -|38: 6426 atmel-aic5 2 Level tty1 - -and accounted it wrongly as correct. This is use after free and the -former example randomly got the "old" pointer which pointed to the same -content. With SLAB_FREELIST_RANDOM and HARDENED I even got -|38: 7067 atmel-aic5 2 Level E=Started User Manager for UID 0 - -or other nonsense. -As it turns out the tty, pointer that is accessed in atmel_startup(), is -freed() before atmel_shutdown(). It seems to happen quite often that the -tty for ttyS0 is allocated and freed while ->shutdown is not invoked. I -don't do anything special - just a systemd boot :) - -It seems not to happen in v4.1.51 but it happens in v4.9 and v4.17-rc2 -so if it broke accidentally it was not recently. - -Use port->name as the IRQ name for request_irq(). This exists as long as -the driver is loaded so no use-after-free here. - -Cc: stable@vger.kernel.org -Signed-off-by: Sebastian Andrzej Siewior ---- - drivers/tty/serial/atmel_serial.c | 4 +--- - 1 file changed, 1 insertion(+), 3 deletions(-) - ---- a/drivers/tty/serial/atmel_serial.c -+++ b/drivers/tty/serial/atmel_serial.c -@@ -1757,7 +1757,6 @@ static int atmel_startup(struct uart_por - { - struct platform_device *pdev = to_platform_device(port->dev); - struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); -- struct tty_struct *tty = port->state->port.tty; - int retval; - - /* -@@ -1772,8 +1771,7 @@ static int atmel_startup(struct uart_por - * Allocate the IRQ - */ - retval = request_irq(port->irq, atmel_interrupt, -- IRQF_SHARED | IRQF_COND_SUSPEND, -- tty ? tty->name : "atmel_serial", port); -+ IRQF_SHARED | IRQF_COND_SUSPEND, port->name, port); - if (retval) { - dev_err(port->dev, "atmel_startup - Can't get irq\n"); - return retval; diff --git a/debian/patches/features/all/rt/upstream-net-rt-remove-preemption-disabling-in-netif_rx.patch b/debian/patches/features/all/rt/upstream-net-rt-remove-preemption-disabling-in-netif_rx.patch index a87883d99..a75f30b3f 100644 --- a/debian/patches/features/all/rt/upstream-net-rt-remove-preemption-disabling-in-netif_rx.patch +++ b/debian/patches/features/all/rt/upstream-net-rt-remove-preemption-disabling-in-netif_rx.patch @@ -1,7 +1,6 @@ Subject: net: Remove preemption disabling in netif_rx() From: Priyanka Jain Date: Thu, 17 May 2012 09:35:11 +0530 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz 1)enqueue_to_backlog() (called from netif_rx) should be bind to a particluar CPU. This can be achieved by diff --git a/debian/patches/features/all/rt/usb-do-not-disable-interrupts-in-giveback.patch b/debian/patches/features/all/rt/usb-do-not-disable-interrupts-in-giveback.patch index 60166521d..15cb8a65c 100644 --- a/debian/patches/features/all/rt/usb-do-not-disable-interrupts-in-giveback.patch +++ b/debian/patches/features/all/rt/usb-do-not-disable-interrupts-in-giveback.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Fri, 8 Nov 2013 17:34:54 +0100 Subject: usb: do no disable interrupts in giveback -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Since commit 94dfd7ed ("USB: HCD: support giveback of URB in tasklet context") the USB code disables interrupts before invoking the complete diff --git a/debian/patches/features/all/rt/usb-use-_nort-in-giveback.patch b/debian/patches/features/all/rt/usb-use-_nort-in-giveback.patch deleted file mode 100644 index 5750646d2..000000000 --- a/debian/patches/features/all/rt/usb-use-_nort-in-giveback.patch +++ /dev/null @@ -1,58 +0,0 @@ -From: Sebastian Andrzej Siewior -Date: Fri, 8 Nov 2013 17:34:54 +0100 -Subject: usb: Use _nort in giveback function -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Since commit 94dfd7ed ("USB: HCD: support giveback of URB in tasklet -context") I see - -|BUG: sleeping function called from invalid context at kernel/rtmutex.c:673 -|in_atomic(): 0, irqs_disabled(): 1, pid: 109, name: irq/11-uhci_hcd -|no locks held by irq/11-uhci_hcd/109. -|irq event stamp: 440 -|hardirqs last enabled at (439): [] _raw_spin_unlock_irqrestore+0x75/0x90 -|hardirqs last disabled at (440): [] __usb_hcd_giveback_urb+0x46/0xc0 -|softirqs last enabled at (0): [] copy_process.part.52+0x511/0x1510 -|softirqs last disabled at (0): [< (null)>] (null) -|CPU: 3 PID: 109 Comm: irq/11-uhci_hcd Not tainted 3.12.0-rt0-rc1+ #13 -|Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 -| 0000000000000000 ffff8800db9ffbe0 ffffffff8169f064 0000000000000000 -| ffff8800db9ffbf8 ffffffff810b2122 ffff88020f03e888 ffff8800db9ffc18 -| ffffffff816a6944 ffffffff810b5748 ffff88020f03c000 ffff8800db9ffc50 -|Call Trace: -| [] dump_stack+0x4e/0x8f -| [] __might_sleep+0x112/0x190 -| [] rt_spin_lock+0x24/0x60 -| [] hid_ctrl+0x3b/0x190 -| [] __usb_hcd_giveback_urb+0x4f/0xc0 -| [] usb_hcd_giveback_urb+0x3f/0x140 -| [] uhci_giveback_urb+0xaf/0x280 -| [] uhci_scan_schedule+0x47a/0xb10 -| [] uhci_irq+0xa6/0x1a0 -| [] usb_hcd_irq+0x28/0x40 -| [] irq_forced_thread_fn+0x23/0x70 -| [] irq_thread+0x10f/0x150 -| [] kthread+0xcd/0xe0 -| [] ret_from_fork+0x7c/0xb0 - -on -RT we run threaded so no need to disable interrupts. - -Signed-off-by: Sebastian Andrzej Siewior ---- - drivers/usb/core/hcd.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/drivers/usb/core/hcd.c -+++ b/drivers/usb/core/hcd.c -@@ -1775,9 +1775,9 @@ static void __usb_hcd_giveback_urb(struc - * and no one may trigger the above deadlock situation when - * running complete() in tasklet. - */ -- local_irq_save(flags); -+ local_irq_save_nort(flags); - urb->complete(urb); -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - - usb_anchor_resume_wakeups(anchor); - atomic_dec(&urb->use_count); diff --git a/debian/patches/features/all/rt/user-use-local-irq-nort.patch b/debian/patches/features/all/rt/user-use-local-irq-nort.patch deleted file mode 100644 index 3e8ab666b..000000000 --- a/debian/patches/features/all/rt/user-use-local-irq-nort.patch +++ /dev/null @@ -1,30 +0,0 @@ -From: Thomas Gleixner -Date: Tue, 21 Jul 2009 23:06:05 +0200 -Subject: core: Do not disable interrupts on RT in kernel/users.c -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz - -Use the local_irq_*_nort variants to reduce latencies in RT. The code -is serialized by the locks. No need to disable interrupts. - -Signed-off-by: Thomas Gleixner - ---- - kernel/user.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - ---- a/kernel/user.c -+++ b/kernel/user.c -@@ -162,11 +162,11 @@ void free_uid(struct user_struct *up) - if (!up) - return; - -- local_irq_save(flags); -+ local_irq_save_nort(flags); - if (atomic_dec_and_lock(&up->__count, &uidhash_lock)) - free_user(up, flags); - else -- local_irq_restore(flags); -+ local_irq_restore_nort(flags); - } - - struct user_struct *alloc_uid(kuid_t uid) diff --git a/debian/patches/features/all/rt/wait.h-include-atomic.h.patch b/debian/patches/features/all/rt/wait.h-include-atomic.h.patch index 8267de3f5..0a04f7859 100644 --- a/debian/patches/features/all/rt/wait.h-include-atomic.h.patch +++ b/debian/patches/features/all/rt/wait.h-include-atomic.h.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Mon, 28 Oct 2013 12:19:57 +0100 Subject: wait.h: include atomic.h -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz | CC init/main.o |In file included from include/linux/mmzone.h:9:0, diff --git a/debian/patches/features/all/rt/work-queue-work-around-irqsafe-timer-optimization.patch b/debian/patches/features/all/rt/work-queue-work-around-irqsafe-timer-optimization.patch index 338463ac1..44fffaf41 100644 --- a/debian/patches/features/all/rt/work-queue-work-around-irqsafe-timer-optimization.patch +++ b/debian/patches/features/all/rt/work-queue-work-around-irqsafe-timer-optimization.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Mon, 01 Jul 2013 11:02:42 +0200 Subject: workqueue: Prevent workqueue versus ata-piix livelock -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz An Intel i7 system regularly detected rcu_preempt stalls after the kernel was upgraded from 3.6-rt to 3.8-rt. When the stall happened, disk I/O was no diff --git a/debian/patches/features/all/rt/work-simple-Simple-work-queue-implemenation.patch b/debian/patches/features/all/rt/work-simple-Simple-work-queue-implemenation.patch index 0d226c08b..b73fc3929 100644 --- a/debian/patches/features/all/rt/work-simple-Simple-work-queue-implemenation.patch +++ b/debian/patches/features/all/rt/work-simple-Simple-work-queue-implemenation.patch @@ -1,7 +1,6 @@ From: Daniel Wagner Date: Fri, 11 Jul 2014 15:26:11 +0200 Subject: work-simple: Simple work queue implemenation -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Provides a framework for enqueuing callbacks from irq context PREEMPT_RT_FULL safe. The callbacks are executed in kthread context. diff --git a/debian/patches/features/all/rt/workqueue-distangle-from-rq-lock.patch b/debian/patches/features/all/rt/workqueue-distangle-from-rq-lock.patch index e02db091d..dbc0560f6 100644 --- a/debian/patches/features/all/rt/workqueue-distangle-from-rq-lock.patch +++ b/debian/patches/features/all/rt/workqueue-distangle-from-rq-lock.patch @@ -22,7 +22,6 @@ Cc: Jens Axboe Cc: Linus Torvalds Link: http://lkml.kernel.org/r/20110622174919.135236139@linutronix.de Signed-off-by: Thomas Gleixner -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz --- kernel/sched/core.c | 84 +++++++------------------------------------- @@ -32,7 +31,7 @@ Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -1726,10 +1726,6 @@ static inline void ttwu_activate(struct +@@ -1727,10 +1727,6 @@ static inline void ttwu_activate(struct { activate_task(rq, p, en_flags); p->on_rq = TASK_ON_RQ_QUEUED; @@ -43,7 +42,7 @@ Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4 } /* -@@ -2170,56 +2166,6 @@ try_to_wake_up(struct task_struct *p, un +@@ -2171,56 +2167,6 @@ try_to_wake_up(struct task_struct *p, un } /** @@ -100,7 +99,7 @@ Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4 * wake_up_process - Wake up a specific process * @p: The process to be woken up. * -@@ -3485,21 +3431,6 @@ static void __sched notrace __schedule(b +@@ -3486,21 +3432,6 @@ static void __sched notrace __schedule(b atomic_inc(&rq->nr_iowait); delayacct_blkio_start(); } @@ -122,7 +121,7 @@ Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4 } switch_count = &prev->nvcsw; } -@@ -3574,6 +3505,14 @@ static inline void sched_submit_work(str +@@ -3575,6 +3506,14 @@ static inline void sched_submit_work(str { if (!tsk->state || tsk_is_pi_blocked(tsk)) return; @@ -137,7 +136,7 @@ Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4 /* * If we are going to sleep and we have plugged IO queued, * make sure to submit it to avoid deadlocks. -@@ -3582,6 +3521,12 @@ static inline void sched_submit_work(str +@@ -3583,6 +3522,12 @@ static inline void sched_submit_work(str blk_schedule_flush_plug(tsk); } @@ -150,7 +149,7 @@ Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4 asmlinkage __visible void __sched schedule(void) { struct task_struct *tsk = current; -@@ -3592,6 +3537,7 @@ asmlinkage __visible void __sched schedu +@@ -3593,6 +3538,7 @@ asmlinkage __visible void __sched schedu __schedule(false); sched_preempt_enable_no_resched(); } while (need_resched()); diff --git a/debian/patches/features/all/rt/workqueue-prevent-deadlock-stall.patch b/debian/patches/features/all/rt/workqueue-prevent-deadlock-stall.patch index 6480177fb..b5c60e78e 100644 --- a/debian/patches/features/all/rt/workqueue-prevent-deadlock-stall.patch +++ b/debian/patches/features/all/rt/workqueue-prevent-deadlock-stall.patch @@ -1,7 +1,6 @@ Subject: workqueue: Prevent deadlock/stall on RT From: Thomas Gleixner Date: Fri, 27 Jun 2014 16:24:52 +0200 (CEST) -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Austin reported a XFS deadlock/stall on RT where scheduled work gets never exececuted and tasks are waiting for each other for ever. @@ -44,7 +43,7 @@ Cc: Steven Rostedt --- a/kernel/sched/core.c +++ b/kernel/sched/core.c -@@ -3549,9 +3549,8 @@ void __noreturn do_task_dead(void) +@@ -3550,9 +3550,8 @@ void __noreturn do_task_dead(void) static inline void sched_submit_work(struct task_struct *tsk) { @@ -55,7 +54,7 @@ Cc: Steven Rostedt /* * If a worker went to sleep, notify and ask workqueue whether * it wants to wake up a task to maintain concurrency. -@@ -3559,6 +3558,10 @@ static inline void sched_submit_work(str +@@ -3560,6 +3559,10 @@ static inline void sched_submit_work(str if (tsk->flags & PF_WQ_WORKER) wq_worker_sleeping(tsk); diff --git a/debian/patches/features/all/rt/workqueue-use-locallock.patch b/debian/patches/features/all/rt/workqueue-use-locallock.patch index 2e413dea3..3565124db 100644 --- a/debian/patches/features/all/rt/workqueue-use-locallock.patch +++ b/debian/patches/features/all/rt/workqueue-use-locallock.patch @@ -1,7 +1,6 @@ Subject: workqueue: Use local irq lock instead of irq disable regions From: Thomas Gleixner Date: Sun, 17 Jul 2011 21:42:26 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Use a local_irq_lock as a replacement for irq off regions. We keep the semantic of irq-off in regard to the pool->lock and remain preemptible. diff --git a/debian/patches/features/all/rt/workqueue-use-rcu.patch b/debian/patches/features/all/rt/workqueue-use-rcu.patch index a53d7311d..bbf3e7b1a 100644 --- a/debian/patches/features/all/rt/workqueue-use-rcu.patch +++ b/debian/patches/features/all/rt/workqueue-use-rcu.patch @@ -1,7 +1,6 @@ Subject: workqueue: Use normal rcu From: Thomas Gleixner Date: Wed, 24 Jul 2013 15:26:54 +0200 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz There is no need for sched_rcu. The undocumented reason why sched_rcu is used is to avoid a few explicit rcu_read_lock()/unlock() pairs by diff --git a/debian/patches/features/all/rt/x86-UV-raw_spinlock-conversion.patch b/debian/patches/features/all/rt/x86-UV-raw_spinlock-conversion.patch deleted file mode 100644 index a9c309af3..000000000 --- a/debian/patches/features/all/rt/x86-UV-raw_spinlock-conversion.patch +++ /dev/null @@ -1,220 +0,0 @@ -From: Mike Galbraith -Date: Sun, 2 Nov 2014 08:31:37 +0100 -Subject: x86: UV: raw_spinlock conversion -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz - -Shrug. Lots of hobbyists have a beast in their basement, right? - - -Signed-off-by: Mike Galbraith -Signed-off-by: Sebastian Andrzej Siewior ---- - arch/x86/include/asm/uv/uv_bau.h | 14 +++++++------- - arch/x86/platform/uv/tlb_uv.c | 26 +++++++++++++------------- - arch/x86/platform/uv/uv_time.c | 20 ++++++++++++-------- - 3 files changed, 32 insertions(+), 28 deletions(-) - ---- a/arch/x86/include/asm/uv/uv_bau.h -+++ b/arch/x86/include/asm/uv/uv_bau.h -@@ -642,9 +642,9 @@ struct bau_control { - cycles_t send_message; - cycles_t period_end; - cycles_t period_time; -- spinlock_t uvhub_lock; -- spinlock_t queue_lock; -- spinlock_t disable_lock; -+ raw_spinlock_t uvhub_lock; -+ raw_spinlock_t queue_lock; -+ raw_spinlock_t disable_lock; - /* tunables */ - int max_concurr; - int max_concurr_const; -@@ -846,15 +846,15 @@ static inline int atom_asr(short i, stru - * to be lowered below the current 'v'. atomic_add_unless can only stop - * on equal. - */ --static inline int atomic_inc_unless_ge(spinlock_t *lock, atomic_t *v, int u) -+static inline int atomic_inc_unless_ge(raw_spinlock_t *lock, atomic_t *v, int u) - { -- spin_lock(lock); -+ raw_spin_lock(lock); - if (atomic_read(v) >= u) { -- spin_unlock(lock); -+ raw_spin_unlock(lock); - return 0; - } - atomic_inc(v); -- spin_unlock(lock); -+ raw_spin_unlock(lock); - return 1; - } - ---- a/arch/x86/platform/uv/tlb_uv.c -+++ b/arch/x86/platform/uv/tlb_uv.c -@@ -740,9 +740,9 @@ static void destination_plugged(struct b - - quiesce_local_uvhub(hmaster); - -- spin_lock(&hmaster->queue_lock); -+ raw_spin_lock(&hmaster->queue_lock); - reset_with_ipi(&bau_desc->distribution, bcp); -- spin_unlock(&hmaster->queue_lock); -+ raw_spin_unlock(&hmaster->queue_lock); - - end_uvhub_quiesce(hmaster); - -@@ -762,9 +762,9 @@ static void destination_timeout(struct b - - quiesce_local_uvhub(hmaster); - -- spin_lock(&hmaster->queue_lock); -+ raw_spin_lock(&hmaster->queue_lock); - reset_with_ipi(&bau_desc->distribution, bcp); -- spin_unlock(&hmaster->queue_lock); -+ raw_spin_unlock(&hmaster->queue_lock); - - end_uvhub_quiesce(hmaster); - -@@ -785,7 +785,7 @@ static void disable_for_period(struct ba - cycles_t tm1; - - hmaster = bcp->uvhub_master; -- spin_lock(&hmaster->disable_lock); -+ raw_spin_lock(&hmaster->disable_lock); - if (!bcp->baudisabled) { - stat->s_bau_disabled++; - tm1 = get_cycles(); -@@ -798,7 +798,7 @@ static void disable_for_period(struct ba - } - } - } -- spin_unlock(&hmaster->disable_lock); -+ raw_spin_unlock(&hmaster->disable_lock); - } - - static void count_max_concurr(int stat, struct bau_control *bcp, -@@ -861,7 +861,7 @@ static void record_send_stats(cycles_t t - */ - static void uv1_throttle(struct bau_control *hmaster, struct ptc_stats *stat) - { -- spinlock_t *lock = &hmaster->uvhub_lock; -+ raw_spinlock_t *lock = &hmaster->uvhub_lock; - atomic_t *v; - - v = &hmaster->active_descriptor_count; -@@ -995,7 +995,7 @@ static int check_enable(struct bau_contr - struct bau_control *hmaster; - - hmaster = bcp->uvhub_master; -- spin_lock(&hmaster->disable_lock); -+ raw_spin_lock(&hmaster->disable_lock); - if (bcp->baudisabled && (get_cycles() >= bcp->set_bau_on_time)) { - stat->s_bau_reenabled++; - for_each_present_cpu(tcpu) { -@@ -1007,10 +1007,10 @@ static int check_enable(struct bau_contr - tbcp->period_giveups = 0; - } - } -- spin_unlock(&hmaster->disable_lock); -+ raw_spin_unlock(&hmaster->disable_lock); - return 0; - } -- spin_unlock(&hmaster->disable_lock); -+ raw_spin_unlock(&hmaster->disable_lock); - return -1; - } - -@@ -1942,9 +1942,9 @@ static void __init init_per_cpu_tunables - bcp->cong_reps = congested_reps; - bcp->disabled_period = sec_2_cycles(disabled_period); - bcp->giveup_limit = giveup_limit; -- spin_lock_init(&bcp->queue_lock); -- spin_lock_init(&bcp->uvhub_lock); -- spin_lock_init(&bcp->disable_lock); -+ raw_spin_lock_init(&bcp->queue_lock); -+ raw_spin_lock_init(&bcp->uvhub_lock); -+ raw_spin_lock_init(&bcp->disable_lock); - } - } - ---- a/arch/x86/platform/uv/uv_time.c -+++ b/arch/x86/platform/uv/uv_time.c -@@ -57,7 +57,7 @@ static DEFINE_PER_CPU(struct clock_event - - /* There is one of these allocated per node */ - struct uv_rtc_timer_head { -- spinlock_t lock; -+ raw_spinlock_t lock; - /* next cpu waiting for timer, local node relative: */ - int next_cpu; - /* number of cpus on this node: */ -@@ -177,7 +177,7 @@ static __init int uv_rtc_allocate_timers - uv_rtc_deallocate_timers(); - return -ENOMEM; - } -- spin_lock_init(&head->lock); -+ raw_spin_lock_init(&head->lock); - head->ncpus = uv_blade_nr_possible_cpus(bid); - head->next_cpu = -1; - blade_info[bid] = head; -@@ -231,7 +231,7 @@ static int uv_rtc_set_timer(int cpu, u64 - unsigned long flags; - int next_cpu; - -- spin_lock_irqsave(&head->lock, flags); -+ raw_spin_lock_irqsave(&head->lock, flags); - - next_cpu = head->next_cpu; - *t = expires; -@@ -243,12 +243,12 @@ static int uv_rtc_set_timer(int cpu, u64 - if (uv_setup_intr(cpu, expires)) { - *t = ULLONG_MAX; - uv_rtc_find_next_timer(head, pnode); -- spin_unlock_irqrestore(&head->lock, flags); -+ raw_spin_unlock_irqrestore(&head->lock, flags); - return -ETIME; - } - } - -- spin_unlock_irqrestore(&head->lock, flags); -+ raw_spin_unlock_irqrestore(&head->lock, flags); - return 0; - } - -@@ -267,7 +267,7 @@ static int uv_rtc_unset_timer(int cpu, i - unsigned long flags; - int rc = 0; - -- spin_lock_irqsave(&head->lock, flags); -+ raw_spin_lock_irqsave(&head->lock, flags); - - if ((head->next_cpu == bcpu && uv_read_rtc(NULL) >= *t) || force) - rc = 1; -@@ -279,7 +279,7 @@ static int uv_rtc_unset_timer(int cpu, i - uv_rtc_find_next_timer(head, pnode); - } - -- spin_unlock_irqrestore(&head->lock, flags); -+ raw_spin_unlock_irqrestore(&head->lock, flags); - - return rc; - } -@@ -299,13 +299,17 @@ static int uv_rtc_unset_timer(int cpu, i - static u64 uv_read_rtc(struct clocksource *cs) - { - unsigned long offset; -+ u64 cycles; - -+ preempt_disable(); - if (uv_get_min_hub_revision_id() == 1) - offset = 0; - else - offset = (uv_blade_processor_id() * L1_CACHE_BYTES) % PAGE_SIZE; - -- return (u64)uv_read_local_mmr(UVH_RTC | offset); -+ cycles = (u64)uv_read_local_mmr(UVH_RTC | offset); -+ preempt_enable(); -+ return cycles; - } - - /* diff --git a/debian/patches/features/all/rt/x86-crypto-reduce-preempt-disabled-regions.patch b/debian/patches/features/all/rt/x86-crypto-reduce-preempt-disabled-regions.patch index 3a9ff5cc7..16a3506d4 100644 --- a/debian/patches/features/all/rt/x86-crypto-reduce-preempt-disabled-regions.patch +++ b/debian/patches/features/all/rt/x86-crypto-reduce-preempt-disabled-regions.patch @@ -1,7 +1,6 @@ Subject: x86: crypto: Reduce preempt disabled regions From: Peter Zijlstra Date: Mon, 14 Nov 2011 18:19:27 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Restrict the preempt disabled regions to the actual floating point operations and enable preemption for the administrative actions. diff --git a/debian/patches/features/all/rt/x86-highmem-add-a-already-used-pte-check.patch b/debian/patches/features/all/rt/x86-highmem-add-a-already-used-pte-check.patch index 959b76df5..a3493efae 100644 --- a/debian/patches/features/all/rt/x86-highmem-add-a-already-used-pte-check.patch +++ b/debian/patches/features/all/rt/x86-highmem-add-a-already-used-pte-check.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Mon, 11 Mar 2013 17:09:55 +0100 Subject: x86/highmem: Add a "already used pte" check -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz This is a copy from kmap_atomic_prot(). diff --git a/debian/patches/features/all/rt/x86-io-apic-migra-no-unmask.patch b/debian/patches/features/all/rt/x86-io-apic-migra-no-unmask.patch index 9e6539778..6c6a51d59 100644 --- a/debian/patches/features/all/rt/x86-io-apic-migra-no-unmask.patch +++ b/debian/patches/features/all/rt/x86-io-apic-migra-no-unmask.patch @@ -1,7 +1,6 @@ From: Ingo Molnar Date: Fri, 3 Jul 2009 08:29:27 -0500 Subject: x86/ioapic: Do not unmask io_apic when interrupt is in progress -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz With threaded interrupts we might see an interrupt in progress on migration. Do not unmask it when this is the case. diff --git a/debian/patches/features/all/rt/x86-kvm-require-const-tsc-for-rt.patch b/debian/patches/features/all/rt/x86-kvm-require-const-tsc-for-rt.patch index a981deb8a..b254f2135 100644 --- a/debian/patches/features/all/rt/x86-kvm-require-const-tsc-for-rt.patch +++ b/debian/patches/features/all/rt/x86-kvm-require-const-tsc-for-rt.patch @@ -1,7 +1,6 @@ Subject: x86: kvm Require const tsc for RT From: Thomas Gleixner Date: Sun, 06 Nov 2011 12:26:18 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Non constant TSC is a nightmare on bare metal already, but with virtualization it becomes a complete disaster because the workarounds @@ -15,7 +14,7 @@ Signed-off-by: Thomas Gleixner --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c -@@ -6391,6 +6391,13 @@ int kvm_arch_init(void *opaque) +@@ -6386,6 +6386,13 @@ int kvm_arch_init(void *opaque) goto out; } diff --git a/debian/patches/features/all/rt/x86-preempt-lazy.patch b/debian/patches/features/all/rt/x86-preempt-lazy.patch index a7bd5f49f..237445ecc 100644 --- a/debian/patches/features/all/rt/x86-preempt-lazy.patch +++ b/debian/patches/features/all/rt/x86-preempt-lazy.patch @@ -1,7 +1,6 @@ Subject: x86: Support for lazy preemption From: Thomas Gleixner Date: Thu, 01 Nov 2012 11:03:47 +0100 -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Implement the x86 pieces for lazy preempt. @@ -177,7 +176,7 @@ Signed-off-by: Thomas Gleixner #endif /* -@@ -82,6 +89,7 @@ struct thread_info { +@@ -83,6 +90,7 @@ struct thread_info { #define TIF_SYSCALL_EMU 6 /* syscall emulation active */ #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */ #define TIF_SECCOMP 8 /* secure computing */ @@ -185,7 +184,7 @@ Signed-off-by: Thomas Gleixner #define TIF_USER_RETURN_NOTIFY 11 /* notify kernel of userspace return */ #define TIF_UPROBE 12 /* breakpointed or singlestepping */ #define TIF_PATCH_PENDING 13 /* pending live patching update */ -@@ -108,6 +116,7 @@ struct thread_info { +@@ -110,6 +118,7 @@ struct thread_info { #define _TIF_SYSCALL_EMU (1 << TIF_SYSCALL_EMU) #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) #define _TIF_SECCOMP (1 << TIF_SECCOMP) @@ -193,7 +192,7 @@ Signed-off-by: Thomas Gleixner #define _TIF_USER_RETURN_NOTIFY (1 << TIF_USER_RETURN_NOTIFY) #define _TIF_UPROBE (1 << TIF_UPROBE) #define _TIF_PATCH_PENDING (1 << TIF_PATCH_PENDING) -@@ -149,6 +158,8 @@ struct thread_info { +@@ -151,6 +160,8 @@ struct thread_info { #define _TIF_WORK_CTXSW_PREV (_TIF_WORK_CTXSW|_TIF_USER_RETURN_NOTIFY) #define _TIF_WORK_CTXSW_NEXT (_TIF_WORK_CTXSW) diff --git a/debian/patches/features/all/rt/x86-signal-delay-calling-signals-on-32bit.patch b/debian/patches/features/all/rt/x86-signal-delay-calling-signals-on-32bit.patch index deb0ba858..e41ae9db7 100644 --- a/debian/patches/features/all/rt/x86-signal-delay-calling-signals-on-32bit.patch +++ b/debian/patches/features/all/rt/x86-signal-delay-calling-signals-on-32bit.patch @@ -1,7 +1,6 @@ From: Yang Shi Date: Thu, 10 Dec 2015 10:58:51 -0800 Subject: x86/signal: delay calling signals on 32bit -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz When running some ptrace single step tests on x86-32 machine, the below problem is triggered: diff --git a/debian/patches/features/all/rt/x86-stackprot-no-random-on-rt.patch b/debian/patches/features/all/rt/x86-stackprot-no-random-on-rt.patch index 1c9e7d652..66c2ecf59 100644 --- a/debian/patches/features/all/rt/x86-stackprot-no-random-on-rt.patch +++ b/debian/patches/features/all/rt/x86-stackprot-no-random-on-rt.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Thu, 16 Dec 2010 14:25:18 +0100 Subject: x86: stackprotector: Avoid random pool on rt -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz CPU bringup calls into the random pool to initialize the stack canary. During boot that works nicely even on RT as the might sleep diff --git a/debian/patches/features/all/rt/x86-use-gen-rwsem-spinlocks-rt.patch b/debian/patches/features/all/rt/x86-use-gen-rwsem-spinlocks-rt.patch index 467e4cc76..a60f148c3 100644 --- a/debian/patches/features/all/rt/x86-use-gen-rwsem-spinlocks-rt.patch +++ b/debian/patches/features/all/rt/x86-use-gen-rwsem-spinlocks-rt.patch @@ -1,7 +1,6 @@ From: Thomas Gleixner Date: Sun, 26 Jul 2009 02:21:32 +0200 Subject: x86: Use generic rwsem_spinlocks on -rt -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz Simplifies the separation of anon_rw_semaphores and rw_semaphores for -rt. diff --git a/debian/patches/features/all/rt/xen-9pfs-don-t-inclide-rwlock.h-directly.patch b/debian/patches/features/all/rt/xen-9pfs-don-t-inclide-rwlock.h-directly.patch index 9d9d9ace4..8c36bf8c7 100644 --- a/debian/patches/features/all/rt/xen-9pfs-don-t-inclide-rwlock.h-directly.patch +++ b/debian/patches/features/all/rt/xen-9pfs-don-t-inclide-rwlock.h-directly.patch @@ -1,7 +1,6 @@ From: Sebastian Andrzej Siewior Date: Thu, 5 Oct 2017 14:38:52 +0200 Subject: [PATCH] xen/9pfs: don't inclide rwlock.h directly. -Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.16/older/patches-4.16.8-rt3.tar.xz rwlock.h should not be included directly. Instead linux/splinlock.h should be included. One thing it does is to break the RT build. diff --git a/debian/patches/series-rt b/debian/patches/series-rt index 8095535ba..a200910b6 100644 --- a/debian/patches/series-rt +++ b/debian/patches/series-rt @@ -96,7 +96,7 @@ features/all/rt/rxrpc-remove-unused-static-variables.patch features/all/rt/delayacct-use-raw_spinlocks.patch features/all/rt/stop-machine-raw-lock.patch features/all/rt/mmci-remove-bogus-irq-save.patch -features/all/rt/tty-serial-atmel-use-port-name-as-name-in-request_ir.patch +#features/all/rt/tty-serial-atmel-use-port-name-as-name-in-request_ir.patch features/all/rt/rbtree-include-rcu.h-because-we-use-it.patch features/all/rt/sched-swait-include-wait.h.patch features/all/rt/block-avoid-disabling-interrupts-during-kmap_atomic.patch @@ -108,9 +108,25 @@ features/all/rt/net-3com-3c59x-Pull-locking-out-of-ISR.patch features/all/rt/net-3com-3c59x-irq-save-variant-of-ISR.patch features/all/rt/ALSA-pcm-Hide-local_irq_disable-enable-and-local_irq.patch features/all/rt/percpu_ida-Use-_irqsave-instead-of-local_irq_save-sp.patch +features/all/rt/lib-percpu_ida.c-don-t-do-alloc-from-per-CPU-list-if.patch features/all/rt/xen-9pfs-don-t-inclide-rwlock.h-directly.patch features/all/rt/ACPICA-provide-abstraction-for-raw_spinlock_t.patch features/all/rt/ACPICA-Convert-acpi_gbl_hardware-lock-back-to-an-acp.patch +features/all/rt/mfd-syscon-atmel-smc-include-string.h.patch +features/all/rt/sched-tracing-Fix-trace_sched_pi_setprio-for-deboost.patch +features/all/rt/0001-PM-suspend-Prevent-might-sleep-splats.patch +features/all/rt/0002-PM-wakeup-Make-events_lock-a-RAW_SPINLOCK.patch +features/all/rt/0003-PM-s2idle-Make-s2idle_wait_head-swait-based.patch +features/all/rt/0004-PM-wakeup-Make-s2idle_lock-a-RAW_SPINLOCK.patch +features/all/rt/rfc-arm-smp-__cpu_disable-fix-sleeping-function-called-from-invalid-context.patch +features/all/rt/alim15x3-move-irq-restore-before-pci_dev_put.patch +features/all/rt/ide-don-t-disable-interrupts-if-they-are-already-dis.patch +features/all/rt/ide-don-t-disable-interrupts-during-kmap_atomic.patch +features/all/rt/ide-don-t-enable-disable-interrupts-in-force-threade.patch +features/all/rt/kernel-signal-Remove-no-longer-required-irqsave-rest.patch +features/all/rt/IB-ipoib-replace-local_irq_disable-with-proper-locki.patch +features/all/rt/SCSI-libsas-remove-irq-save-in-sas_ata_qc_issue.patch +features/all/rt/posix-cpu-timers-remove-lockdep_assert_irqs_disabled.patch ############################################################ # POSTED by others @@ -128,17 +144,15 @@ features/all/rt/0006-ARM-configs-at91-unselect-PIT.patch ############################################################ # POSTED ############################################################ -features/all/rt/mfd-syscon-atmel-smc-include-string.h.patch features/all/rt/Revert-mm-vmstat.c-fix-vmstat_update-preemption-BUG.patch features/all/rt/arm-convert-boot-lock-to-raw.patch features/all/rt/x86-io-apic-migra-no-unmask.patch +features/all/rt/arm-kprobe-replace-patch_lock-to-raw-lock.patch +features/all/rt/arm-unwind-use_raw_lock.patch ############################################################ # Ready for posting ############################################################ -features/all/rt/arm-kprobe-replace-patch_lock-to-raw-lock.patch -features/all/rt/x86-UV-raw_spinlock-conversion.patch -features/all/rt/arm-unwind-use_raw_lock.patch ############################################################ # Needs to address review feedback @@ -148,7 +162,6 @@ features/all/rt/posix-timers-no-broadcast.patch ############################################################ # Almost ready, needs final polishing ############################################################ -features/all/rt/rfc-arm-smp-__cpu_disable-fix-sleeping-function-called-from-invalid-context.patch features/all/rt/drivers-random-reduce-preempt-disabled-region.patch features/all/rt/mm-page_alloc-rt-friendly-per-cpu-pages.patch features/all/rt/mm-page_alloc-reduce-lock-sections-further.patch @@ -171,44 +184,30 @@ features/all/rt/timekeeping-split-jiffies-lock.patch # PTRACE/SIGNAL crap features/all/rt/signal-revert-ptrace-preempt-magic.patch -# PM -features/all/rt/suspend-prevernt-might-sleep-splats.patch - # NETWORKING features/all/rt/net-sched-dev_deactivate_many-use-msleep-1-instead-o.patch # The removal of NONRT helpers -features/all/rt/alim15x3-move-irq-restore-before-pci_dev_put.patch -features/all/rt/ide-don-t-disable-interrupts-if-they-are-already-dis.patch -features/all/rt/ide-don-t-disable-interrupts-during-kmap_atomic.patch -features/all/rt/ide-don-t-enable-disable-interrupts-in-force-threade.patch features/all/rt/dm-rq-remove-BUG_ON-irqs_disabled-check.patch -features/all/rt/kernel-signal-Remove-no-longer-required-irqsave-rest.patch features/all/rt/ntfs-avoid-disabling-interrupts-during-kmap_atomic.patch -features/all/rt/IB-ipoib-replace-local_irq_disable-with-proper-locki.patch -features/all/rt/SCSI-libsas-remove-irq-save-in-sas_ata_qc_issue.patch features/all/rt/SCSI-qla2xxx-remove-irq-save-in-qla2x00_poll.patch features/all/rt/libata-remove-ata_sff_data_xfer_noirq.patch -features/all/rt/posix-cpu-timers-remove-lockdep_assert_irqs_disabled.patch features/all/rt/usb-do-not-disable-interrupts-in-giveback.patch -# refcount_dec_and_lock_irqsave +# atomic_dec_and_lock_irqsave / refcount_dec_and_lock_irqsave +features/all/rt/0001-spinlock-atomic_dec_and_lock-Add-an-irqsave-variant.patch +features/all/rt/0002-drivers-md-raid5-Use-irqsave-variant-of-atomic_dec_a.patch +features/all/rt/0003-drivers-md-raid5-Do-not-disable-irq-on-release_inact.patch features/all/rt/0001-bdi-use-refcount_t-for-reference-counting-instead-at.patch features/all/rt/0002-userns-use-refcount_t-for-reference-counting-instead.patch -features/all/rt/0003-md-raid5-use-refcount_t-for-reference-counting-inste.patch features/all/rt/0004-locking-refcount-implement-refcount_dec_and_lock_irq.patch features/all/rt/0005-bdi-Use-irqsave-variant-of-refcount_dec_and_lock.patch features/all/rt/0006-userns-Use-irqsave-variant-of-refcount_dec_and_lock.patch -features/all/rt/0007-md-raid5-Use-irqsave-variant-of-refcount_dec_and_loc.patch -features/all/rt/0008-md-raid5-Do-not-disable-irq-on-release_inactive_stri.patch #iommu features/all/rt/iommu-amd-hide-unused-iommu_table_lock.patch features/all/rt/iommu-amd-Prevent-possible-null-pointer-dereference-.patch features/all/rt/iommu-amd-Cleanup-locking-in-__attach-detach_device.patch features/all/rt/iommu-amd-Do-not-flush-when-device-is-busy.patch -#net -features/all/rt/lockdep-Add-a-assert_in_softirq.patch -features/all/rt/net-mac808211-rc-warn_on.patch ################################################## # REAL RT STUFF starts here @@ -285,6 +284,7 @@ features/all/rt/slub-disable-SLUB_CPU_PARTIAL.patch # MM features/all/rt/mm-page-alloc-use-local-lock-on-target-cpu.patch +features/all/rt/mm-memcontrol-Don-t-call-schedule_work_on-in-preempt.patch features/all/rt/mm-memcontrol-do_not_disable_irq.patch features/all/rt/mm_zsmalloc_copy_with_get_cpu_var_and_locking.patch @@ -444,6 +444,7 @@ features/all/rt/debugobjects-rt.patch # SEQLOCKS features/all/rt/seqlock-prevent-rt-starvation.patch +features/all/rt/seqlock-provide-the-same-ordering-semantics-as-mainl.patch # NETWORKING features/all/rt/sunrpc-make-svc_xprt_do_enqueue-use-get_cpu_light.patch