Skip to contentSkip to conversation

LTT for 2.5.37 1/9: Core infrastructure

PATCH New Karim Yaghmour 1 participant 1 message Sep 21, 2002

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 LTT for 2.5.37 1/9: Core infrastructure

Thanks to Russell King for his feedback. The following modifications have been made since the last release:
- Added config option for lockless scheme.
- Completed documentation of function headers of trace driver.

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 

The complete patch is available in one piece here:
http://opersys.com/ftp/pub/LTT/ExtraPatches/patch-ltt-linux-2.5.37-vanilla-020921-1.14.bz2

The userspace tools are available here:
http://www.opersys.com/LTT

include/linux/init_task.h +1 -0
diff -urpN linux-2.5.37/include/linux/init_task.h linux-2.5.37-ltt/include/linux/init_task.h
@@ -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
diff -urpN linux-2.5.37/include/linux/sched.h linux-2.5.37-ltt/include/linux/sched.h
@@ -398,6 +398,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
diff -urpN linux-2.5.37/kernel/Makefile linux-2.5.37-ltt/kernel/Makefile
@@ -3,7 +3,7 @@
 #
 
 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 \
@@ -17,6 +17,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
diff -urpN linux-2.5.37/kernel/exit.c linux-2.5.37-ltt/kernel/exit.c
@@ -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>
@@ -620,6 +622,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
diff -urpN linux-2.5.37/kernel/fork.c linux-2.5.37-ltt/kernel/fork.c
@@ -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>
@@ -718,9 +719,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))
@@ -865,6 +868,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