[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK7LNAT3_rk7xysSGnzq1carsght6gziyCnwEX=fjXy-KwhQEg@mail.gmail.com>
Date: Tue, 28 Nov 2023 20:44:11 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: Kent Overstreet <kent.overstreet@...ux.dev>
Cc: linux-kernel@...r.kernel.org,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Nicolas Schier <nicolas@...sle.eu>,
linux-kbuild@...r.kernel.org
Subject: Re: [PATCH] kbuild: Allow gcov to be enabled on the command line
On Sun, Nov 26, 2023 at 4:56 AM Kent Overstreet
<kent.overstreet@...ux.dev> wrote:
>
> On Fri, Nov 24, 2023 at 11:02:00AM +0900, Masahiro Yamada wrote:
> > On Thu, Nov 23, 2023 at 8:55 AM Kent Overstreet
> > <kent.overstreet@...ux.dev> wrote:
> > >
> > > This allows gcov to be enabled for a particular kernel source
> > > subdirectory on the command line, without editing makefiles, like so:
> > >
> > > make GCOV_PROFILE_fs_bcachefs=y
> > >
> > > Cc: Masahiro Yamada <masahiroy@...nel.org>
> > > Cc: Nathan Chancellor <nathan@...nel.org>
> > > Cc: Nick Desaulniers <ndesaulniers@...gle.com>
> > > Cc: Nicolas Schier <nicolas@...sle.eu>
> > > Cc: linux-kbuild@...r.kernel.org
> > > Signed-off-by: Kent Overstreet <kent.overstreet@...ux.dev>
> > > ---
> > > scripts/Kbuild.include | 10 ++++++++++
> > > scripts/Makefile.lib | 2 +-
> > > 2 files changed, 11 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
> > > index 7778cc97a4e0..5341736f2e30 100644
> > > --- a/scripts/Kbuild.include
> > > +++ b/scripts/Kbuild.include
> > > @@ -277,3 +277,13 @@ ifneq ($(and $(filter notintermediate, $(.FEATURES)),$(filter-out 4.4,$(MAKE_VER
> > > else
> > > .SECONDARY:
> > > endif
> > > +
> > > + # expand_parents(a/b/c) = a/b/c a/b a
> > > +expand_parents2 = $(if $(subst .,,$(1)),$(call expand_parents,$(1)),)
> > > +expand_parents = $(1) $(call expand_parents2,$(patsubst %/,%,$(dir $(1))))
> > > +
> > > +# flatten_dirs(a/b/c) = a_b_c a_b a
> > > +flatten_dirs = $(subst /,_,$(call expand_parents,$(1)))
> > > +
> > > +# eval_vars(X_,a/b/c) = $(X_a_b_c) $(X_a_b) $(X_a)
> > > +eval_vars = $(foreach var,$(call flatten_dirs,$(2)),$($(1)$(var)))
> >
> >
> >
> > I do not like tricky code like this.
> >
> > Also, with "fs_bcachefs", it is unclear which directory
> > is enabled.
>
> It's consistent with how we can specify options in makefiles for a
> particular file.
It is consistent in a bad way.
You used "GCOV_PROFILE_" prefix
for the full directory path, while it is already
used as a file name which is relative to the
current directory.
>
> I suppose CONFIG_GCOV_PROFILE_DIRS would be fine, but your patch isn't
> complete so I can't test it.
I do not understand what you mean by "isn't complete".
It is just a matter of adding the config entry somewhere.
I added a patch just in case, though.
Note, both approach pros and cons.
The command line approach works for external modules.
With the CONFIG option approach, you can easily see
which directories are profiled by checking the .config,
but it is not easy to enable gcov for external modules.
--
Best Regards
Masahiro Yamada
View attachment "per-dir-gcov.diff" of type "text/x-patch" (1068 bytes)
Powered by blists - more mailing lists