All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Baron <jbaron@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: mingo@elte.hu, mathieu.desnoyers@polymtl.ca, tglx@linutronix.de,
	rostedt@goodmis.org, ak@suse.de, roland@redhat.com,
	rth@redhat.com, mhiramat@redhat.com
Subject: [PATCH 0/4] jump label patches
Date: Thu, 24 Sep 2009 19:17:45 -0400	[thread overview]
Message-ID: <cover.1253831945.git.jbaron@redhat.com> (raw)


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


             reply	other threads:[~2009-09-24 23:18 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-24 23:17 Jason Baron [this message]
2009-09-24 23:17 ` [PATCH 1/4] jump label - make init_kernel_text() global Jason Baron
2009-10-01 11:20   ` Ingo Molnar
2009-10-01 12:58     ` Mathieu Desnoyers
2009-10-01 20:39     ` Jason Baron
2009-10-03 10:43       ` Ingo Molnar
2009-10-03 12:39         ` Mathieu Desnoyers
2009-10-07  1:54           ` Steven Rostedt
2009-10-07  2:32             ` Mathieu Desnoyers
2009-10-07  3:10               ` Masami Hiramatsu
2009-10-07  3:23                 ` Mathieu Desnoyers
2009-10-07  3:29               ` Mathieu Desnoyers
2009-10-07 12:56               ` Steven Rostedt
2009-10-07 13:35                 ` Mathieu Desnoyers
2009-09-24 23:17 ` [PATCH 2/4] jump label - base patch Jason Baron
2009-09-25  0:49   ` Roland McGrath
2009-09-26 10:21     ` Steven Rostedt
2009-10-01 11:36   ` Ingo Molnar
2009-09-24 23:17 ` [PATCH 3/4] jump label - add module support Jason Baron
2009-09-24 23:18 ` [PATCH 4/4] jump label - tracepoint implementation Jason Baron
2009-10-06  5:39 ` [PATCH 0/4] jump label patches Roland McGrath
2009-10-06 14:07   ` Jason Baron
2009-10-06 23:24   ` Richard Henderson
2009-10-07  0:14     ` Roland McGrath
2009-10-07 15:35       ` Richard Henderson
2009-10-06  6:04 ` Roland McGrath
2009-10-06 14:09   ` Steven Rostedt
2009-10-06 14:13   ` Masami Hiramatsu
2009-10-06 14:30     ` Mathieu Desnoyers

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=cover.1253831945.git.jbaron@redhat.com \
    --to=jbaron@redhat.com \
    --cc=ak@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@polymtl.ca \
    --cc=mhiramat@redhat.com \
    --cc=mingo@elte.hu \
    --cc=roland@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=rth@redhat.com \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.