Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 252660
b: refs/heads/master
c: b1cff0a
h: refs/heads/master
v: v3
  • Loading branch information
Steven Rostedt committed May 26, 2011
1 parent 079f15a commit 455dc14
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 8 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: 7f34b746f79c1e1f8fd6d09799d133263ae7a504
refs/heads/master: b1cff0ad1062621ae63cb6c5dc4165191fe2e9f1
2 changes: 1 addition & 1 deletion trunk/include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,7 @@ struct task_struct {
#ifdef CONFIG_TRACING
/* state flags for use by tracers */
unsigned long trace;
/* bitmask of trace recursion */
/* bitmask and counter of trace recursion */
unsigned long trace_recursion;
#endif /* CONFIG_TRACING */
#ifdef CONFIG_CGROUP_MEM_RES_CTLR /* memcg uses this to do batch job */
Expand Down
13 changes: 12 additions & 1 deletion trunk/kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,18 @@ ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip);
static void ftrace_global_list_func(unsigned long ip,
unsigned long parent_ip)
{
struct ftrace_ops *op = rcu_dereference_raw(ftrace_global_list); /*see above*/
struct ftrace_ops *op;

if (unlikely(trace_recursion_test(TRACE_GLOBAL_BIT)))
return;

trace_recursion_set(TRACE_GLOBAL_BIT);
op = rcu_dereference_raw(ftrace_global_list); /*see above*/
while (op != &ftrace_list_end) {
op->func(ip, parent_ip);
op = rcu_dereference_raw(op->next); /*see above*/
};
trace_recursion_clear(TRACE_GLOBAL_BIT);
}

static void ftrace_pid_func(unsigned long ip, unsigned long parent_ip)
Expand Down Expand Up @@ -3490,6 +3496,10 @@ ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip)
{
struct ftrace_ops *op;

if (unlikely(trace_recursion_test(TRACE_INTERNAL_BIT)))
return;

trace_recursion_set(TRACE_INTERNAL_BIT);
/*
* Some of the ops may be dynamically allocated,
* they must be freed after a synchronize_sched().
Expand All @@ -3502,6 +3512,7 @@ ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip)
op = rcu_dereference_raw(op->next);
};
preempt_enable_notrace();
trace_recursion_clear(TRACE_INTERNAL_BIT);
}

static void clear_ftrace_swapper(void)
Expand Down
10 changes: 5 additions & 5 deletions trunk/kernel/trace/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2216,7 +2216,7 @@ static noinline void trace_recursive_fail(void)

printk_once(KERN_WARNING "Tracing recursion: depth[%ld]:"
"HC[%lu]:SC[%lu]:NMI[%lu]\n",
current->trace_recursion,
trace_recursion_buffer(),
hardirq_count() >> HARDIRQ_SHIFT,
softirq_count() >> SOFTIRQ_SHIFT,
in_nmi());
Expand All @@ -2226,9 +2226,9 @@ static noinline void trace_recursive_fail(void)

static inline int trace_recursive_lock(void)
{
current->trace_recursion++;
trace_recursion_inc();

if (likely(current->trace_recursion < TRACE_RECURSIVE_DEPTH))
if (likely(trace_recursion_buffer() < TRACE_RECURSIVE_DEPTH))
return 0;

trace_recursive_fail();
Expand All @@ -2238,9 +2238,9 @@ static inline int trace_recursive_lock(void)

static inline void trace_recursive_unlock(void)
{
WARN_ON_ONCE(!current->trace_recursion);
WARN_ON_ONCE(!trace_recursion_buffer());

current->trace_recursion--;
trace_recursion_dec();
}

#else
Expand Down
15 changes: 15 additions & 0 deletions trunk/kernel/trace/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -784,4 +784,19 @@ extern const char *__stop___trace_bprintk_fmt[];
FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print))
#include "trace_entries.h"

/* Only current can touch trace_recursion */
#define trace_recursion_inc() do { (current)->trace_recursion++; } while (0)
#define trace_recursion_dec() do { (current)->trace_recursion--; } while (0)

/* Ring buffer has the 10 LSB bits to count */
#define trace_recursion_buffer() ((current)->trace_recursion & 0x3ff)

/* for function tracing recursion */
#define TRACE_INTERNAL_BIT (1<<11)
#define TRACE_GLOBAL_BIT (1<<12)

#define trace_recursion_set(bit) do { (current)->trace_recursion |= (bit); } while (0)
#define trace_recursion_clear(bit) do { (current)->trace_recursion &= ~(bit); } while (0)
#define trace_recursion_test(bit) ((current)->trace_recursion & (bit))

#endif /* _LINUX_KERNEL_TRACE_H */

0 comments on commit 455dc14

Please sign in to comment.