From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754234AbdDMOOV (ORCPT ); Thu, 13 Apr 2017 10:14:21 -0400 Received: from mail.kernel.org ([198.145.29.136]:38324 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752422AbdDMOOT (ORCPT ); Thu, 13 Apr 2017 10:14:19 -0400 Date: Thu, 13 Apr 2017 10:14:15 -0400 From: Steven Rostedt To: Srikar Dronamraju Cc: Mel Gorman , LKML , Peter Zijlstra , Ingo Molnar , Matt Fleming Subject: Re: [PATCH v2] sched: Enabled schedstat when schedstat tracepoints are enabled Message-ID: <20170413101415.2947ca77@gandalf.local.home> In-Reply-To: <20170413110548.GL6820@linux.vnet.ibm.com> References: <20170412160432.481ee5fb@gandalf.local.home> <20170413110548.GL6820@linux.vnet.ibm.com> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; 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 List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 13 Apr 2017 04:05:48 -0700 Srikar Dronamraju wrote: > > +#if defined(CONFIG_TRACING) && defined(CONFIG_SCHEDSTATS) > > +int schedstat_tracepoint_reg(void); > > +void schedstat_tracepoint_unreg(void); > > +#else > > +static inline int schedstat_tracepoint_reg(void) { return 0; } > > +static inline void schedstat_tracepoint_unreg(void) { } > > +#endif > > + > > > > > > +#ifdef CONFIG_TRACING > > Shouldn't this be also > > +#if defined(CONFIG_TRACING) && defined(CONFIG_SCHEDSTATS) ???? This code is within a #ifdef CONFIG_SCHEDSTATS block. That would be redundant putting it here too. -- Steve > > If CONFIG_TRACING is defined but CONFIG_SCHEDSTATS is not then build > should complain about duplicate schedstat_tracepoint_reg(). No? > > > +static int schedstat_tracepoint_ref; > > +static bool schedstat_save_state; > > +/* > > + * schedstat_tracepoint_reg() and unreg() are called by the tracepoint > > + * regfunc/unregfunc functions. They are protected by the tracepoint mutex. > > + * See kernel/tracepoint.c:tracepoint_add_func(). > > + * > > + * The modifications to schedstat_tracepoint_ref and schedstat_save_state > > + * are only done under that mutex, and do not need further protection. > > + */ > > +int schedstat_tracepoint_reg(void) > > +{ > > + if (!schedstat_tracepoint_ref) { > > + schedstat_save_state = schedstat_enabled(); > > + if (!schedstat_save_state) > > + set_schedstats(true); > > + } > > + schedstat_tracepoint_ref++; > > + return 0; > > +} > > + > > +void schedstat_tracepoint_unreg(void) > > +{ > > + schedstat_tracepoint_ref--; > > + if (schedstat_tracepoint_ref || schedstat_save_state) > > + return; > > + set_schedstats(false); > > +} > > +#endif