Most BPF programs are small, but they consume a page each. For systems with busy traffic and many BPF programs, this may also add significant pressure on instruction TLB. High iTLB pressure usually slows down the whole system causing visible performance degradation for production workloads. bpf_prog_pack, a customized allocator that packs multiple bpf programs into preallocated memory chunks, was proposed [1] to address it. This series extends this support on powerpc. Patches 1 & 2 add the arch specific functions needed to support this feature. Patch 3 enables the support for powerpc and ensures cleanup is handled gracefully. Patch 4 introduces patch_instructions() that optimizes some calls while patching more than one instruction. Patch 5 leverages this new function to improve time taken for JIT'ing BPF programs. Note that the first 3 patches are sufficient to enable the support for bpf_prog_pack on powerpc. Patches 4 & 5 are to improve the JIT compilation time of BPF programs on powerpc. Thanks to Christophe and Song for reviewing v2 [2]. Changes in v3: * Fixed segfault issue observed on ppc32 due to inaccurate offset calculation for branching. * Tried to minimize the performance impact for patch_instruction() with the introduction of patch_instructions(). * Corrected uses of u32* vs ppc_instr_t. * Moved the change that introduces patch_instructions() to after enabling bpf_prog_pack support. * Added few comments to improve code readability. [1] https://lore.kernel.org/bpf/20220204185742.271030-1-song@xxxxxxxxxx/ [2] https://lore.kernel.org/all/20230309180028.180200-1-hbathini@xxxxxxxxxxxxx/ Hari Bathini (5): powerpc/bpf: implement bpf_arch_text_copy powerpc/bpf: implement bpf_arch_text_invalidate for bpf_prog_pack powerpc/bpf: use bpf_jit_binary_pack_[alloc|finalize|free] powerpc/code-patching: introduce patch_instructions() powerpc/bpf: use patch_instructions() arch/powerpc/include/asm/code-patching.h | 1 + arch/powerpc/lib/code-patching.c | 94 ++++++++++++--- arch/powerpc/net/bpf_jit.h | 12 +- arch/powerpc/net/bpf_jit_comp.c | 138 ++++++++++++++++++----- arch/powerpc/net/bpf_jit_comp32.c | 13 ++- arch/powerpc/net/bpf_jit_comp64.c | 10 +- 6 files changed, 205 insertions(+), 63 deletions(-) -- 2.41.0