mbox series

[0/3] Fix CONFIG_FUNCTION_TRACER with clang

Message ID 20210325223807.2423265-1-nathan@kernel.org (mailing list archive)
Headers show
Series Fix CONFIG_FUNCTION_TRACER with clang | expand

Message

Nathan Chancellor March 25, 2021, 10:38 p.m. UTC
Hi all,

This series fixes function tracing with clang.

Patch 1 adjusts the mcount regex in scripts/recordmcount.pl to handle
the presence of PLT relocations, which happen with clang. Without this,
the mcount_loc section will not be created properly.

Patch 2 adds a workaround for clang less than 13.0.0 in relation to the
mcount symbol name, which was "mcount" rather than "_mcount". This was
written as a separate patch so that it can be reverted when the minimum
clang version is bumped to clang 13.0.0.

Patch 3 avoids a build error when -fpatchable-function-entry is not
available, which is the case with clang less than 13.0.0. This will make
dynamic ftrace unavailable but all of the other function tracing should
work due to the prescence of the previous patch.

I am hoping this series can go in as fixes for 5.12, due to patch 3, but
if not, they can always be backported (patches 1 and 2 are already
marked for stable).

This series has been build tested with gcc-8 through gcc-10 and clang-11
through clang-13 with defconfig and nommu_virt_defconfig plus
CONFIG_FTRACE=y and CONFIG_FUNCTION_TRACER=y then boot tested under
QEMU.

Cheers,
Nathan

Nathan Chancellor (3):
  scripts/recordmcount.pl: Fix RISC-V regex for clang
  riscv: Workaround mcount name prior to clang-13
  riscv: Select HAVE_DYNAMIC_FTRACE when -fpatchable-function-entry is
    available

 arch/riscv/Kconfig              |  2 +-
 arch/riscv/include/asm/ftrace.h | 14 ++++++++++++--
 arch/riscv/kernel/mcount.S      | 10 +++++-----
 scripts/recordmcount.pl         |  2 +-
 4 files changed, 19 insertions(+), 9 deletions(-)

Comments

Sedat Dilek March 26, 2021, 8:37 a.m. UTC | #1
On Thu, Mar 25, 2021 at 11:38 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> Hi all,
>
> This series fixes function tracing with clang.
>
> Patch 1 adjusts the mcount regex in scripts/recordmcount.pl to handle
> the presence of PLT relocations, which happen with clang. Without this,
> the mcount_loc section will not be created properly.
>
> Patch 2 adds a workaround for clang less than 13.0.0 in relation to the
> mcount symbol name, which was "mcount" rather than "_mcount". This was
> written as a separate patch so that it can be reverted when the minimum
> clang version is bumped to clang 13.0.0.
>
> Patch 3 avoids a build error when -fpatchable-function-entry is not
> available, which is the case with clang less than 13.0.0. This will make
> dynamic ftrace unavailable but all of the other function tracing should
> work due to the prescence of the previous patch.
>
> I am hoping this series can go in as fixes for 5.12, due to patch 3, but
> if not, they can always be backported (patches 1 and 2 are already
> marked for stable).
>
> This series has been build tested with gcc-8 through gcc-10 and clang-11
> through clang-13 with defconfig and nommu_virt_defconfig plus
> CONFIG_FTRACE=y and CONFIG_FUNCTION_TRACER=y then boot tested under
> QEMU.
>
> Cheers,
> Nathan
>
> Nathan Chancellor (3):
>   scripts/recordmcount.pl: Fix RISC-V regex for clang
>   riscv: Workaround mcount name prior to clang-13
>   riscv: Select HAVE_DYNAMIC_FTRACE when -fpatchable-function-entry is
>     available
>

Does this only fixes stuff for clang + riscv?
If so, please put a label "riscv" also in the cover-letter.

- Sedat -

