]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.153/sched-features-fix-config_jump_label-case.patch
6.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.19.153 / sched-features-fix-config_jump_label-case.patch
1 From 02c2586bfbf3302dfdcbdfca4ee840928b64aa47 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Tue, 13 Oct 2020 07:31:14 +0200
4 Subject: sched/features: Fix !CONFIG_JUMP_LABEL case
5
6 From: Juri Lelli <juri.lelli@redhat.com>
7
8 [ Upstream commit a73f863af4ce9730795eab7097fb2102e6854365 ]
9
10 Commit:
11
12 765cc3a4b224e ("sched/core: Optimize sched_feat() for !CONFIG_SCHED_DEBUG builds")
13
14 made sched features static for !CONFIG_SCHED_DEBUG configurations, but
15 overlooked the CONFIG_SCHED_DEBUG=y and !CONFIG_JUMP_LABEL cases.
16
17 For the latter echoing changes to /sys/kernel/debug/sched_features has
18 the nasty effect of effectively changing what sched_features reports,
19 but without actually changing the scheduler behaviour (since different
20 translation units get different sysctl_sched_features).
21
22 Fix CONFIG_SCHED_DEBUG=y and !CONFIG_JUMP_LABEL configurations by properly
23 restructuring ifdefs.
24
25 Fixes: 765cc3a4b224e ("sched/core: Optimize sched_feat() for !CONFIG_SCHED_DEBUG builds")
26 Co-developed-by: Daniel Bristot de Oliveira <bristot@redhat.com>
27 Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com>
28 Signed-off-by: Juri Lelli <juri.lelli@redhat.com>
29 Signed-off-by: Ingo Molnar <mingo@kernel.org>
30 Acked-by: Patrick Bellasi <patrick.bellasi@matbug.net>
31 Reviewed-by: Valentin Schneider <valentin.schneider@arm.com>
32 Link: https://lore.kernel.org/r/20201013053114.160628-1-juri.lelli@redhat.com
33 Signed-off-by: Sasha Levin <sashal@kernel.org>
34 ---
35 kernel/sched/core.c | 2 +-
36 kernel/sched/sched.h | 13 ++++++++++---
37 2 files changed, 11 insertions(+), 4 deletions(-)
38
39 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
40 index faef74f632620..b166320f7633e 100644
41 --- a/kernel/sched/core.c
42 +++ b/kernel/sched/core.c
43 @@ -24,7 +24,7 @@
44
45 DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues);
46
47 -#if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_JUMP_LABEL)
48 +#ifdef CONFIG_SCHED_DEBUG
49 /*
50 * Debugging: various feature bits
51 *
52 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
53 index 5f0eb4565957f..41b7954be68b7 100644
54 --- a/kernel/sched/sched.h
55 +++ b/kernel/sched/sched.h
56 @@ -1361,7 +1361,7 @@ enum {
57
58 #undef SCHED_FEAT
59
60 -#if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_JUMP_LABEL)
61 +#ifdef CONFIG_SCHED_DEBUG
62
63 /*
64 * To support run-time toggling of sched features, all the translation units
65 @@ -1369,6 +1369,7 @@ enum {
66 */
67 extern const_debug unsigned int sysctl_sched_features;
68
69 +#ifdef CONFIG_JUMP_LABEL
70 #define SCHED_FEAT(name, enabled) \
71 static __always_inline bool static_branch_##name(struct static_key *key) \
72 { \
73 @@ -1381,7 +1382,13 @@ static __always_inline bool static_branch_##name(struct static_key *key) \
74 extern struct static_key sched_feat_keys[__SCHED_FEAT_NR];
75 #define sched_feat(x) (static_branch_##x(&sched_feat_keys[__SCHED_FEAT_##x]))
76
77 -#else /* !(SCHED_DEBUG && CONFIG_JUMP_LABEL) */
78 +#else /* !CONFIG_JUMP_LABEL */
79 +
80 +#define sched_feat(x) (sysctl_sched_features & (1UL << __SCHED_FEAT_##x))
81 +
82 +#endif /* CONFIG_JUMP_LABEL */
83 +
84 +#else /* !SCHED_DEBUG */
85
86 /*
87 * Each translation unit has its own copy of sysctl_sched_features to allow
88 @@ -1397,7 +1404,7 @@ static const_debug __maybe_unused unsigned int sysctl_sched_features =
89
90 #define sched_feat(x) !!(sysctl_sched_features & (1UL << __SCHED_FEAT_##x))
91
92 -#endif /* SCHED_DEBUG && CONFIG_JUMP_LABEL */
93 +#endif /* SCHED_DEBUG */
94
95 extern struct static_key_false sched_numa_balancing;
96 extern struct static_key_false sched_schedstats;
97 --
98 2.25.1
99