archive mirror
 help / color / mirror / Atom feed
From: Peter Oberparleiter <>
To: Peter Zijlstra <>,,
Subject: Re: [PATCH] gcov,x86: Mark GCOV broken for x86
Date: Mon, 14 Jun 2021 16:43:27 +0200	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <YMcssV/>

On 14.06.2021 12:17, Peter Zijlstra wrote:
> As recently discovered, there is no function attribute to disable the
> -fprofile-generate instrumentation. As such, GCOV is fundamentally
> incompatible with architectures that rely on 'noinstr' for correctness.

Does this problem affect all code or just those pieces that use
'noinstr'? Doing a quick grep over kernel source shows me ~40 source
files containing 'noinstr' vs. ~30000 that don't.

It seems to me like an extreme measure to disable gcov-based profiling
for all files on an architecture when only a small fraction of code
would actually be affected.

I'll gladly admit that I haven't followed the full discussion that lead
to your patch, so maybe some of the following suggestions may already
have been proposed.

What about marking source files that contain 'noinstr' using the

  GCOV_PROFILE_<filename.o> := n

directive that gcov-kernel profiling provides to exclude those files
from being compiled with the corresponding profiling flags? If that's
too much effort there's also a directive for excluding all files in a

If there was a way to automatically identify 'noinstr'-afflicted source
files (e.g. by grepping the pre-processed source files), one could also
automate this process by adjusting the kbuild-code that adds profiling
flags to automatically exclude such files.

> Until such time as that compilers have added a function attribute to
> disable this instrumentation, mark GCOV as broken.
> Signed-off-by: Peter Zijlstra (Intel) <>
> ---
>  arch/x86/Kconfig    | 2 +-
>  kernel/gcov/Kconfig | 4 ++++
>  2 files changed, 5 insertions(+), 1 deletion(-)
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index 86dae426798b..c0f8c9d4c31a 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -75,7 +75,7 @@ config X86

Assuming none of the above mentioned alternatives are viable, removing
ARCH_HAS_GCOV_PROFILE_ALL should be enough for your purpose. This way
you are already excluding all source files from automatic profiling on x86.

Users that are absolutely sure that their code can work with
gcov-profiling can manually edit their sub-Makefiles to list those files
that should be instrumented. In my opinion your introduction of
ARCH_HAS_GCOV_BROKEN unnecessarily takes away this capability.

  Peter Oberparleiter

Peter Oberparleiter
Linux on Z Development - IBM Germany

  parent reply	other threads:[~2021-06-14 14:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-14 10:17 Peter Zijlstra
2021-06-14 10:31 ` Marco Elver
2021-06-14 14:43 ` Peter Oberparleiter [this message]
2021-06-18 11:13   ` Peter Zijlstra
2021-06-21 13:53     ` Peter Oberparleiter
2021-06-14 16:05 ` Nick Desaulniers
2021-06-14 16:20   ` Peter Zijlstra
2021-06-14 18:05     ` Nick Desaulniers
2021-06-14 18:20       ` Borislav Petkov
2021-06-14 19:03         ` Nick Desaulniers
2021-06-14 19:28           ` Borislav Petkov
2021-06-14 18:31       ` Fangrui Song
2021-06-14 19:07         ` Peter Zijlstra

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:

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

  git send-email \ \ \ \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH] gcov,x86: Mark GCOV broken for x86' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).