From: Peter Zijlstra <peterz@infradead.org>
To: Heiko Carstens <hca@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Juergen Christ <jchrist@linux.ibm.com>,
linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Subject: Re: [PATCH 0/9] s390: Improve this_cpu operations
Date: Tue, 17 Mar 2026 22:08:41 +0100 [thread overview]
Message-ID: <20260317210841.GK2872@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20260317195436.2276810-1-hca@linux.ibm.com>
On Tue, Mar 17, 2026 at 08:54:27PM +0100, Heiko Carstens wrote:
> The idea is that this_cpu operations based on atomic instructions are
> guarded with mvyi instructions:
>
> - The first mvyi instruction writes the register number, which contains
> the percpu address variable to lowcore. This also indicates that a
> percpu code section is executed.
>
> - The first instruction following the mvyi instruction must be the ag
> instruction which adds the percpu offset to the percpu address register.
>
> - Afterwards the atomic percpu operation follows.
>
> - Then a second mvyi instruction writes a zero to lowcore, which indicates
> the end of the percpu code section.
>
> - In case of an interrupt/exception/nmi the register number which was
> written to lowcore is copied to the exception frame (pt_regs), and a zero
> is written to lowcore.
>
> - On return to the previous context it is checked if a percpu code section
> was executed (saved register number not zero), and if the process was
> migrated to a different cpu. If the percpu offset was already added to
> the percpu address register (instruction address does _not_ point to the
> ag instruction) the content of the percpu address register is adjusted so
> it points to percpu variable of the new cpu.
>
> All of this seems to work, but of course it could still be broken since I
> missed some detail.
Right, so this relies on them being single atomic RmW instructions. If
the interrupt/exception happens before the RmW the address is adjusted
and the atomic instruction is executed on the correct CPU. If the
interrupt/exception hits after the atomic but before the second "mvyi"
the address is still adjusted but then goes unused.
I don't immediately see a hole in that scheme. It is neat for not having
retries.
next prev parent reply other threads:[~2026-03-17 21:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-17 19:54 [PATCH 0/9] s390: Improve this_cpu operations Heiko Carstens
2026-03-17 19:54 ` [PATCH 1/9] s390/percpu: Provide arch_raw_cpu_ptr() Heiko Carstens
2026-03-17 19:54 ` [PATCH 2/9] s390/alternatives: Add new ALT_TYPE_PERCPU type Heiko Carstens
2026-03-17 19:54 ` [PATCH 3/9] s390/percpu: Infrastructure for more efficient this_cpu operations Heiko Carstens
2026-03-17 19:54 ` [PATCH 4/9] s390/percpu: Use new percpu code section for arch_this_cpu_add() Heiko Carstens
2026-03-17 19:54 ` [PATCH 5/9] s390/percpu: Use new percpu code section for arch_this_cpu_add_return() Heiko Carstens
2026-03-17 19:54 ` [PATCH 6/9] s390/percpu: Use new percpu code section for arch_this_cpu_[and|or]() Heiko Carstens
2026-03-17 19:54 ` [PATCH 7/9] s390/percpu: Provide arch_this_cpu_read() implementation Heiko Carstens
2026-03-17 19:54 ` [PATCH 8/9] s390/percpu: Provide arch_this_cpu_write() implementation Heiko Carstens
2026-03-17 19:54 ` [PATCH 9/9] s390/percpu: Remove one and two byte this_cpu operation implementation Heiko Carstens
2026-03-17 21:08 ` Peter Zijlstra [this message]
2026-03-23 10:26 ` [PATCH 0/9] s390: Improve this_cpu operations Juergen Christ
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=20260317210841.GK2872@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=jchrist@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=svens@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