>  arch/riscv/Kconfig              |  2 +-
>  arch/riscv/include/asm/ftrace.h | 14 ++++++++++++--
>  arch/riscv/kernel/mcount.S      | 10 +++++-----
>  scripts/recordmcount.pl         |  2 +-
>  4 files changed, 19 insertions(+), 9 deletions(-)
>
> --
> 2.31.0
>
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20210325223807.2423265-1-nathan%40kernel.org.
Nathan Chancellor March 26, 2021, 1:07 p.m. UTC | #2
On Fri, Mar 26, 2021 at 09:37:55AM +0100, Sedat Dilek wrote:
> On Thu, Mar 25, 2021 at 11:38 PM Nathan Chancellor <nathan@kernel.org> wrote:
> >
> > Hi all,
> >
> > This series fixes function tracing with clang.
> >
> > Patch 1 adjusts the mcount regex in scripts/recordmcount.pl to handle
> > the presence of PLT relocations, which happen with clang. Without this,
> > the mcount_loc section will not be created properly.
> >
> > Patch 2 adds a workaround for clang less than 13.0.0 in relation to the
> > mcount symbol name, which was "mcount" rather than "_mcount". This was
> > written as a separate patch so that it can be reverted when the minimum
> > clang version is bumped to clang 13.0.0.
> >
> > Patch 3 avoids a build error when -fpatchable-function-entry is not
> > available, which is the case with clang less than 13.0.0. This will make
> > dynamic ftrace unavailable but all of the other function tracing should
> > work due to the prescence of the previous patch.
> >
> > I am hoping this series can go in as fixes for 5.12, due to patch 3, but
> > if not, they can always be backported (patches 1 and 2 are already
> > marked for stable).
> >
> > This series has been build tested with gcc-8 through gcc-10 and clang-11
> > through clang-13 with defconfig and nommu_virt_defconfig plus
> > CONFIG_FTRACE=y and CONFIG_FUNCTION_TRACER=y then boot tested under
> > QEMU.
> >
> > Cheers,
> > Nathan
> >
> > Nathan Chancellor (3):
> >   scripts/recordmcount.pl: Fix RISC-V regex for clang
> >   riscv: Workaround mcount name prior to clang-13
> >   riscv: Select HAVE_DYNAMIC_FTRACE when -fpatchable-function-entry is
> >     available
> >
> 
> Does this only fixes stuff for clang + riscv?

Yes.

> If so, please put a label "riscv" also in the cover-letter.

Sure, my apologies for not doing that in the first place, I must have
been in a rush with the cover letter.

In my defense, I think the titles of my commit messages and the diffstat
below make that obvious without the tag :)

Cheers,
Nathan

> - Sedat -
> 
> >  arch/riscv/Kconfig              |  2 +-
> >  arch/riscv/include/asm/ftrace.h | 14 ++++++++++++--
> >  arch/riscv/kernel/mcount.S      | 10 +++++-----
> >  scripts/recordmcount.pl         |  2 +-
> >  4 files changed, 19 insertions(+), 9 deletions(-)
> >
> > --
> > 2.31.0
> >
Sedat Dilek March 27, 2021, 12:16 p.m. UTC | #3
On Fri, Mar 26, 2021 at 2:07 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> On Fri, Mar 26, 2021 at 09:37:55AM +0100, Sedat Dilek wrote:
> > On Thu, Mar 25, 2021 at 11:38 PM Nathan Chancellor <nathan@kernel.org> wrote:
> > >
> > > Hi all,
> > >
> > > This series fixes function tracing with clang.
> > >
> > > Patch 1 adjusts the mcount regex in scripts/recordmcount.pl to handle
> > > the presence of PLT relocations, which happen with clang. Without this,
> > > the mcount_loc section will not be created properly.
> > >
> > > Patch 2 adds a workaround for clang less than 13.0.0 in relation to the
> > > mcount symbol name, which was "mcount" rather than "_mcount". This was
> > > written as a separate patch so that it can be reverted when the minimum
> > > clang version is bumped to clang 13.0.0.
> > >
> > > Patch 3 avoids a build error when -fpatchable-function-entry is not
> > > available, which is the case with clang less than 13.0.0. This will make
> > > dynamic ftrace unavailable but all of the other function tracing should
> > > work due to the prescence of the previous patch.
> > >
> > > I am hoping this series can go in as fixes for 5.12, due to patch 3, but
> > > if not, they can always be backported (patches 1 and 2 are already
> > > marked for stable).
> > >
> > > This series has been build tested with gcc-8 through gcc-10 and clang-11
> > > through clang-13 with defconfig and nommu_virt_defconfig plus
> > > CONFIG_FTRACE=y and CONFIG_FUNCTION_TRACER=y then boot tested under
> > > QEMU.
> > >
> > > Cheers,
> > > Nathan
> > >
> > > Nathan Chancellor (3):
> > >   scripts/recordmcount.pl: Fix RISC-V regex for clang
> > >   riscv: Workaround mcount name prior to clang-13
> > >   riscv: Select HAVE_DYNAMIC_FTRACE when -fpatchable-function-entry is
> > >     available
> > >
> >
> > Does this only fixes stuff for clang + riscv?
>
> Yes.
>
> > If so, please put a label "riscv" also in the cover-letter.
>
> Sure, my apologies for not doing that in the first place, I must have
> been in a rush with the cover letter.
>
> In my defense, I think the titles of my commit messages and the diffstat
> below make that obvious without the tag :)
>

