Linux Trace Kernel
 help / color / mirror / Atom feed
From: Peter Oberparleiter <oberpar@linux.ibm.com>
To: Chuck Wolber <chuck@wolber.net>, Masami Hiramatsu <mhiramat@kernel.org>
Cc: Marco Elver <elver@google.com>,
	kasan-dev@googlegroups.com, nathan@kernel.org,
	akpm@linux-foundation.org, anton.ivanov@cambridgegreys.com,
	ardb@kernel.org, arnd@arndb.de, bhelgaas@google.com,
	bp@alien8.de, dave.hansen@linux.intel.com, dvyukov@google.com,
	hpa@zytor.com, jinghao7@illinois.edu, johannes@sipsolutions.net,
	jpoimboe@kernel.org, justinstitt@google.com, kees@kernel.org,
	kent.overstreet@linux.dev, linux-arch@vger.kernel.org,
	linux-efi@vger.kernel.org, linux-kbuild@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	linux-um@lists.infradead.org, llvm@lists.linux.dev,
	luto@kernel.org, marinov@illinois.edu, masahiroy@kernel.org,
	maskray@google.com, mathieu.desnoyers@efficios.com,
	mingo@redhat.com, morbo@google.com,
	Nick Desaulniers <ndesaulniers@google.com>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	richard@nod.at, Steven Rostedt <rostedt@goodmis.org>,
	samitolvanen@google.com, tglx@linutronix.de,
	tingxur@illinois.edu, tyxu@illinois.edu, wentaoz5@illinois.edu,
	x86@kernel.org, peterz@infradead.org,
	Sasha Levin <sashal@kernel.org>,
	Aleksandr Nogikh <nogikh@google.com>,
	Taras Madan <tarasmadan@google.com>,
	Alexander Potapenko <glider@google.com>
Subject: Re: [PROPOSAL] Replace gcov and kcov with llvm-cov
Date: Thu, 8 Oct 2026 17:58:23 +0200	[thread overview]
Message-ID: <2bc4cd4b-c01e-49e6-a0ac-d800489c7fd0@linux.ibm.com> (raw)
In-Reply-To: <c84149c4-26c3-476e-93d5-4fe72f7c708b@app.fastmail.com>

On 07.10.2026 06:17, Chuck Wolber wrote:
> On Wed, Oct 7, 2026, at 2:30 AM, Masami Hiramatsu wrote:
>> On Tue, 06 Oct 2026 16:27:11 +0000, Chuck Wolber <chuck@wolber.net> wrote:
>>> On Tue, Oct 6, 2026, at 4:10 PM, Marco Elver wrote:
>>>> On Tue, 6 Oct 2026 at 17:14, Chuck Wolber <chuck@wolber.net> wrote:
>>
>>>>> If there is a desire to take this in pieces or implement other
>>>>> intermediate steps, let me know. Otherwise I can generate a
>>>>> monolithic set all at once.
>>>>>
>>>>> [1] https://lore.kernel.org/lkml/20240905043245.1389509-1-wentaoz5@illinois.edu/
>>>>>
>>>>>>> llvm-cov is generally useful to have; llvm-cov is closest to
>>>>>>> gcov, so that might make sense to replace.
>>>
>>> Swapping llvm-cov for gcov to start with is pretty straightforward,
>>> so I can aim my initial patch set there.
>>
>> Hmm, is it necessary to remove gcov? Would it be difficult to simply
>> add support for llvm-cov and enable (make kconfig selectable) one or
>> the other depending on the compiler?
> 
> Not strictly necessary, no. And what you are describing is what our
> original patches do.
> 
> The concern was why we would want to have three separate code coverage
> tools in the kernel. Each has their own way of doing things, and they
> can all live together in the kernel harmoniously.
> 
> But the concern was raised so I am trying to find a way forward.
> 
> The llvm-cov approach gives results that are reliably tied to actual
> lines of source, so that is the one I reflexively reach for any time I
> need code coverage. I am at a loss (but definitely willing to be
> educated) as to what value gcov style coverage provides in comparison.

I agree that llvm-cov native kernel support has some advantages over
current gcov-kernel support:

* MC/DC coverage (though a series introducing MC/DC for gcov-kernel
  exists, pending review..)
* Sub-line precision data
* Optimization doesn't affect precision of coverage data

The lack of support for non-x86 architectures would be an initial
obstacle for some users, but one that can be addressed.

