Skip to contentSkip to conversation

LTTng-core 0.5.111 : Relay+DebugFS

PATCH In review Mathieu Desnoyers 1 participant 1 message Sep 16, 2006

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

PATCH 9/11 LTTng-core 0.5.111 : Relay+DebugFS

9 - User space tracing trough new system calls patch-2.6.17-lttng-core-0.5.111-userspace-tracing.diff

OpenPGP public key:              http://krystal.dyndns.org:8080/key/compudj.gpg
Key fingerprint:     8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68 
include/linux/sched.h +5 -0
@@ -39,6 +39,8 @@ #include <linux/futex.h>
 
 #include <linux/auxvec.h>	/* For AT_VECTOR_SIZE */
 
+#include <linux/ltt-facilities.h>
+
 struct exec_domain;
 
 /*
@@ -888,6 +890,9 @@ #endif
 	 * cache last used pipe for splice
 	 */
 	struct pipe_inode_info *splice_pipe;
+#ifdef CONFIG_LTT_USERSPACE_GENERIC
+	ltt_facility_t ltt_facilities[LTT_FAC_PER_PROCESS];
+#endif //CONFIG_LTT_USERSPACE_GENERIC
 };
 
 static inline pid_t process_group(struct task_struct *tsk)
kernel/sys_ni.c +2 -0
@@ -110,6 +110,8 @@ cond_syscall(sys_vm86old);
 cond_syscall(sys_vm86);
 cond_syscall(compat_sys_ipc);
 cond_syscall(compat_sys_sysctl);
+cond_syscall(sys_ltt_trace_generic);
+cond_syscall(sys_ltt_register_generic);
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read);
kernel/ltt-syscall.c new file +175 -0

175 lines not on this page · raw message

kernel/exit.c +12 -0
@@ -4,6 +4,7 @@
  *  Copyright (C) 1991, 1992  Linus Torvalds
  */
 
+#include <linux/ltt-facilities.h>
 #include <linux/config.h>
 #include <linux/mm.h>
 #include <linux/slab.h>
@@ -36,6 +37,7 @@ #include <linux/futex.h>
 #include <linux/compat.h>
 #include <linux/pipe_fs_i.h>
 #include <linux/audit.h> /* for audit_free() */
+#include <linux/ltt-core.h>
 
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
@@ -59,6 +61,16 @@ static void __unhash_process(struct task
 
 		list_del_rcu(&p->tasks);
 		__get_cpu_var(process_counts)--;
+#ifdef CONFIG_LTT_USERSPACE_GENERIC
+		{
+			int i;
+			for(i=0; i<LTT_FAC_PER_PROCESS; i++) {
+				if(p->ltt_facilities[i] == 0) break;
+				WARN_ON(ltt_facility_unregister(
+							p->ltt_facilities[i]));
+			}
+		}
+#endif //CONFIG_LTT_USERSPACE_GENERIC
 	}
 	list_del_rcu(&p->thread_group);
 	remove_parent(p);
kernel/fork.c +29 -2
@@ -44,6 +44,8 @@ #include <linux/profile.h>
 #include <linux/rmap.h>
 #include <linux/acct.h>
 #include <linux/cn_proc.h>
+#include <linux/ltt-core.h>
+#include <linux/ltt-facilities.h>
 
 #include <asm/pgtable.h>
 #include <asm/pgalloc.h>
@@ -1095,6 +1097,20 @@ #endif
 	   
 	p->parent_exec_id = p->self_exec_id;
 
+#ifdef CONFIG_LTT_USERSPACE_GENERIC
+	if (clone_flags & CLONE_THREAD)
+		memset(p->ltt_facilities, 0, sizeof(p->ltt_facilities));
+	else {
+		int i;
+		for(i=0; i<LTT_FAC_PER_PROCESS; i++) {
+			p->ltt_facilities[i] = current->ltt_facilities[i];
+			if(p->ltt_facilities[i] != 0)
+				ltt_facility_ref(p->ltt_facilities[i]);
+		}
+	}
+
+#endif //CONFIG_LTT_USERSPACE_GENERIC
+	
 	/* ok, now we should be set up.. */
 	p->exit_signal = (clone_flags & CLONE_THREAD) ? -1 : (clone_flags & CSIGNAL);
 	p->pdeath_signal = 0;
