From: Benjamin Gray <bgray@linux.ibm.com>
To: Christophe Leroy <christophe.leroy@csgroup.eu>,
"linuxppc-dev@lists.ozlabs.org" <linuxppc-dev@lists.ozlabs.org>,
"mpe@ellerman.id.au" <mpe@ellerman.id.au>
Subject: Re: [PATCH v1 2/2] powerpc/code-patching: Convert to open_patch_window()/close_patch_window()
Date: Mon, 18 Mar 2024 08:34:17 +1100 [thread overview]
Message-ID: <175080fd47ff7e016a73a553c1b93d2bc8bdae39.camel@linux.ibm.com> (raw)
In-Reply-To: <77fdcdeb-4af5-4ad0-a4c6-57bf0762dc65@csgroup.eu>
On Sat, 2024-03-16 at 10:10 +0000, Christophe Leroy wrote:
>
>
> Le 15/03/2024 à 09:38, Christophe Leroy a écrit :
> >
> >
> > Le 15/03/2024 à 03:59, Benjamin Gray a écrit :
> > > The existing patching alias page setup and teardown sections can
> > > be
> > > simplified to make use of the new open_patch_window()
> > > abstraction.
> > >
> > > This eliminates the _mm variants of the helpers, consumers no
> > > longer
> > > need to check mm_patch_enabled(), and consumers no longer need to
> > > worry
> > > about synchronization and flushing beyond the changes they make
> > > in the
> > > patching window.
> >
> > With this patch, the time needed to activate or de-activate
> > function
> > tracer is approx 10% longer on powerpc 8xx.
>
> With the following changes, the performance is restored:
>
> diff --git a/arch/powerpc/lib/code-patching.c
> b/arch/powerpc/lib/code-patching.c
> index fd6f8576033a..bc92b85913d8 100644
> --- a/arch/powerpc/lib/code-patching.c
> +++ b/arch/powerpc/lib/code-patching.c
> @@ -282,13 +282,13 @@ struct patch_window {
> * Interrupts must be disabled for the entire duration of the
> patching. The PIDR
> * is potentially changed during this time.
> */
> -static int open_patch_window(void *addr, struct patch_window *ctx)
> +static __always_inline int open_patch_window(void *addr, struct
> patch_window *ctx)
> {
> unsigned long pfn = get_patch_pfn(addr);
>
> lockdep_assert_irqs_disabled();
>
> - ctx->text_poke_addr = (unsigned
> long)__this_cpu_read(cpu_patching_context.addr);
> + ctx->text_poke_addr = (unsigned
> long)__this_cpu_read(cpu_patching_context.addr) & PAGE_MASK;
>
> if (!mm_patch_enabled()) {
> ctx->ptep =
> __this_cpu_read(cpu_patching_context.pte);
> @@ -331,7 +331,7 @@ static int open_patch_window(void *addr, struct
> patch_window *ctx)
> return 0;
> }
>
> -static void close_patch_window(struct patch_window *ctx)
> +static __always_inline void close_patch_window(struct patch_window
> *ctx)
> {
> lockdep_assert_irqs_disabled();
>
>
Thanks for checking that. I did restore the page mask optimisation in a
later patch while still developing, but the 64-bit assembly looked
slightly worse for it. I didn't check the 32-bit; no way to benchmark
it anyway.
prev parent reply other threads:[~2024-03-17 21:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-15 2:59 [PATCH v1 1/2] powerpc/code-patching: Introduce open_patch_window()/close_patch_window() Benjamin Gray
2024-03-15 2:59 ` [PATCH v1 2/2] powerpc/code-patching: Convert to open_patch_window()/close_patch_window() Benjamin Gray
2024-03-15 8:38 ` Christophe Leroy
2024-03-16 9:50 ` Christophe Leroy
2024-03-16 10:10 ` Christophe Leroy
2024-03-17 21:34 ` Benjamin Gray [this message]
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=175080fd47ff7e016a73a553c1b93d2bc8bdae39.camel@linux.ibm.com \
--to=bgray@linux.ibm.com \
--cc=christophe.leroy@csgroup.eu \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
/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).