tracing updates/fixes, #2
Subsystems (10)
Linus,
Please pull the latest tracing-fixes-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git tracing-fixes-for-linus-2
The biggest item is the new kmemtrace tracer from the SLAB folks.
There's also tracing-core refactoring work included that still was OK for this merge window.
Thanks,
Ingo
------------------>
Eduard - Gabriel Munteanu (10):
SLUB: Replace __builtin_return_address(0) with _RET_IP_.
kmemtrace: Core implementation.
kmemtrace: Additional documentation.
kmemtrace: SLAB hooks.
kmemtrace: SLOB hooks.
kmemtrace: SLUB hooks.
kmemtrace: Fix typos in documentation.
kmemtrace: Better alternative to "kmemtrace: fix printk format warnings".
kmemtrace: SLUB hooks for caller-tracking functions.
kmemtrace: Remove the relay version of kmemtrace
Frederic Weisbecker (5):
tracing/function-graph-tracer: strip ending newlines on comments tracing/ftrace: provide the base infrastructure for histogram tracing tracing/branch-tracer: adapt to the stat tracing API tracing/kmemtrace: normalize the raw tracer event to the unified tracing API tracing/ftrace: fix a memory leak in stat tracing
Ingo Molnar (8):
tracing/ftrace: make trace_find_cmdline() generally available tracing/selftest: remove TRACE_CONT reference
kmemtrace: move #include lines
relayfs: replace BUG() with WARN_ON() in relay_late_setup_files() tracing, kvm: change MARKERS to select instead of depends on tracing/kmemtrace: export kmemtrace_mark_alloc_node() / kmemtrace_mark_free() tracing/kmemtrace: fix typo
kmemtrace: add kmemtrace_init()
Pekka Enberg (3):
kmemtrace: remove unnecessary casts
kmemtrace: allow kmemtrace to be enabled after boot
kmemtrace: remove config option for enabling tracing at boot
Randy Dunlap (1):
sysrq: fix ftrace help msg & doc.
Steven Rostedt (5):
ftrace: remove obsolete print continue functionality
ftrace: set up trace event hash infrastructure
ftrace: change trace.c to use registered events
ftrace: convert unsigned index to signed
trace: clean up funny line breaks in stat_seq_show
Vegard Nossum (1):
kmemtrace: add missing newline
Documentation/ABI/testing/debugfs-kmemtrace | 71 +++ Documentation/kernel-parameters.txt | 10 + Documentation/sysrq.txt | 2 + Documentation/vm/kmemtrace.txt | 126 ++++ MAINTAINERS | 6 + arch/x86/kvm/Kconfig | 3 +- drivers/char/sysrq.c | 2 +- include/linux/slab_def.h | 68 ++- include/linux/slob_def.h | 9 +- include/linux/slub_def.h | 53 ++- include/trace/kmemtrace.h | 75 +++ init/main.c | 2 + kernel/relay.c | 4 +- kernel/trace/Kconfig | 21 + kernel/trace/Makefile | 3 + kernel/trace/ftrace.c | 4 +- kernel/trace/kmemtrace.c | 350 +++++++++++ kernel/trace/trace.c | 741 ++---------------------- kernel/trace/trace.h | 61 ++- kernel/trace/trace_boot.c | 1 + kernel/trace/trace_branch.c | 295 ++++++---- kernel/trace/trace_functions_graph.c | 8 +- kernel/trace/trace_hw_branches.c | 1 + kernel/trace/trace_mmiotrace.c | 4 +- kernel/trace/trace_output.c | 832 +++++++++++++++++++++++++++ kernel/trace/trace_output.h | 59 ++ kernel/trace/trace_power.c | 1 + kernel/trace/trace_selftest.c | 1 - kernel/trace/trace_stat.c | 243 ++++++++ mm/slab.c | 71 ++- mm/slob.c | 37 +- mm/slub.c | 83 +++- 32 files changed, 2368 insertions(+), 879 deletions(-) create mode 100644 Documentation/ABI/testing/debugfs-kmemtrace create mode 100644 Documentation/vm/kmemtrace.txt create mode 100644 include/trace/kmemtrace.h create mode 100644 kernel/trace/kmemtrace.c create mode 100644 kernel/trace/trace_output.c create mode 100644 kernel/trace/trace_output.h create mode 100644 kernel/trace/trace_stat.c
Documentation/ABI/testing/debugfs-kmemtrace new file +71 -0
@@ -0,0 +1,71 @@ +What: /sys/kernel/debug/kmemtrace/ +Date: July 2008 +Contact: Eduard - Gabriel Munteanu <[email protected]> +Description: + +In kmemtrace-enabled kernels, the following files are created: + +/sys/kernel/debug/kmemtrace/ + cpu<n> (0400) Per-CPU tracing data, see below. (binary) + total_overruns (0400) Total number of bytes which were dropped from + cpu<n> files because of full buffer condition, + non-binary. (text) + abi_version (0400) Kernel's kmemtrace ABI version. (text) + +Each per-CPU file should be read according to the relay interface. That is, +the reader should set affinity to that specific CPU and, as currently done by +the userspace application (though there are other methods), use poll() with +an infinite timeout before every read(). Otherwise, erroneous data may be +read. The binary data has the following _core_ format: + + Event ID (1 byte) Unsigned integer, one of: + 0 - represents an allocation (KMEMTRACE_EVENT_ALLOC) + 1 - represents a freeing of previously allocated memory + (KMEMTRACE_EVENT_FREE) + Type ID (1 byte) Unsigned integer, one of: + 0 - this is a kmalloc() / kfree() + 1 - this is a kmem_cache_alloc() / kmem_cache_free() + 2 - this is a __get_free_pages() et al. + Event size (2 bytes) Unsigned integer representing the + size of this event. Used to extend + kmemtrace. Discard the bytes you + don't know about. + Sequence number (4 bytes) Signed integer used to reorder data + logged on SMP machines. Wraparound + must be taken into account, although + it is unlikely. + Caller address (8 bytes) Return address to the caller. + Pointer to mem (8 bytes) Pointer to target memory area. Can be + NULL, but not all such calls might be + recorded. + +In case of KMEMTRACE_EVENT_ALLOC events, the next fields follow: + + Requested bytes (8 bytes) Total number of requested bytes, + unsigned, must not be zero. + Allocated bytes (8 bytes) Total number of actually allocated + bytes, unsigned, must not be lower + than requested bytes. + Requested flags (4 bytes) GFP flags supplied by the caller. + Target CPU (4 bytes) Signed integer, valid for event id 1. + If equal to -1, target CPU is the same + as origin CPU, but the reverse might + not be true. + +The data is made available in the same endianness the machine has. + +Other event ids and type ids may be defined and added. Other fields may be +added by increasing event size, but see below for details. +Every modification to the ABI, including new id definitions, are followed +by bumping the ABI version by one. + +Adding new data to the packet (features) is done at the end of the mandatory +data: + Feature size (2 byte) + Feature ID (1 byte) + Feature data (Feature size - 3 bytes) + + +Users: + kmemtrace-user - git://repo.or.cz/kmemtrace-user.git +
Documentation/kernel-parameters.txt +10 -0
@@ -49,6 +49,7 @@ parameter is applicable: ISAPNP ISA PnP code is enabled. ISDN Appropriate ISDN support is enabled. JOY Appropriate joystick support is enabled. + KMEMTRACE kmemtrace is enabled. LIBATA Libata driver is enabled LP Printer support is enabled. LOOP Loopback device support is enabled.
@@ -1033,6 +1034,15 @@ and is between 256 and 4096 characters. It is defined in the file use the HighMem zone if it exists, and the Normal zone if it does not. + kmemtrace.enable= [KNL,KMEMTRACE] Format: { yes | no } + Controls whether kmemtrace is enabled + at boot-time. + + kmemtrace.subbufs=n [KNL,KMEMTRACE] Overrides the number of + subbufs kmemtrace's relay channel has. Set this + higher than default (KMEMTRACE_N_SUBBUFS in code) if + you experience buffer overruns. + movablecore=nn[KMG] [KNL,X86-32,IA-64,PPC,X86-64] This parameter is similar to kernelcore except it specifies the amount of memory used for migratable allocations.
Documentation/sysrq.txt +2 -0
@@ -114,6 +114,8 @@ On all - write a character to /proc/sysrq-trigger. e.g.: 'x' - Used by xmon interface on ppc/powerpc platforms. +'z' - Dump the ftrace buffer + '0'-'9' - Sets the console log level, controlling which kernel messages will be printed to your console. ('0', for example would make it so that only emergency messages like PANICs or OOPSes would
Documentation/vm/kmemtrace.txt new file +126 -0
126 lines not on this page · raw message
MAINTAINERS +6 -0
@@ -2572,6 +2572,12 @@ M: [email protected] L: [email protected] S: Maintained +KMEMTRACE +P: Eduard - Gabriel Munteanu +M: [email protected] +L: [email protected] +S: Maintained + KPROBES P: Ananth N Mavinakayanahalli M: [email protected]
arch/x86/kvm/Kconfig +2 -1
@@ -55,7 +55,8 @@ config KVM_AMD config KVM_TRACE bool "KVM trace support" - depends on KVM && MARKERS && SYSFS + depends on KVM && SYSFS + select MARKERS select RELAY select DEBUG_FS default n
drivers/char/sysrq.c +1 -1
@@ -283,7 +283,7 @@ static void sysrq_ftrace_dump(int key, struct tty_struct *tty) }static struct sysrq_key_op sysrq_ftrace_dump_op = { .handler = sysrq_ftrace_dump, - .help_msg ="dumpZ-ftrace-buffer" , + .help_msg ="dump-ftrace-buffer(Z)" , .action_msg ="Dump ftrace buffer" , .enable_mask =SYSRQ_ENABLE_DUMP , };
include/linux/slab_def.h +59 -9
102 lines not on this page · raw message
include/linux/slob_def.h +5 -4
@@ -3,14 +3,15 @@void *kmem_cache_alloc_node (struct kmem_cache *,gfp_t flags,int node); -static inline void *kmem_cache_alloc (struct kmem_cache *cachep,gfp_t flags) +static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep, +gfp_t flags) {return kmem_cache_alloc_node (cachep, flags,-1 ); }void *__kmalloc_node (size_t size,gfp_t flags,int node); -static inline void *kmalloc_node (size_t size,gfp_t flags,int node) +static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node) {return __kmalloc_node (size, flags, node); }
@@ -23,12 +24,12 @@ static inline void *kmalloc_node(size_t size, gfp_t flags, int node)* kmalloc is the normal method of allocating memory * in the kernel. */ -static inline void *kmalloc (size_t size,gfp_t flags) +static __always_inline void *kmalloc(size_t size, gfp_t flags) {return __kmalloc_node (size, flags,-1 ); } -static inline void *__kmalloc (size_t size,gfp_t flags) +static __always_inline void *__kmalloc(size_t size, gfp_t flags) {return kmalloc (size, flags); }
include/linux/slub_def.h +50 -3
91 lines not on this page · raw message
include/trace/kmemtrace.h new file +75 -0
75 lines not on this page · raw message
init/main.c +2 -0
@@ -70,6 +70,7 @@#include <asm/setup.h> #include <asm/sections.h> #include <asm/cacheflush.h> +#include <trace/kmemtrace.h> #ifdef CONFIG_X86_LOCAL_APIC #include <asm/smp.h>
@@ -642,6 +643,7 @@ asmlinkage void __init start_kernel(void)enable_debug_pagealloc ();cpu_hotplug_init ();kmem_cache_init (); +kmemtrace_init ();debug_objects_mem_init ();idr_init_cache ();setup_per_cpu_pageset ();
kernel/relay.c +1 -3
@@ -675,9 +675,7 @@ int relay_late_setup_files(struct rchan *chan,*/ for_each_online_cpu (i) {if (unlikely (!chan->buf[i])) { -printk (KERN_ERR "relay_late_setup_files: CPU %u " -"has no buffer, it must have!\n" , i); -BUG (); +WARN_ONCE (1 ,KERN_ERR "CPU has no buffer!\n" ); err = -EINVAL ;break ; }
kernel/trace/Kconfig +21 -0
@@ -264,6 +264,27 @@ config HW_BRANCH_TRACER This tracer records all branches on the system in a circular buffer giving access to the last N branches for each cpu. +config KMEMTRACE + bool "Trace SLAB allocations" + select TRACING + help + kmemtrace provides tracing for slab allocator functions, such as + kmalloc, kfree, kmem_cache_alloc, kmem_cache_free etc.. Collected + data is then fed to the userspace application in order to analyse + allocation hotspots, internal fragmentation and so on, making it + possible to see how well an allocator performs, as well as debug + and profile kernel code. + + This requires an userspace application to use. See + Documentation/vm/kmemtrace.txt for more information. + + Saying Y will make the kernel somewhat larger and slower. However, + if you disable kmemtrace at run-time or boot-time, the performance + impact is minimal (depending on the arch the kernel is built for). + + If unsure, say N. + + config DYNAMIC_FTRACE bool "enable/disable ftrace tracepoints dynamically" depends on FUNCTION_TRACER
kernel/trace/Makefile +3 -0
@@ -19,6 +19,8 @@ obj-$(CONFIG_FUNCTION_TRACER) += libftrace.o obj-$(CONFIG_RING_BUFFER) += ring_buffer.o obj-$(CONFIG_TRACING) += trace.o +obj-$(CONFIG_TRACING) += trace_output.o +obj-$(CONFIG_TRACING) += trace_stat.o obj-$(CONFIG_CONTEXT_SWITCH_TRACER) += trace_sched_switch.o obj-$(CONFIG_SYSPROF_TRACER) += trace_sysprof.o obj-$(CONFIG_FUNCTION_TRACER) += trace_functions.o
@@ -33,5 +35,6 @@ obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += trace_functions_graph.o obj-$(CONFIG_TRACE_BRANCH_PROFILING) += trace_branch.o obj-$(CONFIG_HW_BRANCH_TRACER) += trace_hw_branches.o obj-$(CONFIG_POWER_TRACER) += trace_power.o +obj-$(CONFIG_KMEMTRACE) += kmemtrace.o libftrace-y := ftrace.o
kernel/trace/ftrace.c +2 -2
@@ -289,7 +289,7 @@ static DEFINE_MUTEX(ftrace_regex_lock);struct ftrace_page {struct ftrace_page *next; -unsigned long index; +int index;struct dyn_ftrace records[]; };
@@ -786,7 +786,7 @@ enum {struct ftrace_iterator {struct ftrace_page *pg; -unsigned idx; +int idx;unsigned flags;unsigned char buffer[FTRACE_BUFF_MAX +1 ];unsigned buffer_idx;
kernel/trace/kmemtrace.c new file +350 -0
350 lines not on this page · raw message
kernel/trace/trace.c +41 -700
873 lines not on this page · raw message
kernel/trace/trace.h +45 -16
137 lines not on this page · raw message
kernel/trace/trace_boot.c +1 -0
@@ -11,6 +11,7 @@#include <linux/kallsyms.h> #include "trace.h" +#include "trace_output.h" static struct trace_array *boot_trace;static bool pre_initcalls_finished;
kernel/trace/trace_branch.c +182 -113
369 lines not on this page · raw message
kernel/trace/trace_functions_graph.c +6 -2
@@ -12,6 +12,7 @@#include <linux/fs.h> #include "trace.h" +#include "trace_output.h" #define TRACE_GRAPH_INDENT 2
@@ -589,8 +590,11 @@ print_graph_comment(struct print_entry *trace, struct trace_seq *s,if (!ret)return TRACE_TYPE_PARTIAL_LINE ; -if (ent->flags &TRACE_FLAG_CONT ) -trace_seq_print_cont (s, iter); +/* Strip ending newline */ +if (s->buffer[s->len -1 ] =='\n' ) { + s->buffer[s->len -1 ] ='\0' ; + s->len--; + } ret =trace_seq_printf (s," */\n" );if (!ret)
kernel/trace/trace_hw_branches.c +1 -0
@@ -14,6 +14,7 @@#include <asm/ds.h> #include "trace.h" +#include "trace_output.h" #define SIZEOF_BTS (1 << 13)
kernel/trace/trace_mmiotrace.c +1 -3
@@ -11,6 +11,7 @@#include <linux/pci.h> #include "trace.h" +#include "trace_output.h" struct header_iter {struct pci_dev *dev;
@@ -262,9 +263,6 @@ static enum print_line_t mmio_print_mark(struct trace_iterator *iter)if (!ret)return TRACE_TYPE_PARTIAL_LINE ; -if (entry->flags &TRACE_FLAG_CONT ) -trace_seq_print_cont (s, iter); -return TRACE_TYPE_HANDLED ; }
kernel/trace/trace_output.c new file +832 -0
585 lines not on this page · raw message
kernel/trace/trace_output.h new file +59 -0
59 lines not on this page · raw message
kernel/trace/trace_stat.c new file +243 -0
243 lines not on this page · raw message
mm/slab.c +64 -7
71 lines not on this page · raw message
mm/slub.c +75 -8
83 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
----- End forwarded message -----
Part of the diff is not shown here. View the raw message.