The main problem I see with the idea of replacing gcov-kernel with
llvm-cov is that it would immediately disrupt a lot of gcov-kernel based
workflows that people have developed over time, e.g. automated coverage
measurements as part of CI tests, maybe coupled with specialized tooling
features like lcov's differential coverage analysis. I'm not sure that
the extra value provided by llvm-cov today justifies the effort needed
to move away from gcov-kernel for everyone.

Also not everyone may be able to switch from GCC to LLVM for compiling
instrumented kernels, e.g. because their test kernels need to match the
associated kernel-based product (think Linux distributions). Those users
would then be left with no workable coverage measurement option at all.

> I also found some interesting possibilities using intrinsics to enable
> boot time tracing with llvm-cov. That is, of course, experimental and
> not something I am considering for the intial patch-set. But it got me
> thinking about broader configurability that supports more granular forms
> of coverage that _may_ address kcov needs in the long term.
> 
> I have been working on this off-and on for a few years and still really
> want to see this idea succeed. Any guidance on a workable path forward
> would be greatly appreciated.

My recommendation would be to keep working towards getting llvm-cov
integrated as an alternative to gcov-kernel for LLVM users. This would
enable kernel developers that are not bound to using GCC to benefit from
the current (and potential future) unique benefits of llvm-cov data.

As for whether the kernel needs two coverage mechanisms (not counting
KCOV - see Marco Elver's previous email): coverage and instrumentation
are inherently toolchain-specific today. Since the kernel supports both
GCC and LLVM, supporting the corresponding toolchain-specific coverage
mechanisms seems reasonable to me.

> Another option, proposed by Sasha Levin[1], was to use a single
> /sys/kernel/debug/coverage interface, quoting him here:
> 
> "To clarify, are you suggesting that we'll have something like a single
>  /sys/kernel/debug/coverage interface that is producing the same structured
>  output whether we use gcov or llvm?"
> 
> I am not sure it is feasible to use the same structured ouput, but it
> would isolate things down to a single interface with KConfig knobs being
> used to select which coverage data one can expect to find there.

The data format produced by instrumented kernel code is defined by the
associated toolchain. I don't see a feasible way to merge/map these. One
could argue though that the code for both mechanisms could be better
co-located, both in kernel source tree and configuration menus. Also
there might be some value in merging the per-directory/per-file
no-profile indicators (GCOV_PROFILE/LLVM_COV_PROFILE).


-- 
Peter Oberparleiter
Linux on IBM Z Development - IBM Germany R&D

      parent reply	other threads:[~2026-10-08 16:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06 15:14 [PROPOSAL] Replace gcov and kcov with llvm-cov Chuck Wolber
2026-10-06 16:10 ` Marco Elver
2026-10-06 16:27   ` Chuck Wolber
2026-10-07  2:30     ` Masami Hiramatsu
2026-10-07  4:17       ` Chuck Wolber
2026-10-07  4:50         ` Masami Hiramatsu
2026-10-08 15:58         ` Peter Oberparleiter [this message]

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=2bc4cd4b-c01e-49e6-a0ac-d800489c7fd0@linux.ibm.com \
    --to=oberpar@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=anton.ivanov@cambridgegreys.com \
    --cc=ardb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=bhelgaas@google.com \
    --cc=bp@alien8.de \
    --cc=chuck@wolber.net \
    --cc=dave.hansen@linux.intel.com \
    --cc=dvyukov@google.com \
    --cc=elver@google.com \
    --cc=glider@google.com \
    --cc=hpa@zytor.com \
    --cc=jinghao7@illinois.edu \
    --cc=johannes@sipsolutions.net \
    --cc=jpoimboe@kernel.org \
    --cc=justinstitt@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=kees@kernel.org \
    --cc=kent.overstreet@linux.dev \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=linux-um@lists.infradead.org \
    --cc=llvm@lists.linux.dev \
    --cc=luto@kernel.org \
    --cc=marinov@illinois.edu \
    --cc=masahiroy@kernel.org \
    --cc=maskray@google.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=mingo@redhat.com \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nogikh@google.com \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=richard@nod.at \
    --cc=rostedt@goodmis.org \
    --cc=samitolvanen@google.com \
    --cc=sashal@kernel.org \
    --cc=tarasmadan@google.com \
    --cc=tglx@linutronix.de \
    --cc=tingxur@illinois.edu \
    --cc=tyxu@illinois.edu \
    --cc=wentaoz5@illinois.edu \
    --cc=x86@kernel.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