From: Sasha Levin Date: Wed, 24 Apr 2019 01:27:05 +0000 (-0400) Subject: patches for 4.19 X-Git-Tag: v3.18.139~33 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6353379f87531005a646b151857288b2971650f1;p=thirdparty%2Fkernel%2Fstable-queue.git patches for 4.19 Signed-off-by: Sasha Levin --- diff --git a/queue-4.19/revert-kbuild-use-oz-instead-of-os-when-using-clang.patch b/queue-4.19/revert-kbuild-use-oz-instead-of-os-when-using-clang.patch new file mode 100644 index 00000000000..a7fe7869e67 --- /dev/null +++ b/queue-4.19/revert-kbuild-use-oz-instead-of-os-when-using-clang.patch @@ -0,0 +1,41 @@ +From d0a2c835a354336c69d567b9f4bb8e0724dd1d89 Mon Sep 17 00:00:00 2001 +From: Matthias Kaehlcke +Date: Tue, 23 Apr 2019 12:04:23 -0700 +Subject: Revert "kbuild: use -Oz instead of -Os when using clang" + +commit a75bb4eb9e565b9f5115e2e8c07377ce32cbe69a upstream. + +The clang option -Oz enables *aggressive* optimization for size, +which doesn't necessarily result in smaller images, but can have +negative impact on performance. Switch back to the less aggressive +-Os. + +This reverts commit 6748cb3c299de1ffbe56733647b01dbcc398c419. + +Suggested-by: Peter Zijlstra +Signed-off-by: Matthias Kaehlcke +Reviewed-by: Nick Desaulniers +Signed-off-by: Masahiro Yamada +Signed-off-by: Nathan Chancellor +Signed-off-by: Sasha Levin +--- + Makefile | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/Makefile b/Makefile +index 3fac08f6a11e..91e265ca0ca5 100644 +--- a/Makefile ++++ b/Makefile +@@ -661,8 +661,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) + KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context) + + ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE +-KBUILD_CFLAGS += $(call cc-option,-Oz,-Os) +-KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,) ++KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,) + else + ifdef CONFIG_PROFILE_ALL_BRANCHES + KBUILD_CFLAGS += -O2 $(call cc-disable-warning,maybe-uninitialized,) +-- +2.19.1 + diff --git a/queue-4.19/sched-fair-limit-sched_cfs_period_timer-loop-to-avoi.patch b/queue-4.19/sched-fair-limit-sched_cfs_period_timer-loop-to-avoi.patch new file mode 100644 index 00000000000..4f89b4dcc15 --- /dev/null +++ b/queue-4.19/sched-fair-limit-sched_cfs_period_timer-loop-to-avoi.patch @@ -0,0 +1,101 @@ +From 93c3b3963957745f3fe9047502297f91858db47b Mon Sep 17 00:00:00 2001 +From: Phil Auld +Date: Tue, 23 Apr 2019 19:51:06 -0400 +Subject: sched/fair: Limit sched_cfs_period_timer() loop to avoid hard lockup + +[ Upstream commit 2e8e19226398db8265a8e675fcc0118b9e80c9e8 ] + +With extremely short cfs_period_us setting on a parent task group with a large +number of children the for loop in sched_cfs_period_timer() can run until the +watchdog fires. There is no guarantee that the call to hrtimer_forward_now() +will ever return 0. The large number of children can make +do_sched_cfs_period_timer() take longer than the period. + + NMI watchdog: Watchdog detected hard LOCKUP on cpu 24 + RIP: 0010:tg_nop+0x0/0x10 + + walk_tg_tree_from+0x29/0xb0 + unthrottle_cfs_rq+0xe0/0x1a0 + distribute_cfs_runtime+0xd3/0xf0 + sched_cfs_period_timer+0xcb/0x160 + ? sched_cfs_slack_timer+0xd0/0xd0 + __hrtimer_run_queues+0xfb/0x270 + hrtimer_interrupt+0x122/0x270 + smp_apic_timer_interrupt+0x6a/0x140 + apic_timer_interrupt+0xf/0x20 + + +To prevent this we add protection to the loop that detects when the loop has run +too many times and scales the period and quota up, proportionally, so that the timer +can complete before then next period expires. This preserves the relative runtime +quota while preventing the hard lockup. + +A warning is issued reporting this state and the new values. + +Signed-off-by: Phil Auld +Signed-off-by: Peter Zijlstra (Intel) +Cc: +Cc: Anton Blanchard +Cc: Ben Segall +Cc: Linus Torvalds +Cc: Peter Zijlstra +Cc: Thomas Gleixner +Link: https://lkml.kernel.org/r/20190319130005.25492-1-pauld@redhat.com +Signed-off-by: Ingo Molnar +Signed-off-by: Sasha Levin +--- + kernel/sched/fair.c | 25 +++++++++++++++++++++++++ + 1 file changed, 25 insertions(+) + +diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c +index 640094391169..4aa8e7d90c25 100644 +--- a/kernel/sched/fair.c ++++ b/kernel/sched/fair.c +@@ -4847,12 +4847,15 @@ static enum hrtimer_restart sched_cfs_slack_timer(struct hrtimer *timer) + return HRTIMER_NORESTART; + } + ++extern const u64 max_cfs_quota_period; ++ + static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer) + { + struct cfs_bandwidth *cfs_b = + container_of(timer, struct cfs_bandwidth, period_timer); + int overrun; + int idle = 0; ++ int count = 0; + + raw_spin_lock(&cfs_b->lock); + for (;;) { +@@ -4860,6 +4863,28 @@ static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer) + if (!overrun) + break; + ++ if (++count > 3) { ++ u64 new, old = ktime_to_ns(cfs_b->period); ++ ++ new = (old * 147) / 128; /* ~115% */ ++ new = min(new, max_cfs_quota_period); ++ ++ cfs_b->period = ns_to_ktime(new); ++ ++ /* since max is 1s, this is limited to 1e9^2, which fits in u64 */ ++ cfs_b->quota *= new; ++ cfs_b->quota = div64_u64(cfs_b->quota, old); ++ ++ pr_warn_ratelimited( ++ "cfs_period_timer[cpu%d]: period too short, scaling up (new cfs_period_us %lld, cfs_quota_us = %lld)\n", ++ smp_processor_id(), ++ div_u64(new, NSEC_PER_USEC), ++ div_u64(cfs_b->quota, NSEC_PER_USEC)); ++ ++ /* reset count so we don't come right back in here */ ++ count = 0; ++ } ++ + idle = do_sched_cfs_period_timer(cfs_b, overrun); + } + if (idle) +-- +2.19.1 + diff --git a/queue-4.19/series b/queue-4.19/series index 063682a2ddb..fab235f0929 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -85,3 +85,5 @@ modpost-file2alias-go-back-to-simple-devtable-lookup.patch modpost-file2alias-check-prototype-of-handler.patch tpm-tpm_i2c_atmel-return-e2big-when-the-transfer-is-.patch tpm-fix-the-type-of-the-return-value-in-calc_tpm2_ev.patch +revert-kbuild-use-oz-instead-of-os-when-using-clang.patch +sched-fair-limit-sched_cfs_period_timer-loop-to-avoi.patch