Kernel tracing thread flag
Subsystems (16)
RFC PATCH 4/20 LTTng Kernel Trace Thread Flag Blackfin
In reply to Mathieu DesnoyersAdd a thread flag to activate system-wide syscall tracing.
--- arch/blackfin/include/asm/thread_info.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/blackfin/include/asm/thread_info.h +3 -1
@@ -123,6 +123,7 @@ static inline struct thread_info *curren#define TIF_RESTORE_SIGMASK 5/* restore signal mask in do_signal() */ #define TIF_FREEZE 6/* is freezing for suspend */ #define TIF_IRQ_SYNC 7/* sync pipeline stage */ +#define TIF_KERNEL_TRACE 8/* kernel trace active */ /* as above, but as bit values */ #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
@@ -132,8 +133,9 @@ static inline struct thread_info *curren#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)#define _TIF_FREEZE (1<<TIF_FREEZE)#define _TIF_IRQ_SYNC (1<<TIF_IRQ_SYNC) +#define _TIF_KERNEL_TRACE (1<<TIF_KERNEL_TRACE) -#define _TIF_WORK_MASK 0x0000FFFE/* work to do on interrupt/exception return */ +#define _TIF_WORK_MASK 0x0000FEFE/* work to do on interrupt/exception return */ #endif /* __KERNEL__ */
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
RFC PATCH 9/20 LTTng Kernel Trace Thread Flag m32r
In reply to Mathieu DesnoyersAdd a thread flag to activate system-wide syscall tracing.
--- arch/m32r/include/asm/thread_info.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/m32r/include/asm/thread_info.h +7 -2
@@ -151,6 +151,7 @@ static inline unsigned int get_thread_fa#define TIF_NEED_RESCHED 2/* rescheduling necessary */ #define TIF_SINGLESTEP 3/* restore singlestep on return to user mode */ #define TIF_IRET 4/* return with iret */ +#define TIF_KERNEL_TRACE 5/* kernel trace active */ #define TIF_RESTORE_SIGMASK 8/* restore signal mask in do_signal() */ #define TIF_USEDFPU 16/* FPU was used by this task this quantum (SMP) */ #define TIF_POLLING_NRFLAG 17/* true if poll_idle() is polling TIF_NEED_RESCHED */
@@ -162,13 +163,17 @@ static inline unsigned int get_thread_fa#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)#define _TIF_IRET (1<<TIF_IRET) +#define _TIF_KERNEL_TRACE (1<<TIF_KERNEL_TRACE)#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)#define _TIF_USEDFPU (1<<TIF_USEDFPU)#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)#define _TIF_FREEZE (1<<TIF_FREEZE) -#define _TIF_WORK_MASK 0x0000FFFE/* work to do on interrupt/exception return */ -#define _TIF_ALLWORK_MASK 0x0000FFFF/* work to do on any return to u-space */ +/* work to do on any return to u-space */ +#define _TIF_ALLWORK_MASK 0x0000FFFF +/* work to do on interrupt/exception return */ +#define _TIF_WORK_MASK \ + (0x0000FFFF & ~(_TIF_SYSCALL_TRACE | _TIF_KERNEL_TRACE))/* * Thread-synchronous status.
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
RFC PATCH 13/20 LTTng Kernel Trace Thread Flag powerpc
In reply to Mathieu DesnoyersAdd a thread flag to activate system-wide syscall tracing.
--- arch/powerpc/include/asm/thread_info.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/powerpc/include/asm/thread_info.h +5 -3
@@ -102,7 +102,7 @@ static inline struct thread_info *curren#define TIF_POLLING_NRFLAG 3/* true if poll_idle() is polling TIF_NEED_RESCHED */ #define TIF_32BIT 4/* 32 bit binary */ -#define TIF_PERFMON_WORK 5/* work for pfm_handle_work() */ +#define TIF_KERNEL_TRACE 5/* kernel trace active */ #define TIF_PERFMON_CTXSW 6/* perfmon needs ctxsw calls */ #define TIF_SYSCALL_AUDIT 7/* syscall auditing active */ #define TIF_SINGLESTEP 8/* singlestepping active */
@@ -114,6 +114,7 @@ static inline struct thread_info *curren#define TIF_FREEZE 14/* Freezing for suspend */ #define TIF_RUNLATCH 15/* Is the runlatch enabled? */ #define TIF_ABI_PENDING 16/* 32/64 bit switch needed */ +#define TIF_PERFMON_WORK 17/* work for pfm_handle_work() */ /* as above, but as bit values */ #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
@@ -121,7 +122,7 @@ static inline struct thread_info *curren#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)#define _TIF_32BIT (1<<TIF_32BIT) -#define _TIF_PERFMON_WORK (1<<TIF_PERFMON_WORK) +#define _TIF_KERNEL_TRACE (1<<TIF_KERNEL_TRACE)#define _TIF_PERFMON_CTXSW (1<<TIF_PERFMON_CTXSW)#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
@@ -132,7 +133,8 @@ static inline struct thread_info *curren#define _TIF_FREEZE (1<<TIF_FREEZE)#define _TIF_RUNLATCH (1<<TIF_RUNLATCH)#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) -#define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP) +#define _TIF_PERFMON_WORK (1<<TIF_PERFMON_WORK) +#define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP|_TIF_KERNEL_TRACE)#define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \ _TIF_NOTIFY_RESUME)
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
RFC PATCH 5/20 LTTng Kernel Trace Thread Flag Cris
In reply to Mathieu DesnoyersAdd a thread flag to activate system-wide syscall tracing.
--- arch/cris/include/asm/thread_info.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/cris/include/asm/thread_info.h +7 -2
@@ -85,6 +85,7 @@ struct thread_info {#define TIF_NOTIFY_RESUME 1/* resumption notification requested */ #define TIF_SIGPENDING 2/* signal pending */ #define TIF_NEED_RESCHED 3/* rescheduling necessary */ +#define TIF_KERNEL_TRACE 4/* kernel trace active */ #define TIF_RESTORE_SIGMASK 9/* restore signal mask in do_signal() */ #define TIF_POLLING_NRFLAG 16/* true if poll_idle() is polling TIF_NEED_RESCHED */ #define TIF_MEMDIE 17
@@ -94,12 +95,16 @@ struct thread_info {#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) +#define _TIF_KERNEL_TRACE (1<<TIF_KERNEL_TRACE)#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)#define _TIF_FREEZE (1<<TIF_FREEZE) -#define _TIF_WORK_MASK 0x0000FFFE/* work to do on interrupt/exception return */ -#define _TIF_ALLWORK_MASK 0x0000FFFF/* work to do on any return to u-space */ +/* work to do on interrupt/exception return */ +#define _TIF_WORK_MASK 0x0000FFFF & \ + (~_TIF_SYSCALL_TRACE | ~_TIF_KERNEL_TRACE) +/* work to do on any return to u-space */ +#define _TIF_ALLWORK_MASK 0x0000FFFF#endif /* __KERNEL__ */
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
RFC PATCH 7/20 LTTng Kernel Trace Thread Flag H8300
In reply to Mathieu DesnoyersAdd a thread flag to activate system-wide syscall tracing.
--- arch/h8300/include/asm/thread_info.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/h8300/include/asm/thread_info.h +3 -1
@@ -89,6 +89,7 @@ static inline struct thread_info *currenTIF_NEED_RESCHED */ #define TIF_MEMDIE 4#define TIF_RESTORE_SIGMASK 5/* restore signal mask in do_signal() */ +#define TIF_KERNEL_TRACE 6/* kernel trace active */ #define TIF_FREEZE 16/* is freezing for suspend */ /* as above, but as bit values */
@@ -97,9 +98,10 @@ static inline struct thread_info *curren#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) +#define _TIF_KERNEL_TRACE (1<<TIF_KERNEL_TRACE)#define _TIF_FREEZE (1<<TIF_FREEZE) -#define _TIF_WORK_MASK 0x0000FFFE/* work to do on interrupt/exception return */ +#define _TIF_WORK_MASK 0x0000FFBE/* work to do on interrupt/exception return */ #endif /* __KERNEL__ */
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
RFC PATCH 14/20 LTTng Kernel Trace Thread Flag s390
In reply to Mathieu DesnoyersAdd a thread flag to activate system-wide syscall tracing.
--- arch/s390/include/asm/thread_info.h | 2 ++ arch/s390/kernel/entry.S | 10 ++++++++-- arch/s390/kernel/entry64.S | 10 ++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-)
arch/s390/include/asm/thread_info.h +2 -0
@@ -90,6 +90,7 @@ static inline struct thread_info *curren#define TIF_SYSCALL_AUDIT 5/* syscall auditing active */ #define TIF_SINGLE_STEP 6/* deliver sigtrap on return to user */ #define TIF_MCCK_PENDING 7/* machine check handling is pending */ +#define TIF_KERNEL_TRACE 8/* kernel trace active */ #define TIF_USEDFPU 16/* FPU was used by this task this quantum (SMP) */ #define TIF_POLLING_NRFLAG 17/* true if poll_idle() is polling TIF_NEED_RESCHED */
@@ -107,6 +108,7 @@ static inline struct thread_info *curren#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)#define _TIF_SINGLE_STEP (1<<TIF_SINGLE_STEP)#define _TIF_MCCK_PENDING (1<<TIF_MCCK_PENDING) +#define _TIF_KERNEL_TRACE (1<<TIF_KERNEL_TRACE)#define _TIF_USEDFPU (1<<TIF_USEDFPU)#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)#define _TIF_31BIT (1<<TIF_31BIT)
arch/s390/kernel/entry.S +8 -2
@@ -265,7 +265,9 @@ sysc_do_restart: sth %r7,SP_SVCNR(%r15) sll %r7,2 # svc number *4 l %r8,BASED(.Lsysc_table) - tm __TI_flags+3(%r9),(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT) + l %r8,__TI_flags+3(%r9) + n %r8,BASED(.Lc_tif_syscall_trace_or_audit_or_kernel_trace) + ltr %r8,%r8 l %r8,0(%r7,%r8) # get system call addr. bnz BASED(sysc_tracesys) basr %r14,%r8 # call sys_xxxx
@@ -405,7 +407,9 @@ sysc_tracego: basr %r14,%r8 # call sys_xxx st %r2,SP_R2(%r15) # store return value sysc_tracenogo: - tm __TI_flags+3(%r9),(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT) + l %r8,__TI_flags+3(%r9) + n %r8,BASED(.Lc_tif_syscall_trace_or_audit_or_kernel_trace) + ltr %r8,%r8 bz BASED(sysc_return) l %r1,BASED(.Ltrace_exit) la %r2,SP_PTREGS(%r15) # load pt_regs
@@ -1049,6 +1053,8 @@ cleanup_io_leave_insn: .L0x030: .short 0x030 .L0x038: .short 0x038 .Lc_1: .long 1 +.Lc_tif_syscall_trace_or_audit_or_kernel_trace: + .long _TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_KERNEL_TRACE /* * Symbol constants
arch/s390/kernel/entry64.S +8 -2
@@ -260,7 +260,9 @@ sysc_do_restart: larl %r10,sys_call_table_emu # use 31 bit emulation system calls sysc_noemu: #endif - tm __TI_flags+7(%r9),(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT) + l %r8,__TI_flags+7(%r9) + n %r8,BASED(.Lc_tif_syscall_trace_or_audit_or_kernel_trace) + ltr %r8,%r8 lgf %r8,0(%r7,%r10) # load address of system call routine jnz sysc_tracesys basr %r14,%r8 # call sys_xxxx
@@ -391,7 +393,9 @@ sysc_tracego: basr %r14,%r8 # call sys_xxx stg %r2,SP_R2(%r15) # store return value sysc_tracenogo: - tm __TI_flags+7(%r9),(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT) + l %r8,__TI_flags+7(%r9) + n %r8,BASED(.Lc_tif_syscall_trace_or_audit_or_kernel_trace) + ltr %r8,%r8 jz sysc_return la %r2,SP_PTREGS(%r15) # load pt_regs larl %r14,sysc_return # return point is sysc_return
@@ -1033,6 +1037,8 @@ cleanup_io_leave_insn: .align 4 .Lconst: .Lnr_syscalls: .long NR_syscalls +.Lc_tif_syscall_trace_or_audit_or_kernel_trace: + .long _TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_KERNEL_TRACE .L0x0130: .short 0x130 .L0x0140: .short 0x140 .L0x0150: .short 0x150
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
RFC PATCH 3/20 LTTng Kernel Trace Thread Flag AVR32
In reply to Mathieu DesnoyersAdd a thread flag to activate system-wide syscall tracing.
--- arch/avr32/include/asm/thread_info.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/avr32/include/asm/thread_info.h +3 -1
@@ -84,6 +84,7 @@ static inline struct thread_info *curren#define TIF_MEMDIE 6#define TIF_RESTORE_SIGMASK 7/* restore signal mask in do_signal */ #define TIF_CPU_GOING_TO_SLEEP 8/* CPU is entering sleep 0 mode */ +#define TIF_KERNEL_TRACE 9/* kernel trace active */ #define TIF_FREEZE 29#define TIF_DEBUG 30/* debugging enabled */ #define TIF_USERSPACE 31/* true if FS sets userspace */
@@ -96,6 +97,7 @@ static inline struct thread_info *curren#define _TIF_MEMDIE (1 << TIF_MEMDIE)#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)#define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP) +#define _TIF_KERNEL_TRACE (1 << TIF_KERNEL_TRACE)#define _TIF_FREEZE (1 << TIF_FREEZE)/* Note: The masks below must never span more than 16 bits! */
@@ -109,7 +111,7 @@ static inline struct thread_info *curren | (1 << TIF_RESTORE_SIGMASK))/* work to do on any return to userspace */ -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | (1 << TIF_SYSCALL_TRACE)) +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_SYSCALL_TRACE | _TIF_KERNEL_TRACE)/* work to do on return from debug mode */ #define _TIF_DBGWORK_MASK (_TIF_WORK_MASK & ~(1 << TIF_BREAKPOINT))
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
RFC PATCH 1/20 LTTng Kernel Trace Thread Flag Alpha
In reply to Mathieu DesnoyersAdd a thread flag to activate system-wide syscall tracing.
--- arch/alpha/include/asm/thread_info.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/alpha/include/asm/thread_info.h +3 -1
@@ -74,6 +74,7 @@ register struct thread_info *__current_t#define TIF_UAC_SIGBUS 7#define TIF_MEMDIE 8#define TIF_RESTORE_SIGMASK 9/* restore signal mask in do_signal */ +#define TIF_KERNEL_TRACE 10/* Kernel tracing of syscalls */ #define TIF_FREEZE 16/* is freezing for suspend */ #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
@@ -81,6 +82,7 @@ register struct thread_info *__current_t#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) +#define _TIF_KERNEL_TRACE (1<<TIF_KERNEL_TRACE)#define _TIF_FREEZE (1<<TIF_FREEZE)/* Work to do on interrupt/exception return. */
@@ -88,7 +90,7 @@ register struct thread_info *__current_t/* Work to do on any return to userspace. */ #define _TIF_ALLWORK_MASK (_TIF_WORK_MASK \ - | _TIF_SYSCALL_TRACE) + | _TIF_SYSCALL_TRACE | _TIF_KERNEL_TRACE)#define ALPHA_UAC_SHIFT 6#define ALPHA_UAC_MASK (1 << TIF_UAC_NOPRINT | 1 << TIF_UAC_NOFIX | \
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
RFC PATCH 2/20 LTTng Kernel Trace Thread Flag ARM
In reply to Mathieu DesnoyersAdd a thread flag to activate system-wide syscall tracing.
folded omap-arm-fix-syscall-exit-trace-flag.patch.
--- arch/arm/include/asm/thread_info.h | 3 +++ arch/arm/kernel/entry-common.S | 2 ++ 2 files changed, 5 insertions(+)
arch/arm/include/asm/thread_info.h +3 -0
@@ -128,6 +128,7 @@ extern void vfp_sync_state(struct thread/* * thread information flags: * TIF_SYSCALL_TRACE - syscall trace active +* TIF_KERNEL_TRACE - kernel trace active * TIF_SIGPENDING - signal pending * TIF_NEED_RESCHED - rescheduling necessary * TIF_USEDFPU - FPU was used by this task this quantum (SMP)
@@ -135,6 +136,7 @@ extern void vfp_sync_state(struct thread*/ #define TIF_SIGPENDING 0#define TIF_NEED_RESCHED 1 +#define TIF_KERNEL_TRACE 7#define TIF_SYSCALL_TRACE 8#define TIF_POLLING_NRFLAG 16#define TIF_USING_IWMMXT 17
@@ -143,6 +145,7 @@ extern void vfp_sync_state(struct thread#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) +#define _TIF_KERNEL_TRACE (1 << TIF_KERNEL_TRACE)#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)#define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
arch/arm/kernel/entry-common.S +2 -0
@@ -47,6 +47,8 @@ ret_fast_syscall: * Ok, we need to do extra processing, enter the slow path. */ fast_work_pending: + tst r1, #_TIF_KERNEL_TRACE @ flag can be set asynchronously + bne __sys_trace_return str r0, [sp, #S_R0+S_OFF]! @ returned r0 work_pending: tst r1, #_TIF_NEED_RESCHED
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
RFC PATCH 16/20 LTTng Kernel Trace Thread Flag sparc
In reply to Mathieu DesnoyersAdd a thread flag to activate system-wide syscall tracing.
Folded lttng-kernel-trace-thread-flag-sparc64.patch.
--- arch/sparc/include/asm/thread_info_32.h | 2 ++ arch/sparc/include/asm/thread_info_64.h | 3 ++- arch/sparc/kernel/entry.S | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-)
arch/sparc/include/asm/thread_info_32.h +2 -0
@@ -130,6 +130,7 @@ BTFIXUPDEF_CALL(void, free_thread_info,#define TIF_SIGPENDING 2/* signal pending */ #define TIF_NEED_RESCHED 3/* rescheduling necessary */ #define TIF_RESTORE_SIGMASK 4/* restore signal mask in do_signal() */ +#define TIF_KERNEL_TRACE 5/* kernel trace active */ #define TIF_USEDFPU 8/* FPU was used by this task * this quantum (SMP) */ #define TIF_POLLING_NRFLAG 9/* true if poll_idle() is polling
@@ -139,6 +140,7 @@ BTFIXUPDEF_CALL(void, free_thread_info,/* as above, but as bit values */ #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) +#define _TIF_KERNEL_TRACE (1<<TIF_KERNEL_TRACE)#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
arch/sparc/kernel/entry.S +4 -4
@@ -1118,7 +1118,7 @@ sys_sigreturn: add %sp, STACKFRAME_SZ, %o0 ld [%curptr + TI_FLAGS], %l5 - andcc %l5, _TIF_SYSCALL_TRACE, %g0 + andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_KERNEL_TRACE), %g0 be 1f nop
@@ -1138,7 +1138,7 @@ sys_rt_sigreturn: add %sp, STACKFRAME_SZ, %o0 ld [%curptr + TI_FLAGS], %l5 - andcc %l5, _TIF_SYSCALL_TRACE, %g0 + andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_KERNEL_TRACE), %g0 be 1f nop
@@ -1280,7 +1280,7 @@ syscall_is_too_hard: ld [%curptr + TI_FLAGS], %l5 mov %i3, %o3 - andcc %l5, _TIF_SYSCALL_TRACE, %g0 + andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_KERNEL_TRACE), %g0 mov %i4, %o4 bne linux_syscall_trace mov %i0, %l5
@@ -1297,7 +1297,7 @@ ret_sys_call: ld [%sp + STACKFRAME_SZ + PT_PSR], %g3 set PSR_C, %g2 bgeu 1f - andcc %l6, _TIF_SYSCALL_TRACE, %g0 + andcc %l6, (_TIF_SYSCALL_TRACE|_TIF_KERNEL_TRACE), %g0 /* System call success, clear Carry condition code. */ andn %g3, %g2, %g3
arch/sparc/include/asm/thread_info_64.h +2 -1
@@ -226,7 +226,7 @@ register struct thread_info *current_thr#define TIF_UNALIGNED 5/* allowed to do unaligned accesses */ /* flag bit 6 is available */ #define TIF_32BIT 7/* 32-bit binary */ -/* flag bit 8 is available */ +#define TIF_KERNEL_TRACE 8/* kernel trace active */ #define TIF_SECCOMP 9/* secure computing */ #define TIF_SYSCALL_AUDIT 10/* syscall auditing active */ /* flag bit 11 is available */
@@ -246,6 +246,7 @@ register struct thread_info *current_thr#define _TIF_PERFCTR (1<<TIF_PERFCTR)#define _TIF_UNALIGNED (1<<TIF_UNALIGNED)#define _TIF_32BIT (1<<TIF_32BIT) +#define _TIF_KERNEL_TRACE (1<<TIF_KERNEL_TRACE)#define _TIF_SECCOMP (1<<TIF_SECCOMP)#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING)
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
RFC PATCH 20/20 LTTng Kernel Trace Thread Flag API
In reply to Mathieu DesnoyersAdd an API to set/clear the kernel wide tracing thread flags. Implemented in kernel/sched.c. Updates thread flags *asynchronously* while holding the tasklist read lock.
Upon fork, the flag must be re-copied while the tasklist write lock is held.
We are holding the read lock only to make sure we don't delay thread creation for too long while iterating on all threads.
--- include/linux/sched.h | 3 ++ kernel/fork.c | 9 ++++++++ kernel/sched.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+)
include/linux/sched.h +3 -0
@@ -2403,6 +2403,9 @@ static inline void mm_init_owner(struct#define TASK_STATE_TO_CHAR_STR "RSDTtZX" +extern void clear_kernel_trace_flag_all_tasks (void ); +extern void set_kernel_trace_flag_all_tasks (void ); +#endif /* __KERNEL__ */ #endif
kernel/fork.c +9 -0
@@ -1209,6 +1209,15 @@ static struct task_struct *copy_process( !cpu_online(task_cpu(p))))set_task_cpu (p,smp_processor_id ()); +/* +* The state of the parent's TIF_KTRACE flag may have changed +* since it was copied in dup_task_struct() so we re-copy it here. +*/ +if (test_thread_flag (TIF_KERNEL_TRACE )) +set_tsk_thread_flag (p,TIF_KERNEL_TRACE ); +else +clear_tsk_thread_flag (p,TIF_KERNEL_TRACE ); +/* CLONE_PARENT re-uses the old parent */ if (clone_flags & (CLONE_PARENT |CLONE_THREAD )) { p->real_parent = current->real_parent;
kernel/sched.c +55 -0
58 lines not on this page · raw message
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
RFC PATCH 10/20 LTTng Kernel Trace Thread Flag m68k
In reply to Mathieu DesnoyersAdd a thread flag to activate system-wide syscall tracing.
--- arch/m68k/include/asm/thread_info_mm.h | 1 + arch/m68k/include/asm/thread_info_no.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)
arch/m68k/include/asm/thread_info_mm.h +1 -0
@@ -49,6 +49,7 @@ struct thread_info {*/ #define TIF_SIGPENDING 6/* signal pending */ #define TIF_NEED_RESCHED 7/* rescheduling necessary */ +#define TIF_KERNEL_TRACE 13/* kernel trace active */ #define TIF_DELAYED_TRACE 14/* single step a syscall */ #define TIF_SYSCALL_TRACE 15/* syscall trace active */ #define TIF_MEMDIE 16
arch/m68k/include/asm/thread_info_no.h +3 -1
@@ -84,6 +84,7 @@ static inline struct thread_info *curren#define TIF_POLLING_NRFLAG 3/* true if poll_idle() is polling TIF_NEED_RESCHED */ #define TIF_MEMDIE 4 +#define TIF_KERNEL_TRACE 5/* kernel trace active */ #define TIF_FREEZE 16/* is freezing for suspend */ /* as above, but as bit values */
@@ -92,8 +93,9 @@ static inline struct thread_info *curren#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)#define _TIF_FREEZE (1<<TIF_FREEZE) +#define _TIF_KERNEL_TRACE (1<<TIF_KERNEL_TRACE) -#define _TIF_WORK_MASK 0x0000FFFE/* work to do on interrupt/exception return */ +#define _TIF_WORK_MASK 0x0000FFDE/* work to do on interrupt/exception return */ #endif /* __KERNEL__ */
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
cover Kernel tracing thread flag
This is the generalisation of the TIF_SYSCALL_FTRACE thread flag for :
- multiple tracers (even accessible from modules)
- multiple architectures
It includes :
- Addition of the TIF_KERNEL_TRACE for all Linux architectures.
- Modification of some architecture entry*.S files to ensure that the thread flag is re-read upon syscall exit to ensure that syscall exit is traced. Basically, what I try to achieve here is to make sure that given the following sequence will get its syscall exit event traced :
- Thread preempted in a system call
- Activation of all TIF_KERNEL_TRACE thread flags
- ...enough time passes to expect that all tracing sites are activated...
- syscall exit -> expected to be traced
But if the thread flags used at syscall exit are the same that has been read at syscall entry, the event will be skipped. This does not permit reaching a known "quiescent state" where we know that all tracing sites are activated.
Note that having non-perfectly matched syscall trace entry/exit may have implications wrt getname/putname refcounting for instance, and could cause problems if getname/putname was used in the syscall entry/exit pairs. We will have to deal with this somehow when we face this problem. Keeping a per-thread flag saying that a matching syscall_entry tracing has been executed could fix this problem. We could even re-use TIF_SYSCALL_FTRACE for this specific purpose.
Mathieu
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
RFC PATCH 12/20 LTTng Kernel Trace Thread Flag parisc
Add a thread flag to activate system-wide syscall tracing.
--- arch/parisc/include/asm/thread_info.h | 2 ++ 1 file changed, 2 insertions(+)
arch/parisc/include/asm/thread_info.h +2 -0
@@ -59,6 +59,7 @@ struct thread_info {#define TIF_MEMDIE 5#define TIF_RESTORE_SIGMASK 6/* restore saved signal mask */ #define TIF_FREEZE 7/* is freezing for suspend */ +#define TIF_KERNEL_TRACE 8/* kernel trace active */ #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
@@ -67,6 +68,7 @@ struct thread_info {#define _TIF_32BIT (1 << TIF_32BIT)#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)#define _TIF_FREEZE (1 << TIF_FREEZE) +#define _TIF_KERNEL_TRACE (1 << TIF_KERNEL_TRACE)#define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | \ _TIF_NEED_RESCHED | _TIF_RESTORE_SIGMASK)
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
RFC PATCH 6/20 LTTng Kernel Trace Thread Flag Frv
In reply to Mathieu DesnoyersAdd a thread flag to activate system-wide syscall tracing.
--- arch/frv/include/asm/thread_info.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/frv/include/asm/thread_info.h +3 -1
@@ -114,6 +114,7 @@ register struct thread_info *__current_t#define TIF_SINGLESTEP 3/* restore singlestep on return to user mode */ #define TIF_IRET 4/* return with iret */ #define TIF_RESTORE_SIGMASK 5/* restore signal mask in do_signal() */ +#define TIF_KERNEL_TRACE 6/* kernel trace active */ #define TIF_POLLING_NRFLAG 16/* true if poll_idle() is polling TIF_NEED_RESCHED */ #define TIF_MEMDIE 17/* OOM killer killed process */ #define TIF_FREEZE 18/* freezing for suspend */
@@ -124,10 +125,11 @@ register struct thread_info *__current_t#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)#define _TIF_IRET (1 << TIF_IRET)#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) +#define _TIF_KERNEL_TRACE (1 << TIF_KERNEL_TRACE)#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)#define _TIF_FREEZE (1 << TIF_FREEZE) -#define _TIF_WORK_MASK 0x0000FFFE/* work to do on interrupt/exception return */ +#define _TIF_WORK_MASK 0x0000FFBE/* work to do on interrupt/exception return */ #define _TIF_ALLWORK_MASK 0x0000FFFF/* work to do on any return to u-space */ /*
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
RFC PATCH 11/20 LTTng Kernel Trace Thread Flag MIPS
In reply to Mathieu DesnoyersAdd a thread flag to activate system-wide syscall tracing.
--- arch/mips/include/asm/thread_info.h | 4 +++- arch/mips/kernel/entry.S | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
arch/mips/include/asm/thread_info.h +3 -1
@@ -125,6 +125,7 @@ register struct thread_info *__current_t#define TIF_32BIT_ADDR 23/* 32-bit address space (o32/n32) */ #define TIF_FPUBOUND 24/* thread bound to FPU-full CPU set */ #define TIF_LOAD_WATCH 25/* If set, load watch registers */ +#define TIF_KERNEL_TRACE 30/* kernel trace active */ #define TIF_SYSCALL_TRACE 31/* syscall trace active */ #ifdef CONFIG_MIPS32_O32
@@ -134,6 +135,7 @@ register struct thread_info *__current_t#endif /* CONFIG_MIPS32_O32 */ #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) +#define _TIF_KERNEL_TRACE (1<<TIF_KERNEL_TRACE)#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
@@ -152,7 +154,7 @@ register struct thread_info *__current_t/* work to do on interrupt/exception return */ #define _TIF_WORK_MASK (0x0000ffef & ~_TIF_SECCOMP)/* work to do on any return to u-space */ -#define _TIF_ALLWORK_MASK (0x8000ffff & ~_TIF_SECCOMP) +#define _TIF_ALLWORK_MASK (0xc000ffff & ~_TIF_SECCOMP)#endif /* __KERNEL__ */
arch/mips/kernel/entry.S +1 -1
@@ -167,7 +167,7 @@ work_notifysig: # deal with pending s FEXPORT(syscall_exit_work_partial) SAVE_STATIC syscall_exit_work: - li t0, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT + li t0, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_KERNEL_TRACE and t0, a2 # a2 is preloaded with TI_FLAGS beqz t0, work_pending # trace bit set? local_irq_enable # could let do_syscall_trace()
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
RFC PATCH 8/20 LTTng Kernel Trace Thread Flag ia64
In reply to Mathieu DesnoyersAdd a thread flag to activate system-wide syscall tracing.
FIXME : Masami reported that enabling the KERNEL_TRACE thread flag did disable the gate page for gettimeofday, falling back on a standard system call. More work would be needed in this area and I don't have the architecture available.
--- arch/ia64/include/asm/thread_info.h | 10 +++++++--- arch/ia64/kernel/entry.S | 6 ++++-- 2 files changed, 11 insertions(+), 5 deletions(-)
arch/ia64/include/asm/thread_info.h +7 -3
@@ -100,6 +100,7 @@ struct thread_info {#define TIF_SYSCALL_TRACE 2/* syscall trace active */ #define TIF_SYSCALL_AUDIT 3/* syscall auditing active */ #define TIF_SINGLESTEP 4/* restore singlestep on return to user mode */ +#define TIF_KERNEL_TRACE 5/* kernel trace active */ #define TIF_NOTIFY_RESUME 6/* resumption notification requested */ #define TIF_POLLING_NRFLAG 16/* true if poll_idle() is polling TIF_NEED_RESCHED */ #define TIF_MEMDIE 17
@@ -111,7 +112,9 @@ struct thread_info {#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP) -#define _TIF_SYSCALL_TRACEAUDIT (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SINGLESTEP) +#define _TIF_KERNEL_TRACE (1 << TIF_KERNEL_TRACE) +#define _TIF_SYSCALL_TRACEAUDIT (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|\ + _TIF_SINGLESTEP|_TIF_KERNEL_TRACE)#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
@@ -124,8 +127,9 @@ struct thread_info {/* "work to do on user-return" bits */ #define TIF_ALLWORK_MASK (_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SYSCALL_AUDIT|\ _TIF_NEED_RESCHED|_TIF_SYSCALL_TRACE) -/* like TIF_ALLWORK_BITS but sans TIF_SYSCALL_TRACE or TIF_SYSCALL_AUDIT */ -#define TIF_WORK_MASK (TIF_ALLWORK_MASK&~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT)) +/* like TIF_ALLWORK_BITS but sans TIF_SYSCALL_TRACE, TIF_KERNEL_TRACE or TIF_SYSCALL_AUDIT */ +#define TIF_WORK_MASK (TIF_ALLWORK_MASK&~(_TIF_SYSCALL_TRACE|_TIF_KERNEL_TRACE|\ + _TIF_SYSCALL_AUDIT))#define TS_POLLING 1/* true if in idle loop and not sleeping */ #define TS_RESTORE_SIGMASK 2/* restore signal mask in do_signal() */
arch/ia64/kernel/entry.S +4 -2
@@ -635,9 +635,11 @@ GLOBAL_ENTRY(ia64_ret_from_clone) ;; ld4 r2=[r2] ;; + movl r8=_TIF_SYSCALL_TRACEAUDIT + ;; // added stop bits to prevent r8 dependency + and r2=r8,r2 mov r8=0 - and r2=_TIF_SYSCALL_TRACEAUDIT,r2 - ;; + ;; // added stop bits to prevent r2 dependency cmp.ne p6,p0=r2,r0 (p6) br.cond.spnt .strace_check_retval ;; // added stop bits to prevent r8 dependency
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
RFC PATCH 18/20 LTTng Linux Kernel Trace Thread Flag x86
In reply to Mathieu DesnoyersAdd a thread flag to activate system-wide syscall tracing.
Make x86 support TIF_SYSCALL_TRACE async flag set in entry_32.S/entry_64.S.
x86_64 :
When the flag is inactive upon syscall entry and concurrently activated before exit, we seem to reach a state where the top of stack is incorrect upon return to user space.
Fix this by fixing the top of stack and jumping to int_ret_from_sys_call if we detect that thread flags has been modified.
We make sure that the thread flag read is coherent between our new test and the ALLWORK_MASK test by first saving it in a register used for both comparisons.
Note :
Removed :
# perform syscall exit tracing
ALIGN
syscall_exit_work:
- testb $_TIF_WORK_SYSCALL_EXIT, %cl
jz work_pending
TRACE_IRQS_ON
ENABLE_INTERRUPTS(CLBR_ANY) # could let syscall_trace_leave() call
--- 571,578 ----
# perform syscall exit tracing
ALIGN
syscall_exit_work:
+ /* Note, _TIF_KERNEL_TRACE is bit number 9, and so it needs testw and not testb */
+ testw $_TIF_WORK_SYSCALL_EXIT, %cx
jz work_pending
TRACE_IRQS_ON
ENABLE_INTERRUPTS(CLBR_ANY) # could let syscall_trace_leave() callbecause testl now used in mainline since 2.6.30-rc1.
--- arch/x86/include/asm/thread_info.h | 9 ++++++--- arch/x86/kernel/entry_64.S | 12 ++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-)
arch/x86/include/asm/thread_info.h +6 -3
@@ -82,6 +82,7 @@ struct thread_info {#define TIF_SYSCALL_EMU 6/* syscall emulation active */ #define TIF_SYSCALL_AUDIT 7/* syscall auditing active */ #define TIF_SECCOMP 8/* secure computing */ +#define TIF_KERNEL_TRACE 9/* kernel trace active */ #define TIF_MCE_NOTIFY 10/* notify userspace of an MCE */ #define TIF_NOTSC 16/* TSC is not accessible in userland */ #define TIF_IA32 17/* 32bit process */
@@ -105,6 +106,7 @@ struct thread_info {#define _TIF_SYSCALL_EMU (1 << TIF_SYSCALL_EMU)#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)#define _TIF_SECCOMP (1 << TIF_SECCOMP) +#define _TIF_KERNEL_TRACE (1 << TIF_KERNEL_TRACE)#define _TIF_MCE_NOTIFY (1 << TIF_MCE_NOTIFY)#define _TIF_NOTSC (1 << TIF_NOTSC)#define _TIF_IA32 (1 << TIF_IA32)
@@ -121,18 +123,19 @@ struct thread_info {/* work to do in syscall_trace_enter() */ #define _TIF_WORK_SYSCALL_ENTRY \ (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_FTRACE | \ - _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | _TIF_SINGLESTEP) + _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | _TIF_SINGLESTEP | \ + _TIF_KERNEL_TRACE)/* work to do in syscall_trace_leave() */ #define _TIF_WORK_SYSCALL_EXIT \ (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \ - _TIF_SYSCALL_FTRACE) + _TIF_SYSCALL_FTRACE | _TIF_KERNEL_TRACE)/* work to do on interrupt/exception return */ #define _TIF_WORK_MASK \ (0x0000FFFF & \ ~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT| \ - _TIF_SINGLESTEP|_TIF_SECCOMP|_TIF_SYSCALL_EMU)) + _TIF_SINGLESTEP|_TIF_SECCOMP|_TIF_SYSCALL_EMU|_TIF_KERNEL_TRACE))/* work to do on any return to user space */ #define _TIF_ALLWORK_MASK ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_FTRACE)
arch/x86/kernel/entry_64.S +12 -0
@@ -528,6 +528,8 @@ sysret_check: /* Handle reschedules */ /* edx: work, edi: workmask */ sysret_careful: + testl $_TIF_KERNEL_TRACE,%edx /* Re-read : concurrently changed */ + jnz ret_from_sys_call_trace bt $TIF_NEED_RESCHED,%edx jnc sysret_signal TRACE_IRQS_ON
@@ -539,6 +541,16 @@ sysret_careful: CFI_ADJUST_CFA_OFFSET -8 jmp sysret_check +ret_from_sys_call_trace: + TRACE_IRQS_ON + sti + SAVE_REST + FIXUP_TOP_OF_STACK %rdi + movq %rsp,%rdi + LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */ + RESTORE_REST + jmp int_ret_from_sys_call + /* Handle a signal */ sysret_signal: TRACE_IRQS_ON
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
RFC PATCH 19/20 LTTng Kernel Trace Thread Flag xtensa
In reply to Mathieu DesnoyersAdd a thread flag to activate system-wide syscall tracing.
--- arch/xtensa/include/asm/thread_info.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/xtensa/include/asm/thread_info.h +3 -1
@@ -133,6 +133,7 @@ static inline struct thread_info *curren#define TIF_IRET 4/* return with iret */ #define TIF_MEMDIE 5#define TIF_RESTORE_SIGMASK 6/* restore signal mask in do_signal() */ +#define TIF_KERNEL_TRACE 7/* kernel trace active */ #define TIF_POLLING_NRFLAG 16/* true if poll_idle() is polling TIF_NEED_RESCHED */ #define TIF_FREEZE 17/* is freezing for suspend */
@@ -141,11 +142,12 @@ static inline struct thread_info *curren#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)#define _TIF_IRET (1<<TIF_IRET) +#define _TIF_KERNEL_TRACE (1<<TIF_KERNEL_TRACE)#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)#define _TIF_FREEZE (1<<TIF_FREEZE) -#define _TIF_WORK_MASK 0x0000FFFE/* work to do on interrupt/exception return */ +#define _TIF_WORK_MASK 0x0000FF7E/* work to do on interrupt/exception return */ #define _TIF_ALLWORK_MASK 0x0000FFFF/* work to do on any return to u-space */ /*
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
RFC PATCH 15/20 LTTng Kernel Trace Thread Flag SH
In reply to Mathieu DesnoyersAdd a thread flag to activate system-wide syscall tracing.
--- arch/sh/include/asm/thread_info.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
arch/sh/include/asm/thread_info.h +7 -3
@@ -116,6 +116,7 @@ extern void free_thread_info(struct thre#define TIF_SYSCALL_AUDIT 5/* syscall auditing active */ #define TIF_SECCOMP 6/* secure computing */ #define TIF_NOTIFY_RESUME 7/* callback before returning to user */ +#define TIF_KERNEL_TRACE 8/* kernel trace active */ #define TIF_USEDFPU 16/* FPU was used by this task this quantum (SMP) */ #define TIF_POLLING_NRFLAG 17/* true if poll_idle() is polling TIF_NEED_RESCHED */ #define TIF_MEMDIE 18
@@ -129,6 +130,7 @@ extern void free_thread_info(struct thre#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)#define _TIF_SECCOMP (1 << TIF_SECCOMP)#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) +#define _TIF_KERNEL_TRACE (1 << TIF_KERNEL_TRACE)#define _TIF_USEDFPU (1 << TIF_USEDFPU)#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)#define _TIF_FREEZE (1 << TIF_FREEZE)
@@ -141,17 +143,19 @@ extern void free_thread_info(struct thre/* work to do in syscall trace */ #define _TIF_WORK_SYSCALL_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \ - _TIF_SYSCALL_AUDIT | _TIF_SECCOMP) + _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \ + _TIF_KERNEL_TRACE)/* work to do on any return to u-space */ #define _TIF_ALLWORK_MASK (_TIF_SYSCALL_TRACE | _TIF_SIGPENDING | \ _TIF_NEED_RESCHED | _TIF_SYSCALL_AUDIT | \ _TIF_SINGLESTEP | _TIF_RESTORE_SIGMASK | \ - _TIF_NOTIFY_RESUME) + _TIF_NOTIFY_RESUME | _TIF_KERNEL_TRACE)/* work to do on interrupt/exception return */ #define _TIF_WORK_MASK (_TIF_ALLWORK_MASK & ~(_TIF_SYSCALL_TRACE | \ - _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP)) + _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \ + _TIF_KERNEL_TRACE))#endif /* __KERNEL__ */
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
RFC PATCH 17/20 LTTng Kernel Trace Thread Flag UML
In reply to Mathieu DesnoyersAdd a thread flag to activate system-wide syscall tracing.
--- arch/um/include/asm/thread_info.h | 2 ++ 1 file changed, 2 insertions(+)
arch/um/include/asm/thread_info.h +2 -0
@@ -69,6 +69,7 @@ static inline struct thread_info *curren#define TIF_MEMDIE 5#define TIF_SYSCALL_AUDIT 6#define TIF_RESTORE_SIGMASK 7 +#define TIF_KERNEL_TRACE 8/* kernel trace active */ #define TIF_FREEZE 16/* is freezing for suspend */ #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
@@ -78,6 +79,7 @@ static inline struct thread_info *curren#define _TIF_MEMDIE (1 << TIF_MEMDIE)#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) +#define _TIF_KERNEL_TRACE (1 << TIF_KERNEL_TRACE)#define _TIF_FREEZE (1 << TIF_FREEZE)#endif
Signature · 2 lines
Mathieu Desnoyers OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
Re: [RFC patch 15/20] LTTng Kernel Trace Thread Flag SH
In reply to Mathieu DesnoyersQuoted 33 lines · Mathieu Desnoyers
Index:
linux-2.6-lttng/arch/sh/include/asm/thread_info.h
===================================================================arch/sh/include/asm/thread_info.h +4
-2@@ -116,6 +116,7 @@ extern void free_thread_info(struct thre#define TIF_SYSCALL_AUDIT 5/* syscall auditing active */ #define TIF_SECCOMP 6/* secure computing */ #define TIF_NOTIFY_RESUME 7/* callback before returning to user */ +#define TIF_KERNEL_TRACE 8/* kernel trace active */ #define TIF_USEDFPU 16/* FPU was used by this task this quantum (SMP) */ #define TIF_POLLING_NRFLAG 17/* true if poll_idle() is polling TIF_NEED_RESCHED */ #define TIF_MEMDIE 18@@ -129,6 +130,7 @@ extern void free_thread_info(struct thre#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)#define _TIF_SECCOMP (1 << TIF_SECCOMP)#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) +#define _TIF_KERNEL_TRACE (1 << TIF_KERNEL_TRACE)#define _TIF_USEDFPU (1 << TIF_USEDFPU)#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)#define _TIF_FREEZE (1 << TIF_FREEZE)@@ -141,17 +143,19 @@ extern void free_thread_info(struct thre/* work to do in syscall trace */ #define _TIF_WORK_SYSCALL_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \ - _TIF_SYSCALL_AUDIT | _TIF_SECCOMP) + _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \ + _TIF_KERNEL_TRACE)/* work to do on any return to u-space */ #define _TIF_ALLWORK_MASK (_TIF_SYSCALL_TRACE | _TIF_SIGPENDING | \ _TIF_NEED_RESCHED | _TIF_SYSCALL_AUDIT | \ _TIF_SINGLESTEP | _TIF_RESTORE_SIGMASK | \ - _TIF_NOTIFY_RESUME)
arch/sh/include/asm/thread_info.h extern void free_thread_info(struct thre · line 161
Quoted 10 lines
arch/sh/include/asm/thread_info.h +3
-1+ _TIF_NOTIFY_RESUME | _TIF_KERNEL_TRACE)/* work to do on interrupt/exception return */ #define _TIF_WORK_MASK (_TIF_ALLWORK_MASK & ~(_TIF_SYSCALL_TRACE | \ - _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP)) + _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \ + _TIF_KERNEL_TRACE))#endif /* __KERNEL__ */
I think you missed the comment above this hunk in the code..
This will blow up immediately, _TIF_ALLWORK_MASK must presently fit within a byte, as it just happens to right now. If this can take the place of _TIF_SYSCALL_TRACE in the future, then that bit position can be used instead, otherwise the assembly code will have to be rewritten to load a larger value, which means we lose the ability to load the mask as an immediate without resorting to shifting and masking :-(
Other platforms have similar constraints, have you verified that this is not a problem on any of the other platforms?
I'll of course rewrite the assembly if we can't avoid it.
I suspect you will hit troubles with some arch's not having a bit to spare. (Even on x86, it probably hurts several bytes of cache wastage to have to use longer immediates in some 'test' instructions.)
Another direction to go for this is overloading TIF_SYSCALL_TRACE, so we do not need any arch changes. Before the end of the ptrace cleanup work that Oleg is in the middle of, it should become simple to divorce ptrace's own bookkeeping from TIF_SYSCALL_TRACE. At that point, we just need a little bit of cooperation (in generic non-arch code) to overload that bit for multiple simultaneous purposes.
Thanks,
Roland
Re: [RFC patch 14/20] LTTng Kernel Trace Thread Flag s390
In reply to Mathieu DesnoyersQuoted 34 lines · On Sat, 09 May 2009 12:22:23 -0400 Mathieu Desnoyers…
Add a thread flag to activate system-wide syscall tracing.
Signed-off-by Mathieu Desnoyers <[email protected]>--- arch/s390/include/asm/thread_info.h | 2 ++ arch/s390/kernel/entry.S | 10 ++++++++-- arch/s390/kernel/entry64.S | 10 ++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-)Index:
linux-2.6-lttng/arch/s390/include/asm/thread_info.h
===================================================================arch/s390/include/asm/thread_info.h +2
-0@@ -90,6 +90,7 @@ static inline struct thread_info *curren#define TIF_SYSCALL_AUDIT 5/* syscall auditing active */ #define TIF_SINGLE_STEP 6/* deliver sigtrap on return to user */ #define TIF_MCCK_PENDING 7/* machine check handling is pending */ +#define TIF_KERNEL_TRACE 8/* kernel trace active */ #define TIF_USEDFPU 16/* FPU was used by this task this quantum (SMP) */ #define TIF_POLLING_NRFLAG 17/* true if poll_idle() is polling TIF_NEED_RESCHED */ @@ -107,6 +108,7 @@ static inline struct thread_info *curren#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)#define _TIF_SINGLE_STEP (1<<TIF_SINGLE_STEP)#define _TIF_MCCK_PENDING (1<<TIF_MCCK_PENDING) +#define _TIF_KERNEL_TRACE (1<<TIF_KERNEL_TRACE)#define _TIF_USEDFPU (1<<TIF_USEDFPU)#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)#define _TIF_31BIT (1<<TIF_31BIT)Index:
linux-2.6-lttng/arch/s390/kernel/entry.S
===================================================================
arch/s390/kernel/entry.S sysc_do_restart: · line 272
Quoted 9 lines
arch/s390/kernel/entry.S +3
-1@@ -265,7 +265,9 @@ sysc_do_restart: sth %r7,SP_SVCNR(%r15) sll %r7,2 # svc number *4 l %r8,BASED(.Lsysc_table) - tm __TI_flags+3(%r9),(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT) + l %r8,__TI_flags+3(%r9) + n %r8,BASED(.Lc_tif_syscall_trace_or_audit_or_kernel_trace) + ltr %r8,%r8 l %r8,0(%r7,%r8) # get system call addr. bnz BASED(sysc_tracesys)
That would be two more instructions (ltr is not needed) and an additional memory access instead of just one for the fast path just for debugging purposes.
All this can be avoided if the TIF flags would be rearranged. And that's exactly what I already did because I needed it for something else.
Please have a look at linux-next.