Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sched/debug: Make CONFIG_SCHED_DEBUG functionality unconditional

All the big Linux distros enable CONFIG_SCHED_DEBUG, because
the various features it provides help not just with kernel
development, but with system administration and user-space
software development as well.

Reflect this reality and enable this functionality
unconditionally.

Signed-off-by: Ingo Molnar <mingo@kernel.org>
Tested-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Juri Lelli <juri.lelli@redhat.com>
Cc: Vincent Guittot <vincent.guittot@linaro.org>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Ben Segall <bsegall@google.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Valentin Schneider <vschneid@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20250317104257.3496611-4-mingo@kernel.org

+9 -108
-7
fs/proc/base.c
··· 1489 1489 #endif 1490 1490 1491 1491 1492 - #ifdef CONFIG_SCHED_DEBUG 1493 1492 /* 1494 1493 * Print out various scheduling related per-task fields: 1495 1494 */ ··· 1537 1538 .llseek = seq_lseek, 1538 1539 .release = single_release, 1539 1540 }; 1540 - 1541 - #endif 1542 1541 1543 1542 #ifdef CONFIG_SCHED_AUTOGROUP 1544 1543 /* ··· 3328 3331 ONE("status", S_IRUGO, proc_pid_status), 3329 3332 ONE("personality", S_IRUSR, proc_pid_personality), 3330 3333 ONE("limits", S_IRUGO, proc_pid_limits), 3331 - #ifdef CONFIG_SCHED_DEBUG 3332 3334 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations), 3333 - #endif 3334 3335 #ifdef CONFIG_SCHED_AUTOGROUP 3335 3336 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations), 3336 3337 #endif ··· 3677 3682 ONE("status", S_IRUGO, proc_pid_status), 3678 3683 ONE("personality", S_IRUSR, proc_pid_personality), 3679 3684 ONE("limits", S_IRUGO, proc_pid_limits), 3680 - #ifdef CONFIG_SCHED_DEBUG 3681 3685 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations), 3682 - #endif 3683 3686 NOD("comm", S_IFREG|S_IRUGO|S_IWUSR, 3684 3687 &proc_tid_comm_inode_operations, 3685 3688 &proc_pid_set_comm_operations, {}),
-2
include/linux/energy_model.h
··· 240 240 struct em_perf_state *ps; 241 241 int i; 242 242 243 - #ifdef CONFIG_SCHED_DEBUG 244 243 WARN_ONCE(!rcu_read_lock_held(), "EM: rcu read lock needed\n"); 245 - #endif 246 244 247 245 if (!sum_util) 248 246 return 0;
-2
include/linux/sched/debug.h
··· 35 35 36 36 extern void sched_show_task(struct task_struct *p); 37 37 38 - #ifdef CONFIG_SCHED_DEBUG 39 38 struct seq_file; 40 39 extern void proc_sched_show_task(struct task_struct *p, 41 40 struct pid_namespace *ns, struct seq_file *m); 42 41 extern void proc_sched_set_task(struct task_struct *p); 43 - #endif 44 42 45 43 /* Attach to any functions which should be ignored in wchan output. */ 46 44 #define __sched __section(".sched.text")
-4
include/linux/sched/topology.h
··· 25 25 }; 26 26 #undef SD_FLAG 27 27 28 - #ifdef CONFIG_SCHED_DEBUG 29 - 30 28 struct sd_flag_debug { 31 29 unsigned int meta_flags; 32 30 char *name; 33 31 }; 34 32 extern const struct sd_flag_debug sd_flag_debug[]; 35 - 36 - #endif 37 33 38 34 #ifdef CONFIG_SCHED_SMT 39 35 static inline int cpu_smt_flags(void)
-2
include/trace/events/sched.h
··· 193 193 { 194 194 unsigned int state; 195 195 196 - #ifdef CONFIG_SCHED_DEBUG 197 196 BUG_ON(p != current); 198 - #endif /* CONFIG_SCHED_DEBUG */ 199 197 200 198 /* 201 199 * Preemption ignores task state, therefore preempted tasks are always
+1 -3
kernel/sched/build_utility.c
··· 68 68 # include "cpufreq_schedutil.c" 69 69 #endif 70 70 71 - #ifdef CONFIG_SCHED_DEBUG 72 - # include "debug.c" 73 - #endif 71 + #include "debug.c" 74 72 75 73 #ifdef CONFIG_SCHEDSTATS 76 74 # include "stats.c"
+3 -15
kernel/sched/core.c
··· 118 118 119 119 DEFINE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues); 120 120 121 - #ifdef CONFIG_SCHED_DEBUG 122 121 /* 123 122 * Debugging: various feature bits 124 123 * ··· 141 142 */ 142 143 __read_mostly int sysctl_resched_latency_warn_ms = 100; 143 144 __read_mostly int sysctl_resched_latency_warn_once = 1; 144 - #endif /* CONFIG_SCHED_DEBUG */ 145 145 146 146 /* 147 147 * Number of tasks to iterate in a single balance run. ··· 797 799 if (rq->clock_update_flags & RQCF_ACT_SKIP) 798 800 return; 799 801 800 - #ifdef CONFIG_SCHED_DEBUG 801 802 if (sched_feat(WARN_DOUBLE_CLOCK)) 802 803 WARN_ON_ONCE(rq->clock_update_flags & RQCF_UPDATED); 803 804 rq->clock_update_flags |= RQCF_UPDATED; 804 - #endif 805 + 805 806 clock = sched_clock_cpu(cpu_of(rq)); 806 807 scx_rq_clock_update(rq, clock); 807 808 ··· 3288 3291 3289 3292 void set_task_cpu(struct task_struct *p, unsigned int new_cpu) 3290 3293 { 3291 - #ifdef CONFIG_SCHED_DEBUG 3292 3294 unsigned int state = READ_ONCE(p->__state); 3293 3295 3294 3296 /* ··· 3325 3329 WARN_ON_ONCE(!cpu_online(new_cpu)); 3326 3330 3327 3331 WARN_ON_ONCE(is_migration_disabled(p)); 3328 - #endif 3329 3332 3330 3333 trace_sched_migrate_task(p, new_cpu); 3331 3334 ··· 5572 5577 return ns; 5573 5578 } 5574 5579 5575 - #ifdef CONFIG_SCHED_DEBUG 5576 5580 static u64 cpu_resched_latency(struct rq *rq) 5577 5581 { 5578 5582 int latency_warn_ms = READ_ONCE(sysctl_resched_latency_warn_ms); ··· 5616 5622 return 1; 5617 5623 } 5618 5624 __setup("resched_latency_warn_ms=", setup_resched_latency_warn_ms); 5619 - #else 5620 - static inline u64 cpu_resched_latency(struct rq *rq) { return 0; } 5621 - #endif /* CONFIG_SCHED_DEBUG */ 5622 5625 5623 5626 /* 5624 5627 * This function gets called by the timer code, with HZ frequency. ··· 6709 6718 picked: 6710 6719 clear_tsk_need_resched(prev); 6711 6720 clear_preempt_need_resched(); 6712 - #ifdef CONFIG_SCHED_DEBUG 6713 6721 rq->last_seen_need_resched_ns = 0; 6714 - #endif 6715 6722 6716 6723 if (likely(prev != next)) { 6717 6724 rq->nr_switches++; ··· 7083 7094 int default_wake_function(wait_queue_entry_t *curr, unsigned mode, int wake_flags, 7084 7095 void *key) 7085 7096 { 7086 - WARN_ON_ONCE(IS_ENABLED(CONFIG_SCHED_DEBUG) && wake_flags & ~(WF_SYNC|WF_CURRENT_CPU)); 7097 + WARN_ON_ONCE(wake_flags & ~(WF_SYNC|WF_CURRENT_CPU)); 7087 7098 return try_to_wake_up(curr->private, mode, wake_flags); 7088 7099 } 7089 7100 EXPORT_SYMBOL(default_wake_function); ··· 7800 7811 sched_show_task(p); 7801 7812 } 7802 7813 7803 - #ifdef CONFIG_SCHED_DEBUG 7804 7814 if (!state_filter) 7805 7815 sysrq_sched_debug_show(); 7806 - #endif 7816 + 7807 7817 rcu_read_unlock(); 7808 7818 /* 7809 7819 * Only show locks if all tasks are dumped:
-2
kernel/sched/deadline.c
··· 3574 3574 } 3575 3575 #endif 3576 3576 3577 - #ifdef CONFIG_SCHED_DEBUG 3578 3577 void print_dl_stats(struct seq_file *m, int cpu) 3579 3578 { 3580 3579 print_dl_rq(m, cpu, &cpu_rq(cpu)->dl); 3581 3580 } 3582 - #endif /* CONFIG_SCHED_DEBUG */
-4
kernel/sched/fair.c
··· 983 983 return best; 984 984 } 985 985 986 - #ifdef CONFIG_SCHED_DEBUG 987 986 struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq) 988 987 { 989 988 struct rb_node *last = rb_last(&cfs_rq->tasks_timeline.rb_root); ··· 1008 1009 1009 1010 return 0; 1010 1011 } 1011 - #endif 1012 1012 #endif 1013 1013 1014 1014 static void clear_buddies(struct cfs_rq *cfs_rq, struct sched_entity *se); ··· 13666 13668 #endif 13667 13669 }; 13668 13670 13669 - #ifdef CONFIG_SCHED_DEBUG 13670 13671 void print_cfs_stats(struct seq_file *m, int cpu) 13671 13672 { 13672 13673 struct cfs_rq *cfs_rq, *pos; ··· 13699 13702 rcu_read_unlock(); 13700 13703 } 13701 13704 #endif /* CONFIG_NUMA_BALANCING */ 13702 - #endif /* CONFIG_SCHED_DEBUG */ 13703 13705 13704 13706 __init void init_sched_fair_class(void) 13705 13707 {
+1 -4
kernel/sched/rt.c
··· 169 169 170 170 static inline struct task_struct *rt_task_of(struct sched_rt_entity *rt_se) 171 171 { 172 - #ifdef CONFIG_SCHED_DEBUG 173 172 WARN_ON_ONCE(!rt_entity_is_task(rt_se)); 174 - #endif 173 + 175 174 return container_of(rt_se, struct task_struct, rt); 176 175 } 177 176 ··· 2968 2969 } 2969 2970 #endif /* CONFIG_SYSCTL */ 2970 2971 2971 - #ifdef CONFIG_SCHED_DEBUG 2972 2972 void print_rt_stats(struct seq_file *m, int cpu) 2973 2973 { 2974 2974 rt_rq_iter_t iter; ··· 2978 2980 print_rt_rq(m, cpu, rt_rq); 2979 2981 rcu_read_unlock(); 2980 2982 } 2981 - #endif /* CONFIG_SCHED_DEBUG */
+4 -50
kernel/sched/sched.h
··· 1174 1174 1175 1175 atomic_t nr_iowait; 1176 1176 1177 - #ifdef CONFIG_SCHED_DEBUG 1178 1177 u64 last_seen_need_resched_ns; 1179 1178 int ticks_without_resched; 1180 - #endif 1181 1179 1182 1180 #ifdef CONFIG_MEMBARRIER 1183 1181 int membarrier_state; ··· 1704 1706 struct rq_flags { 1705 1707 unsigned long flags; 1706 1708 struct pin_cookie cookie; 1707 - #ifdef CONFIG_SCHED_DEBUG 1708 1709 /* 1709 1710 * A copy of (rq::clock_update_flags & RQCF_UPDATED) for the 1710 1711 * current pin context is stashed here in case it needs to be 1711 1712 * restored in rq_repin_lock(). 1712 1713 */ 1713 1714 unsigned int clock_update_flags; 1714 - #endif 1715 1715 }; 1716 1716 1717 1717 extern struct balance_callback balance_push_callback; ··· 1760 1764 { 1761 1765 rf->cookie = lockdep_pin_lock(__rq_lockp(rq)); 1762 1766 1763 - #ifdef CONFIG_SCHED_DEBUG 1764 1767 rq->clock_update_flags &= (RQCF_REQ_SKIP|RQCF_ACT_SKIP); 1765 1768 rf->clock_update_flags = 0; 1766 - # ifdef CONFIG_SMP 1769 + #ifdef CONFIG_SMP 1767 1770 WARN_ON_ONCE(rq->balance_callback && rq->balance_callback != &balance_push_callback); 1768 - # endif 1769 1771 #endif 1770 1772 } 1771 1773 1772 1774 static inline void rq_unpin_lock(struct rq *rq, struct rq_flags *rf) 1773 1775 { 1774 - #ifdef CONFIG_SCHED_DEBUG 1775 1776 if (rq->clock_update_flags > RQCF_ACT_SKIP) 1776 1777 rf->clock_update_flags = RQCF_UPDATED; 1777 - #endif 1778 + 1778 1779 scx_rq_clock_invalidate(rq); 1779 1780 lockdep_unpin_lock(__rq_lockp(rq), rf->cookie); 1780 1781 } ··· 1780 1787 { 1781 1788 lockdep_repin_lock(__rq_lockp(rq), rf->cookie); 1782 1789 1783 - #ifdef CONFIG_SCHED_DEBUG 1784 1790 /* 1785 1791 * Restore the value we stashed in @rf for this pin context. 1786 1792 */ 1787 1793 rq->clock_update_flags |= rf->clock_update_flags; 1788 - #endif 1789 1794 } 1790 1795 1791 1796 extern ··· 2057 2066 unsigned long next_update; 2058 2067 int imbalance; /* XXX unrelated to capacity but shared group state */ 2059 2068 2060 - #ifdef CONFIG_SCHED_DEBUG 2061 2069 int id; 2062 - #endif 2063 2070 2064 2071 unsigned long cpumask[]; /* Balance mask */ 2065 2072 }; ··· 2097 2108 2098 2109 extern int group_balance_cpu(struct sched_group *sg); 2099 2110 2100 - #ifdef CONFIG_SCHED_DEBUG 2101 2111 extern void update_sched_domain_debugfs(void); 2102 2112 extern void dirty_sched_domain_sysctl(int cpu); 2103 - #else 2104 - static inline void update_sched_domain_debugfs(void) { } 2105 - static inline void dirty_sched_domain_sysctl(int cpu) { } 2106 - #endif 2107 2113 2108 2114 extern int sched_update_scaling(void); 2109 2115 ··· 2191 2207 2192 2208 #undef SCHED_FEAT 2193 2209 2194 - #ifdef CONFIG_SCHED_DEBUG 2195 - 2196 2210 /* 2197 2211 * To support run-time toggling of sched features, all the translation units 2198 2212 * (but core.c) reference the sysctl_sched_features defined in core.c. ··· 2216 2234 #define sched_feat(x) (sysctl_sched_features & (1UL << __SCHED_FEAT_##x)) 2217 2235 2218 2236 #endif /* !CONFIG_JUMP_LABEL */ 2219 - 2220 - #else /* !SCHED_DEBUG: */ 2221 - 2222 - /* 2223 - * Each translation unit has its own copy of sysctl_sched_features to allow 2224 - * constants propagation at compile time and compiler optimization based on 2225 - * features default. 2226 - */ 2227 - #define SCHED_FEAT(name, enabled) \ 2228 - (1UL << __SCHED_FEAT_##name) * enabled | 2229 - static __read_mostly __maybe_unused unsigned int sysctl_sched_features = 2230 - #include "features.h" 2231 - 0; 2232 - #undef SCHED_FEAT 2233 - 2234 - #define sched_feat(x) !!(sysctl_sched_features & (1UL << __SCHED_FEAT_##x)) 2235 - 2236 - #endif /* !SCHED_DEBUG */ 2237 2237 2238 2238 extern struct static_key_false sched_numa_balancing; 2239 2239 extern struct static_key_false sched_schedstats; ··· 2801 2837 2802 2838 extern unsigned int sysctl_sched_base_slice; 2803 2839 2804 - #ifdef CONFIG_SCHED_DEBUG 2805 2840 extern int sysctl_resched_latency_warn_ms; 2806 2841 extern int sysctl_resched_latency_warn_once; 2807 2842 ··· 2811 2848 extern unsigned int sysctl_numa_balancing_scan_period_max; 2812 2849 extern unsigned int sysctl_numa_balancing_scan_size; 2813 2850 extern unsigned int sysctl_numa_balancing_hot_threshold; 2814 - #endif 2815 2851 2816 2852 #ifdef CONFIG_SCHED_HRTICK 2817 2853 ··· 2883 2921 } 2884 2922 #endif 2885 2923 2886 - #ifdef CONFIG_SCHED_DEBUG 2887 2924 /* 2888 2925 * In double_lock_balance()/double_rq_lock(), we use raw_spin_rq_lock() to 2889 2926 * acquire rq lock instead of rq_lock(). So at the end of these two functions ··· 2897 2936 rq2->clock_update_flags &= (RQCF_REQ_SKIP|RQCF_ACT_SKIP); 2898 2937 #endif 2899 2938 } 2900 - #else 2901 - static inline void double_rq_clock_clear_update(struct rq *rq1, struct rq *rq2) { } 2902 - #endif 2903 2939 2904 2940 #define DEFINE_LOCK_GUARD_2(name, type, _lock, _unlock, ...) \ 2905 2941 __DEFINE_UNLOCK_GUARD(name, type, _unlock, type *lock2; __VA_ARGS__) \ ··· 3109 3151 extern struct sched_entity *__pick_first_entity(struct cfs_rq *cfs_rq); 3110 3152 extern struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq); 3111 3153 3112 - #ifdef CONFIG_SCHED_DEBUG 3113 3154 extern bool sched_debug_verbose; 3114 3155 3115 3156 extern void print_cfs_stats(struct seq_file *m, int cpu); ··· 3119 3162 extern void print_dl_rq(struct seq_file *m, int cpu, struct dl_rq *dl_rq); 3120 3163 3121 3164 extern void resched_latency_warn(int cpu, u64 latency); 3122 - # ifdef CONFIG_NUMA_BALANCING 3165 + #ifdef CONFIG_NUMA_BALANCING 3123 3166 extern void show_numa_stats(struct task_struct *p, struct seq_file *m); 3124 3167 extern void 3125 3168 print_numa_stats(struct seq_file *m, int node, unsigned long tsf, 3126 3169 unsigned long tpf, unsigned long gsf, unsigned long gpf); 3127 - # endif /* CONFIG_NUMA_BALANCING */ 3128 - #else /* !CONFIG_SCHED_DEBUG: */ 3129 - static inline void resched_latency_warn(int cpu, u64 latency) { } 3130 - #endif /* !CONFIG_SCHED_DEBUG */ 3170 + #endif /* CONFIG_NUMA_BALANCING */ 3131 3171 3132 3172 extern void init_cfs_rq(struct cfs_rq *cfs_rq); 3133 3173 extern void init_rt_rq(struct rt_rq *rt_rq);
-13
kernel/sched/topology.c
··· 19 19 static cpumask_var_t sched_domains_tmpmask; 20 20 static cpumask_var_t sched_domains_tmpmask2; 21 21 22 - #ifdef CONFIG_SCHED_DEBUG 23 - 24 22 static int __init sched_debug_setup(char *str) 25 23 { 26 24 sched_debug_verbose = true; ··· 157 159 break; 158 160 } 159 161 } 160 - #else /* !CONFIG_SCHED_DEBUG */ 161 - 162 - # define sched_debug_verbose 0 163 - # define sched_domain_debug(sd, cpu) do { } while (0) 164 - static inline bool sched_debug(void) 165 - { 166 - return false; 167 - } 168 - #endif /* CONFIG_SCHED_DEBUG */ 169 162 170 163 /* Generate a mask of SD flags with the SDF_NEEDS_GROUPS metaflag */ 171 164 #define SD_FLAG(name, mflags) (name * !!((mflags) & SDF_NEEDS_GROUPS)) | ··· 2272 2283 if (!sgc) 2273 2284 return -ENOMEM; 2274 2285 2275 - #ifdef CONFIG_SCHED_DEBUG 2276 2286 sgc->id = j; 2277 - #endif 2278 2287 2279 2288 *per_cpu_ptr(sdd->sgc, j) = sgc; 2280 2289 }