Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1632244imu; Fri, 9 Nov 2018 21:49:36 -0800 (PST) X-Google-Smtp-Source: AJdET5e0cfk8miHaGzmkkfyXQbAZRtzjfwc8tWlVdn/YXRggmb9Gvg7kFnz2hACgkl7BnuCrtk8F X-Received: by 2002:a17:902:7797:: with SMTP id o23-v6mr12013824pll.30.1541828976695; Fri, 09 Nov 2018 21:49:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541828976; cv=none; d=google.com; s=arc-20160816; b=UmbswierSmgG3MNXdpaAwBRIvn1IpqJ4gYa8Q3mQFmGH/aiFjRLu4H4+EKhuKDkwdk OZBRSz619h35EcdqLRwz2koGTsNj4+r1ZbHE8VOszfAzdfAdgQN6dMkmYlo4sMOP1Xfn 466+Ijr1FDk5Sm5EpDDBxRRwxcpJhxjuGl+6SVFI29VbuLKoGWkMP5LlGZ6sOlTEwzoS G5Ck6G5AvHhD7ZJNC34fUZDPgfMq4GH2RhaTlRz3KlE3SiPyVxk1WAhjCCGIJjbf+dPI 3FysvezZvujOVOzDymJVFlxgCRvWE/dvD9jrRk7L81mQR554Qqod+IWYokjzaGKcns13 Xrbw== 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=iT8PtsYJWFR5EJS04g2/rcjUYK6PYAAGIfvWIJURSKo=; b=wmZxZBMlmVq1SvUXHGRNEAwwVezr8gdMBJECtEzZOOwKjnURMjyOCSIlQSPGtHhlda UnGU/mnRAAFbL6H33/j+q7G4f+qxIr1OhpJst9oI9u2klnWQAKPIHhm/o50R2IpHm0z4 2edd0phkYPLvt4yBaFqiPz3l8DtXibbJ9ikdnCB4TTqZ4IO0EZUusBkyJCgE6JdaTcRR f5YpIv/Az1QmnuBp3uIRsOVlXNVlhbHrJZg894GxO/byskOWwS1QV0cM0TSP6jAld5A9 wHV3/Poyukva8ipJ9naEltAlnuO2RXElY5ec0aJwD7wrtGw0KTEbmmKquqotfNuvl34f DXIQ== 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 h13-v6si9188587pgj.457.2018.11.09.21.49.20; Fri, 09 Nov 2018 21:49:36 -0800 (PST) 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 S1728952AbeKJPbS convert rfc822-to-8bit (ORCPT + 99 others); Sat, 10 Nov 2018 10:31:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:56000 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728662AbeKJPbS (ORCPT ); Sat, 10 Nov 2018 10:31:18 -0500 Received: from vmware.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (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 5EF732081C; Sat, 10 Nov 2018 05:10:25 +0000 (UTC) Date: Sat, 10 Nov 2018 00:10:23 -0500 From: Steven Rostedt To: Josh Poimboeuf Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Ard Biesheuvel , Andy Lutomirski , Peter Zijlstra , Ingo Molnar , Thomas Gleixner , Linus Torvalds , Masami Hiramatsu , Jason Baron , Jiri Kosina , David Laight , Borislav Petkov Subject: Re: [RFC PATCH 1/3] static_call: Add static call infrastructure Message-ID: <20181110001023.57f27312@vmware.local.home> In-Reply-To: <20181109203459.wbftlkxcvfnwo2bm@treble> References: <3cf04e113d71c9f8e4be95fb84a510f085aa4afa.1541711457.git.jpoimboe@redhat.com> <20181109133337.63487e3a@gandalf.local.home> <20181109193505.5p5iddrtgpk2cpb4@treble> <20181109145746.0037da3f@gandalf.local.home> <20181109203459.wbftlkxcvfnwo2bm@treble> X-Mailer: Claws Mail 3.15.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 9 Nov 2018 14:34:59 -0600 Josh Poimboeuf wrote: I'm slowly massaging this to work with tracepoints. But I hit a snag on this patch. > On Fri, Nov 09, 2018 at 02:57:46PM -0500, Steven Rostedt wrote: > > On Fri, 9 Nov 2018 13:35:05 -0600 > > Josh Poimboeuf wrote: > > > > > > > > > +#define DECLARE_STATIC_CALL(key, func) \ > > > > > + extern struct static_call_key key; \ > > > > > + extern typeof(func) STATIC_CALL_TRAMP(key); \ > > > > > + /* Preserve the ELF symbol so objtool can access it: */ \ > > > > > + __ADDRESSABLE(key) > > > > > > > > Does the __ADDRESSABLE(key) need to be in the DECLARE part? > > > > If so, there needs to be more explanation than just the comment above > > > > it. > > > > > > For each call site, objtool creates a struct in .static_call_sites: > > > > > > struct static_call_site { > > > s32 addr; > > > s32 key; > > > }; > > > > > > In order to do that, it needs to create a relocation which references > > > the key symbol. If the key is defined in another .o file, then the > > > current .o will not have an ELF symbol associated with the key. The > > > __ADDRESSABLE(key) thing tells GCC to leave the key symbol in the .o > > > file, even though it's not referenced anywhere. That makes objtool's > > > job easier, so it doesn't have to edit the symbol table. > > > > > > I could add a comment saying as much, though it's hard to explain it in > > > fewer words than I just did :-) > > > > Does this have to do with adding the references by relative address? > > > > In record_mcount, I just picked an existing symbol and referenced that.. > > But perhaps this is a cleaner way. > > I think recordmcount is different. It creates references (in > __mcount_loc) to functions which are already in the object file, so they > already have symbols associated with them. > > But in this case, when objtool is creating references, the symbol it > needs to reference is outside the .o file, so there's no symbol to > associate it with. > The __ADDRESSABLE() appears to fail if you have a header with a DECLARE_STATIC_CALL() that is included where the DEFINE_STATIC_CALL() is, because I'm getting this: In file included from : /work/git/linux-trace.git/include/linux/compiler.h:285:11: error: redefinition of ‘__addressable___tp_func_sys_enter40’ __PASTE(__addressable_##sym, __LINE__) = (void *)&sym; ^~~~~~~~~~~~~~ /work/git/linux-trace.git/include/linux/compiler_types.h:53:23: note: in definition of macro ‘___PASTE’ #define ___PASTE(a,b) a##b ^ /work/git/linux-trace.git/include/linux/compiler.h:285:3: note: in expansion of macro ‘__PASTE’ __PASTE(__addressable_##sym, __LINE__) = (void *)&sym; ^~~~~~~ /work/git/linux-trace.git/include/linux/static_call.h:112:2: note: in expansion of macro ‘__ADDRESSABLE’ __ADDRESSABLE(key) ^~~~~~~~~~~~~ /work/git/linux-trace.git/include/linux/static_call.h:115:2: note: in expansion of macro ‘DECLARE_STATIC_CALL’ DECLARE_STATIC_CALL(key, _func); \ ^~~~~~~~~~~~~~~~~~~ /work/git/linux-trace.git/include/linux/tracepoint.h:310:2: note: in expansion of macro ‘DEFINE_STATIC_CALL’ DEFINE_STATIC_CALL(__tp_func_##name, __tracepoint_iter_##name); ^~~~~~~~~~~~~~~~~~ /work/git/linux-trace.git/include/trace/define_trace.h:42:2: note: in expansion of macro ‘DEFINE_TRACE_FN’ DEFINE_TRACE_FN(name, reg, unreg, PARAMS(proto), PARAMS(args)) ^~~~~~~~~~~~~~~ /work/git/linux-trace.git/include/trace/events/syscalls.h:18:1: note: in expansion of macro ‘TRACE_EVENT_FN’ TRACE_EVENT_FN(sys_enter, ^~~~~~~~~~~~~~ /work/git/linux-trace.git/include/linux/compiler.h:285:11: note: previous definition of ‘__addressable___tp_func_sys_enter40’ was here __PASTE(__addressable_##sym, __LINE__) = (void *)&sym; ^~~~~~~~~~~~~~ /work/git/linux-trace.git/include/linux/compiler_types.h:53:23: note: in definition of macro ‘___PASTE’ #define ___PASTE(a,b) a##b ^ /work/git/linux-trace.git/include/linux/compiler.h:285:3: note: in expansion of macro ‘__PASTE’ __PASTE(__addressable_##sym, __LINE__) = (void *)&sym; ^~~~~~~ /work/git/linux-trace.git/include/linux/static_call.h:112:2: note: in expansion of macro ‘__ADDRESSABLE’ __ADDRESSABLE(key) ^~~~~~~~~~~~~ /work/git/linux-trace.git/include/linux/tracepoint.h:234:2: note: in expansion of macro ‘DECLARE_STATIC_CALL’ DECLARE_STATIC_CALL(__tp_func_##name, __tracepoint_iter_##name); \ ^~~~~~~~~~~~~~~~~~~ /work/git/linux-trace.git/include/linux/tracepoint.h:421:2: note: in expansion of macro ‘__DECLARE_TRACE’ __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), \ ^~~~~~~~~~~~~~~ /work/git/linux-trace.git/include/linux/tracepoint.h:560:2: note: in expansion of macro ‘DECLARE_TRACE’ DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)) ^~~~~~~~~~~~~ /work/git/linux-trace.git/include/trace/events/syscalls.h:18:1: note: in expansion of macro ‘TRACE_EVENT_FN’ TRACE_EVENT_FN(sys_enter, The complaint is on: DEFINE_STATIC_CALL(__tp_func_##name, __tracepoint_iter_##name); And the previous definition is on: DECLARE_STATIC_CALL(__tp_func_##name, __tracepoint_iter_##name); \ -- Steve