diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2018-08-22 00:56:22 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-22 13:52:47 -0400 |
commit | 46e0c9be206fa7b11aca75da2d6b8535d0139752 (patch) | |
tree | deafa098d7949523aa07a71ff1149062fe09eace /kernel/tracepoint.c | |
parent | c9d8b55fa0191623fccb9ed67d2ff8f9159e9a89 (diff) |
kernel: tracepoints: add support for relative references
To avoid the need for relocating absolute references to tracepoint
structures at boot time when running relocatable kernels (which may
take a disproportionate amount of space), add the option to emit
these tables as relative references instead.
Link: http://lkml.kernel.org/r/20180704083651.24360-7-ard.biesheuvel@linaro.org
Acked-by: Michael Ellerman <mpe@ellerman.id.au>
Acked-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: James Morris <james.morris@microsoft.com>
Cc: James Morris <jmorris@namei.org>
Cc: Jessica Yu <jeyu@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Nicolas Pitre <nico@linaro.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Petr Mladek <pmladek@suse.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Thomas Garnier <thgarnie@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/tracepoint.c')
-rw-r--r-- | kernel/tracepoint.c | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c index 96db841bf0fc..bf2c06ef9afc 100644 --- a/kernel/tracepoint.c +++ b/kernel/tracepoint.c | |||
@@ -371,6 +371,27 @@ int tracepoint_probe_unregister(struct tracepoint *tp, void *probe, void *data) | |||
371 | } | 371 | } |
372 | EXPORT_SYMBOL_GPL(tracepoint_probe_unregister); | 372 | EXPORT_SYMBOL_GPL(tracepoint_probe_unregister); |
373 | 373 | ||
374 | static void for_each_tracepoint_range(struct tracepoint * const *begin, | ||
375 | struct tracepoint * const *end, | ||
376 | void (*fct)(struct tracepoint *tp, void *priv), | ||
377 | void *priv) | ||
378 | { | ||
379 | if (!begin) | ||
380 | return; | ||
381 | |||
382 | if (IS_ENABLED(CONFIG_HAVE_ARCH_PREL32_RELOCATIONS)) { | ||
383 | const int *iter; | ||
384 | |||
385 | for (iter = (const int *)begin; iter < (const int *)end; iter++) | ||
386 | fct(offset_to_ptr(iter), priv); | ||
387 | } else { | ||
388 | struct tracepoint * const *iter; | ||
389 | |||
390 | for (iter = begin; iter < end; iter++) | ||
391 | fct(*iter, priv); | ||
392 | } | ||
393 | } | ||
394 | |||
374 | #ifdef CONFIG_MODULES | 395 | #ifdef CONFIG_MODULES |
375 | bool trace_module_has_bad_taint(struct module *mod) | 396 | bool trace_module_has_bad_taint(struct module *mod) |
376 | { | 397 | { |
@@ -435,15 +456,9 @@ EXPORT_SYMBOL_GPL(unregister_tracepoint_module_notifier); | |||
435 | * Ensure the tracer unregistered the module's probes before the module | 456 | * Ensure the tracer unregistered the module's probes before the module |
436 | * teardown is performed. Prevents leaks of probe and data pointers. | 457 | * teardown is performed. Prevents leaks of probe and data pointers. |
437 | */ | 458 | */ |
438 | static void tp_module_going_check_quiescent(struct tracepoint * const *begin, | 459 | static void tp_module_going_check_quiescent(struct tracepoint *tp, void *priv) |
439 | struct tracepoint * const *end) | ||
440 | { | 460 | { |
441 | struct tracepoint * const *iter; | 461 | WARN_ON_ONCE(tp->funcs); |
442 | |||
443 | if (!begin) | ||
444 | return; | ||
445 | for (iter = begin; iter < end; iter++) | ||
446 | WARN_ON_ONCE((*iter)->funcs); | ||
447 | } | 462 | } |
448 | 463 | ||
449 | static int tracepoint_module_coming(struct module *mod) | 464 | static int tracepoint_module_coming(struct module *mod) |
@@ -494,8 +509,9 @@ static void tracepoint_module_going(struct module *mod) | |||
494 | * Called the going notifier before checking for | 509 | * Called the going notifier before checking for |
495 | * quiescence. | 510 | * quiescence. |
496 | */ | 511 | */ |
497 | tp_module_going_check_quiescent(mod->tracepoints_ptrs, | 512 | for_each_tracepoint_range(mod->tracepoints_ptrs, |
498 | mod->tracepoints_ptrs + mod->num_tracepoints); | 513 | mod->tracepoints_ptrs + mod->num_tracepoints, |
514 | tp_module_going_check_quiescent, NULL); | ||
499 | break; | 515 | break; |
500 | } | 516 | } |
501 | } | 517 | } |
@@ -547,19 +563,6 @@ static __init int init_tracepoints(void) | |||
547 | __initcall(init_tracepoints); | 563 | __initcall(init_tracepoints); |
548 | #endif /* CONFIG_MODULES */ | 564 | #endif /* CONFIG_MODULES */ |
549 | 565 | ||
550 | static void for_each_tracepoint_range(struct tracepoint * const *begin, | ||
551 | struct tracepoint * const *end, | ||
552 | void (*fct)(struct tracepoint *tp, void *priv), | ||
553 | void *priv) | ||
554 | { | ||
555 | struct tracepoint * const *iter; | ||
556 | |||
557 | if (!begin) | ||
558 | return; | ||
559 | for (iter = begin; iter < end; iter++) | ||
560 | fct(*iter, priv); | ||
561 | } | ||
562 | |||
563 | /** | 566 | /** |
564 | * for_each_kernel_tracepoint - iteration on all kernel tracepoints | 567 | * for_each_kernel_tracepoint - iteration on all kernel tracepoints |
565 | * @fct: callback | 568 | * @fct: callback |