aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace_output.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace/trace_output.c')
-rw-r--r--kernel/trace/trace_output.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
index 489c0e8ada09..7136420603aa 100644
--- a/kernel/trace/trace_output.c
+++ b/kernel/trace/trace_output.c
@@ -14,7 +14,7 @@
14/* must be a power of 2 */ 14/* must be a power of 2 */
15#define EVENT_HASHSIZE 128 15#define EVENT_HASHSIZE 128
16 16
17static DEFINE_MUTEX(trace_event_mutex); 17static DECLARE_RWSEM(trace_event_mutex);
18static struct hlist_head event_hash[EVENT_HASHSIZE] __read_mostly; 18static struct hlist_head event_hash[EVENT_HASHSIZE] __read_mostly;
19 19
20static int next_event_type = __TRACE_LAST_TYPE + 1; 20static int next_event_type = __TRACE_LAST_TYPE + 1;
@@ -466,6 +466,7 @@ static int task_state_char(unsigned long state)
466 * @type: the type of event to look for 466 * @type: the type of event to look for
467 * 467 *
468 * Returns an event of type @type otherwise NULL 468 * Returns an event of type @type otherwise NULL
469 * Called with trace_event_read_lock() held.
469 */ 470 */
470struct trace_event *ftrace_find_event(int type) 471struct trace_event *ftrace_find_event(int type)
471{ 472{
@@ -475,7 +476,7 @@ struct trace_event *ftrace_find_event(int type)
475 476
476 key = type & (EVENT_HASHSIZE - 1); 477 key = type & (EVENT_HASHSIZE - 1);
477 478
478 hlist_for_each_entry_rcu(event, n, &event_hash[key], node) { 479 hlist_for_each_entry(event, n, &event_hash[key], node) {
479 if (event->type == type) 480 if (event->type == type)
480 return event; 481 return event;
481 } 482 }
@@ -513,6 +514,16 @@ static int trace_search_list(struct list_head **list)
513 return last + 1; 514 return last + 1;
514} 515}
515 516
517void trace_event_read_lock(void)
518{
519 down_read(&trace_event_mutex);
520}
521
522void trace_event_read_unlock(void)
523{
524 up_read(&trace_event_mutex);
525}
526
516/** 527/**
517 * register_ftrace_event - register output for an event type 528 * register_ftrace_event - register output for an event type
518 * @event: the event type to register 529 * @event: the event type to register
@@ -533,7 +544,7 @@ int register_ftrace_event(struct trace_event *event)
533 unsigned key; 544 unsigned key;
534 int ret = 0; 545 int ret = 0;
535 546
536 mutex_lock(&trace_event_mutex); 547 down_write(&trace_event_mutex);
537 548
538 if (WARN_ON(!event)) 549 if (WARN_ON(!event))
539 goto out; 550 goto out;
@@ -581,11 +592,11 @@ int register_ftrace_event(struct trace_event *event)
581 592
582 key = event->type & (EVENT_HASHSIZE - 1); 593 key = event->type & (EVENT_HASHSIZE - 1);
583 594
584 hlist_add_head_rcu(&event->node, &event_hash[key]); 595 hlist_add_head(&event->node, &event_hash[key]);
585 596
586 ret = event->type; 597 ret = event->type;
587 out: 598 out:
588 mutex_unlock(&trace_event_mutex); 599 up_write(&trace_event_mutex);
589 600
590 return ret; 601 return ret;
591} 602}
@@ -597,10 +608,10 @@ EXPORT_SYMBOL_GPL(register_ftrace_event);
597 */ 608 */
598int unregister_ftrace_event(struct trace_event *event) 609int unregister_ftrace_event(struct trace_event *event)
599{ 610{
600 mutex_lock(&trace_event_mutex); 611 down_write(&trace_event_mutex);
601 hlist_del(&event->node); 612 hlist_del(&event->node);
602 list_del(&event->list); 613 list_del(&event->list);
603 mutex_unlock(&trace_event_mutex); 614 up_write(&trace_event_mutex);
604 615
605 return 0; 616 return 0;
606} 617}