Skip to content

jump label patches

Jason Baron lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 24 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4jump label - make init_kernel_text() globalinclude/linux/kernel.h kernel/extable.c+2 -112 replies
2/4jump label - base patcharch/x86/include/asm/jump_label.h arch/x86/kernel/Makefile arch/x86/kernel/jump_label.c +2 more+184 -13 replies
3/4jump label - add module supportarch/x86/kernel/jump_label.c include/linux/jump_label.h include/linux/module.h +1 more+71 -100 replies
4/4jump label - tracepoint implementationinclude/linux/tracepoint.h kernel/tracepoint.c+27 -140 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/4] jump label patches

hi,

For background, I introduced this patchset in:
http://marc.info/?l=linux-kernel&m=125200966226921&w=2

This patchset updates the jump label mechanism to look like:

#define JUMP_LABEL(tag, label, cond)                                       \
        do {                                                               \
                static const char __jlstrtab_##tag[]                       \
                __used __attribute__((section("__jump_strings")))  = #tag; \
                asm goto ("1:"                                             \
                        "jmp %l[" #label "] \n\t"                          \
                        ".pushsection __jump_table,  \"a\" \n\t"           \
                        _ASM_PTR "1b, %l[" #label "], %c0, 0 \n\t"         \
                        ".popsection \n\t"                                 \
                        : :  "i" (__jlstrtab_##tag) :  : label);           \
        } while (0)

#endif

and usage case is:

#define DECLARE_TRACE(name, proto, args)                                 \
        extern struct tracepoint __tracepoint_##name;                    \
        static inline void trace_##name(proto)                           \
        {                                                                \
                JUMP_LABEL(name, trace_label, __tracepoint_##name.state);\
                __DO_TRACE(&__tracepoint_##name,                         \
                           TP_PROTO(proto), TP_ARGS(args));              \
trace_label:                                                             \
                return;                                                  \
        }                                                                \

So the idea now, is that by default we jump over the disabled code. In order to enable the 'disabled' code, or tracing, we simply replace the jump with a 'jump 0'. Thus, we now avoid the issue of not having enough instruction space. Thus, in most cases the jump we are patching is an '0xeb' opcode which is simply 2 bytes (occasionally its an 0xeb). I have this patchset working nicely on x86_64. I'm not sure if we need to recognize additional jump opcodes for x86 32-bit....I have not yet tested there. In my x86_64 testing under memory pressure I saw about a 30 cycle improvement with this code per tracepoint. Additionally, this code reduces the icache bytes from 9 bytes (cmpl; je), to just 2 bytes (jmp).

The patchset makes use of text_poke_fixup() interface introduced by Masami in:
http://marc.info/?l=linux-kernel&m=125297186224609&w=2.

Thus, that patchset needs to be applied first. Patch is against the latest -tip tree.

thanks,

-Jason

 arch/x86/include/asm/jump_label.h |   27 +++++++++++
 arch/x86/kernel/Makefile          |    2 +-
 arch/x86/kernel/jump_label.c      |   94 +++++++++++++++++++++++++++++++++++++
 include/asm-generic/vmlinux.lds.h |   11 ++++
 include/linux/jump_label.h        |   71 ++++++++++++++++++++++++++++
 include/linux/kernel.h            |    1 +
 include/linux/module.h            |   12 ++++-
 include/linux/tracepoint.h        |   31 +++++++------
 kernel/extable.c                  |    2 +-
 kernel/module.c                   |   31 ++++++++++++
 kernel/tracepoint.c               |   10 ++++
 11 files changed, 275 insertions(+), 17 deletions(-)
 create mode 100644 arch/x86/include/asm/jump_label.h
 create mode 100644 arch/x86/kernel/jump_label.c
 create mode 100644 include/linux/jump_label.h