From mboxrd@z Thu Jan 1 00:00:00 1970 From: wade_farnsworth@mentor.com (Wade Farnsworth) Date: Wed, 15 Aug 2012 09:58:44 -0700 Subject: [PATCH v2] ARM: support syscall tracing In-Reply-To: <20120815162157.GJ29448@mudshark.cambridge.arm.com> References: <502BBCCC.1020006@mentor.com> <20120815162157.GJ29448@mudshark.cambridge.arm.com> Message-ID: <502BD544.70903@mentor.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Will Deacon wrote: > Hi Wade, > > On Wed, Aug 15, 2012 at 04:14:20PM +0100, Wade Farnsworth wrote: >> diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c >> index 3e0fc5f..4e82fc1 100644 >> --- a/arch/arm/kernel/ptrace.c >> +++ b/arch/arm/kernel/ptrace.c >> @@ -30,6 +30,9 @@ >> #include >> #include >> >> +#define CREATE_TRACE_POINTS >> +#include >> + >> #define REG_PC 15 >> #define REG_PSR 16 >> /* >> @@ -918,7 +921,8 @@ static int ptrace_syscall_trace(struct pt_regs *regs, int scno, >> { >> unsigned long ip; >> >> - if (!test_thread_flag(TIF_SYSCALL_TRACE)) >> + if (!test_thread_flag(TIF_SYSCALL_TRACE)&& >> + !test_thread_flag(TIF_SYSCALL_TRACEPOINT)) >> return scno; > > Can we now remove this hunk? > >> current_thread_info()->syscall = scno; >> @@ -930,10 +934,12 @@ static int ptrace_syscall_trace(struct pt_regs *regs, int scno, >> ip = regs->ARM_ip; >> regs->ARM_ip = dir; >> >> - if (dir == PTRACE_SYSCALL_EXIT) >> - tracehook_report_syscall_exit(regs, 0); >> - else if (tracehook_report_syscall_entry(regs)) >> - current_thread_info()->syscall = -1; >> + if (test_thread_flag(TIF_SYSCALL_TRACE)) { >> + if (dir == PTRACE_SYSCALL_EXIT) >> + tracehook_report_syscall_exit(regs, 0); >> + else if (tracehook_report_syscall_entry(regs)) >> + current_thread_info()->syscall = -1; >> + } > > and also this one? > We need to set current_thread_info()->syscall, since it's used in the call to syscall_get_nr() in perf_syscall_{enter,exit}. What about moving the setting of ->syscall to syscall_trace_{enter,exit}? That would preserve ptrace_syscall_trace() for the TIF_SYSCALL_TRACE case only, but ensure that the field is set the TRACEPOINT case as well. Thoughts? Thanks for the feedback! Wade