Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3816998img; Mon, 25 Mar 2019 19:22:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqxy9e4Y/wOMP0nqIEuRW1ElB4vQfwKBEhUP5fpzq7XI1HUcEYYygL9BIELSA5vGxrOdGCOT X-Received: by 2002:a63:f541:: with SMTP id e1mr26223620pgk.388.1553566938915; Mon, 25 Mar 2019 19:22:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553566938; cv=none; d=google.com; s=arc-20160816; b=ljS/eNtFdTD3bm5q/bhfN3Kk7yUtvhG0zFqLTzFFqHxeyx2xeN1zkvRPmzVVSrCpCw mxgOXQiR7A1poFNQEcBNiWUnNRJoEvoGodv4ppM7021D5DtMarCWSuA7vVNX7R9U2Zna tKAb/eJMlCtV5I12vb7K6jmXHHVv2L8Cf8PnGSk2GbCkc5NNG0UyHHD4s3F3SuMuny/x vzllNDfHHwCSE1zQrsXXjyyXRR3VvxmHtJPX6Dda1MZbwIeOsVol/GPQdoASVqcnY6kg LpIjJrBXbdAg76ly9b75mS3+7i3Qht2yQhGkJXihkCPxfCDUJsPiKo80tQhqZ1HMo0B6 nRbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=CjsSUHtA6zIQJ7eGjWMa3vhBIzFI2xtRKUjAaLGD4HM=; b=FNZ028ZgIBYsJDjlUWMTIwZkEmsuapatOHiAIoW0qam4vpxFD+51Q1Of5EWWPVuiPG swTtei+TEshvT/WFb/xf/DrfqgZPdTLAT9sEZ1+Fk4jJaGPAlEQe4w6dKKM2zhho39gH pFLub7i6nFbH596BjUsyxJhkvv52h6D43GHX3+U4WFB8o5oByFsk4iFT5QeBiuzEZc64 peC1Xsa/w9BibD6kfPXFTvckpFm0GW2rcnj+zl56JSkawGpIIzkNj/wztFIdZtjTCwWV 6OdpVT2JhZuJtb9bPUhblgggP0WGnEBPrDM/V2MK6g5doz0CBJIL15/XgAniIDT48Miz RCDQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q189si15020528pga.544.2019.03.25.19.22.04; Mon, 25 Mar 2019 19:22:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730981AbfCZCVJ (ORCPT + 99 others); Mon, 25 Mar 2019 22:21:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:37820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730533AbfCZCVI (ORCPT ); Mon, 25 Mar 2019 22:21:08 -0400 Received: from oasis.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 49C1F20823; Tue, 26 Mar 2019 02:21:07 +0000 (UTC) Date: Mon, 25 Mar 2019 22:21:05 -0400 From: Steven Rostedt To: Yafang Shao 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 Message-ID: <20190325222105.637f7e23@oasis.local.home> In-Reply-To: <1553564407-1162-3-git-send-email-laoar.shao@gmail.com> References: <1553564407-1162-1-git-send-email-laoar.shao@gmail.com> <1553564407-1162-3-git-send-email-laoar.shao@gmail.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 26 Mar 2019 09:40:06 +0800 Yafang Shao 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 > --- > 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).