Linux kbuild/kconfig development
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Peter Oberparleiter" <oberpar@linux.ibm.com>,
	"Konstantin Khorenko" <khorenko@virtuozzo.com>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nicolas Schier" <nsc@kernel.org>
Cc: "Mikhail Zaslonko" <zaslonko@linux.ibm.com>,
	"Masahiro Yamada" <masahiroy@kernel.org>,
	"Thomas Weißschuh" <linux@weissschuh.net>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Pavel Tikhomirov" <ptikhomirov@virtuozzo.com>,
	"Vasileios Almpanis" <vasileios.almpanis@virtuozzo.com>,
	"Andrew Morton" <akpm@linux-foundation.org>
Subject: Re: [PATCH v2] gcov: use atomic counter updates to fix concurrent access crashes
Date: Thu, 07 May 2026 15:43:01 +0200	[thread overview]
Message-ID: <c66e6c37-2068-4adc-bd25-3f8aad9c5195@app.fastmail.com> (raw)
In-Reply-To: <ff2a4c49-463d-4d8a-9519-bb51308f7ba1@linux.ibm.com>

On Thu, May 7, 2026, at 15:31, Peter Oberparleiter wrote:
> On 28.04.2026 22:56, Arnd Bergmann wrote:
>> On Wed, Apr 22, 2026, at 14:51, Konstantin Khorenko wrote:
>> 
>> ERROR: modpost: "__atomic_fetch_add_8" [kernel/trace/ring_buffer_benchmark.ko] undefined!
>> ERROR: modpost: "__aarch64_ldadd8_relax" [kernel/trace/preemptirq_delay_test.ko] undefined!
>> ERROR: modpost: "__aarch64_ldadd8_relax" [kernel/trace/synth_event_gen_test.ko] undefined!
>> ERROR: modpost: "__aarch64_ldadd8_relax" [kernel/trace/remote_test.ko] undefined!
>> 
>> ERROR: modpost: "__aarch64_ldadd8_relax" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined!
>> 
>> Since I build only with CONFIG_COMPILE_TEST=y, it looks like these
>> are the files that explictly enable GCOV, and likely all others
>> would run into the same issue.
>
> So the use of -fprofile-update=prefer-atomic in the kernel causes link
> errors on systems for which GCC does not support built-in atomic ops for
> the 64 bit profiling data type. Your test triggers this due to
> CONFIG_COMPILE_TEST but as you stated this would hit all GCOV users on
> such systems.
>
> I can see multiple approaches to address this issue:
>
> 1. Drop the patch
>    => not preferred - crash would still remain, and the consistency
>    improvements would be lost

This might be an option for the moment, until we have a better
solution though.

> 2. Make -fprofile-update dependent on !COMPILE_TEST
>    => would enable randconfig compiles with COMPILE_TEST=y

This would still leave the same build failure for any actual users
on the affected systems (x86-64 and arm64 at least), right?

> 3. Make -fprofile-update dependent on the result of a test-compile of a
>    user space test program (not sure if there is an easier way to
>    determine whether built-in atomic ops are available for the gcov
>    type)
>    => would enable fix + improvements for all environments, where
>    they are supported, but requires slightly more complex changes in
>    linux/Makefile

This seems fine to me, but I wonder which architectures actually
support it at the moment. I assume you are successfully using it
on s390, but if the two most commonly used architectures don't
support it, it's not clear to me who else actually can.

> 4. Provide wrappers for GCC libatomic => kernel atomic functions
>    => would enable fix + improvements for GCOV users on all systems
>    But: bigger change + linker errors mentioned above suggest that
>    GCC libatomic function names may be arch specific which makes this
>    approach more complex

The lack of libatomic support in the kernel has come up a few times
before, when driver writers attempted to use standard C11 _Atomic
variables. I think so far we have always reverted back to the kernel's
own atomic_t implementation here, mostly because kernel developers
are more comfortable with the existing memory model, which seems
to have some subtle differences from the C11 semantics.

      Arnd

  reply	other threads:[~2026-05-07 13:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-22 12:51 [PATCH v2 0/1] gcov: use -fprofile-update=prefer-atomic to fix concurrent access crashes Konstantin Khorenko
2026-04-22 12:51 ` [PATCH v2] gcov: use atomic counter updates " Konstantin Khorenko
2026-04-22 21:26   ` Konstantin Khorenko
2026-04-28 20:56   ` Arnd Bergmann
2026-05-07 13:31     ` Peter Oberparleiter
2026-05-07 13:43       ` Arnd Bergmann [this message]
2026-05-08 19:48         ` Andrew Morton
2026-05-09 11:50       ` Konstantin Khorenko
2026-05-09 14:36         ` Konstantin Khorenko
2026-05-09 15:14         ` Arnd Bergmann
2026-05-11  9:43           ` Konstantin Khorenko

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=c66e6c37-2068-4adc-bd25-3f8aad9c5195@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=akpm@linux-foundation.org \
    --cc=khorenko@virtuozzo.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    --cc=oberpar@linux.ibm.com \
    --cc=ojeda@kernel.org \
    --cc=ptikhomirov@virtuozzo.com \
    --cc=vasileios.almpanis@virtuozzo.com \
    --cc=zaslonko@linux.ibm.com \
    /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