From patchwork Thu Sep 24 17:09:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 11798017 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7D8D559D for ; Thu, 24 Sep 2020 17:18:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0F20D2396E for ; Thu, 24 Sep 2020 17:18:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F20D2396E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BF5986B005D; Thu, 24 Sep 2020 13:18:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9AD756B006E; Thu, 24 Sep 2020 13:18:51 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D8976B0068; Thu, 24 Sep 2020 13:18:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0026.hostedemail.com [216.40.44.26]) by kanga.kvack.org (Postfix) with ESMTP id 3C1CD6B0062 for ; Thu, 24 Sep 2020 13:18:51 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 013B03651 for ; Thu, 24 Sep 2020 17:18:50 +0000 (UTC) X-FDA: 77298614862.13.bone23_3c0a9ef27160 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id CE7E8181415A0 for ; Thu, 24 Sep 2020 17:18:50 +0000 (UTC) X-Spam-Summary: 1,0,0,45b0b085c2a702ef,d41d8cd98f00b204,srs0=be04=db=goodmis.org=rostedt@kernel.org,,RULES_HIT:41:69:355:379:960:967:973:988:989:1183:1260:1345:1434:1437:1534:1542:1711:1730:1747:1777:1792:2194:2199:2393:2525:2553:2559:2563:2682:2685:2859:2902:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4321:4605:5007:6119:6261:6742:7903:7904:8660:9025:10004:11026:11473:11658:11914:12043:12114:12291:12296:12297:12517:12519:12555:12679:12683:12700:12737:12986:13148:13161:13229:13230:14096:14181:14394:14721:21067:21080:21433:21451:21627:21939:30012:30054:30070:30090,0,RBL:198.145.29.99:@kernel.org:.lbl8.mailshell.net-64.100.201.201 62.2.0.100;04ygjqxx56wzh6mbw8xhosfaxy4rhocqz5nx1y3picbx9i4n8aonosi3jgb9gob.joupoh9oub56pzraq339to9wwk9wwe34s59wu1m6wn88zy389xcy7nqs3szy7jy.a-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCa che:0,MS X-HE-Tag: bone23_3c0a9ef27160 X-Filterd-Recvd-Size: 3441 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Thu, 24 Sep 2020 17:18:50 +0000 (UTC) Received: from gandalf.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 1184B2395C; Thu, 24 Sep 2020 17:18:49 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.94) (envelope-from ) id 1kLUtK-0029ba-VA; Thu, 24 Sep 2020 13:18:46 -0400 Message-ID: <20200924170928.466191266@goodmis.org> User-Agent: quilt/0.66 Date: Thu, 24 Sep 2020 13:09:28 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Yafang Shao , Axel Rasmussen , Andrew Morton , Vlastimil Babka , Michel Lespinasse , Daniel Jordan , Davidlohr Bueso , Linux MM , Ingo Molnar , Joonsoo Kim , Mathieu Desnoyers Subject: [PATCH 0/2] tracing/mm: Add tracepoint_enabled() helper function for headers X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Tracepoints are not safe to be called directly from header files as they may be included by C code that has CREATE_TRACE_POINTS defined, and this would cause side effects and possibly break the build in hard to debug ways. Instead, it is recommended to call a tracepoint helper function that is defined in a C file that calls the tracepoint. But we would only want this function to be called if the tracepoint is enabled, as function calls add overhead. The trace__enabled() function is also no safe to be called in a header file as it is created by the tracepoint header, which suffers the same fate if CREATE_TRACE_POINTS is defined. Instead, the tracepoint needs to be declared as an extern, and the helper function can test the static key to call the helper function that calls the tracepoint. This has been done by open coding the tracepoint extern and calling the static key directly: commit 95813b8faa0cd ("mm/page_ref: add tracepoint to track down page reference manipulation") does this (back in 2016). Now we have another use case, so a helper function should be created to keep the internals of the tracepoints from being spread out in other subsystems. Link: https://lore.kernel.org/r/20200922125113.12ef1e03@gandalf.local.home This adds tracepoint_enabled() helper macro and DECLARE_TRACEPOINT() macro to allow this to be done without exposing the internals of the tracepoints. The first patch adds the infrastructure, the second converts page_ref over to it. I also noticed that the msr tracepoint needs to be converted as well. Steven Rostedt (VMware) (2): tracepoints: Add helper to test if tracepoint is enabled in a header mm/page_ref: Convert the open coded tracepoint enabled to the new helper ---- Documentation/trace/tracepoints.rst | 25 ++++++++++++++++++++++ include/linux/page_ref.h | 42 ++++++++++++++++++------------------- include/linux/tracepoint-defs.h | 33 +++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 21 deletions(-)