Skip to content

Commit 2a09b5d

Browse files
laoarrostedt
authored andcommitted
sched/fair: do not expose some tracepoints to user if CONFIG_SCHEDSTATS is not set
The tracepoints trace_sched_stat_{iowait, blocked, wait, sleep} should be not exposed to user if CONFIG_SCHEDSTATS is not set. Link: http://lkml.kernel.org/r/[email protected] Acked-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Yafang Shao <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 1633634 commit 2a09b5d

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

include/trace/events/sched.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ DECLARE_EVENT_CLASS(sched_process_template,
241241
DEFINE_EVENT(sched_process_template, sched_process_free,
242242
TP_PROTO(struct task_struct *p),
243243
TP_ARGS(p));
244-
245244

246245
/*
247246
* Tracepoint for a task exiting:
@@ -336,11 +335,20 @@ TRACE_EVENT(sched_process_exec,
336335
__entry->pid, __entry->old_pid)
337336
);
338337

338+
339+
#ifdef CONFIG_SCHEDSTATS
340+
#define DEFINE_EVENT_SCHEDSTAT DEFINE_EVENT
341+
#define DECLARE_EVENT_CLASS_SCHEDSTAT DECLARE_EVENT_CLASS
342+
#else
343+
#define DEFINE_EVENT_SCHEDSTAT DEFINE_EVENT_NOP
344+
#define DECLARE_EVENT_CLASS_SCHEDSTAT DECLARE_EVENT_CLASS_NOP
345+
#endif
346+
339347
/*
340348
* XXX the below sched_stat tracepoints only apply to SCHED_OTHER/BATCH/IDLE
341349
* adding sched_stat support to SCHED_FIFO/RR would be welcome.
342350
*/
343-
DECLARE_EVENT_CLASS(sched_stat_template,
351+
DECLARE_EVENT_CLASS_SCHEDSTAT(sched_stat_template,
344352

345353
TP_PROTO(struct task_struct *tsk, u64 delay),
346354

@@ -363,35 +371,34 @@ DECLARE_EVENT_CLASS(sched_stat_template,
363371
(unsigned long long)__entry->delay)
364372
);
365373

366-
367374
/*
368375
* Tracepoint for accounting wait time (time the task is runnable
369376
* but not actually running due to scheduler contention).
370377
*/
371-
DEFINE_EVENT(sched_stat_template, sched_stat_wait,
378+
DEFINE_EVENT_SCHEDSTAT(sched_stat_template, sched_stat_wait,
372379
TP_PROTO(struct task_struct *tsk, u64 delay),
373380
TP_ARGS(tsk, delay));
374381

375382
/*
376383
* Tracepoint for accounting sleep time (time the task is not runnable,
377384
* including iowait, see below).
378385
*/
379-
DEFINE_EVENT(sched_stat_template, sched_stat_sleep,
386+
DEFINE_EVENT_SCHEDSTAT(sched_stat_template, sched_stat_sleep,
380387
TP_PROTO(struct task_struct *tsk, u64 delay),
381388
TP_ARGS(tsk, delay));
382389

383390
/*
384391
* Tracepoint for accounting iowait time (time the task is not runnable
385392
* due to waiting on IO to complete).
386393
*/
387-
DEFINE_EVENT(sched_stat_template, sched_stat_iowait,
394+
DEFINE_EVENT_SCHEDSTAT(sched_stat_template, sched_stat_iowait,
388395
TP_PROTO(struct task_struct *tsk, u64 delay),
389396
TP_ARGS(tsk, delay));
390397

391398
/*
392399
* Tracepoint for accounting blocked time (time the task is in uninterruptible).
393400
*/
394-
DEFINE_EVENT(sched_stat_template, sched_stat_blocked,
401+
DEFINE_EVENT_SCHEDSTAT(sched_stat_template, sched_stat_blocked,
395402
TP_PROTO(struct task_struct *tsk, u64 delay),
396403
TP_ARGS(tsk, delay));
397404

0 commit comments

Comments
 (0)