Message ID | 20171107160658.4839-1-patrick.bellasi@arm.com |
---|---|
State | Superseded |
Headers | show |
Series | sched: fix sched_feat for !SCHED_DEBUG builds | expand |
On Tue, Nov 07, 2017 at 04:06:58PM +0000, Patrick Bellasi wrote: > For this mechanism to properly work it's required for the compiler to > have full access, from each translation unit, to whatever is the value > defined by the sched_feat macro. > 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 the > 99 percentile. > Ack
* tip-bot for Patrick Bellasi <tipbot@zytor.com> wrote: > Commit-ID: 692ee9a79c14c9f707eeb03754a26b9427c0e005 > Gitweb: https://git.kernel.org/tip/692ee9a79c14c9f707eeb03754a26b9427c0e005 > Author: Patrick Bellasi <patrick.bellasi@arm.com> > AuthorDate: Tue, 7 Nov 2017 16:06:58 +0000 > Committer: Ingo Molnar <mingo@kernel.org> > CommitDate: Wed, 8 Nov 2017 10:17:29 +0100 > > sched/core: Optimize sched_feat() for !SCHED_DEBUG builds Hm, I noticed this too late, but lots of architecture defconfig builds now produce a ton of warnings: In file included from /home/mingo/tip/kernel/sched/idle.c:19:0: /home/mingo/tip/kernel/sched/sched.h:1275:33: warning: 'sysctl_sched_features' defined but not used [-Wunused-variable] static const_debug unsigned int sysctl_sched_features = ^ I'm dropping this patch for now. Thanks, Ingo
On 08-Nov 11:03, Ingo Molnar wrote: > > * tip-bot for Patrick Bellasi <tipbot@zytor.com> wrote: > > > Commit-ID: 692ee9a79c14c9f707eeb03754a26b9427c0e005 > > Gitweb: https://git.kernel.org/tip/692ee9a79c14c9f707eeb03754a26b9427c0e005 > > Author: Patrick Bellasi <patrick.bellasi@arm.com> > > AuthorDate: Tue, 7 Nov 2017 16:06:58 +0000 > > Committer: Ingo Molnar <mingo@kernel.org> > > CommitDate: Wed, 8 Nov 2017 10:17:29 +0100 > > > > sched/core: Optimize sched_feat() for !SCHED_DEBUG builds > > Hm, I noticed this too late, but lots of architecture defconfig builds now produce > a ton of warnings: > > In file included from /home/mingo/tip/kernel/sched/idle.c:19:0: > /home/mingo/tip/kernel/sched/sched.h:1275:33: warning: 'sysctl_sched_features' defined but not used [-Wunused-variable] > static const_debug unsigned int sysctl_sched_features = > ^ > > I'm dropping this patch for now. Ok Ingo, thanks. Actually, my fault I did not checked archs other then arm64 and x86_64. I'll look into this and respin a clean new version. > Thanks, > > Ingo Cheers Patrick -- #include <best/regards.h> Patrick Bellasi
On 08-Nov 11:02, Patrick Bellasi wrote: > On 08-Nov 11:03, Ingo Molnar wrote: > > > > * tip-bot for Patrick Bellasi <tipbot@zytor.com> wrote: > > > > > Commit-ID: 692ee9a79c14c9f707eeb03754a26b9427c0e005 > > > Gitweb: https://git.kernel.org/tip/692ee9a79c14c9f707eeb03754a26b9427c0e005 > > > Author: Patrick Bellasi <patrick.bellasi@arm.com> > > > AuthorDate: Tue, 7 Nov 2017 16:06:58 +0000 > > > Committer: Ingo Molnar <mingo@kernel.org> > > > CommitDate: Wed, 8 Nov 2017 10:17:29 +0100 > > > > > > sched/core: Optimize sched_feat() for !SCHED_DEBUG builds > > > > Hm, I noticed this too late, but lots of architecture defconfig builds now produce > > a ton of warnings: > > > > In file included from /home/mingo/tip/kernel/sched/idle.c:19:0: > > /home/mingo/tip/kernel/sched/sched.h:1275:33: warning: 'sysctl_sched_features' defined but not used [-Wunused-variable] > > static const_debug unsigned int sysctl_sched_features = > > ^ Perhaps just using a "__maybe_unused" attribute should fix the problem. Going to compile test with some more archs, can you tell me a defconfig failing for you? > > I'm dropping this patch for now. > > Ok Ingo, thanks. > Actually, my fault I did not checked archs other then arm64 and x86_64. > I'll look into this and respin a clean new version. > > > Thanks, > > > > Ingo > > Cheers Patrick > > -- > #include <best/regards.h> > > Patrick Bellasi -- #include <best/regards.h> Patrick Bellasi
* Patrick Bellasi <patrick.bellasi@arm.com> wrote: > On 08-Nov 11:02, Patrick Bellasi wrote: > > On 08-Nov 11:03, Ingo Molnar wrote: > > > > > > * tip-bot for Patrick Bellasi <tipbot@zytor.com> wrote: > > > > > > > Commit-ID: 692ee9a79c14c9f707eeb03754a26b9427c0e005 > > > > Gitweb: https://git.kernel.org/tip/692ee9a79c14c9f707eeb03754a26b9427c0e005 > > > > Author: Patrick Bellasi <patrick.bellasi@arm.com> > > > > AuthorDate: Tue, 7 Nov 2017 16:06:58 +0000 > > > > Committer: Ingo Molnar <mingo@kernel.org> > > > > CommitDate: Wed, 8 Nov 2017 10:17:29 +0100 > > > > > > > > sched/core: Optimize sched_feat() for !SCHED_DEBUG builds > > > > > > Hm, I noticed this too late, but lots of architecture defconfig builds now produce > > > a ton of warnings: > > > > > > In file included from /home/mingo/tip/kernel/sched/idle.c:19:0: > > > /home/mingo/tip/kernel/sched/sched.h:1275:33: warning: 'sysctl_sched_features' defined but not used [-Wunused-variable] > > > static const_debug unsigned int sysctl_sched_features = > > > ^ > > Perhaps just using a "__maybe_unused" attribute should fix the problem. Yeah, that would be OK in this case. > Going to compile test with some more archs, can you tell me a > defconfig failing for you? Alpha was one of them - don't have the logs of the other warnings anymore. Thanks, Ingo
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index d17c5da523a0..0edb08716555 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -42,18 +42,21 @@ DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); +#if defined(CONFIG_SCHED_DEBUG) && defined(HAVE_JUMP_LABEL) /* * Debugging: various feature bits + * + * If SCHED_DEBUG is disabled, each compilation unit has its own copy of + * sysctl_sched_features, defined in sched.h, to allow constants propagation + * at compile time and compiler optimization based on features default. */ - #define SCHED_FEAT(name, enabled) \ (1UL << __SCHED_FEAT_##name) * enabled | - const_debug unsigned int sysctl_sched_features = #include "features.h" 0; - #undef SCHED_FEAT +#endif /* * Number of tasks to iterate in a single balance run. diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 3b448ba82225..e1666b3e2fb2 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1219,8 +1219,6 @@ static inline void __set_task_cpu(struct task_struct *p, unsigned int cpu) # define const_debug const #endif -extern const_debug unsigned int sysctl_sched_features; - #define SCHED_FEAT(name, enabled) \ __SCHED_FEAT_##name , @@ -1232,6 +1230,13 @@ enum { #undef SCHED_FEAT #if defined(CONFIG_SCHED_DEBUG) && defined(HAVE_JUMP_LABEL) + +/* + * To support run-time toggling of sched features, all the translation units + * (but core.c) reference the sysctl_sched_features defined in core.c. + */ +extern const_debug unsigned int sysctl_sched_features; + #define SCHED_FEAT(name, enabled) \ static __always_inline bool static_branch_##name(struct static_key *key) \ { \ @@ -1239,13 +1244,27 @@ static __always_inline bool static_branch_##name(struct static_key *key) \ } #include "features.h" - #undef SCHED_FEAT extern struct static_key sched_feat_keys[__SCHED_FEAT_NR]; #define sched_feat(x) (static_branch_##x(&sched_feat_keys[__SCHED_FEAT_##x])) + #else /* !(SCHED_DEBUG && HAVE_JUMP_LABEL) */ + +/* + * Each translation unit has its own copy of sysctl_sched_features to allow + * constants propagation at compile time and compiler optimization based on + * features default. + */ +#define SCHED_FEAT(name, enabled) \ + (1UL << __SCHED_FEAT_##name) * enabled | +static const_debug unsigned int sysctl_sched_features = +#include "features.h" + 0; +#undef SCHED_FEAT + #define sched_feat(x) (sysctl_sched_features & (1UL << __SCHED_FEAT_##x)) + #endif /* SCHED_DEBUG && HAVE_JUMP_LABEL */ extern struct static_key_false sched_numa_balancing;