Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 146176
b: refs/heads/master
c: 4f53596
h: refs/heads/master
v: v3
  • Loading branch information
Lai Jiangshan authored and Frederic Weisbecker committed May 25, 2009
1 parent 16d1fe1 commit 329f34b
Show file tree
Hide file tree
Showing 4 changed files with 29 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: 5537937696c55530447c20aa27daccb8d0d29b33
refs/heads/master: 4f5359685af6de7dca101393dc606620adbe963f
8 changes: 8 additions & 0 deletions trunk/kernel/trace/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1569,12 +1569,14 @@ static void *s_start(struct seq_file *m, loff_t *pos)
p = s_next(m, p, &l);
}

trace_event_read_lock();
return p;
}

static void s_stop(struct seq_file *m, void *p)
{
atomic_dec(&trace_record_cmdline_disabled);
trace_event_read_unlock();
}

static void print_lat_help_header(struct seq_file *m)
Expand Down Expand Up @@ -1817,6 +1819,7 @@ static int trace_empty(struct trace_iterator *iter)
return 1;
}

/* Called with trace_event_read_lock() held. */
static enum print_line_t print_trace_line(struct trace_iterator *iter)
{
enum print_line_t ret;
Expand Down Expand Up @@ -3008,6 +3011,7 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
offsetof(struct trace_iterator, seq));
iter->pos = -1;

trace_event_read_lock();
while (find_next_entry_inc(iter) != NULL) {
enum print_line_t ret;
int len = iter->seq.len;
Expand All @@ -3024,6 +3028,7 @@ tracing_read_pipe(struct file *filp, char __user *ubuf,
if (iter->seq.len >= cnt)
break;
}
trace_event_read_unlock();

/* Now copy what we have to the user */
sret = trace_seq_to_user(&iter->seq, ubuf, cnt);
Expand Down Expand Up @@ -3146,6 +3151,8 @@ static ssize_t tracing_splice_read_pipe(struct file *filp,
goto out_err;
}

trace_event_read_lock();

/* Fill as many pages as possible. */
for (i = 0, rem = len; i < PIPE_BUFFERS && rem; i++) {
pages[i] = alloc_page(GFP_KERNEL);
Expand All @@ -3168,6 +3175,7 @@ static ssize_t tracing_splice_read_pipe(struct file *filp,
trace_seq_init(&iter->seq);
}

trace_event_read_unlock();
mutex_unlock(&iter->mutex);

spd.nr_pages = i;
Expand Down
25 changes: 18 additions & 7 deletions trunk/kernel/trace/trace_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/* must be a power of 2 */
#define EVENT_HASHSIZE 128

static DEFINE_MUTEX(trace_event_mutex);
static DECLARE_RWSEM(trace_event_mutex);
static struct hlist_head event_hash[EVENT_HASHSIZE] __read_mostly;

static int next_event_type = __TRACE_LAST_TYPE + 1;
Expand Down Expand Up @@ -466,6 +466,7 @@ static int task_state_char(unsigned long state)
* @type: the type of event to look for
*
* Returns an event of type @type otherwise NULL
* Called with trace_event_read_lock() held.
*/
struct trace_event *ftrace_find_event(int type)
{
Expand All @@ -475,7 +476,7 @@ struct trace_event *ftrace_find_event(int type)

key = type & (EVENT_HASHSIZE - 1);

hlist_for_each_entry_rcu(event, n, &event_hash[key], node) {
hlist_for_each_entry(event, n, &event_hash[key], node) {
if (event->type == type)
return event;
}
Expand Down Expand Up @@ -513,6 +514,16 @@ static int trace_search_list(struct list_head **list)
return last + 1;
}

void trace_event_read_lock(void)
{
down_read(&trace_event_mutex);
}

void trace_event_read_unlock(void)
{
up_read(&trace_event_mutex);
}

/**
* register_ftrace_event - register output for an event type
* @event: the event type to register
Expand All @@ -533,7 +544,7 @@ int register_ftrace_event(struct trace_event *event)
unsigned key;
int ret = 0;

mutex_lock(&trace_event_mutex);
down_write(&trace_event_mutex);

if (WARN_ON(!event))
goto out;
Expand Down Expand Up @@ -581,11 +592,11 @@ int register_ftrace_event(struct trace_event *event)

key = event->type & (EVENT_HASHSIZE - 1);

hlist_add_head_rcu(&event->node, &event_hash[key]);
hlist_add_head(&event->node, &event_hash[key]);

ret = event->type;
out:
mutex_unlock(&trace_event_mutex);
up_write(&trace_event_mutex);

return ret;
}
Expand All @@ -597,10 +608,10 @@ EXPORT_SYMBOL_GPL(register_ftrace_event);
*/
int unregister_ftrace_event(struct trace_event *event)
{
mutex_lock(&trace_event_mutex);
down_write(&trace_event_mutex);
hlist_del(&event->node);
list_del(&event->list);
mutex_unlock(&trace_event_mutex);
up_write(&trace_event_mutex);

return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions trunk/kernel/trace/trace_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ extern int seq_print_user_ip(struct trace_seq *s, struct mm_struct *mm,
extern int trace_print_context(struct trace_iterator *iter);
extern int trace_print_lat_context(struct trace_iterator *iter);

extern void trace_event_read_lock(void);
extern void trace_event_read_unlock(void);
extern struct trace_event *ftrace_find_event(int type);

extern enum print_line_t trace_nop_print(struct trace_iterator *iter,
Expand Down

0 comments on commit 329f34b

Please sign in to comment.