From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Nicholas Piggin <npiggin@gmail.com>,
qemu-devel@nongnu.org, qemu-ppc@nongnu.org
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Brian Cain" <bcain@quicinc.com>,
"Mark Burton" <mburton@qti.qualcomm.com>,
"Anton Johansson" <anjo@rev.ng>, "Emilio Cota" <cota@braap.org>,
"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [RFC PATCH] accel/tcg: clear all TBs from a page when it is written to
Date: Fri, 9 Aug 2024 10:26:26 +0200 [thread overview]
Message-ID: <e1fcd91b-643d-4a5e-956c-0642d001aec1@linaro.org> (raw)
In-Reply-To: <20240809074725.320801-1-npiggin@gmail.com>
(Widening Cc list)
On 9/8/24 09:47, Nicholas Piggin wrote:
> This is not a clean patch, but does fix a problem I hit with TB
> invalidation due to the target software writing to memory with TBs.
>
> Lockup messages are triggering in Linux due to page clearing taking a
> long time when a code page has been freed, because it takes a lot of
> notdirty notifiers, which massively slows things down. Linux might
> possibly have a bug here too because it seems to hang indefinitely in
> some cases, but even if it didn't, the latency of clearing these pages
> is very high.
>
> This showed when running KVM on the emulated machine, starting and
> stopping guests. That causes lots of instruction pages to be freed.
> Usually if you're just running Linux, executable pages remain in
> pagecache so you get fewer of these bombs in the kernel memory
> allocator. But page reclaim, JITs, deleting executable files, etc.,
> could trigger it too.
>
> Invalidating all TBs from the page on any hit seems to avoid the problem
> and generally speeds things up.
>
> How important is the precise invalidation? These days I assume the
> tricky kind of SMC that frequently writes code close to where it's
> executing is pretty rare and might not be something we really care about
> for performance. Could we remove sub-page TB invalidation entirely?
>
> Thanks,
> Nick
> ---
> accel/tcg/tb-maint.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c
> index cc0f5afd47..d9a76b1665 100644
> --- a/accel/tcg/tb-maint.c
> +++ b/accel/tcg/tb-maint.c
> @@ -1107,6 +1107,9 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages,
> TranslationBlock *current_tb = retaddr ? tcg_tb_lookup(retaddr) : NULL;
> #endif /* TARGET_HAS_PRECISE_SMC */
>
> + start &= TARGET_PAGE_MASK;
> + last |= ~TARGET_PAGE_MASK;
> +
> /* Range may not cross a page. */
> tcg_debug_assert(((start ^ last) & TARGET_PAGE_MASK) == 0);
>
next prev parent reply other threads:[~2024-08-09 8:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-09 7:47 [RFC PATCH] accel/tcg: clear all TBs from a page when it is written to Nicholas Piggin
2024-08-09 8:26 ` Philippe Mathieu-Daudé [this message]
2024-08-12 1:25 ` Richard Henderson
2024-08-14 6:09 ` Nicholas Piggin
2024-08-20 23:16 ` Richard Henderson
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=e1fcd91b-643d-4a5e-956c-0642d001aec1@linaro.org \
--to=philmd@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=anjo@rev.ng \
--cc=bcain@quicinc.com \
--cc=cota@braap.org \
--cc=mburton@qti.qualcomm.com \
--cc=npiggin@gmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=richard.henderson@linaro.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;
as well as URLs for NNTP newsgroup(s).