Index: linux-2.6.21-rc5/lib/Kconfig.debug =================================================================== --- linux-2.6.21-rc5.orig/lib/Kconfig.debug +++ linux-2.6.21-rc5/lib/Kconfig.debug @@ -458,6 +458,6 @@ config THREAD_PERF_STAT config THREAD_PERF_STAT_SYSC bool "Enable syscall counter" - depends on THREAD_PERF_STAT && X86_32 + depends on THREAD_PERF_STAT && X86 help This option adds a syscall counter to /proc/PID/status. Index: linux-2.6.21-rc5/include/asm-x86_64/thread_info.h =================================================================== --- linux-2.6.21-rc5.orig/include/asm-x86_64/thread_info.h +++ linux-2.6.21-rc5/include/asm-x86_64/thread_info.h @@ -30,7 +30,9 @@ struct thread_info { __u32 status; /* thread synchronous flags */ __u32 cpu; /* current CPU */ int preempt_count; /* 0 => preemptable, <0 => BUG */ - +#ifdef CONFIG_THREAD_PERF_STAT_SYSC + unsigned long sysc_cnt; /* Syscall counter */ +#endif /* CONFIG_THREAD_PERF_STAT_SYSC */ mm_segment_t addr_limit; struct restart_block restart_block; }; Index: linux-2.6.21-rc5/arch/x86_64/kernel/entry.S =================================================================== --- linux-2.6.21-rc5.orig/arch/x86_64/kernel/entry.S +++ linux-2.6.21-rc5/arch/x86_64/kernel/entry.S @@ -236,6 +236,11 @@ ENTRY(system_call) movq %r10,%rcx call *sys_call_table(,%rax,8) # XXX: rip relative movq %rax,RAX-ARGOFFSET(%rsp) +#ifdef CONFIG_THREAD_PERF_STAT_SYSC + GET_THREAD_INFO(%rcx) + addq $1, threadinfo_sysc_cnt(%rcx) # Increment syscalls counter +#endif /* CONFIG_THREAD_PERF_STAT_SYSC */ + /* * Syscall return path ending with SYSRET (fast path) * Has incomplete stack frame and undefined top of stack. @@ -319,6 +324,10 @@ tracesys: call *sys_call_table(,%rax,8) 1: movq %rax,RAX-ARGOFFSET(%rsp) /* Use IRET because user could have changed frame */ +#ifdef CONFIG_THREAD_PERF_STAT_SYSC + GET_THREAD_INFO(%rcx) + addq $1, threadinfo_sysc_cnt(%rcx) # Increment syscalls counter +#endif /* CONFIG_THREAD_PERF_STAT_SYSC */ /* * Syscall return path ending with IRET. Index: linux-2.6.21-rc5/arch/x86_64/kernel/asm-offsets.c =================================================================== --- linux-2.6.21-rc5.orig/arch/x86_64/kernel/asm-offsets.c +++ linux-2.6.21-rc5/arch/x86_64/kernel/asm-offsets.c @@ -35,6 +35,9 @@ int main(void) ENTRY(addr_limit); ENTRY(preempt_count); ENTRY(status); +#ifdef CONFIG_THREAD_PERF_STAT_SYSC + ENTRY(sysc_cnt); +#endif /* CONFIG_THREAD_PERF_STAT_SYSC */ BLANK(); #undef ENTRY #define ENTRY(entry) DEFINE(pda_ ## entry, offsetof(struct x8664_pda, entry))