From: Alexander Gordeev <agordeev@linux.ibm.com>
To: Ryan Roberts <ryan.roberts@arm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"David S. Miller" <davem@davemloft.net>,
Andreas Larsson <andreas@gaisler.com>,
Juergen Gross <jgross@suse.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
Catalin Marinas <catalin.marinas@arm.com>,
linux-mm@kvack.org, sparclinux@vger.kernel.org,
xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 0/5] Fix lazy mmu mode
Date: Thu, 10 Apr 2025 18:07:49 +0200 [thread overview]
Message-ID: <912c7a32-b39c-494f-a29c-4865cd92aeba@agordeev.local> (raw)
In-Reply-To: <20250303141542.3371656-1-ryan.roberts@arm.com>
On Mon, Mar 03, 2025 at 02:15:34PM +0000, Ryan Roberts wrote:
Hi Ryan,
> I'm planning to implement lazy mmu mode for arm64 to optimize vmalloc. As part
> of that, I will extend lazy mmu mode to cover kernel mappings in vmalloc table
> walkers. While lazy mmu mode is already used for kernel mappings in a few
> places, this will extend it's use significantly.
>
> Having reviewed the existing lazy mmu implementations in powerpc, sparc and x86,
> it looks like there are a bunch of bugs, some of which may be more likely to
> trigger once I extend the use of lazy mmu.
Do you have any idea about generic code issues as result of not adhering to
the originally stated requirement:
/*
...
* the PTE updates which happen during this window. Note that using this
* interface requires that read hazards be removed from the code. A read
* hazard could result in the direct mode hypervisor case, since the actual
* write to the page tables may not yet have taken place, so reads though
* a raw PTE pointer after it has been modified are not guaranteed to be
* up to date.
...
*/
I tried to follow few code paths and at least this one does not look so good:
copy_pte_range(..., src_pte, ...)
ret = copy_nonpresent_pte(..., src_pte, ...)
try_restore_exclusive_pte(..., src_pte, ...) // is_device_exclusive_entry(entry)
restore_exclusive_pte(..., ptep, ...)
set_pte_at(..., ptep, ...)
set_pte(ptep, pte); // save in lazy mmu mode
// ret == -ENOENT
ptent = ptep_get(src_pte); // lazy mmu save is not observed
ret = copy_present_ptes(..., ptent, ...); // wrong ptent used
I am not aware whether the effort to "read hazards be removed from the code"
has ever been made and the generic code is safe in this regard.
What is your take on this?
Thanks!
next prev parent reply other threads:[~2025-04-10 16:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-03 14:15 Ryan Roberts
2025-03-03 14:15 ` [PATCH v2 1/5] mm: Fix lazy mmu docs and usage Ryan Roberts
2025-03-03 14:15 ` [PATCH v2 2/5] fs/proc/task_mmu: Reduce scope of lazy mmu region Ryan Roberts
2025-03-03 14:15 ` [PATCH v2 3/5] sparc/mm: Disable preemption in lazy mmu mode Ryan Roberts
2025-03-03 14:15 ` [PATCH v2 4/5] sparc/mm: Avoid calling arch_enter/leave_lazy_mmu() in set_ptes Ryan Roberts
2025-03-03 14:15 ` [PATCH v2 5/5] Revert "x86/xen: allow nesting of same lazy mode" Ryan Roberts
2025-03-03 14:36 ` [PATCH v2 0/5] Fix lazy mmu mode Jürgen Groß
2025-04-10 16:07 ` Alexander Gordeev [this message]
2025-04-14 13:22 ` Ryan Roberts
2025-04-14 14:04 ` Alexander Gordeev
2025-04-14 14:11 ` Ryan Roberts
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=912c7a32-b39c-494f-a29c-4865cd92aeba@agordeev.local \
--to=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=andreas@gaisler.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mingo@redhat.com \
--cc=ryan.roberts@arm.com \
--cc=sparclinux@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=willy@infradead.org \
--cc=xen-devel@lists.xenproject.org \
/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