diff options
Diffstat (limited to 'kernel/trace/ftrace.c')
| -rw-r--r-- | kernel/trace/ftrace.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index e51a1bcb7bed..7968762c8167 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
| @@ -1724,7 +1724,7 @@ ftrace_match_record(struct dyn_ftrace *rec, char *regex, int len, int type) | |||
| 1724 | return ftrace_match(str, regex, len, type); | 1724 | return ftrace_match(str, regex, len, type); |
| 1725 | } | 1725 | } |
| 1726 | 1726 | ||
| 1727 | static void ftrace_match_records(char *buff, int len, int enable) | 1727 | static int ftrace_match_records(char *buff, int len, int enable) |
| 1728 | { | 1728 | { |
| 1729 | unsigned int search_len; | 1729 | unsigned int search_len; |
| 1730 | struct ftrace_page *pg; | 1730 | struct ftrace_page *pg; |
| @@ -1733,6 +1733,7 @@ static void ftrace_match_records(char *buff, int len, int enable) | |||
| 1733 | char *search; | 1733 | char *search; |
| 1734 | int type; | 1734 | int type; |
| 1735 | int not; | 1735 | int not; |
| 1736 | int found = 0; | ||
| 1736 | 1737 | ||
| 1737 | flag = enable ? FTRACE_FL_FILTER : FTRACE_FL_NOTRACE; | 1738 | flag = enable ? FTRACE_FL_FILTER : FTRACE_FL_NOTRACE; |
| 1738 | type = filter_parse_regex(buff, len, &search, ¬); | 1739 | type = filter_parse_regex(buff, len, &search, ¬); |
| @@ -1750,6 +1751,7 @@ static void ftrace_match_records(char *buff, int len, int enable) | |||
| 1750 | rec->flags &= ~flag; | 1751 | rec->flags &= ~flag; |
| 1751 | else | 1752 | else |
| 1752 | rec->flags |= flag; | 1753 | rec->flags |= flag; |
| 1754 | found = 1; | ||
| 1753 | } | 1755 | } |
| 1754 | /* | 1756 | /* |
| 1755 | * Only enable filtering if we have a function that | 1757 | * Only enable filtering if we have a function that |
| @@ -1759,6 +1761,8 @@ static void ftrace_match_records(char *buff, int len, int enable) | |||
| 1759 | ftrace_filtered = 1; | 1761 | ftrace_filtered = 1; |
| 1760 | } while_for_each_ftrace_rec(); | 1762 | } while_for_each_ftrace_rec(); |
| 1761 | mutex_unlock(&ftrace_lock); | 1763 | mutex_unlock(&ftrace_lock); |
| 1764 | |||
| 1765 | return found; | ||
| 1762 | } | 1766 | } |
| 1763 | 1767 | ||
| 1764 | static int | 1768 | static int |
| @@ -1780,7 +1784,7 @@ ftrace_match_module_record(struct dyn_ftrace *rec, char *mod, | |||
| 1780 | return 1; | 1784 | return 1; |
| 1781 | } | 1785 | } |
| 1782 | 1786 | ||
| 1783 | static void ftrace_match_module_records(char *buff, char *mod, int enable) | 1787 | static int ftrace_match_module_records(char *buff, char *mod, int enable) |
| 1784 | { | 1788 | { |
| 1785 | unsigned search_len = 0; | 1789 | unsigned search_len = 0; |
| 1786 | struct ftrace_page *pg; | 1790 | struct ftrace_page *pg; |
| @@ -1789,6 +1793,7 @@ static void ftrace_match_module_records(char *buff, char *mod, int enable) | |||
| 1789 | char *search = buff; | 1793 | char *search = buff; |
| 1790 | unsigned long flag; | 1794 | unsigned long flag; |
| 1791 | int not = 0; | 1795 | int not = 0; |
| 1796 | int found = 0; | ||
| 1792 | 1797 | ||
| 1793 | flag = enable ? FTRACE_FL_FILTER : FTRACE_FL_NOTRACE; | 1798 | flag = enable ? FTRACE_FL_FILTER : FTRACE_FL_NOTRACE; |
| 1794 | 1799 | ||
| @@ -1819,12 +1824,15 @@ static void ftrace_match_module_records(char *buff, char *mod, int enable) | |||
| 1819 | rec->flags &= ~flag; | 1824 | rec->flags &= ~flag; |
| 1820 | else | 1825 | else |
| 1821 | rec->flags |= flag; | 1826 | rec->flags |= flag; |
| 1827 | found = 1; | ||
| 1822 | } | 1828 | } |
| 1823 | if (enable && (rec->flags & FTRACE_FL_FILTER)) | 1829 | if (enable && (rec->flags & FTRACE_FL_FILTER)) |
| 1824 | ftrace_filtered = 1; | 1830 | ftrace_filtered = 1; |
| 1825 | 1831 | ||
| 1826 | } while_for_each_ftrace_rec(); | 1832 | } while_for_each_ftrace_rec(); |
| 1827 | mutex_unlock(&ftrace_lock); | 1833 | mutex_unlock(&ftrace_lock); |
| 1834 | |||
| 1835 | return found; | ||
| 1828 | } | 1836 | } |
| 1829 | 1837 | ||
| 1830 | /* | 1838 | /* |
| @@ -1853,8 +1861,9 @@ ftrace_mod_callback(char *func, char *cmd, char *param, int enable) | |||
| 1853 | if (!strlen(mod)) | 1861 | if (!strlen(mod)) |
| 1854 | return -EINVAL; | 1862 | return -EINVAL; |
| 1855 | 1863 | ||
| 1856 | ftrace_match_module_records(func, mod, enable); | 1864 | if (ftrace_match_module_records(func, mod, enable)) |
| 1857 | return 0; | 1865 | return 0; |
| 1866 | return -EINVAL; | ||
| 1858 | } | 1867 | } |
| 1859 | 1868 | ||
| 1860 | static struct ftrace_func_command ftrace_mod_cmd = { | 1869 | static struct ftrace_func_command ftrace_mod_cmd = { |
| @@ -2151,8 +2160,9 @@ static int ftrace_process_regex(char *buff, int len, int enable) | |||
| 2151 | func = strsep(&next, ":"); | 2160 | func = strsep(&next, ":"); |
| 2152 | 2161 | ||
| 2153 | if (!next) { | 2162 | if (!next) { |
| 2154 | ftrace_match_records(func, len, enable); | 2163 | if (ftrace_match_records(func, len, enable)) |
| 2155 | return 0; | 2164 | return 0; |
| 2165 | return ret; | ||
| 2156 | } | 2166 | } |
| 2157 | 2167 | ||
| 2158 | /* command found */ | 2168 | /* command found */ |
| @@ -2198,10 +2208,9 @@ ftrace_regex_write(struct file *file, const char __user *ubuf, | |||
| 2198 | !trace_parser_cont(parser)) { | 2208 | !trace_parser_cont(parser)) { |
| 2199 | ret = ftrace_process_regex(parser->buffer, | 2209 | ret = ftrace_process_regex(parser->buffer, |
| 2200 | parser->idx, enable); | 2210 | parser->idx, enable); |
| 2211 | trace_parser_clear(parser); | ||
| 2201 | if (ret) | 2212 | if (ret) |
| 2202 | goto out_unlock; | 2213 | goto out_unlock; |
| 2203 | |||
| 2204 | trace_parser_clear(parser); | ||
| 2205 | } | 2214 | } |
| 2206 | 2215 | ||
| 2207 | ret = read; | 2216 | ret = read; |
| @@ -2543,10 +2552,9 @@ ftrace_set_func(unsigned long *array, int *idx, char *buffer) | |||
| 2543 | exists = true; | 2552 | exists = true; |
| 2544 | break; | 2553 | break; |
| 2545 | } | 2554 | } |
| 2546 | if (!exists) { | 2555 | if (!exists) |
| 2547 | array[(*idx)++] = rec->ip; | 2556 | array[(*idx)++] = rec->ip; |
| 2548 | found = 1; | 2557 | found = 1; |
| 2549 | } | ||
| 2550 | } | 2558 | } |
| 2551 | } while_for_each_ftrace_rec(); | 2559 | } while_for_each_ftrace_rec(); |
| 2552 | 2560 | ||