No need for any apologies.
I was fooled as you sent two triple-patchset nearly simultaneously.
This riscv patchset here was not of interest to me.

- Sedat -

>
> > - Sedat -
> >
> > >  arch/riscv/Kconfig              |  2 +-
> > >  arch/riscv/include/asm/ftrace.h | 14 ++++++++++++--
> > >  arch/riscv/kernel/mcount.S      | 10 +++++-----
> > >  scripts/recordmcount.pl         |  2 +-
> > >  4 files changed, 19 insertions(+), 9 deletions(-)
> > >
> > > --
> > > 2.31.0
> > >
Palmer Dabbelt April 11, 2021, 9:27 p.m. UTC | #4
On Thu, 25 Mar 2021 15:38:04 PDT (-0700), nathan@kernel.org wrote:
> Hi all,
>
> This series fixes function tracing with clang.
>
> Patch 1 adjusts the mcount regex in scripts/recordmcount.pl to handle
> the presence of PLT relocations, which happen with clang. Without this,
> the mcount_loc section will not be created properly.
>
> Patch 2 adds a workaround for clang less than 13.0.0 in relation to the
> mcount symbol name, which was "mcount" rather than "_mcount". This was
> written as a separate patch so that it can be reverted when the minimum
> clang version is bumped to clang 13.0.0.
>
> Patch 3 avoids a build error when -fpatchable-function-entry is not
> available, which is the case with clang less than 13.0.0. This will make
> dynamic ftrace unavailable but all of the other function tracing should
> work due to the prescence of the previous patch.
>
> I am hoping this series can go in as fixes for 5.12, due to patch 3, but
> if not, they can always be backported (patches 1 and 2 are already
> marked for stable).
>
> This series has been build tested with gcc-8 through gcc-10 and clang-11
> through clang-13 with defconfig and nommu_virt_defconfig plus
> CONFIG_FTRACE=y and CONFIG_FUNCTION_TRACER=y then boot tested under
> QEMU.
>
> Cheers,
> Nathan
>
> Nathan Chancellor (3):
>   scripts/recordmcount.pl: Fix RISC-V regex for clang
>   riscv: Workaround mcount name prior to clang-13
>   riscv: Select HAVE_DYNAMIC_FTRACE when -fpatchable-function-entry is
>     available
>
>  arch/riscv/Kconfig              |  2 +-
>  arch/riscv/include/asm/ftrace.h | 14 ++++++++++++--
>  arch/riscv/kernel/mcount.S      | 10 +++++-----
>  scripts/recordmcount.pl         |  2 +-
>  4 files changed, 19 insertions(+), 9 deletions(-)

Thanks, these are on for-next.