aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2016-04-14 07:38:13 -0400
committerSteven Rostedt <rostedt@goodmis.org>2016-06-20 09:54:16 -0400
commit4e267db135c44d0b18e553899fe7df32b89211a5 (patch)
treeb1bad551792fd5f2ddce929802db8be0a90324f6
parent0ded5174e976e2b2a354fe38abf1ebf4492c6dc3 (diff)
tracing: Make the pid filtering helper functions global
Make the functions used for pid filtering global for tracing, such that the function tracer can use the pid code as well. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--kernel/trace/trace.h9
-rw-r--r--kernel/trace/trace_events.c34
2 files changed, 26 insertions, 17 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 5167c366d6b7..172330891c6d 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -628,6 +628,15 @@ extern unsigned long nsecs_to_usecs(unsigned long nsecs);
628 628
629extern unsigned long tracing_thresh; 629extern unsigned long tracing_thresh;
630 630
631/* PID filtering */
632bool trace_find_filtered_pid(struct trace_pid_list *filtered_pids,
633 pid_t search_pid);
634bool trace_ignore_this_task(struct trace_pid_list *filtered_pids,
635 struct task_struct *task);
636void trace_filter_add_remove_task(struct trace_pid_list *pid_list,
637 struct task_struct *self,
638 struct task_struct *task);
639
631#ifdef CONFIG_TRACER_MAX_TRACE 640#ifdef CONFIG_TRACER_MAX_TRACE
632void update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu); 641void update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu);
633void update_max_tr_single(struct trace_array *tr, 642void update_max_tr_single(struct trace_array *tr,
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 3d4155892a1e..b5e514c4dada 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -503,8 +503,8 @@ static void ftrace_clear_events(struct trace_array *tr)
503extern int pid_max; 503extern int pid_max;
504 504
505/* Returns true if found in filter */ 505/* Returns true if found in filter */
506static bool 506bool
507find_filtered_pid(struct trace_pid_list *filtered_pids, pid_t search_pid) 507trace_find_filtered_pid(struct trace_pid_list *filtered_pids, pid_t search_pid)
508{ 508{
509 /* 509 /*
510 * If pid_max changed after filtered_pids was created, we 510 * If pid_max changed after filtered_pids was created, we
@@ -516,8 +516,8 @@ find_filtered_pid(struct trace_pid_list *filtered_pids, pid_t search_pid)
516 return test_bit(search_pid, filtered_pids->pids); 516 return test_bit(search_pid, filtered_pids->pids);
517} 517}
518 518
519static bool 519bool
520ignore_this_task(struct trace_pid_list *filtered_pids, struct task_struct *task) 520trace_ignore_this_task(struct trace_pid_list *filtered_pids, struct task_struct *task)
521{ 521{
522 /* 522 /*
523 * Return false, because if filtered_pids does not exist, 523 * Return false, because if filtered_pids does not exist,
@@ -526,19 +526,19 @@ ignore_this_task(struct trace_pid_list *filtered_pids, struct task_struct *task)
526 if (!filtered_pids) 526 if (!filtered_pids)
527 return false; 527 return false;
528 528
529 return !find_filtered_pid(filtered_pids, task->pid); 529 return !trace_find_filtered_pid(filtered_pids, task->pid);
530} 530}
531 531
532static void filter_add_remove_task(struct trace_pid_list *pid_list, 532void trace_filter_add_remove_task(struct trace_pid_list *pid_list,
533 struct task_struct *self, 533 struct task_struct *self,
534 struct task_struct *task) 534 struct task_struct *task)
535{ 535{
536 if (!pid_list) 536 if (!pid_list)
537 return; 537 return;
538 538
539 /* For forks, we only add if the forking task is listed */ 539 /* For forks, we only add if the forking task is listed */
540 if (self) { 540 if (self) {
541 if (!find_filtered_pid(pid_list, self->pid)) 541 if (!trace_find_filtered_pid(pid_list, self->pid))
542 return; 542 return;
543 } 543 }
544 544
@@ -560,7 +560,7 @@ event_filter_pid_sched_process_exit(void *data, struct task_struct *task)
560 struct trace_array *tr = data; 560 struct trace_array *tr = data;
561 561
562 pid_list = rcu_dereference_sched(tr->filtered_pids); 562 pid_list = rcu_dereference_sched(tr->filtered_pids);
563 filter_add_remove_task(pid_list, NULL, task); 563 trace_filter_add_remove_task(pid_list, NULL, task);
564} 564}
565 565
566static void 566static void
@@ -572,7 +572,7 @@ event_filter_pid_sched_process_fork(void *data,
572 struct trace_array *tr = data; 572 struct trace_array *tr = data;
573 573
574 pid_list = rcu_dereference_sched(tr->filtered_pids); 574 pid_list = rcu_dereference_sched(tr->filtered_pids);
575 filter_add_remove_task(pid_list, self, task); 575 trace_filter_add_remove_task(pid_list, self, task);
576} 576}
577 577
578void trace_event_follow_fork(struct trace_array *tr, bool enable) 578void trace_event_follow_fork(struct trace_array *tr, bool enable)
@@ -600,8 +600,8 @@ event_filter_pid_sched_switch_probe_pre(void *data, bool preempt,
600 pid_list = rcu_dereference_sched(tr->filtered_pids); 600 pid_list = rcu_dereference_sched(tr->filtered_pids);
601 601
602 this_cpu_write(tr->trace_buffer.data->ignore_pid, 602 this_cpu_write(tr->trace_buffer.data->ignore_pid,
603 ignore_this_task(pid_list, prev) && 603 trace_ignore_this_task(pid_list, prev) &&
604 ignore_this_task(pid_list, next)); 604 trace_ignore_this_task(pid_list, next));
605} 605}
606 606
607static void 607static void
@@ -614,7 +614,7 @@ event_filter_pid_sched_switch_probe_post(void *data, bool preempt,
614 pid_list = rcu_dereference_sched(tr->filtered_pids); 614 pid_list = rcu_dereference_sched(tr->filtered_pids);
615 615
616 this_cpu_write(tr->trace_buffer.data->ignore_pid, 616 this_cpu_write(tr->trace_buffer.data->ignore_pid,
617 ignore_this_task(pid_list, next)); 617 trace_ignore_this_task(pid_list, next));
618} 618}
619 619
620static void 620static void
@@ -630,7 +630,7 @@ event_filter_pid_sched_wakeup_probe_pre(void *data, struct task_struct *task)
630 pid_list = rcu_dereference_sched(tr->filtered_pids); 630 pid_list = rcu_dereference_sched(tr->filtered_pids);
631 631
632 this_cpu_write(tr->trace_buffer.data->ignore_pid, 632 this_cpu_write(tr->trace_buffer.data->ignore_pid,
633 ignore_this_task(pid_list, task)); 633 trace_ignore_this_task(pid_list, task));
634} 634}
635 635
636static void 636static void
@@ -647,7 +647,7 @@ event_filter_pid_sched_wakeup_probe_post(void *data, struct task_struct *task)
647 647
648 /* Set tracing if current is enabled */ 648 /* Set tracing if current is enabled */
649 this_cpu_write(tr->trace_buffer.data->ignore_pid, 649 this_cpu_write(tr->trace_buffer.data->ignore_pid,
650 ignore_this_task(pid_list, current)); 650 trace_ignore_this_task(pid_list, current));
651} 651}
652 652
653static void __ftrace_clear_event_pids(struct trace_array *tr) 653static void __ftrace_clear_event_pids(struct trace_array *tr)
@@ -1654,7 +1654,7 @@ static void ignore_task_cpu(void *data)
1654 mutex_is_locked(&event_mutex)); 1654 mutex_is_locked(&event_mutex));
1655 1655
1656 this_cpu_write(tr->trace_buffer.data->ignore_pid, 1656 this_cpu_write(tr->trace_buffer.data->ignore_pid,
1657 ignore_this_task(pid_list, current)); 1657 trace_ignore_this_task(pid_list, current));
1658} 1658}
1659 1659
1660static ssize_t 1660static ssize_t