Re: [PATCH 0/3] KCOV function entry/exit records
From: Jann Horn
Date: Thu Mar 12 2026 - 07:51:02 EST
On Wed, Mar 11, 2026 at 11:57 PM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
> And I don't suppose KCOV will finally honour noinstr ?
I believe it should, as long as the compiler is new enough?
We have this in include/linux/compiler-clang.h, and I just checked
that, for example, the noinstr function fpu_idle_fpregs indeed doesn't
get instrumented with clang:
```
/*
* Support for __has_feature(coverage_sanitizer) was added in Clang 13 together
* with no_sanitize("coverage"). Prior versions of Clang support coverage
* instrumentation, but cannot be queried for support by the preprocessor.
*/
#if __has_feature(coverage_sanitizer)
#define __no_sanitize_coverage __attribute__((no_sanitize("coverage")))
#else
#define __no_sanitize_coverage
#endif
```
And include/linux/compiler-gcc.h has this, which also seems to be
effective in a GCC build:
```
/*
* Only supported since gcc >= 12
*/
#if defined(CONFIG_KCOV) && __has_attribute(__no_sanitize_coverage__)
#define __no_sanitize_coverage __attribute__((__no_sanitize_coverage__))
#else
#define __no_sanitize_coverage
#endif
```