From f4396389a56dd7c0c1ef1ff9111bd95313c6fca9 Mon Sep 17 00:00:00 2001 From: "Gary S. Robertson" Date: Wed, 10 Sep 2014 14:57:16 -0500 Subject: [PATCH 1/4] hrtimer.h: prevent pinned timer state from breaking inactive test An hrtimer may be pinned to a CPU but inactive, so it is no longer valid to test the hrtimer.state struct member as having no bits set when inactive. Changed the test function to mask out the HRTIMER_STATE_PINNED bit when checking for inactive state. Change-Id: Icb4156f4b7cb10138ea6c5cd5b762e35dc25428d Signed-off-by: Gary S. Robertson [ohaugan@codeaurora.org: Port to 4.4] Git-commit: 902e4d4eb0d2158d2792166221a72a829caecf07 Git-repo: git://git.linaro.org/people/mike.holmes/santosh.shukla/lng-isol.git Signed-off-by: Olav Haugan [satyap@codeaurora.org: Port to 4.19 and fix merge conflicts] Signed-off-by: Satya Durga Srinivasu Prabhala --- kernel/time/hrtimer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 66885f6f8d4b..2feb5db24220 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1452,8 +1452,8 @@ bool hrtimer_active(const struct hrtimer *timer) base = READ_ONCE(timer->base); seq = raw_read_seqcount_begin(&base->seq); - if (timer->state != HRTIMER_STATE_INACTIVE || - base->running == timer) + if (((timer->state & ~HRTIMER_STATE_PINNED) != + HRTIMER_STATE_INACTIVE) || base->running == timer) return true; } while (read_seqcount_retry(&base->seq, seq) || From 2d9dd2dcc396e8f4271317441e85b5c9f13a939f Mon Sep 17 00:00:00 2001 From: Santosh Shukla Date: Wed, 25 Mar 2015 16:09:32 +0530 Subject: [PATCH 2/4] timer: Add function to migrate timers Add function to migrate timer that will be used by later patch set. Change-Id: I2d4fbe312fe635273c7386aba8378937f4b0ac15 Signed-off-by: Santosh Shukla [ohaugan@codeaurora.org: Updated commit text and fixed trivial merge conflict] Git-commit: 3633b88d8fcb4273807574c27c328b6908a741e5 Git-repo: git://git.linaro.org/people/mike.holmes/santosh.shukla/lng-isol.git Signed-off-by: Olav Haugan [rameezmustafa@codeaurora.org: Port to msm-4.9] Signed-off-by: Syed Rameez Mustafa Signed-off-by: Satya Durga Srinivasu Prabhala --- kernel/time/timer.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index d168d6ff3799..7f772cdeca5d 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -2057,6 +2057,13 @@ int timers_dead_cpu(unsigned int cpu) return 0; } +#ifdef CONFIG_CPUSETS +void timer_quiesce_cpu(void *cpup) +{ + __migrate_timers(*(unsigned int *)cpup, false); +} +#endif /* CONFIG_CPUSETS */ + #endif /* CONFIG_HOTPLUG_CPU */ static void __init init_timer_cpu(int cpu) From 3ab58753c893f97939d049dea1c97a58dea8d3a9 Mon Sep 17 00:00:00 2001 From: Satya Durga Srinivasu Prabhala Date: Wed, 31 Jan 2018 14:38:24 -0800 Subject: [PATCH 3/4] sched: Introduce PANIC_ON_SCHED_BUG Introduce PANIC_ON_SCHED_BUG to catch issues related to scheduler like calling sleepable functions inside atomic context etc. Change-Id: I9f1fe96772b317b17bd0e7423a48023d3cf141c7 Signed-off-by: Satya Durga Srinivasu Prabhala --- kernel/sched/core.c | 6 ++++++ lib/Kconfig.debug | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index d09e4107b895..74fd1edad65e 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3864,6 +3864,9 @@ static noinline void __schedule_bug(struct task_struct *prev) if (panic_on_warn) panic("scheduling while atomic\n"); +#ifdef CONFIG_PANIC_ON_SCHED_BUG + BUG(); +#endif dump_stack(); add_taint(TAINT_WARN, LOCKDEP_STILL_OK); } @@ -6787,6 +6790,9 @@ void ___might_sleep(const char *file, int line, int preempt_offset) print_ip_sym(preempt_disable_ip); pr_cont("\n"); } +#ifdef CONFIG_PANIC_ON_SCHED_BUG + BUG(); +#endif dump_stack(); add_taint(TAINT_WARN, LOCKDEP_STILL_OK); } diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 93d97f9b0157..8d41569c67d4 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -1013,6 +1013,15 @@ config SCHED_INFO bool default n +config PANIC_ON_SCHED_BUG + bool "Panic on all bugs encountered by the scheduler" + help + Say Y here to panic on all 'BUG:' conditions encountered by the + scheduler, even potentially-recoverable ones such as scheduling + while atomic and sleeping from invalid context etc. + + Say N if unsure. + config SCHEDSTATS bool "Collect scheduler statistics" depends on DEBUG_KERNEL && PROC_FS From 61f31539cfa7e9b813866679d5950b368b05da8f Mon Sep 17 00:00:00 2001 From: Syed Rameez Mustafa Date: Mon, 13 Jul 2015 11:03:02 -0700 Subject: [PATCH 4/4] sched: turn off the TTWU_QUEUE feature While the feature TTWU_QUEUE has the advantage of reducing cache bouncing of runqueue locks, it has the side effect that runqueue statistics are not updated until the remote CPU has a chance to enqueue the task. Since there is no upper bound on the amount of time it can take the remote CPU to enqueue the task, several sequential wakeups can result in suboptimal task placement based on the stale statistics. Turn off the feature as the cost of sub-optimal placement is much higher than the cost of cache bouncing spinlocks for msm based systems. Change-Id: I0b85c0225237b2bc44f54934769f5e3750c0f3d6 Signed-off-by: Syed Rameez Mustafa [satyap@codeaurora.org: fix trivial merge conflict] Signed-off-by: Satya Durga Srinivasu Prabhala --- kernel/sched/features.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/features.h b/kernel/sched/features.h index 2410db5e9a35..602ce1ed59b8 100644 --- a/kernel/sched/features.h +++ b/kernel/sched/features.h @@ -49,7 +49,7 @@ SCHED_FEAT(NONTASK_CAPACITY, true) * Queue remote wakeups on the target CPU and process them * using the scheduler IPI. Reduces rq->lock contention/bounces. */ -SCHED_FEAT(TTWU_QUEUE, true) +SCHED_FEAT(TTWU_QUEUE, false) /* * When doing wakeups, attempt to limit superfluous scans of the LLC domain.