From: Heiko Carstens <hca@linux.ibm.com>
To: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Andrey Ryabinin <ryabinin.a.a@gmail.com>,
linux-s390@vger.kernel.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com
Subject: Re: [PATCH v7 2/4] s390/mm: Batch PTE updates in lazy MMU mode
Date: Mon, 24 Aug 2026 12:40:48 +0200 [thread overview]
Message-ID: <20260824104048.11040Cdc-hca@linux.ibm.com> (raw)
In-Reply-To: <d7fd78377a7278108ef501cf76571e80caef5968.1786956464.git.agordeev@linux.ibm.com>
On Mon, Aug 17, 2026 at 01:33:00PM +0200, Alexander Gordeev wrote:
> diff --git a/arch/s390/include/asm/lowcore.h b/arch/s390/include/asm/lowcore.h
> index 3b3ecc647993..dba236664da9 100644
> --- a/arch/s390/include/asm/lowcore.h
> +++ b/arch/s390/include/asm/lowcore.h
> @@ -163,7 +163,7 @@ struct lowcore {
> __s32 preempt_count; /* 0x03a8 */
> __u32 spinlock_lockval; /* 0x03ac */
> __u32 spinlock_index; /* 0x03b0 */
> - __u8 pad_0x03b4[0x03b8-0x03b4]; /* 0x03b4 */
> + __s32 lazy_mmu_count; /* 0x03b4 */
Why is this signed? Can it get negative?
> +static __always_inline bool is_lazy_mmu_active(void)
> +{
> + if (__is_defined(__DECOMPRESSOR))
> + return false;
> + if (!get_lowcore()->lazy_mmu_count)
> + return false;
I guess there is opportunity to generate better code here using an
alternative and using a flag output constraint too.
> --- a/arch/s390/kernel/setup.c
> +++ b/arch/s390/kernel/setup.c
> @@ -77,6 +77,7 @@
> #include <asm/maccess.h>
> #include <asm/uv.h>
> #include <asm/asm-offsets.h>
> +#include <asm/lazy_mmu.h>
> #include "entry.h"
>
> /*
> @@ -1012,5 +1013,6 @@ void __init setup_arch(char **cmdline_p)
>
> void __init arch_cpu_finalize_init(void)
> {
> + lazy_mmu_online_boot_cpu();
> sclp_init();
> }
What makes this code so special that an explicit call from
arch_cpu_finalize_init() is required? This is really the last resort if
everything else fails. To me it looks like the code can be changed to use a
new static key, and add a generic early (pre-smp) initcall to allocate
memory for cpu 0, and if that succeeds enable the static key.
> --- a/arch/s390/kernel/smp.c
> +++ b/arch/s390/kernel/smp.c
> @@ -59,6 +59,7 @@
> #include <asm/topology.h>
> #include <asm/vdso.h>
> #include <asm/maccess.h>
> +#include <asm/lazy_mmu.h>
> #include "entry.h"
>
> enum {
> @@ -866,6 +867,11 @@ int __cpu_up(unsigned int cpu, struct task_struct *tidle)
> rc = pcpu_alloc_lowcore(pcpu, cpu);
> if (rc)
> return rc;
> + rc = lazy_mmu_online_cpu(GFP_KERNEL, cpu);
> + if (rc) {
> + pcpu_free_lowcore(pcpu, cpu);
> + return rc;
> + }
> /*
> * Make sure global control register contents do not change
> * until new CPU has initialized control registers.
> @@ -921,6 +927,7 @@ void __cpu_die(unsigned int cpu)
> pcpu = per_cpu_ptr(&pcpu_devices, cpu);
> while (!pcpu_stopped(pcpu))
> cpu_relax();
> + lazy_mmu_offline_cpu(cpu);
Same here: what makes this code so special that this needs to be open-coded
into the low level cpu hotplug code? Everybody who needs to change this
code in future will wonder why the mmu code is so special that it needs to
be directly handled here, and then needs to understand the mmu code.
And the answer is: there is no reason.
Please use a generic cpu hotplug notifier to avoid that maintenance get's
more expensive.
> +static void leave_ipte_range(void)
> +{
> + pte_t *ptep, *start, *start_cache, *cache;
> + unsigned long start_addr, addr;
> + struct ipte_range *range;
> + int start_idx;
> +
> + if (!test_facility(13))
> + return;
> +
> + local_bh_disable();
> +
> + lockdep_assert_preemption_disabled();
> + range = this_cpu_read(ipte_range);
Why is it required to disable bottom halves? A comment would be helpful.
Or a hint in the commit message - this is not obvious.
Also at least for !PREEMPT_RT (which is always true for s390)
lockdep_assert_preemption_disabled() is quite pointless, since
local_bh_disable() just one line above disables preemption.
I guess you wanted to add that check above local_bh_disable()?
If not you could as well remove it
next prev parent reply other threads:[~2026-08-24 10:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 11:32 [PATCH v7 0/4] s390/mm: Batch PTE updates in lazy MMU mode Alexander Gordeev
2026-08-17 11:32 ` [PATCH v7 1/4] mm: Make lazy MMU mode context-aware Alexander Gordeev
2026-08-17 11:33 ` [PATCH v7 2/4] s390/mm: Batch PTE updates in lazy MMU mode Alexander Gordeev
2026-08-24 10:40 ` Heiko Carstens [this message]
2026-08-17 11:33 ` [PATCH v7 3/4] mm/kasan: Introduce helpers for lazy MMU mode sanitizer Alexander Gordeev
2026-08-17 22:11 ` Andrey Konovalov
2026-08-18 12:01 ` Alexander Gordeev
2026-08-24 9:56 ` Heiko Carstens
2026-08-25 7:50 ` Alexander Gordeev
2026-08-25 10:08 ` Heiko Carstens
2026-08-17 11:33 ` [PATCH v7 4/4] s390/mm: Lazy " 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=20260824104048.11040Cdc-hca@linux.ibm.com \
--to=hca@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gerald.schaefer@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-s390@vger.kernel.org \
--cc=ryabinin.a.a@gmail.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