s390/preempt: disable __preempt_count_add() optimization for PROFILE_ALL_BRANCHES
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 6 May 2022 09:33:19 +0000 (11:33 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jun 2022 14:53:45 +0000 (16:53 +0200)
commit30cf47a602746a9a5e37834193885824c7a28f2e
tree8d9cf7db127c6d3ad4004278994d1f3baba5aa5a
parent9f30da95040bb0b6a0e4f953d9395498f3dcf807
s390/preempt: disable __preempt_count_add() optimization for PROFILE_ALL_BRANCHES

[ Upstream commit 63678eecec57fc51b778be3da35a397931287170 ]

gcc 12 does not (always) optimize away code that should only be generated
if parameters are constant and within in a certain range. This depends on
various obscure kernel config options, however in particular
PROFILE_ALL_BRANCHES can trigger this compile error:

In function ‘__atomic_add_const’,
    inlined from ‘__preempt_count_add.part.0’ at ./arch/s390/include/asm/preempt.h:50:3:
./arch/s390/include/asm/atomic_ops.h:80:9: error: impossible constraint in ‘asm’
   80 |         asm volatile(                                                   \
      |         ^~~

Workaround this by simply disabling the optimization for
PROFILE_ALL_BRANCHES, since the kernel will be so slow, that this
optimization won't matter at all.

Reported-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/s390/include/asm/preempt.h