All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Heiko Carstens" <hca@linux.ibm.com>
Cc: linux-s390@vger.kernel.org, "Vasily Gorbik" <gor@linux.ibm.com>,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>
Subject: Re: [PATCH 3/4] s390/percpu: Drop unused output register from arch_this_cpu_to_op()
Date: Mon, 12 Oct 2026 11:54:14 +0000	[thread overview]
Message-ID: <sashiko-outbox-168033@kernel.org> (raw)
In-Reply-To: <20261012114249.2898572-4-hca@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] s390/percpu: unpredictable LAN/LAO behavior from R1==R3
--

commit 657f51d5e5b9873bdbdaca586024d213577edd7b
Author: Heiko Carstens <hca@linux.ibm.com>

s390/percpu: Drop unused output register from arch_this_cpu_to_op()

The lan/lang/lao/laog instructions return the old memory content, but
arch_this_cpu_to_op() does not need it. This commit changes the val__
constraint to use it as an input/output register instead of a dedicated
old__ register, aiming to reduce register pressure.

> diff --git a/arch/s390/include/asm/percpu.h b/arch/s390/include/asm/percpu.h
> index fd0a3a9951ce7..7d87e0a262c37 100644
> --- a/arch/s390/include/asm/percpu.h
> +++ b/arch/s390/include/asm/percpu.h
> @@ -257,18 +257,18 @@ do {									\
>  	typedef typeof(pcp) pcp_op_T__; 				\
>  	union register_pair rp__;					\
>  	pcp_op_T__ val__ = (val);					\
> -	pcp_op_T__ old__, *ptr__;					\
> +	pcp_op_T__ *ptr__;						\
>  									\
>  	ptr__ = PERCPU_PTR(&(pcp));					\
>  	asm_inline volatile(						\
>  		__PCPU_BEGIN("%[lcreg]","%[lcoff]","%[ptr__]",		\
>  			     "%[pair__]","%N[pair__]")			\
> -		op "    %[old__],%[val__],0(%N[pair__])\n"		\
> +		op "    %[val__],%[val__],0(%N[pair__])\n"		\

[Severity: High]
Does this inline assembly string force the compiler to emit the atomic
instruction using the identical register for both the r1 and r3 operands?

According to the z/Architecture Principles of Operation, if r1 and r3
designate the same register in laa, lan, and lao instructions, the results
are unpredictable.

By hardcoding `%[val__],%[val__]`, the exact same register is used for both r1
(the output destination for the old value) and r3 (the input addend/mask). Does
this emit unpredictable assembly for invocations of this_cpu_and_* or
this_cpu_or_*?

Also, arch_this_cpu_add() was modified similarly just one commit earlier in
this series ("s390/percpu: Drop unused output register from
arch_this_cpu_add()"). Does that macro have the same unpredictability
regression for laa?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261012114249.2898572-1-hca@linux.ibm.com?part=3

  reply	other threads:[~2026-10-12 11:54 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12 11:42 [PATCH 0/4] s390/percpu: More small improvements Heiko Carstens
2026-10-12 11:42 ` [PATCH 1/4] s390/percpu: Use asm_inline for arch_this_cpu_add() Heiko Carstens
2026-10-12 11:46   ` sashiko-bot
2026-10-12 12:41   ` Alexander Gordeev
2026-10-12 11:42 ` [PATCH 2/4] s390/percpu: Drop unused output register from arch_this_cpu_add() Heiko Carstens
2026-10-12 11:51   ` sashiko-bot
2026-10-12 13:24   ` Alexander Gordeev
2026-10-12 14:16     ` Heiko Carstens
2026-10-12 14:34   ` Alexander Gordeev
2026-10-12 11:42 ` [PATCH 3/4] s390/percpu: Drop unused output register from arch_this_cpu_to_op() Heiko Carstens
2026-10-12 11:54   ` sashiko-bot [this message]
2026-10-12 12:18     ` Heiko Carstens
2026-10-12 14:35   ` Alexander Gordeev
2026-10-12 11:42 ` [PATCH 4/4] s390/percpu: Implement this_cpu_try_cmpxchg() Heiko Carstens
2026-10-12 11:51   ` sashiko-bot
2026-10-12 15:11   ` Alexander Gordeev

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=sashiko-outbox-168033@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.