Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 140963
b: refs/heads/master
c: 5be71b6
h: refs/heads/master
i:
  140961: eb9b5b6
  140959: 64f9771
v: v3
  • Loading branch information
Frederic Weisbecker authored and Ingo Molnar committed Mar 16, 2009
1 parent bd49a5b commit 07be841
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6404434525bb9f8f2239998f30fd7c93f2efa5b3
refs/heads/master: 5be71b61f17b0e3bc8ad0b1a1b7b53ab7d574ebb
24 changes: 19 additions & 5 deletions trunk/kernel/trace/trace_syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
#include "trace_output.h"
#include "trace.h"

static atomic_t refcount;
/* Keep a counter of the syscall tracing users */
static int refcount;

/* Prevent from races on thread flags toggling */
static DEFINE_MUTEX(syscall_trace_lock);

/* Option to display the parameters types */
enum {
Expand Down Expand Up @@ -96,9 +100,11 @@ void start_ftrace_syscalls(void)
unsigned long flags;
struct task_struct *g, *t;

mutex_lock(&syscall_trace_lock);

/* Don't enable the flag on the tasks twice */
if (atomic_inc_return(&refcount) != 1)
return;
if (++refcount != 1)
goto unlock;

arch_init_ftrace_syscalls();
read_lock_irqsave(&tasklist_lock, flags);
Expand All @@ -108,16 +114,21 @@ void start_ftrace_syscalls(void)
} while_each_thread(g, t);

read_unlock_irqrestore(&tasklist_lock, flags);

unlock:
mutex_unlock(&syscall_trace_lock);
}

void stop_ftrace_syscalls(void)
{
unsigned long flags;
struct task_struct *g, *t;

mutex_lock(&syscall_trace_lock);

/* There are perhaps still some users */
if (atomic_dec_return(&refcount))
return;
if (--refcount)
goto unlock;

read_lock_irqsave(&tasklist_lock, flags);

Expand All @@ -126,6 +137,9 @@ void stop_ftrace_syscalls(void)
} while_each_thread(g, t);

read_unlock_irqrestore(&tasklist_lock, flags);

unlock:
mutex_unlock(&syscall_trace_lock);
}

void ftrace_syscall_enter(struct pt_regs *regs)
Expand Down

0 comments on commit 07be841

Please sign in to comment.