@@ -1151,7 +1167,7 @@ #endif
 		spin_unlock(&current->sighand->siglock);
 		write_unlock_irq(&tasklist_lock);
 		retval = -ERESTARTNOINTR;
-		goto bad_fork_cleanup_namespace;
+		goto bad_fork_cleanup_ltt_facilities;
 	}
 
 	if (clone_flags & CLONE_THREAD) {
@@ -1164,7 +1180,7 @@ #endif
 			spin_unlock(&current->sighand->siglock);
 			write_unlock_irq(&tasklist_lock);
 			retval = -EAGAIN;
-			goto bad_fork_cleanup_namespace;
+			goto bad_fork_cleanup_ltt_facilities;
 		}
 
 		p->group_leader = current->group_leader;
@@ -1216,6 +1232,17 @@ #endif
 	proc_fork_connector(p);
 	return p;
 
+bad_fork_cleanup_ltt_facilities:
+#ifdef CONFIG_LTT_USERSPACE_GENERIC
+		{
+			int i;
+			for(i=0; i<LTT_FAC_PER_PROCESS; i++) {
+				if(p->ltt_facilities[i] == 0) break;
+				WARN_ON(ltt_facility_unregister(
+							p->ltt_facilities[i]));
+			}
+		}
+#endif //CONFIG_LTT_USERSPACE_GENERIC
 bad_fork_cleanup_namespace:
 	exit_namespace(p);
 bad_fork_cleanup_keys:
include/asm-i386/unistd.h +3 -1
@@ -322,8 +322,10 @@ #define __NR_splice		313
 #define __NR_sync_file_range	314
 #define __NR_tee		315
 #define __NR_vmsplice		316
+#define __NR_ltt_trace_generic	317
+#define __NR_ltt_register_generic	318
 
-#define NR_syscalls 317
+#define NR_syscalls 319
 
 /*
  * user-visible error numbers are in the range -1 - -128: see
include/asm-powerpc/unistd.h +3 -1
@@ -323,8 +323,10 @@ #define __NR_fchmodat		297
 #define __NR_faccessat		298
 #define __NR_get_robust_list	299
 #define __NR_set_robust_list	300
+#define __NR_ltt_trace_generic	301
+#define __NR_ltt_register_generic	302
 
-#define __NR_syscalls		301
+#define __NR_syscalls		303
 
 #ifdef __KERNEL__
 #define __NR__exit __NR_exit
include/asm-x86_64/ia32_unistd.h +5 -0
@@ -317,4 +317,9 @@ #define __NR_ia32_pselect6		308
 #define __NR_ia32_ppoll			309
 #define __NR_ia32_unshare		310
 
+/* A few defines seem to have been forgotten by kernel developers.
+   See arch/x86_64/ia32/ia32entry.S and include/asm-i386/unistd.h */
+#define __NR_ia32_ltt_trace_generic	317
+#define __NR_ia32_ltt_register_generic	318
+
 #endif /* _ASM_X86_64_IA32_UNISTD_H_ */
include/asm-x86_64/unistd.h +5 -1
@@ -617,8 +617,12 @@ #define __NR_sync_file_range	277
 __SYSCALL(__NR_sync_file_range, sys_sync_file_range)
 #define __NR_vmsplice		278
 __SYSCALL(__NR_vmsplice, sys_vmsplice)
+#define __NR_ltt_trace_generic	279
+__SYSCALL(__NR_ltt_trace_generic, sys_ltt_trace_generic)
+#define __NR_ltt_register_generic	280
+__SYSCALL(__NR_ltt_register_generic, sys_ltt_register_generic)
 
-#define __NR_syscall_max __NR_vmsplice
+#define __NR_syscall_max __NR_ltt_register_generic
 
 #ifndef __NO_STUBS