forked fromtorvalds/linux
- Notifications
You must be signed in to change notification settings - Fork0
Commit765cc3a
sched/core: Optimize sched_feat() for !CONFIG_SCHED_DEBUG builds
When the kernel is compiled with !CONFIG_SCHED_DEBUG support, we expect thatall SCHED_FEAT are turned into compile time constants being propagatedto support compiler optimizations.Specifically, we expect that code blocks like this: if (sched_feat(FEATURE_NAME) [&& <other_conditions>]) {/* FEATURE CODE */ }are turned into dead-code in case FEATURE_NAME defaults to FALSE, and thusbeing removed by the compiler from the finale image.For this mechanism to properly work it's required for the compiler tohave full access, from each translation unit, to whatever is the valuedefined by the sched_feat macro. This macro is defined as: #define sched_feat(x) (sysctl_sched_features & (1UL << __SCHED_FEAT_##x))and thus, the compiler can optimize that code only if the value ofsysctl_sched_features is visible within each translation unit.Since:029632f ("sched: Make separate sched*.c translation units")the scheduler code has been split into separate translation unitshowever the definition of sysctl_sched_features is part ofkernel/sched/core.c while, for all the other scheduler modules, it isvisible only via kernel/sched/sched.h as an: extern const_debug unsigned int sysctl_sched_featuresUnfortunately, an extern reference does not allow the compiler to applyconstants propagation. Thus, on !CONFIG_SCHED_DEBUG kernel we still end upwith code to load a memory reference and (eventually) doing an unconditionaljump of a chunk of code.This mechanism is unavoidable when sched_features can be turned on and off atrun-time. However, this is not the case for "production" kernels compiled with!CONFIG_SCHED_DEBUG. In this case, sysctl_sched_features is just a constant valuewhich cannot be changed at run-time and thus memory loads and jumps can beavoided altogether.This patch fixes the case of !CONFIG_SCHED_DEBUG kernel by declaring a local versionof the sysctl_sched_features constant for each translation unit. This willultimately allow the compiler to perform constants propagation and dead-codepruning.Tests have been done, with !CONFIG_SCHED_DEBUG on a v4.14-rc8 with and withoutthe patch, by running 30 iterations of: perf bench sched messaging --pipe --thread --group 4 --loop 50000on a 40 cores Intel(R) Xeon(R) CPU E5-2690 v2 @ 3.00GHz using thepowersave governor to rule out variations due to frequency scaling.Statistics on the reported completion time: count mean std min 99% max v4.14-rc8 30.0 15.7831 0.176032 15.442 16.01226 16.014 v4.14-rc8+patch 30.0 15.5033 0.189681 15.232 15.93938 15.962... show a 1.8% speedup on average completion time and 0.5% speedup in the99 percentile.Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>Signed-off-by: Chris Redpath <chris.redpath@arm.com>Reviewed-by: Dietmar Eggemann <dietmar.eggemann@arm.com>Reviewed-by: Brendan Jackman <brendan.jackman@arm.com>Acked-by: Peter Zijlstra <peterz@infradead.org>Cc: Juri Lelli <juri.lelli@redhat.com>Cc: Linus Torvalds <torvalds@linux-foundation.org>Cc: Morten Rasmussen <morten.rasmussen@arm.com>Cc: Thomas Gleixner <tglx@linutronix.de>Cc: Vincent Guittot <vincent.guittot@linaro.org>Link:http://lkml.kernel.org/r/20171108184101.16006-1-patrick.bellasi@arm.comSigned-off-by: Ingo Molnar <mingo@kernel.org>1 parent8a103df commit765cc3a
2 files changed
+28
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
48 | 53 | | |
49 | | - | |
50 | 54 | | |
51 | 55 | | |
52 | | - | |
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
56 | | - | |
57 | 59 | | |
| 60 | + | |
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1233 | 1233 | | |
1234 | 1234 | | |
1235 | 1235 | | |
1236 | | - | |
1237 | | - | |
1238 | 1236 | | |
1239 | 1237 | | |
1240 | 1238 | | |
| |||
1246 | 1244 | | |
1247 | 1245 | | |
1248 | 1246 | | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
1249 | 1254 | | |
1250 | 1255 | | |
1251 | 1256 | | |
1252 | 1257 | | |
1253 | 1258 | | |
1254 | 1259 | | |
1255 | 1260 | | |
1256 | | - | |
1257 | 1261 | | |
1258 | 1262 | | |
1259 | 1263 | | |
1260 | 1264 | | |
| 1265 | + | |
1261 | 1266 | | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
1262 | 1280 | | |
| 1281 | + | |
1263 | 1282 | | |
1264 | 1283 | | |
1265 | 1284 | | |
| |||
0 commit comments
Comments
(0)