Re: [PATCH 2/3] kcsan: Update Documentation/dev-tools/kcsan.rst

From: Marco Elver
Date: Wed Mar 04 2020 - 11:57:16 EST


On Wed, 4 Mar 2020 at 17:44, Qian Cai <cai@xxxxxx> wrote:
>
> On Wed, 2020-03-04 at 17:25 +0100, 'Marco Elver' via kasan-dev wrote:
> > Selective analysis
> > ~~~~~~~~~~~~~~~~~~
> > @@ -111,8 +107,8 @@ the below options are available:
> >
> > * Disabling data race detection for entire functions can be accomplished by
> > using the function attribute ``__no_kcsan`` (or ``__no_kcsan_or_inline`` for
> > - ``__always_inline`` functions). To dynamically control for which functions
> > - data races are reported, see the `debugfs`_ blacklist/whitelist feature.
> > + ``__always_inline`` functions). To dynamically limit for which functions to
> > + generate reports, see the `DebugFS interface`_ blacklist/whitelist feature.
>
> As mentioned in [1], do it worth mentioning "using __no_kcsan_or_inline for
> inline functions as well when CONFIG_OPTIMIZE_INLINING=y" ?
>
> [1] https://lore.kernel.org/lkml/E9162CDC-BBC5-4D69-87FB-C93AB8B3D581@xxxxxx/

Strictly speaking it shouldn't be necessary. Only __always_inline is
incompatible with __no_kcsan.

AFAIK what you noticed is a bug with some versions of GCC. I think
with GCC >=9 and Clang there is no problem.

The bigger problem is turning a bunch of 'inline' functions into
'__always_inline' accidentally, that's why the text only mentions
'__no_kcsan_or_inline' for '__always_inline'. For extremely small
functions, that's probably ok, but it's not general advice we should
give for that reason.

I will try to write something about this here, but sadly there is no
clear rule for this until the misbehaving compilers are no longer
supported.

Thanks,
-- Marco