From: Yang Shi <yang@os.amperecomputing.com>
To: Ryan Roberts <ryan.roberts@arm.com>, Yeoreum Yun <yeoreum.yun@arm.com>
Cc: Will Deacon <will@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev,
catalin.marinas@arm.com, akpm@linux-oundation.org,
david@kernel.org, kevin.brodsky@arm.com,
quic_zhenhuah@quicinc.com, dev.jain@arm.com,
chaitanyas.prakash@arm.com, bigeasy@linutronix.de,
clrkwllms@kernel.org, rostedt@goodmis.org,
lorenzo.stoakes@oracle.com, ardb@kernel.org, jackmanb@google.com,
vbabka@suse.cz, mhocko@suse.com
Subject: Re: [PATCH v5 2/3] arm64: mmu: avoid allocating pages while splitting the linear mapping
Date: Tue, 20 Jan 2026 16:12:20 -0800 [thread overview]
Message-ID: <02bb61cc-f0be-41e5-b8b2-59768afd5254@os.amperecomputing.com> (raw)
In-Reply-To: <11a01f4e-9ae5-4001-9f9c-74a746f898cd@arm.com>
>> My concern is that if a secondary CPU can race and cause a split, that is
>> unsound because we have determined that although the primary CPU supports BBML2,
>> at least one of the secondary CPUs does not. So splitting a live mapping is unsafe.
>>
>> I just had a brief chat with Rutland, and he agrees that this _could_ be a
>> problem. Basically there is a window between onlining the secondary cpus and
>> entering the stop_machine() where one of those cpus _could_ end up doing
>> something that causes us to split the linear map.
If I remember correctly, split_kernel_leaf_mapping() does call
system_supports_bbml2_noabort() before doing real split. So we basically
should fall into two categories:
1. bbml2_noabort is supported on all cpus. Everything is fine.
2. bbml2_noabort is not supported on all cpus.
split_kernel_leaf_mapping() just returns 0. Kernel doesn't split page
table, so there won't be TLB conflict issue. But the following page prot
update may see unexpected block mapping, then a WARN will be raised
and it will return -EINVAL. So the worst case is the caller will fail
(IIRC all the callers of set_memory_*() handle the failure), and we can
know who is trying to change linear mapping before the linear mapping
gets finalized. AFAICT I haven't seen such WARN yet.
>>
>> I'm not immediately sure how to solve that.
Do we need some synchronization mechanism? If the linear mapping is not
finalized yet, split_kernel_leaf_mapping() will spin. For example,
something like this off the top of my head,
DEFINE_STATIC_KEY_FALSE(linear_mapping_finalized);
Once the linear mapping is finalized, we can call
static_branch_enable(&linear_mapping_finalized);
In split_kernel_leaf_mapping(), we can just do:
retry:
if (!static_branch_likely(&linear_mapping_finalized))
goto retry;
There may be better way to handle it. But this case should be very
unlikely IMHO. It sounds crazy to have such complicated kernel threads
run so early. I'm not sure whether we should pay immediate attention to
it or not.
Thanks,
Yang
>>
>> --
>> Sincerely,
>> Yeoreum Yun
next prev parent reply other threads:[~2026-01-21 0:12 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-05 20:23 [PATCH v5 0/3] fix wrong usage of memory allocation APIs under PREEMPT_RT in arm64 Yeoreum Yun
2026-01-05 20:23 ` [PATCH v5 1/3] arm64: mmu: introduce pgtable_alloc_t Yeoreum Yun
2026-01-05 20:23 ` [PATCH v5 2/3] arm64: mmu: avoid allocating pages while splitting the linear mapping Yeoreum Yun
2026-01-19 17:28 ` Will Deacon
2026-01-19 21:24 ` Yeoreum Yun
2026-01-20 8:56 ` Ryan Roberts
2026-01-20 9:29 ` Yeoreum Yun
2026-01-20 10:40 ` Ryan Roberts
2026-01-20 10:54 ` Yeoreum Yun
2026-01-20 15:53 ` Will Deacon
2026-01-20 16:16 ` Yeoreum Yun
2026-01-20 16:22 ` Ryan Roberts
2026-01-20 16:31 ` Yeoreum Yun
2026-01-20 17:35 ` Ryan Roberts
2026-01-20 17:49 ` Yeoreum Yun
2026-01-21 0:12 ` Yang Shi [this message]
2026-01-21 8:32 ` Yeoreum Yun
2026-01-21 10:20 ` Ryan Roberts
2026-01-21 11:30 ` Yeoreum Yun
2026-01-21 22:57 ` Yang Shi
2026-01-22 7:42 ` Yeoreum Yun
2026-01-22 13:47 ` Ryan Roberts
2026-01-20 22:24 ` Yang Shi
2026-01-20 23:01 ` Yeoreum Yun
2026-01-21 0:43 ` Yang Shi
2026-01-21 8:15 ` Yeoreum Yun
2026-01-05 20:23 ` [PATCH v5 3/3] arm64: mmu: avoid allocating pages while installing ng-mapping for KPTI Yeoreum Yun
2026-01-19 17:31 ` Will Deacon
2026-01-19 21:30 ` Yeoreum Yun
2026-01-20 11:44 ` Will Deacon
2026-01-20 15:30 ` Yeoreum Yun
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=02bb61cc-f0be-41e5-b8b2-59768afd5254@os.amperecomputing.com \
--to=yang@os.amperecomputing.com \
--cc=akpm@linux-oundation.org \
--cc=ardb@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=catalin.marinas@arm.com \
--cc=chaitanyas.prakash@arm.com \
--cc=clrkwllms@kernel.org \
--cc=david@kernel.org \
--cc=dev.jain@arm.com \
--cc=jackmanb@google.com \
--cc=kevin.brodsky@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=lorenzo.stoakes@oracle.com \
--cc=mhocko@suse.com \
--cc=quic_zhenhuah@quicinc.com \
--cc=rostedt@goodmis.org \
--cc=ryan.roberts@arm.com \
--cc=vbabka@suse.cz \
--cc=will@kernel.org \
--cc=yeoreum.yun@arm.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
all inboxes | Powered by JetHome®