public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Matt Helsley <mhelsley@vmware.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [RFC][PATCH 10/13] objtool: Make recordmcount into an objtool subcmd
Date: Tue, 28 May 2019 09:54:58 -0500	[thread overview]
Message-ID: <20190528145458.2xmlkzucuekj2km4@treble> (raw)
In-Reply-To: <10da56db6206a99d1b909e56ee48cb4ceb374ef8.1558569448.git.mhelsley@vmware.com>

On Wed, May 22, 2019 at 05:03:33PM -0700, Matt Helsley wrote:
> Rather than a standalone executable merge recordmcount as a sub
> command of objtool. This is a small step towards cleaning up
> recordmcount and eventually saving ELF code with objtool.
> 
> For the initial step all that's required is a bit of Makefile
> changes and invoking the former main() function from recordmcount.c
> because the subcommand code uses similar function arguments as
> main when dispatching.
> 
> Subsequent patches will gradually convert recordmcount to use
> more and more of libelf/objtool's ELF accessor code. This will both
> clean up recordmcount to be more easily readable and remove
> recordmcount's crude accessor wrapping code.
> 
> Signed-off-by: Matt Helsley <mhelsley@vmware.com>
> ---
>  scripts/Makefile.build         | 15 +++++--
>  tools/objtool/Build            |  3 +-
>  tools/objtool/Makefile         | 18 +++------
>  tools/objtool/builtin-mcount.c | 72 ++++++++++++++++++++++++++++++++++
>  tools/objtool/builtin-mcount.h | 23 +++++++++++
>  tools/objtool/builtin.h        |  6 +++
>  tools/objtool/objtool.c        |  6 +++
>  tools/objtool/recordmcount.c   | 29 +++++---------
>  8 files changed, 134 insertions(+), 38 deletions(-)
>  create mode 100644 tools/objtool/builtin-mcount.c
>  create mode 100644 tools/objtool/builtin-mcount.h
> 
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index f32cfe63bb0e..6a3a5a477cbd 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -173,10 +173,13 @@ cmd_modversions_c =								\
>  	fi
>  endif
>  
> +objtool_dep =
> +
>  ifdef CONFIG_FTRACE_MCOUNT_RECORD
>  ifndef CC_USING_RECORD_MCOUNT
> -# compiler will not generate __mcount_loc use recordmcount or recordmcount.pl
> +# compiler will not generate __mcount_loc use objtool mcount record or recordmcount.pl
>  ifdef BUILD_C_RECORDMCOUNT
> +objtool_dep += $(objtree)/tools/objtool/objtool
>  ifeq ("$(origin RECORDMCOUNT_WARN)", "command line")
>    RECORDMCOUNT_FLAGS = -w
>  endif
> @@ -186,10 +189,12 @@ endif
>  # files, including recordmcount.
>  sub_cmd_record_mcount =					\
>  	if [ $(@) != "scripts/mod/empty.o" ]; then	\
> -		$(objtree)/tools/objtool/recordmcount $(RECORDMCOUNT_FLAGS) "$(@)";	\
> +		$(objtree)/tools/objtool/objtool mcount record $(RECORDMCOUNT_FLAGS) "$(@)";	\
>  	fi;
>  
> -recordmcount_source := $(srctree)/tools/objtool/recordmcount.c \
> +recordmcount_source := $(srctree)/tools/objtool/builtin-mcount.c \
> +		    $(srctree)/tools/objtool/builtin-mcount.h \
> +		    $(srctree)/tools/objtool/recordmcount.c \
>  		    $(srctree)/tools/objtool/recordmcount.h

Is this needed? if any of these files change, then objtool will change,
and which is already covered by the objtool_dep assignment above.

>  else
>  sub_cmd_record_mcount = perl $(srctree)/tools/objtool/recordmcount.pl "$(ARCH)" \
> @@ -203,6 +208,8 @@ endif # BUILD_C_RECORDMCOUNT
>  cmd_record_mcount = $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)),	\
>  	$(sub_cmd_record_mcount))
>  endif # CC_USING_RECORD_MCOUNT
> +
> +objtool_dep += $(recordmcount_source)

I don't think this is needed because recordmcount_source is already
listed as a dependency for .o files.

