public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Yafang Shao <laoar.shao@gmail.com>
Cc: mingo@redhat.com, peterz@infradead.org,
	paulmck@linux.vnet.ibm.com, josh@joshtriplett.org,
	mathieu.desnoyers@efficios.com, jiangshanlai@gmail.com,
	joel@joelfernandes.org, shaoyafang@didiglobal.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] sched/fair: do not expose some tracepoints to user if CONFIG_SCHEDSTATS is not set
Date: Mon, 25 Mar 2019 22:21:05 -0400	[thread overview]
Message-ID: <20190325222105.637f7e23@oasis.local.home> (raw)
In-Reply-To: <1553564407-1162-3-git-send-email-laoar.shao@gmail.com>

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.

-- 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	other threads:[~2019-03-26  2:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-26  1:40 [PATCH 0/3] tracing: introduce TRACE_EVENT_NONE and use it Yafang Shao
2019-03-26  1:40 ` [PATCH 1/3] tracing: introduce TRACE_EVENT_NONE() Yafang Shao
2019-03-26  1:40 ` [PATCH 2/3] sched/fair: do not expose some tracepoints to user if CONFIG_SCHEDSTATS is not set Yafang Shao
2019-03-26  2:21   ` Steven Rostedt [this message]
2019-03-26  2:23     ` Yafang Shao
2019-03-26  1:40 ` [PATCH 3/3] rcu: validate arguments for rcu tracepoints Yafang Shao
2019-03-26 14:32   ` Paul E. McKenney
2019-03-26  2:17 ` [PATCH 0/3] tracing: introduce TRACE_EVENT_NONE and use it Steven Rostedt
2019-03-26  2:24   ` Yafang Shao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190325222105.637f7e23@oasis.local.home \
    --to=rostedt@goodmis.org \
    --cc=jiangshanlai@gmail.com \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=laoar.shao@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mingo@redhat.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=shaoyafang@didiglobal.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox