diff options
| author | Oleg Nesterov <oleg@redhat.com> | 2014-07-15 14:48:29 -0400 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2014-07-16 14:33:35 -0400 |
| commit | bb9ef1cb7d8668d6b0038b6f9f783c849135e40d (patch) | |
| tree | 73e5fb0db1f01ad6e4031bebc78387c885f1d571 /kernel/trace | |
| parent | e738d3ebbf70ebadb83f3a4060dc34f422c2fbe7 (diff) | |
tracing: Change apply_subsystem_event_filter() paths to check file->system == dir
filter_free_subsystem_preds(), filter_free_subsystem_filters() and
replace_system_preds() can simply check file->system->subsystem and
avoid strcmp(call->class->system).
Better yet, we can pass "struct ftrace_subsystem_dir *dir" instead of
event_subsystem and just check file->system == dir.
Thanks to Namhyung Kim who pointed out that replace_system_preds() can
be changed too.
Link: http://lkml.kernel.org/p/20140715184829.GA20516@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
| -rw-r--r-- | kernel/trace/trace_events_filter.c | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index 54a125c8467a..c2ef5a5f21da 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c | |||
| @@ -842,17 +842,14 @@ static inline void __remove_filter(struct ftrace_event_file *file) | |||
| 842 | remove_filter_string(file->filter); | 842 | remove_filter_string(file->filter); |
| 843 | } | 843 | } |
| 844 | 844 | ||
| 845 | static void filter_free_subsystem_preds(struct event_subsystem *system, | 845 | static void filter_free_subsystem_preds(struct ftrace_subsystem_dir *dir, |
| 846 | struct trace_array *tr) | 846 | struct trace_array *tr) |
| 847 | { | 847 | { |
| 848 | struct ftrace_event_file *file; | 848 | struct ftrace_event_file *file; |
| 849 | struct ftrace_event_call *call; | ||
| 850 | 849 | ||
| 851 | list_for_each_entry(file, &tr->events, list) { | 850 | list_for_each_entry(file, &tr->events, list) { |
| 852 | call = file->event_call; | 851 | if (file->system != dir) |
| 853 | if (strcmp(call->class->system, system->name) != 0) | ||
| 854 | continue; | 852 | continue; |
| 855 | |||
| 856 | __remove_filter(file); | 853 | __remove_filter(file); |
| 857 | } | 854 | } |
| 858 | } | 855 | } |
| @@ -870,15 +867,13 @@ static inline void __free_subsystem_filter(struct ftrace_event_file *file) | |||
| 870 | } | 867 | } |
| 871 | } | 868 | } |
| 872 | 869 | ||
| 873 | static void filter_free_subsystem_filters(struct event_subsystem *system, | 870 | static void filter_free_subsystem_filters(struct ftrace_subsystem_dir *dir, |
| 874 | struct trace_array *tr) | 871 | struct trace_array *tr) |
| 875 | { | 872 | { |
| 876 | struct ftrace_event_file *file; | 873 | struct ftrace_event_file *file; |
| 877 | struct ftrace_event_call *call; | ||
| 878 | 874 | ||
| 879 | list_for_each_entry(file, &tr->events, list) { | 875 | list_for_each_entry(file, &tr->events, list) { |
| 880 | call = file->event_call; | 876 | if (file->system != dir) |
| 881 | if (strcmp(call->class->system, system->name) != 0) | ||
| 882 | continue; | 877 | continue; |
| 883 | __free_subsystem_filter(file); | 878 | __free_subsystem_filter(file); |
| 884 | } | 879 | } |
| @@ -1724,13 +1719,12 @@ struct filter_list { | |||
| 1724 | struct event_filter *filter; | 1719 | struct event_filter *filter; |
| 1725 | }; | 1720 | }; |
| 1726 | 1721 | ||
| 1727 | static int replace_system_preds(struct event_subsystem *system, | 1722 | static int replace_system_preds(struct ftrace_subsystem_dir *dir, |
| 1728 | struct trace_array *tr, | 1723 | struct trace_array *tr, |
| 1729 | struct filter_parse_state *ps, | 1724 | struct filter_parse_state *ps, |
| 1730 | char *filter_string) | 1725 | char *filter_string) |
| 1731 | { | 1726 | { |
| 1732 | struct ftrace_event_file *file; | 1727 | struct ftrace_event_file *file; |
| 1733 | struct ftrace_event_call *call; | ||
| 1734 | struct filter_list *filter_item; | 1728 | struct filter_list *filter_item; |
| 1735 | struct filter_list *tmp; | 1729 | struct filter_list *tmp; |
| 1736 | LIST_HEAD(filter_list); | 1730 | LIST_HEAD(filter_list); |
| @@ -1738,15 +1732,15 @@ static int replace_system_preds(struct event_subsystem *system, | |||
| 1738 | int err; | 1732 | int err; |
| 1739 | 1733 | ||
| 1740 | list_for_each_entry(file, &tr->events, list) { | 1734 | list_for_each_entry(file, &tr->events, list) { |
| 1741 | call = file->event_call; | 1735 | if (file->system != dir) |
| 1742 | if (strcmp(call->class->system, system->name) != 0) | ||
| 1743 | continue; | 1736 | continue; |
| 1744 | 1737 | ||
| 1745 | /* | 1738 | /* |
| 1746 | * Try to see if the filter can be applied | 1739 | * Try to see if the filter can be applied |
| 1747 | * (filter arg is ignored on dry_run) | 1740 | * (filter arg is ignored on dry_run) |
| 1748 | */ | 1741 | */ |
| 1749 | err = replace_preds(call, NULL, ps, filter_string, true); | 1742 | err = replace_preds(file->event_call, NULL, ps, |
| 1743 | filter_string, true); | ||
| 1750 | if (err) | 1744 | if (err) |
| 1751 | event_set_no_set_filter_flag(file); | 1745 | event_set_no_set_filter_flag(file); |
| 1752 | else | 1746 | else |
| @@ -1756,9 +1750,7 @@ static int replace_system_preds(struct event_subsystem *system, | |||
| 1756 | list_for_each_entry(file, &tr->events, list) { | 1750 | list_for_each_entry(file, &tr->events, list) { |
| 1757 | struct event_filter *filter; | 1751 | struct event_filter *filter; |
| 1758 | 1752 | ||
| 1759 | call = file->event_call; | 1753 | if (file->system != dir) |
| 1760 | |||
| 1761 | if (strcmp(call->class->system, system->name) != 0) | ||
| 1762 | continue; | 1754 | continue; |
| 1763 | 1755 | ||
| 1764 | if (event_no_set_filter_flag(file)) | 1756 | if (event_no_set_filter_flag(file)) |
| @@ -1780,7 +1772,8 @@ static int replace_system_preds(struct event_subsystem *system, | |||
| 1780 | if (err) | 1772 | if (err) |
| 1781 | goto fail_mem; | 1773 | goto fail_mem; |
| 1782 | 1774 | ||
| 1783 | err = replace_preds(call, filter, ps, filter_string, false); | 1775 | err = replace_preds(file->event_call, filter, ps, |
| 1776 | filter_string, false); | ||
| 1784 | if (err) { | 1777 | if (err) { |
| 1785 | filter_disable(file); | 1778 | filter_disable(file); |
| 1786 | parse_error(ps, FILT_ERR_BAD_SUBSYS_FILTER, 0); | 1779 | parse_error(ps, FILT_ERR_BAD_SUBSYS_FILTER, 0); |
| @@ -1928,7 +1921,7 @@ int create_event_filter(struct ftrace_event_call *call, | |||
| 1928 | * Identical to create_filter() except that it creates a subsystem filter | 1921 | * Identical to create_filter() except that it creates a subsystem filter |
| 1929 | * and always remembers @filter_str. | 1922 | * and always remembers @filter_str. |
| 1930 | */ | 1923 | */ |
| 1931 | static int create_system_filter(struct event_subsystem *system, | 1924 | static int create_system_filter(struct ftrace_subsystem_dir *dir, |
| 1932 | struct trace_array *tr, | 1925 | struct trace_array *tr, |
| 1933 | char *filter_str, struct event_filter **filterp) | 1926 | char *filter_str, struct event_filter **filterp) |
| 1934 | { | 1927 | { |
| @@ -1938,7 +1931,7 @@ static int create_system_filter(struct event_subsystem *system, | |||
| 1938 | 1931 | ||
| 1939 | err = create_filter_start(filter_str, true, &ps, &filter); | 1932 | err = create_filter_start(filter_str, true, &ps, &filter); |
| 1940 | if (!err) { | 1933 | if (!err) { |
| 1941 | err = replace_system_preds(system, tr, ps, filter_str); | 1934 | err = replace_system_preds(dir, tr, ps, filter_str); |
| 1942 | if (!err) { | 1935 | if (!err) { |
| 1943 | /* System filters just show a default message */ | 1936 | /* System filters just show a default message */ |
| 1944 | kfree(filter->filter_string); | 1937 | kfree(filter->filter_string); |
| @@ -2022,18 +2015,18 @@ int apply_subsystem_event_filter(struct ftrace_subsystem_dir *dir, | |||
| 2022 | } | 2015 | } |
| 2023 | 2016 | ||
| 2024 | if (!strcmp(strstrip(filter_string), "0")) { | 2017 | if (!strcmp(strstrip(filter_string), "0")) { |
| 2025 | filter_free_subsystem_preds(system, tr); | 2018 | filter_free_subsystem_preds(dir, tr); |
| 2026 | remove_filter_string(system->filter); | 2019 | remove_filter_string(system->filter); |
| 2027 | filter = system->filter; | 2020 | filter = system->filter; |
| 2028 | system->filter = NULL; | 2021 | system->filter = NULL; |
| 2029 | /* Ensure all filters are no longer used */ | 2022 | /* Ensure all filters are no longer used */ |
| 2030 | synchronize_sched(); | 2023 | synchronize_sched(); |
| 2031 | filter_free_subsystem_filters(system, tr); | 2024 | filter_free_subsystem_filters(dir, tr); |
| 2032 | __free_filter(filter); | 2025 | __free_filter(filter); |
| 2033 | goto out_unlock; | 2026 | goto out_unlock; |
| 2034 | } | 2027 | } |
| 2035 | 2028 | ||
| 2036 | err = create_system_filter(system, tr, filter_string, &filter); | 2029 | err = create_system_filter(dir, tr, filter_string, &filter); |
| 2037 | if (filter) { | 2030 | if (filter) { |
| 2038 | /* | 2031 | /* |
| 2039 | * No event actually uses the system filter | 2032 | * No event actually uses the system filter |
