Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp599857ybz; Wed, 15 Apr 2020 14:54:13 -0700 (PDT) X-Google-Smtp-Source: APiQypJ1+b5keW/sh0yIt9jyZHqOQJ7mNsgctvNljdNP2ah5td2G3WqB/ZN715ca5VJTF5XXuWCG X-Received: by 2002:aa7:cdce:: with SMTP id h14mr19293206edw.51.1586987653209; Wed, 15 Apr 2020 14:54:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586987653; cv=none; d=google.com; s=arc-20160816; b=jiZ1C++JnDpG4Xtq6qrgym8ZoRT0Rfi5HXEtDQK7clK8HESk8ZWAqRHUxs6tk124Ue w2c/mPvBBTRsed5gAMZnTEihps0Cu5dNsRermMYtZFLQfQMy3oi/fQq3yiwuo8uIiFrM OieOrG+0fPpYTulDWRmueB/5RnwbLoSxzGMe8ejWaI5if9zc/JjhdGUjl0c2iyxDFbT3 R3cWqkFA+r4fqfHStoN0RrBduniv9C2z70IA62UvKix3+A2R19smgPLtYkoB2Sc/BZAC 8CcRjoT2u6mMR7GVOrRkEHcRDhGoDWfpGRjZ5lXVpsXphvGvJVH8VW1FNW7lvOA1m4SK 4Njw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date; bh=DDcPJdDd1/6QsITWhxjI2Ygj7cvxwKCB0UymD/XUboM=; b=Vd76yP3F/MjjcvHbKIiorRbd4u5ow4YpCzI02u0iM3tSKHRlK4iuUid0wzriShNIQA 4lyz3o8cIz8H/q18cjs3KWuQPVE4l5eFRXFbIixK28CDIDMALSCwiSdWs+BTACIiNX3+ OS4xdV2MqkzbkjKdGxqzPGlgo0jeDCSNfveACJymdArakA+5wyccYXkiKuDAKPeoKEK2 QyjYMf2l7t2reuLvyXpx//63bOfeEr1GqsPFAyfftv4i4QRQLUI+8h3rWdMoCI1XFKst suIFHTSAkPRnLCT5AFIMdi3yR+09PG8xpDuC6l15RNjMYPz5K/bVkyYaE7vWvgNDO4lC kTQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vmware.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i9si10849278edv.230.2020.04.15.14.53.48; Wed, 15 Apr 2020 14:54:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vmware.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2505490AbgDNUJL (ORCPT + 99 others); Tue, 14 Apr 2020 16:09:11 -0400 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:14482 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2505445AbgDNUJL (ORCPT ); Tue, 14 Apr 2020 16:09:11 -0400 Received: from sc9-mailhost3.vmware.com (10.113.161.73) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Tue, 14 Apr 2020 13:09:08 -0700 Received: from localhost (unknown [10.129.220.242]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 8678C40733; Tue, 14 Apr 2020 13:09:10 -0700 (PDT) Date: Tue, 14 Apr 2020 13:09:10 -0700 From: Matt Helsley To: Steven Rostedt CC: Julien Thierry , , Josh Poimboeuf , Peter Zijlstra , Ingo Molnar , Miroslav Benes Subject: Re: [RFC][PATCH 00/36] objtool: Make recordmcount a subcommand Message-ID: <20200414200910.GB118458@rlwimi.vmware.com> Mail-Followup-To: Matt Helsley , Steven Rostedt , Julien Thierry , linux-kernel@vger.kernel.org, Josh Poimboeuf , Peter Zijlstra , Ingo Molnar , Miroslav Benes References: <3a3f70df-07b0-91d9-33e1-e997e72b0c5c@redhat.com> <20200414093506.7b91bbbb@gandalf.local.home> <064f41bd-0dfe-e875-df7c-214184c29fa7@redhat.com> <20200414115458.093e221b@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20200414115458.093e221b@gandalf.local.home> Received-SPF: None (EX13-EDG-OU-001.vmware.com: mhelsley@vmware.com does not designate permitted sender hosts) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 14, 2020 at 11:54:58AM -0400, Steven Rostedt wrote: > On Tue, 14 Apr 2020 15:17:39 +0100 > Julien Thierry wrote: > > > > I was hoping to have objtool handle all the operations needed that required > > > reading elf headers. > > > > > > > That makes sense, however, having each operation as an objtool > > subcommand doesn't solve that issue, right? Each invocation of objtool > > will re-read the elf object. > > > > I guess having all the relevant code in objtool as subcommand would be a > > first step towards that goal. > > Exactly. I believe the goal (it's been a while since we discussed this), > was that we could "batch" the sub commands into a single command. That way, > the executable will be executed once per object file, load all the elf > headers, than iterate over all the sub commands that we set on the command > line. Yup. The idea is it's somewhat like a pipe but instead of reloading the file and re-creating the linked data structures each time, each sub command would simply hand off the ELF section/symbol/relocation structures to the next tool. If we look in scripts/Makefile.build for example we can see the rule_cc_o_c definition, after producing the initial .o with the compiler, does: $(call cmd,gen_ksymdeps) $(call cmd,checkdoc) $(call cmd,objtool) $(call cmd,modversions_c) $(call cmd,record_mcount) The latter 3 all deal with loading and walking the ELF file output from the previous step. If we could merge that into a single "call" to objtool then we can avoid the extra write-close-open-read cycles. I also wonder if we could move "checkdoc" because then 4 tools in a row could be relevant to convert (genksyms makes simple use of nm). I also noticed that, for example, sorttable uses the same ELF code / patterns as recordmcount -- like the double-include trick. Of course it operates on a larger scale than per-object-file and so there might only be code maintenance savings there... Also, the follow-on is definitely more speculative -- these patches show that things like recordmcount can be converted to share the same ELF code as objtool. The benefits of chaining commands together, how easy/hard that would be, etc. haven't been fully fleshed out. For instance, I was only looking at "check" and "mcount" chained together. But even aside from those changes, having all of the tools use the same ELF code and keeping that ELF code in one place rather than copy-paste it seems like it would be useful for maintenance. Cheers, -Matt