Skip to content

Commit

Permalink
tracing: Fix preempt count leak
Browse files Browse the repository at this point in the history
While running my ftrace stress test, this showed up:

BUG: sleeping function called from invalid context at mm/mmap.c:233
...
note: cat[3293] exited with preempt_count 1

The bug was introduced by commit 91e86e5
("tracing: Fix recursive user stack trace")

Cc: <stable@kernel.org>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4D0089AC.1020802@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
  • Loading branch information
Li Zefan authored and Steven Rostedt committed Jan 8, 2011
1 parent bd1c8b2 commit 1dbd195
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1313,12 +1313,10 @@ ftrace_trace_userstack(struct ring_buffer *buffer, unsigned long flags, int pc)

__this_cpu_inc(user_stack_count);



event = trace_buffer_lock_reserve(buffer, TRACE_USER_STACK,
sizeof(*entry), flags, pc);
if (!event)
return;
goto out_drop_count;
entry = ring_buffer_event_data(event);

entry->tgid = current->tgid;
Expand All @@ -1333,8 +1331,8 @@ ftrace_trace_userstack(struct ring_buffer *buffer, unsigned long flags, int pc)
if (!filter_check_discard(call, entry, buffer, event))
ring_buffer_unlock_commit(buffer, event);

out_drop_count:
__this_cpu_dec(user_stack_count);

out:
preempt_enable();
}
Expand Down

0 comments on commit 1dbd195

Please sign in to comment.