Skip to content

Commit a73f863

Browse files
jlelliIngo Molnar
authored andcommitted
sched/features: Fix !CONFIG_JUMP_LABEL case
Commit: 765cc3a ("sched/core: Optimize sched_feat() for !CONFIG_SCHED_DEBUG builds") made sched features static for !CONFIG_SCHED_DEBUG configurations, but overlooked the CONFIG_SCHED_DEBUG=y and !CONFIG_JUMP_LABEL cases. For the latter echoing changes to /sys/kernel/debug/sched_features has the nasty effect of effectively changing what sched_features reports, but without actually changing the scheduler behaviour (since different translation units get different sysctl_sched_features). Fix CONFIG_SCHED_DEBUG=y and !CONFIG_JUMP_LABEL configurations by properly restructuring ifdefs. Fixes: 765cc3a ("sched/core: Optimize sched_feat() for !CONFIG_SCHED_DEBUG builds") Co-developed-by: Daniel Bristot de Oliveira <[email protected]> Signed-off-by: Daniel Bristot de Oliveira <[email protected]> Signed-off-by: Juri Lelli <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Acked-by: Patrick Bellasi <[email protected]> Reviewed-by: Valentin Schneider <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent eba9f08 commit a73f863

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

kernel/sched/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(sched_update_nr_running_tp);
4444

4545
DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues);
4646

47-
#if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_JUMP_LABEL)
47+
#ifdef CONFIG_SCHED_DEBUG
4848
/*
4949
* Debugging: various feature bits
5050
*

kernel/sched/sched.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,14 +1629,15 @@ enum {
16291629

16301630
#undef SCHED_FEAT
16311631

1632-
#if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_JUMP_LABEL)
1632+
#ifdef CONFIG_SCHED_DEBUG
16331633

16341634
/*
16351635
* To support run-time toggling of sched features, all the translation units
16361636
* (but core.c) reference the sysctl_sched_features defined in core.c.
16371637
*/
16381638
extern const_debug unsigned int sysctl_sched_features;
16391639

1640+
#ifdef CONFIG_JUMP_LABEL
16401641
#define SCHED_FEAT(name, enabled) \
16411642
static __always_inline bool static_branch_##name(struct static_key *key) \
16421643
{ \
@@ -1649,7 +1650,13 @@ static __always_inline bool static_branch_##name(struct static_key *key) \
16491650
extern struct static_key sched_feat_keys[__SCHED_FEAT_NR];
16501651
#define sched_feat(x) (static_branch_##x(&sched_feat_keys[__SCHED_FEAT_##x]))
16511652

1652-
#else /* !(SCHED_DEBUG && CONFIG_JUMP_LABEL) */
1653+
#else /* !CONFIG_JUMP_LABEL */
1654+
1655+
#define sched_feat(x) (sysctl_sched_features & (1UL << __SCHED_FEAT_##x))
1656+
1657+
#endif /* CONFIG_JUMP_LABEL */
1658+
1659+
#else /* !SCHED_DEBUG */
16531660

16541661
/*
16551662
* Each translation unit has its own copy of sysctl_sched_features to allow
@@ -1665,7 +1672,7 @@ static const_debug __maybe_unused unsigned int sysctl_sched_features =
16651672

16661673
#define sched_feat(x) !!(sysctl_sched_features & (1UL << __SCHED_FEAT_##x))
16671674

1668-
#endif /* SCHED_DEBUG && CONFIG_JUMP_LABEL */
1675+
#endif /* SCHED_DEBUG */
16691676

16701677
extern struct static_key_false sched_numa_balancing;
16711678
extern struct static_key_false sched_schedstats;

0 commit comments

Comments
 (0)