From: Benjamin Gray <bgray@linux.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: christophe.leroy@c-s.fr, ajd@linux.ibm.com, peterz@infradead.org,
Benjamin Gray <bgray@linux.ibm.com>,
npiggin@gmail.com, ardb@kernel.org, jbaron@akamai.com,
rostedt@goodmis.org, jpoimboe@kernel.org
Subject: [PATCH v2 0/6] Out-of-line static calls for powerpc64 ELF V2
Date: Mon, 26 Sep 2022 16:43:10 +1000 [thread overview]
Message-ID: <20220926064316.765967-1-bgray@linux.ibm.com> (raw)
Implementation of out-of-line static calls for PowerPC 64-bit ELF V2 ABI.
Static calls patch an indirect branch into a direct branch at runtime.
Out-of-line specifically has a caller directly call a trampoline, and
the trampoline gets patched to directly call the target.
Previous version here:
https://lore.kernel.org/all/20220916062330.430468-1-bgray@linux.ibm.com/
I couldn't see a dedicated ftrace benchmark in the kernel, but my own
benchmarking showed no significant impact to ftrace activation.
The __patch_memory function is meant to be accessed through the size checking
patch_memory wrapper. I don't think there's a way to expose the macro without
also exposing __patch_memory though. I considered making the type an explicit
macro param, but using the value type seemed more ergonomic.
V2:
Mostly accounting for feedback from Christophe:
* Code patching rewritten
- Rename to *_memory
- Use __always_inline to get the compiler to realise it can
collapse all the sub-functions
- Pass data directly instead of through a pointer, elliding a redundant load
- Flush the last byte of data too (technically redundant if an instrucion, but
saves a conditional branch + the isync will be the bottleneck).
- Handle a non-cohenrent icache, assume a coherent dcache
- Handle when we don't assume a 64 byte icache on 64-bits
- Flatten the poke address init and teardown
- Check the data size in patch_memory at build time
(inline function was suggested, but a macro makes checking
based on the data type easier).
- It builds now on 32 bit and without strict RWX
* Static call enabling is no longer configurable
* Refactored arch_static_call_transform to minimise casting
* Made the KUnit tests more robust (previously they changed non-volatile
registers in the init hook, but that's incorrect because it returns to
the KUnit framework before the test case is called).
* Some other minor refactoring in other patches
Benjamin Gray (6):
powerpc/code-patching: Implement generic text patching function
powerpc/module: Handle caller-saved TOC in module linker
powerpc/module: Optimise nearby branches in ELF V2 ABI stub
static_call: Move static call selftest to static_call_selftest.c
powerpc/64: Add support for out-of-line static calls
powerpc/64: Add tests for out-of-line static calls
arch/powerpc/Kconfig | 12 +-
arch/powerpc/include/asm/code-patching.h | 8 +
arch/powerpc/include/asm/static_call.h | 80 +++++++-
arch/powerpc/kernel/Makefile | 4 +-
arch/powerpc/kernel/module_64.c | 27 ++-
arch/powerpc/kernel/static_call.c | 151 +++++++++++++-
arch/powerpc/kernel/static_call_test.c | 251 +++++++++++++++++++++++
arch/powerpc/kernel/static_call_test.h | 56 +++++
arch/powerpc/lib/code-patching.c | 90 +++++---
kernel/Makefile | 1 +
kernel/static_call_inline.c | 43 ----
kernel/static_call_selftest.c | 41 ++++
12 files changed, 682 insertions(+), 82 deletions(-)
create mode 100644 arch/powerpc/kernel/static_call_test.c
create mode 100644 arch/powerpc/kernel/static_call_test.h
create mode 100644 kernel/static_call_selftest.c
base-commit: 3d7a198cfdb47405cfb4a3ea523876569fe341e6
--
2.37.3
next reply other threads:[~2022-09-26 6:45 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-26 6:43 Benjamin Gray [this message]
2022-09-26 6:43 ` [PATCH v2 1/6] powerpc/code-patching: Implement generic text patching function Benjamin Gray
2022-09-26 8:56 ` kernel test robot
2022-09-26 13:28 ` kernel test robot
2022-09-26 14:33 ` Christophe Leroy
2022-09-27 2:57 ` Benjamin Gray
2022-09-27 5:54 ` Christophe Leroy
2022-09-27 6:40 ` Christophe Leroy
2022-09-28 1:30 ` Benjamin Gray
2022-09-28 10:52 ` Christophe Leroy
2022-09-27 7:30 ` Christophe Leroy
2022-09-26 6:43 ` [PATCH v2 2/6] powerpc/module: Handle caller-saved TOC in module linker Benjamin Gray
2022-09-26 6:43 ` [PATCH v2 3/6] powerpc/module: Optimise nearby branches in ELF V2 ABI stub Benjamin Gray
2022-09-26 14:49 ` Christophe Leroy
2022-09-27 3:12 ` Benjamin Gray
2022-09-26 6:43 ` [PATCH v2 4/6] static_call: Move static call selftest to static_call_selftest.c Benjamin Gray
2022-09-26 14:50 ` Christophe Leroy
2022-09-26 6:43 ` [PATCH v2 5/6] powerpc/64: Add support for out-of-line static calls Benjamin Gray
2022-09-26 13:16 ` Christophe Leroy
2022-09-27 5:18 ` Benjamin Gray
2022-09-27 6:07 ` Christophe Leroy
2022-09-26 14:54 ` Christophe Leroy
2022-09-27 3:21 ` Benjamin Gray
2022-09-27 6:01 ` Christophe Leroy
2022-09-26 6:43 ` [PATCH v2 6/6] powerpc/64: Add tests " Benjamin Gray
2022-09-26 14:55 ` Christophe Leroy
2022-09-27 3:31 ` Benjamin Gray
2022-09-27 6:05 ` Christophe Leroy
2022-09-26 14:19 ` [PATCH v2 0/6] Out-of-line static calls for powerpc64 ELF V2 Christophe Leroy
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=20220926064316.765967-1-bgray@linux.ibm.com \
--to=bgray@linux.ibm.com \
--cc=ajd@linux.ibm.com \
--cc=ardb@kernel.org \
--cc=christophe.leroy@c-s.fr \
--cc=jbaron@akamai.com \
--cc=jpoimboe@kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=npiggin@gmail.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.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).