From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: Peter Oberparleiter <oberpar@linux.ibm.com>,
Arnd Bergmann <arnd@arndb.de>
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>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nicolas Schier" <nsc@kernel.org>
Subject: Re: [PATCH v2] gcov: use atomic counter updates to fix concurrent access crashes
Date: Sat, 9 May 2026 13:50:42 +0200 [thread overview]
Message-ID: <dca5a1ce-feb3-420a-b452-52707373dd61@virtuozzo.com> (raw)
In-Reply-To: <ff2a4c49-463d-4d8a-9519-bb51308f7ba1@linux.ibm.com>
On 5/7/26 15:31, Peter Oberparleiter wrote:
> On 28.04.2026 22:56, Arnd Bergmann wrote:
...
>
> 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
> 2. Make -fprofile-update dependent on !COMPILE_TEST
> => would enable randconfig compiles with COMPILE_TEST=y
> 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
> 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
>
> I tend towards option 3 or 2, but I'm also open for other ideas.
>
> @Konstantin Khorenko: would you be willing to work on this as the author
> of the original fix?
Peter, Arnd,
Thank you very much for taking a look here.
I'll work on option 3 (compile-time check).
If i understand this correctly the idea is to verify at build time
whether the compiler actually inlines 64-bit atomic increments or
emits calls to libatomic helpers, and only add
-fprofile-update=prefer-atomic when it's safe.
I did a quick test: with GCC 14.2.1 in -m32 mode (i386 target), 64-bit
atomics are fully inlined via lock cmpxchg8b - no __atomic_fetch_add_8
call is generated.
So this might actually be a GCC-16 regression in codegen rather than
an inherent architecture limitation.
I'm currently rebuilding GCC trunk to verify.
Arnd,
could you please share the two .config files that triggered the link
failures (the x86_64 one with __atomic_fetch_add_8 and the aarch64 one
with __aarch64_ldadd8_relax)?
That could make my life a bit easier. :)
Thank you,
Konstantin
next prev parent reply other threads:[~2026-05-09 11:50 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
2026-05-08 19:48 ` Andrew Morton
2026-05-09 11:50 ` Konstantin Khorenko [this message]
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=dca5a1ce-feb3-420a-b452-52707373dd61@virtuozzo.com \
--to=khorenko@virtuozzo.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--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