From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752002AbdDMLGE (ORCPT ); Thu, 13 Apr 2017 07:06:04 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:40180 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750952AbdDMLGC (ORCPT ); Thu, 13 Apr 2017 07:06:02 -0400 Date: Thu, 13 Apr 2017 04:05:48 -0700 From: Srikar Dronamraju To: Steven Rostedt Cc: Mel Gorman , LKML , Peter Zijlstra , Ingo Molnar , Matt Fleming Subject: Re: [PATCH v2] sched: Enabled schedstat when schedstat tracepoints are enabled Reply-To: Srikar Dronamraju References: <20170412160432.481ee5fb@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20170412160432.481ee5fb@gandalf.local.home> User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-MML: disable x-cbid: 17041311-7323-0000-0000-000000EE0C7C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17041311-7324-0000-0000-00000293A13C Message-Id: <20170413110548.GL6820@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-04-13_10:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1704130093 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +#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) ???? 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