On Tue, 26 Mar 2019 09:40:06 +0800
Yafang Shao <laoar.s...@gmail.com> wrote:

> The tracepoints trace_sched_stat_{iowait, blocked, wait, sleep} should
> be not exposed to user if CONFIG_SCHEDSTATS is not set.
> 
> Signed-off-by: Yafang Shao <laoar.s...@gmail.com>
> ---
>  include/trace/events/sched.h | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/include/trace/events/sched.h b/include/trace/events/sched.h
> index 9a4bdfa..4686c7f 100644
> --- a/include/trace/events/sched.h
> +++ b/include/trace/events/sched.h
> @@ -336,6 +336,7 @@ static inline long __trace_sched_switch_state(bool 
> preempt, struct task_struct *
>                 __entry->pid, __entry->old_pid)
>  );
>  
> +#ifdef CONFIG_SCHEDSTATS

Instead of doing this #ifdef here, perhaps we should have at the top of the 
file:

#ifdef CONFIG_SCHEDSTATS
# define TRACE_EVENT_SCHEDSTAT TRACE_EVENT
#else
# define TRACE_EVENT_SCHEDSTAT TRACE_EVENT_NOP
#endif

And then switch the sched stat tracepoints from TRACE_EVENT to
use TRACE_EVENT_SCHEDSTAT.

And if my magic macro hat is working while sitting on the shelf (don't
have time to put it on), then the TRACE_EVENT_SCHEDSTAT will work like
a TRACE_EVENT when enabled, and a TRACE_EVENT_NOP when not.

Can you give that a try?

If this works, you don't need to duplicate all the parameters again.

-- Steve

>  /*
>   * XXX the below sched_stat tracepoints only apply to
> SCHED_OTHER/BATCH/IDLE
>   *     adding sched_stat support to SCHED_FIFO/RR would be welcome.
> @@ -395,6 +396,19 @@ static inline long
> __trace_sched_switch_state(bool preempt, struct task_struct *
> TP_PROTO(struct task_struct *tsk, u64 delay), TP_ARGS(tsk, delay));
>  
> +#else /* CONFIG_SCHEDSTATS */
> +
> +TRACE_EVENT_NONE(sched_stat_wait,
> +              TP_PROTO(struct task_struct *tsk, u64 delay));
> +TRACE_EVENT_NONE(sched_stat_sleep,
> +              TP_PROTO(struct task_struct *tsk, u64 delay));
> +TRACE_EVENT_NONE(sched_stat_iowait,
> +              TP_PROTO(struct task_struct *tsk, u64 delay));
> +TRACE_EVENT_NONE(sched_stat_blocked,
> +              TP_PROTO(struct task_struct *tsk, u64 delay));
> +
> +#endif /* CONFIG_SCHEDSTATS */
> +
>  /*
>   * Tracepoint for accounting runtime (time the task is executing
>   * on a CPU).

Reply via email to