LTT for 2.5.36 1/9: Core infrastructure
Subsystems (4)
PATCH 1/1 LTT for 2.5.36 1/9: Core infrastructure
Thanks to Keith Owens, Daniel Phillips, Randy Dunlap, and Sam Ravnborg for their feedback to my previous postings. The following modifications have been made:
- Added lockless logging scheme for logging events without using any spinlocks or IRQ disabling whatsoever. Thanks for Tom Zanussi (IBM) for implementing this and Bob Wisniewski (IBM), K42 and Irix tracing guru, for his insight.
- ARM port by Frank Rowand (MontaVista).
- MIPS port cleanup/update by Frank Rowand (MontaVista).
- kernel/Makefile now includes trace.c only if tracing is set to y or m; thanks Keith.
D: The core tracing infrastructure serves as the main rallying point for
D: all the tracing activity in the kernel. (Tracing here isn't meant in
D: the ptrace sense, but in the sense of recording key kernel events along
D: with a time-stamp in order to reconstruct the system's behavior post-
D: mortem.) Whether the trace driver (which buffers the data collected
D: and provides it to the user-space trace daemon via a char dev) is loaded
D: or not, the kernel sees a unique tracing function: trace_event().
D: Basically, this provides a trace driver register/unregister service.
D: When a trace driver registers, it is forwarded all the events generated
D: by the kernel. If no trace driver is registered, then the events go
D: nowhere.
D:
D: In addition to these basic services, this patch allows kernel modules
D: to allocate and trace their own custom events. Hence, a driver can
D: create its own set of events and log them part of the kernel trace.
D: Many existing drivers who go a long way in writing their own trace
D: driver and implementing their own tracing mechanism should actually
D: be using this custom event creation interface. And again, whether the
D: trace driver is active or even present makes little difference for
D: the users of the kernel's tracing infrastructure.
Here are the files being added:
include/linux/trace.h | 467 ++++++++++++++++++++++++++++++ kernel/trace.c | 712 ++++++++++++++++++++++++++++++++++++++++++++++
Here are the files being modified:
include/linux/init_task.h | 1 include/linux/sched.h | 3 kernel/Makefile | 3 kernel/exit.c | 4 kernel/fork.c | 7 7 files changed, 1195 insertions, 2 deletions
In order to support the lockless scheme, we had to add a "void *trace" entry in the task struct and mofidy the process creation/deletion accordingly. This new entry is mainly used to keep track of which processes still have pending writes to the trace buffer. Since there is no locking on the buffer, we can't free the trace buffer until all processes with pending writes are through.
The complete patch is available in one piece here:
http://opersys.com/ftp/pub/LTT/ExtraPatches/patch-ltt-linux-2.5.36-vanilla-020919-1.14.bz2
The userspace tools are available here:
http://www.opersys.com/LTT
include/linux/init_task.h +1 -0
@@ -98,6 +98,7 @@ .alloc_lock = SPIN_LOCK_UNLOCKED, \ .switch_lock = SPIN_LOCK_UNLOCKED, \ .journal_info = NULL, \ + .trace_info = NULL, \ }
include/linux/sched.h +3 -0
@@ -396,6 +396,9 @@ struct task_struct {/* journalling filesystem info */ void *journal_info;struct dentry *proc_dentry; + +/* Linux Trace Toolkit trace info */ +void *trace_info; };extern void __put_task_struct (struct task_struct *tsk);
include/linux/trace.h +467 -0
467 lines not on this page · raw message
kernel/Makefile +2 -1
@@ -10,7 +10,7 @@ O_TARGET := kernel.o export-objs = signal.o sys.o kmod.o context.o ksyms.o pm.o exec_domain.o \ - printk.o platform.o suspend.o dma.o + printk.o platform.o suspend.o dma.o trace.o obj-y = sched.o fork.o exec_domain.o panic.o printk.o \ module.o exit.o itimer.o time.o softirq.o resource.o \
@@ -24,6 +24,7 @@ obj-$(CONFIG_MODULES) += ksyms.o obj-$(CONFIG_PM) += pm.o obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o obj-$(CONFIG_SOFTWARE_SUSPEND) += suspend.o +obj-$(subst m,y,$(CONFIG_TRACE)) += trace.o ifneq ($(CONFIG_IA64),y) # According to Alan Modra <[email protected]>, the -fno-omit-frame-pointer is
kernel/exit.c +4 -0
@@ -20,6 +20,8 @@#include <linux/binfmts.h> #include <linux/ptrace.h> +#include <linux/trace.h> +#include <asm/uaccess.h> #include <asm/pgtable.h> #include <asm/mmu_context.h>
@@ -618,6 +620,8 @@ NORET_TYPE void do_exit(long code) fake_volatile:acct_process (code);__exit_mm (tsk); + +free_trace_info (tsk);sem_exit ();__exit_files (tsk);
kernel/fork.c +6 -1
@@ -28,6 +28,7 @@#include <linux/security.h> #include <linux/futex.h> #include <linux/ptrace.h> +#include <linux/trace.h> #include <asm/pgtable.h> #include <asm/pgalloc.h>
@@ -768,9 +769,11 @@ static struct task_struct *copy_process( retval = -ENOMEM ;if (security_ops->task_alloc_security (p)) goto bad_fork_cleanup; +if (alloc_trace_info (p)) + goto bad_fork_cleanup_security;/* copy all the process information */ if (copy_semundo (clone_flags, p)) - goto bad_fork_cleanup_security; + goto bad_fork_cleanup_trace;if (copy_files (clone_flags, p)) goto bad_fork_cleanup_semundo;if (copy_fs (clone_flags, p))
@@ -909,6 +912,8 @@ bad_fork_cleanup_files:exit_files (p);/* blocking */ bad_fork_cleanup_semundo:exit_semundo (p); +bad_fork_cleanup_trace: +free_trace_info (p); bad_fork_cleanup_security: security_ops->task_free_security (p); bad_fork_cleanup:
kernel/trace.c +712 -0
712 lines not on this page · raw message