lkml.org 
[lkml]   [2019]   [Mar]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 2/3] sched/fair: do not expose some tracepoints to user if CONFIG_SCHEDSTATS is not set
On Tue, Mar 26, 2019 at 10:21 AM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Tue, 26 Mar 2019 09:40:06 +0800
> Yafang Shao <laoar.shao@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.shao@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.
>

You proposal seems like a better solution.
I will have a try.
Thanks for your suggestion.

-Yafang

>
> > /*
> > * 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).
>

\
 
 \ /
  Last update: 2019-03-26 03:24    [W:0.036 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site