From: "David Hildenbrand (Red Hat)" <david@kernel.org>
To: Ryan Roberts <ryan.roberts@arm.com>,
catalin.marinas@arm.com, will@kernel.org,
yang@os.amperecomputing.com, ardb@kernel.org, dev.jain@arm.com,
scott@os.amperecomputing.com, cl@gentwo.org
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Guenter Roeck <groeck@google.com>
Subject: Re: [PATCH v1] arm64: mm: Don't sleep in split_kernel_leaf_mapping() when in atomic context
Date: Mon, 3 Nov 2025 16:38:02 +0100 [thread overview]
Message-ID: <e5fee14a-4569-49c8-9f42-844839e51e85@kernel.org> (raw)
In-Reply-To: <20251103125738.3073566-1-ryan.roberts@arm.com>
> }
>
> +static inline bool force_pte_mapping(void)
> +{
> + bool bbml2 = system_capabilities_finalized() ?
> + system_supports_bbml2_noabort() : cpu_supports_bbml2_noabort();
You are only moving this function. Still, there is some room for improvement I want to point out :)
bbml2 could be a const (or a helper function like bbml2_supported).
> +
> + return (!bbml2 && (rodata_full || arm64_kfence_can_set_direct_map() ||
> + is_realm_world())) ||
> + debug_pagealloc_enabled();
I suspect this could be made a bit easier to read.
if (debug_pagealloc_enabled())
return true;
if (bbml2)
return false;
return rodata_full || arm64_kfence_can_set_direct_map() || is_realm_world();
> +}
> +
> static DEFINE_MUTEX(pgtable_split_lock);
>
> int split_kernel_leaf_mapping(unsigned long start, unsigned long end)
> @@ -723,6 +733,16 @@ int split_kernel_leaf_mapping(unsigned long start, unsigned long end)
> if (!system_supports_bbml2_noabort())
> return 0;
>
> + /*
> + * If the region is within a pte-mapped area, there is no need to try to
> + * split. Additionally, CONFIG_DEBUG_PAGEALLOC and CONFIG_KFENCE may
> + * change permissions from softirq context so for those cases (which are
> + * always pte-mapped), we must not go any further because taking the
> + * mutex below may sleep.
> + */
> + if (force_pte_mapping() || is_kfence_address((void *)start))
> + return 0;
> +
We're effectively performing two system_supports_bbml2_noabort() checks, similarly in
arch_kfence_init_pool().
I wonder if there is a clean way to avoid that.
I'm not super up-to-date on that code. Nothing else jumped at me.
--
Cheers
David
next prev parent reply other threads:[~2025-11-03 15:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-03 12:57 Ryan Roberts
2025-11-03 15:37 ` Will Deacon
2025-11-03 16:28 ` Ryan Roberts
2025-11-04 8:31 ` Ryan Roberts
2025-11-04 12:41 ` Will Deacon
2025-11-04 12:52 ` Ryan Roberts
2025-11-03 15:38 ` David Hildenbrand (Red Hat) [this message]
2025-11-03 17:28 ` Ryan Roberts
2025-11-03 18:06 ` David Hildenbrand (Red Hat)
2025-11-03 18:05 ` Yang Shi
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=e5fee14a-4569-49c8-9f42-844839e51e85@kernel.org \
--to=david@kernel.org \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=cl@gentwo.org \
--cc=dev.jain@arm.com \
--cc=groeck@google.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ryan.roberts@arm.com \
--cc=scott@os.amperecomputing.com \
--cc=will@kernel.org \
--cc=yang@os.amperecomputing.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®