>  endif # CONFIG_FTRACE_MCOUNT_RECORD
>  
>  ifdef CONFIG_STACK_VALIDATION
> @@ -241,7 +248,7 @@ endif # SKIP_STACK_VALIDATION
>  endif # CONFIG_STACK_VALIDATION
>  
>  # Rebuild all objects when objtool changes, or is enabled/disabled.
> -objtool_dep = $(objtool_obj)					\
> +objtool_dep += $(objtool_obj)		\

The backslash should be aligned with the following ones.

>  	      $(wildcard include/config/orc/unwinder.h		\
>  			 include/config/stack/validation.h)

Should we also add an ftrace config dependency here?
Like include/config/ftrace/mcount/record.h?

>  
> diff --git a/tools/objtool/Build b/tools/objtool/Build
> index 78c4a8a2f9e7..7b71534767bd 100644
> --- a/tools/objtool/Build
> +++ b/tools/objtool/Build
> @@ -1,6 +1,7 @@
>  objtool-y += arch/$(SRCARCH)/
>  objtool-y += builtin-check.o
>  objtool-y += builtin-orc.o
> +objtool-$(BUILD_C_RECORDMCOUNT) += builtin-mcount.o recordmcount.o

Can we just build these files unconditionally, even if they're not used?
Thus far, objtool doesn't have any kernel config dependencies like this.
It helps keep things simple and keeps objtool more separate from the
kernel.

So if you build record mcount unconditionally then I think you can also
get rid of the BUILD_C_RECORDMCOUNT export, the CMD_MCOUNT define, and
cmd_nop().

-- 
Josh

  reply	other threads:[~2019-05-28 14:55 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-23  0:03 [RFC][PATCH 00/13] Cleanup recordmcount and begin objtool conversion Matt Helsley
2019-05-23  0:03 ` [RFC][PATCH 01/13] recordmcount: Remove redundant strcmp Matt Helsley
2019-05-23  0:03 ` [RFC][PATCH 02/13] recordmcount: Remove uread() Matt Helsley
2019-05-23  0:03 ` [RFC][PATCH 03/13] recordmcount: Remove unused fd from uwrite() and ulseek() Matt Helsley
2019-05-23  0:03 ` [RFC][PATCH 04/13] recordmcount: Rewrite error/success handling Matt Helsley
2019-05-23  0:03 ` [RFC][PATCH 05/13] recordmcount: Kernel style function signature formatting Matt Helsley
2019-05-23  0:03 ` [RFC][PATCH 06/13] recordmcount: Kernel style formatting Matt Helsley
2019-05-23  0:03 ` [RFC][PATCH 07/13] recordmcount: Remove redundant cleanup() calls Matt Helsley
2019-05-23  0:03 ` [RFC][PATCH 08/13] recordmcount: Clarify what cleanup() does Matt Helsley
2019-05-23  0:03 ` [RFC][PATCH 09/13] objtool: Prepare to merge recordmcount Matt Helsley
2019-05-23  0:03 ` [RFC][PATCH 10/13] objtool: Make recordmcount into an objtool subcmd Matt Helsley
2019-05-28 14:54   ` Josh Poimboeuf [this message]
2019-05-23  0:03 ` [RFC][PATCH 11/13] objtool: recordmcount: Start using objtool's elf wrapper Matt Helsley
2019-05-23  0:03 ` [RFC][PATCH 12/13] objtool: recordmcount: Search for __mcount_loc before walking the sections Matt Helsley
2019-05-23  0:03 ` [RFC][PATCH 13/13] objtool: recordmcount: Convert do_func() relhdrs Matt Helsley
2019-05-28 14:43 ` [RFC][PATCH 00/13] Cleanup recordmcount and begin objtool conversion Josh Poimboeuf
2019-05-28 14:50   ` Steven Rostedt
2019-05-29 13:41   ` Peter Zijlstra
2019-05-29 14:11     ` Josh Poimboeuf
2019-05-30 23:52       ` Matt Helsley
2019-05-31 18:34         ` Josh Poimboeuf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190528145458.2xmlkzucuekj2km4@treble \
    --to=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhelsley@vmware.com \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox