Pull tracing updates from Steven Rostedt: "The majority of the changes are for fixes and clean ups. Notable changes: - Rework trace event triggers code to be easier to interact with. - Support for embedding bootconfig with the kernel (as suppose to having it embedded in initram). This is useful for embedded boards without initram disks. - Speed up boot by parallelizing the creation of tracefs files. - Allow absolute ring buffer timestamps handle timestamps that use more than 59 bits. - Added new tracing clock "TAI" (International Atomic Time) - Have weak functions show up in available_filter_function list as: __ftrace_invalid_address___<invalid-offset> instead of using the name of the function before it" * tag 'trace-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (52 commits) ftrace: Add FTRACE_MCOUNT_MAX_OFFSET to avoid adding weak function tracing: Fix comments for event_trigger_separate_filter() x86/traceponit: Fix comment about irq vector tracepoints x86,tracing: Remove unused headers ftrace: Clean up hash direct_functions on register failures tracing: Fix comments of create_filter() tracing: Disable kcov on trace_preemptirq.c tracing: Initialize integer variable to prevent garbage return value ftrace: Fix typo in comment ftrace: Remove return value of ftrace_arch_modify_*() tracing: Cleanup code by removing init "char *name" tracing: Change "char *" string form to "char []" tracing/timerlat: Do not wakeup the thread if the trace stops at the IRQ tracing/timerlat: Print stacktrace in the IRQ handler if needed tracing/timerlat: Notify IRQ new max latency only if stop tracing is set kprobes: Fix build errors with CONFIG_KRETPROBES=n tracing: Fix return value of trace_pid_write() tracing: Fix potential double free in create_var_ref() tracing: Use strim() to remove whitespace instead of doing it manually ftrace: Deal with error return code of the ftrace_process_locs() function ...
Showing the changes to kernel (21 of 40 files). Show all
Unified · Split
| @@ -1257,79 +1257,6 @@ void kprobe_busy_end(void) · 1256 unmodified lines | ||
| 1257 | 1257 | preempt_enable(); |
| 1258 | 1258 | } |
| 1259 | 1259 | |
| 1260 | −#if !defined(CONFIG_KRETPROBE_ON_RETHOOK) | |
| 1261 | −static void free_rp_inst_rcu(struct rcu_head *head) | |
| 1262 | −{ | |
| 1263 | − struct kretprobe_instance *ri = container_of(head, struct kretprobe_instance, rcu); | |
| 1264 | − | |
| 1265 | − if (refcount_dec_and_test(&ri->rph->ref)) | |
| 1266 | − kfree(ri->rph); | |
| 1267 | − kfree(ri); | |
| 1268 | −} | |
| 1269 | −NOKPROBE_SYMBOL(free_rp_inst_rcu); | |
| 1270 | − | |
| 1271 | −static void recycle_rp_inst(struct kretprobe_instance *ri) | |
| 1272 | −{ | |
| 1273 | − struct kretprobe *rp = get_kretprobe(ri); | |
| 1274 | − | |
| 1275 | − if (likely(rp)) | |
| 1276 | − freelist_add(&ri->freelist, &rp->freelist); | |
| 1277 | − else | |
| 1278 | − call_rcu(&ri->rcu, free_rp_inst_rcu); | |
| 1279 | −} | |
| 1280 | −NOKPROBE_SYMBOL(recycle_rp_inst); | |
| 1281 | − | |
| 1282 | −/* | |
| 1283 | − * This function is called from delayed_put_task_struct() when a task is | |
| 1284 | − * dead and cleaned up to recycle any kretprobe instances associated with | |
| 1285 | − * this task. These left over instances represent probed functions that | |
| 1286 | − * have been called but will never return. | |
| 1287 | − */ | |
| 1288 | −void kprobe_flush_task(struct task_struct *tk) | |
| 1289 | −{ | |
| 1290 | − struct kretprobe_instance *ri; | |
| 1291 | − struct llist_node *node; | |
| 1292 | − | |
| 1293 | − /* Early boot, not yet initialized. */ | |
| 1294 | − if (unlikely(!kprobes_initialized)) | |
| 1295 | − return; | |
| 1296 | − | |
| 1297 | − kprobe_busy_begin(); | |
| 1298 | − | |
| 1299 | − node = __llist_del_all(&tk->kretprobe_instances); | |
| 1300 | − while (node) { | |
| 1301 | − ri = container_of(node, struct kretprobe_instance, llist); | |
| 1302 | − node = node->next; | |
| 1303 | − | |
| 1304 | − recycle_rp_inst(ri); | |
| 1305 | − } | |
| 1306 | − | |
| 1307 | − kprobe_busy_end(); | |
| 1308 | −} | |
| 1309 | −NOKPROBE_SYMBOL(kprobe_flush_task); | |
| 1310 | − | |
| 1311 | −static inline void free_rp_inst(struct kretprobe *rp) | |
| 1312 | −{ | |
| 1313 | − struct kretprobe_instance *ri; | |
| 1314 | − struct freelist_node *node; | |
| 1315 | − int count = 0; | |
| 1316 | − | |
| 1317 | − node = rp->freelist.head; | |
| 1318 | − while (node) { | |
| 1319 | − ri = container_of(node, struct kretprobe_instance, freelist); | |
| 1320 | − node = node->next; | |
| 1321 | − | |
| 1322 | − kfree(ri); | |
| 1323 | − count++; | |
| 1324 | − } | |
| 1325 | − | |
| 1326 | − if (refcount_sub_and_test(count, &rp->rph->ref)) { | |
| 1327 | − kfree(rp->rph); | |
| 1328 | − rp->rph = NULL; | |
| 1329 | − } | |
| 1330 | −} | |
| 1331 | −#endif /* !CONFIG_KRETPROBE_ON_RETHOOK */ | |
| 1332 | − | |
| 1333 | 1260 | /* Add the new probe to 'ap->list'. */ |
| 1334 | 1261 | static int add_new_kprobe(struct kprobe *ap, struct kprobe *p) |
| 1335 | 1262 | { |
| @@ -1928,6 +1855,77 @@ static struct notifier_block kprobe_exceptions_nb = { · 592 unmodified lines | ||
| 1928 | 1855 | #ifdef CONFIG_KRETPROBES |
| 1929 | 1856 | |
| 1930 | 1857 | #if !defined(CONFIG_KRETPROBE_ON_RETHOOK) |
| 1858 | +static void free_rp_inst_rcu(struct rcu_head *head) | |
| 1859 | +{ | |
| 1860 | + struct kretprobe_instance *ri = container_of(head, struct kretprobe_instance, rcu); | |
| 1861 | + | |
| 1862 | + if (refcount_dec_and_test(&ri->rph->ref)) | |
| 1863 | + kfree(ri->rph); | |
| 1864 | + kfree(ri); | |
| 1865 | +} | |
| 1866 | +NOKPROBE_SYMBOL(free_rp_inst_rcu); | |
| 1867 | + | |
| 1868 | +static void recycle_rp_inst(struct kretprobe_instance *ri) | |
| 1869 | +{ | |
| 1870 | + struct kretprobe *rp = get_kretprobe(ri); | |
| 1871 | + | |
| 1872 | + if (likely(rp)) | |
| 1873 | + freelist_add(&ri->freelist, &rp->freelist); | |
| 1874 | + else | |
| 1875 | + call_rcu(&ri->rcu, free_rp_inst_rcu); | |
| 1876 | +} | |
| 1877 | +NOKPROBE_SYMBOL(recycle_rp_inst); | |
| 1878 | + | |
| 1879 | +/* | |
| 1880 | + * This function is called from delayed_put_task_struct() when a task is | |
| 1881 | + * dead and cleaned up to recycle any kretprobe instances associated with | |
| 1882 | + * this task. These left over instances represent probed functions that | |
| 1883 | + * have been called but will never return. | |
| 1884 | + */ | |
| 1885 | +void kprobe_flush_task(struct task_struct *tk) | |
| 1886 | +{ | |
| 1887 | + struct kretprobe_instance *ri; | |
| 1888 | + struct llist_node *node; | |
| 1889 | + | |
| 1890 | + /* Early boot, not yet initialized. */ | |
| 1891 | + if (unlikely(!kprobes_initialized)) | |
| 1892 | + return; | |
| 1893 | + | |
| 1894 | + kprobe_busy_begin(); | |
| 1895 | + | |
| 1896 | + node = __llist_del_all(&tk->kretprobe_instances); | |
| 1897 | + while (node) { | |
| 1898 | + ri = container_of(node, struct kretprobe_instance, llist); | |
| 1899 | + node = node->next; | |
| 1900 | + | |
| 1901 | + recycle_rp_inst(ri); | |
| 1902 | + } | |
| 1903 | + | |
| 1904 | + kprobe_busy_end(); | |
| 1905 | +} | |
| 1906 | +NOKPROBE_SYMBOL(kprobe_flush_task); | |
| 1907 | + | |
| 1908 | +static inline void free_rp_inst(struct kretprobe *rp) | |
| 1909 | +{ | |
| 1910 | + struct kretprobe_instance *ri; | |
| 1911 | + struct freelist_node *node; | |
| 1912 | + int count = 0; | |
| 1913 | + | |
| 1914 | + node = rp->freelist.head; | |
| 1915 | + while (node) { | |
| 1916 | + ri = container_of(node, struct kretprobe_instance, freelist); | |
| 1917 | + node = node->next; | |
| 1918 | + | |
| 1919 | + kfree(ri); | |
| 1920 | + count++; | |
| 1921 | + } | |
| 1922 | + | |
| 1923 | + if (refcount_sub_and_test(count, &rp->rph->ref)) { | |
| 1924 | + kfree(rp->rph); | |
| 1925 | + rp->rph = NULL; | |
| 1926 | + } | |
| 1927 | +} | |
| 1928 | + | |
| 1931 | 1929 | /* This assumes the 'tsk' is the current task or the is not running. */ |
| 1932 | 1930 | static kprobe_opcode_t *__kretprobe_find_ret_addr(struct task_struct *tsk, |
| 1933 | 1931 | struct llist_node **cur) |
| @@ -31,6 +31,10 @@ ifdef CONFIG_GCOV_PROFILE_FTRACE · 30 unmodified lines | ||
| 31 | 31 | GCOV_PROFILE := y |
| 32 | 32 | endif |
| 33 | 33 | |
| 34 | +# Functions in this file could be invoked from early interrupt | |
| 35 | +# code and produce random code coverage. | |
| 36 | +KCOV_INSTRUMENT_trace_preemptirq.o := n | |
| 37 | + | |
| 34 | 38 | CFLAGS_bpf_trace.o := -I$(src) |
| 35 | 39 | |
| 36 | 40 | CFLAGS_trace_benchmark.o := -I$(src) |
| @@ -45,6 +45,8 @@ · 44 unmodified lines | ||
| 45 | 45 | #include "trace_output.h" |
| 46 | 46 | #include "trace_stat.h" |
| 47 | 47 | |
| 48 | +#define FTRACE_INVALID_FUNCTION "__ftrace_invalid_address__" | |
| 49 | + | |
| 48 | 50 | #define FTRACE_WARN_ON(cond) \ |
| 49 | 51 | ({ \ |
| 50 | 52 | int ___r = cond; \ |
| @@ -119,7 +121,7 @@ struct ftrace_ops __rcu *ftrace_ops_list __read_mostly = &ftrace_list_end; · 68 unmodified lines | ||
| 119 | 121 | ftrace_func_t ftrace_trace_function __read_mostly = ftrace_stub; |
| 120 | 122 | struct ftrace_ops global_ops; |
| 121 | 123 | |
| 122 | −/* Defined by vmlinux.lds.h see the commment above arch_ftrace_ops_list_func for details */ | |
| 124 | +/* Defined by vmlinux.lds.h see the comment above arch_ftrace_ops_list_func for details */ | |
| 123 | 125 | void ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip, |
| 124 | 126 | struct ftrace_ops *op, struct ftrace_regs *fregs); |
| 125 | 127 | |
| @@ -952,7 +954,6 @@ static struct tracer_stat function_stats __initdata = { · 826 unmodified lines | ||
| 952 | 954 | static __init void ftrace_profile_tracefs(struct dentry *d_tracer) |
| 953 | 955 | { |
| 954 | 956 | struct ftrace_profile_stat *stat; |
| 955 | − struct dentry *entry; | |
| 956 | 957 | char *name; |
| 957 | 958 | int ret; |
| 958 | 959 | int cpu; |
| @@ -983,11 +984,9 @@ static __init void ftrace_profile_tracefs(struct dentry *d_tracer) · 24 unmodified lines | ||
| 983 | 984 | } |
| 984 | 985 | } |
| 985 | 986 | |
| 986 | − entry = tracefs_create_file("function_profile_enabled", | |
| 987 | − TRACE_MODE_WRITE, d_tracer, NULL, | |
| 988 | − &ftrace_profile_fops); | |
| 989 | − if (!entry) | |
| 990 | − pr_warn("Could not create tracefs 'function_profile_enabled' entry\n"); | |
| 987 | + trace_create_file("function_profile_enabled", | |
| 988 | + TRACE_MODE_WRITE, d_tracer, NULL, | |
| 989 | + &ftrace_profile_fops); | |
| 991 | 990 | } |
| 992 | 991 | |
| 993 | 992 | #else /* CONFIG_FUNCTION_PROFILER */ |
| @@ -2707,18 +2706,16 @@ ftrace_nop_initialize(struct module *mod, struct dyn_ftrace *rec) · 1713 unmodified lines | ||
| 2707 | 2706 | * archs can override this function if they must do something |
| 2708 | 2707 | * before the modifying code is performed. |
| 2709 | 2708 | */ |
| 2710 | −int __weak ftrace_arch_code_modify_prepare(void) | |
| 2709 | +void __weak ftrace_arch_code_modify_prepare(void) | |
| 2711 | 2710 | { |
| 2712 | − return 0; | |
| 2713 | 2711 | } |
| 2714 | 2712 | |
| 2715 | 2713 | /* |
| 2716 | 2714 | * archs can override this function if they must do something |
| 2717 | 2715 | * after the modifying code is performed. |
| 2718 | 2716 | */ |
| 2719 | −int __weak ftrace_arch_code_modify_post_process(void) | |
| 2717 | +void __weak ftrace_arch_code_modify_post_process(void) | |
| 2720 | 2718 | { |
| 2721 | − return 0; | |
| 2722 | 2719 | } |
| 2723 | 2720 | |
| 2724 | 2721 | void ftrace_modify_all_code(int command) |
| @@ -2804,12 +2801,7 @@ void __weak arch_ftrace_update_code(int command) · 79 unmodified lines | ||
| 2804 | 2801 | |
| 2805 | 2802 | static void ftrace_run_update_code(int command) |
| 2806 | 2803 | { |
| 2807 | − int ret; | |
| 2808 | − | |
| 2809 | − ret = ftrace_arch_code_modify_prepare(); | |
| 2810 | − FTRACE_WARN_ON(ret); | |
| 2811 | − if (ret) | |
| 2812 | − return; | |
| 2804 | + ftrace_arch_code_modify_prepare(); | |
| 2813 | 2805 | |
| 2814 | 2806 | /* |
| 2815 | 2807 | * By default we use stop_machine() to modify the code. |
| @@ -2819,8 +2811,7 @@ static void ftrace_run_update_code(int command) · 3 unmodified lines | ||
| 2819 | 2811 | */ |
| 2820 | 2812 | arch_ftrace_update_code(command); |
| 2821 | 2813 | |
| 2822 | − ret = ftrace_arch_code_modify_post_process(); | |
| 2823 | − FTRACE_WARN_ON(ret); | |
| 2814 | + ftrace_arch_code_modify_post_process(); | |
| 2824 | 2815 | } |
| 2825 | 2816 | |
| 2826 | 2817 | static void ftrace_run_modify_code(struct ftrace_ops *ops, int command, |
| @@ -3631,6 +3622,105 @@ static void add_trampoline_func(struct seq_file *m, struct ftrace_ops *ops, · 804 unmodified lines | ||
| 3631 | 3622 | seq_printf(m, " ->%pS", ptr); |
| 3632 | 3623 | } |
| 3633 | 3624 | |
| 3625 | +#ifdef FTRACE_MCOUNT_MAX_OFFSET | |
| 3626 | +/* | |
| 3627 | + * Weak functions can still have an mcount/fentry that is saved in | |
| 3628 | + * the __mcount_loc section. These can be detected by having a | |
| 3629 | + * symbol offset of greater than FTRACE_MCOUNT_MAX_OFFSET, as the | |
| 3630 | + * symbol found by kallsyms is not the function that the mcount/fentry | |
| 3631 | + * is part of. The offset is much greater in these cases. | |
| 3632 | + * | |
| 3633 | + * Test the record to make sure that the ip points to a valid kallsyms | |
| 3634 | + * and if not, mark it disabled. | |
| 3635 | + */ | |
| 3636 | +static int test_for_valid_rec(struct dyn_ftrace *rec) | |
| 3637 | +{ | |
| 3638 | + char str[KSYM_SYMBOL_LEN]; | |
| 3639 | + unsigned long offset; | |
| 3640 | + const char *ret; | |
| 3641 | + | |
| 3642 | + ret = kallsyms_lookup(rec->ip, NULL, &offset, NULL, str); | |
| 3643 | + | |
| 3644 | + /* Weak functions can cause invalid addresses */ | |
| 3645 | + if (!ret || offset > FTRACE_MCOUNT_MAX_OFFSET) { | |
| 3646 | + rec->flags |= FTRACE_FL_DISABLED; | |
| 3647 | + return 0; | |
| 3648 | + } | |
| 3649 | + return 1; | |
| 3650 | +} | |
| 3651 | + | |
| 3652 | +static struct workqueue_struct *ftrace_check_wq __initdata; | |
| 3653 | +static struct work_struct ftrace_check_work __initdata; | |
| 3654 | + | |
| 3655 | +/* | |
| 3656 | + * Scan all the mcount/fentry entries to make sure they are valid. | |
| 3657 | + */ | |
| 3658 | +static __init void ftrace_check_work_func(struct work_struct *work) | |
| 3659 | +{ | |
| 3660 | + struct ftrace_page *pg; | |
| 3661 | + struct dyn_ftrace *rec; | |
| 3662 | + | |
| 3663 | + mutex_lock(&ftrace_lock); | |
| 3664 | + do_for_each_ftrace_rec(pg, rec) { | |
| 3665 | + test_for_valid_rec(rec); | |
| 3666 | + } while_for_each_ftrace_rec(); | |
| 3667 | + mutex_unlock(&ftrace_lock); | |
| 3668 | +} | |
| 3669 | + | |
| 3670 | +static int __init ftrace_check_for_weak_functions(void) | |
| 3671 | +{ | |
| 3672 | + INIT_WORK(&ftrace_check_work, ftrace_check_work_func); | |
| 3673 | + | |
| 3674 | + ftrace_check_wq = alloc_workqueue("ftrace_check_wq", WQ_UNBOUND, 0); | |
| 3675 | + | |
| 3676 | + queue_work(ftrace_check_wq, &ftrace_check_work); | |
| 3677 | + return 0; | |
| 3678 | +} | |
| 3679 | + | |
| 3680 | +static int __init ftrace_check_sync(void) | |
| 3681 | +{ | |
| 3682 | + /* Make sure the ftrace_check updates are finished */ | |
| 3683 | + if (ftrace_check_wq) | |
| 3684 | + destroy_workqueue(ftrace_check_wq); | |
| 3685 | + return 0; | |
| 3686 | +} | |
| 3687 | + | |
| 3688 | +late_initcall_sync(ftrace_check_sync); | |
| 3689 | +subsys_initcall(ftrace_check_for_weak_functions); | |
| 3690 | + | |
| 3691 | +static int print_rec(struct seq_file *m, unsigned long ip) | |
| 3692 | +{ | |
| 3693 | + unsigned long offset; | |
| 3694 | + char str[KSYM_SYMBOL_LEN]; | |
| 3695 | + char *modname; | |
| 3696 | + const char *ret; | |
| 3697 | + | |
| 3698 | + ret = kallsyms_lookup(ip, NULL, &offset, &modname, str); | |
| 3699 | + /* Weak functions can cause invalid addresses */ | |
| 3700 | + if (!ret || offset > FTRACE_MCOUNT_MAX_OFFSET) { | |
| 3701 | + snprintf(str, KSYM_SYMBOL_LEN, "%s_%ld", | |
| 3702 | + FTRACE_INVALID_FUNCTION, offset); | |
| 3703 | + ret = NULL; | |
| 3704 | + } | |
| 3705 | + | |
| 3706 | + seq_puts(m, str); | |
| 3707 | + if (modname) | |
| 3708 | + seq_printf(m, " [%s]", modname); | |
| 3709 | + return ret == NULL ? -1 : 0; | |
| 3710 | +} | |
| 3711 | +#else | |
| 3712 | +static inline int test_for_valid_rec(struct dyn_ftrace *rec) | |
| 3713 | +{ | |
| 3714 | + return 1; | |
| 3715 | +} | |
| 3716 | + | |
| 3717 | +static inline int print_rec(struct seq_file *m, unsigned long ip) | |
| 3718 | +{ | |
| 3719 | + seq_printf(m, "%ps", (void *)ip); | |
| 3720 | + return 0; | |
| 3721 | +} | |
| 3722 | +#endif | |
| 3723 | + | |
| 3634 | 3724 | static int t_show(struct seq_file *m, void *v) |
| 3635 | 3725 | { |
| 3636 | 3726 | struct ftrace_iterator *iter = m->private; |
| @@ -3655,7 +3745,13 @@ static int t_show(struct seq_file *m, void *v) · 18 unmodified lines | ||
| 3655 | 3745 | if (!rec) |
| 3656 | 3746 | return 0; |
| 3657 | 3747 | |
| 3658 | − seq_printf(m, "%ps", (void *)rec->ip); | |
| 3748 | + if (print_rec(m, rec->ip)) { | |
| 3749 | + /* This should only happen when a rec is disabled */ | |
| 3750 | + WARN_ON_ONCE(!(rec->flags & FTRACE_FL_DISABLED)); | |
| 3751 | + seq_putc(m, '\n'); | |
| 3752 | + return 0; | |
| 3753 | + } | |
| 3754 | + | |
| 3659 | 3755 | if (iter->flags & FTRACE_ITER_ENABLED) { |
| 3660 | 3756 | struct ftrace_ops *ops; |
| 3661 | 3757 | |
| @@ -3973,6 +4069,24 @@ add_rec_by_index(struct ftrace_hash *hash, struct ftrace_glob *func_g, · 311 unmodified lines | ||
| 3973 | 4069 | return 0; |
| 3974 | 4070 | } |
| 3975 | 4071 | |
| 4072 | +#ifdef FTRACE_MCOUNT_MAX_OFFSET | |
| 4073 | +static int lookup_ip(unsigned long ip, char **modname, char *str) | |
| 4074 | +{ | |
| 4075 | + unsigned long offset; | |
| 4076 | + | |
| 4077 | + kallsyms_lookup(ip, NULL, &offset, modname, str); | |
| 4078 | + if (offset > FTRACE_MCOUNT_MAX_OFFSET) | |
| 4079 | + return -1; | |
| 4080 | + return 0; | |
| 4081 | +} | |
| 4082 | +#else | |
| 4083 | +static int lookup_ip(unsigned long ip, char **modname, char *str) | |
| 4084 | +{ | |
| 4085 | + kallsyms_lookup(ip, NULL, NULL, modname, str); | |
| 4086 | + return 0; | |
| 4087 | +} | |
| 4088 | +#endif | |
| 4089 | + | |
| 3976 | 4090 | static int |
| 3977 | 4091 | ftrace_match_record(struct dyn_ftrace *rec, struct ftrace_glob *func_g, |
| 3978 | 4092 | struct ftrace_glob *mod_g, int exclude_mod) |
| @@ -3980,7 +4094,12 @@ ftrace_match_record(struct dyn_ftrace *rec, struct ftrace_glob *func_g, · 1 unmodified line | ||
| 3980 | 4094 | char str[KSYM_SYMBOL_LEN]; |
| 3981 | 4095 | char *modname; |
| 3982 | 4096 | |
| 3983 | − kallsyms_lookup(rec->ip, NULL, NULL, &modname, str); | |
| 4097 | + if (lookup_ip(rec->ip, &modname, str)) { | |
| 4098 | + /* This should only happen when a rec is disabled */ | |
| 4099 | + WARN_ON_ONCE(system_state == SYSTEM_RUNNING && | |
| 4100 | + !(rec->flags & FTRACE_FL_DISABLED)); | |
| 4101 | + return 0; | |
| 4102 | + } | |
| 3984 | 4103 | |
| 3985 | 4104 | if (mod_g) { |
| 3986 | 4105 | int mod_matches = (modname) ? ftrace_match(modname, mod_g) : 0; |
| @@ -4431,7 +4550,7 @@ int ftrace_func_mapper_add_ip(struct ftrace_func_mapper *mapper, · 444 unmodified lines | ||
| 4431 | 4550 | * @ip: The instruction pointer address to remove the data from |
| 4432 | 4551 | * |
| 4433 | 4552 | * Returns the data if it is found, otherwise NULL. |
| 4434 | − * Note, if the data pointer is used as the data itself, (see | |
| 4553 | + * Note, if the data pointer is used as the data itself, (see | |
| 4435 | 4554 | * ftrace_func_mapper_find_ip(), then the return value may be meaningless, |
| 4436 | 4555 | * if the data pointer was set to zero. |
| 4437 | 4556 | */ |
| @@ -4526,8 +4645,8 @@ register_ftrace_function_probe(char *glob, struct trace_array *tr, · 88 unmodified lines | ||
| 4526 | 4645 | struct ftrace_probe_ops *probe_ops, |
| 4527 | 4646 | void *data) |
| 4528 | 4647 | { |
| 4648 | + struct ftrace_func_probe *probe = NULL, *iter; | |
| 4529 | 4649 | struct ftrace_func_entry *entry; |
| 4530 | − struct ftrace_func_probe *probe; | |
| 4531 | 4650 | struct ftrace_hash **orig_hash; |
| 4532 | 4651 | struct ftrace_hash *old_hash; |
| 4533 | 4652 | struct ftrace_hash *hash; |
| @@ -4546,11 +4665,13 @@ register_ftrace_function_probe(char *glob, struct trace_array *tr, · 12 unmodified lines | ||
| 4546 | 4665 | |
| 4547 | 4666 | mutex_lock(&ftrace_lock); |
| 4548 | 4667 | /* Check if the probe_ops is already registered */ |
| 4549 | − list_for_each_entry(probe, &tr->func_probes, list) { | |
| 4550 | − if (probe->probe_ops == probe_ops) | |
| 4668 | + list_for_each_entry(iter, &tr->func_probes, list) { | |
| 4669 | + if (iter->probe_ops == probe_ops) { | |
| 4670 | + probe = iter; | |
| 4551 | 4671 | break; |
| 4672 | + } | |
| 4552 | 4673 | } |
| 4553 | − if (&probe->list == &tr->func_probes) { | |
| 4674 | + if (!probe) { | |
| 4554 | 4675 | probe = kzalloc(sizeof(*probe), GFP_KERNEL); |
| 4555 | 4676 | if (!probe) { |
| 4556 | 4677 | mutex_unlock(&ftrace_lock); |
| @@ -4668,9 +4789,9 @@ int · 111 unmodified lines | ||
| 4668 | 4789 | unregister_ftrace_function_probe_func(char *glob, struct trace_array *tr, |
| 4669 | 4790 | struct ftrace_probe_ops *probe_ops) |
| 4670 | 4791 | { |
| 4792 | + struct ftrace_func_probe *probe = NULL, *iter; | |
| 4671 | 4793 | struct ftrace_ops_hash old_hash_ops; |
| 4672 | 4794 | struct ftrace_func_entry *entry; |
| 4673 | − struct ftrace_func_probe *probe; | |
| 4674 | 4795 | struct ftrace_glob func_g; |
| 4675 | 4796 | struct ftrace_hash **orig_hash; |
| 4676 | 4797 | struct ftrace_hash *old_hash; |
| @@ -4698,11 +4819,13 @@ unregister_ftrace_function_probe_func(char *glob, struct trace_array *tr, · 21 unmodified lines | ||
| 4698 | 4819 | |
| 4699 | 4820 | mutex_lock(&ftrace_lock); |
| 4700 | 4821 | /* Check if the probe_ops is already registered */ |
| 4701 | − list_for_each_entry(probe, &tr->func_probes, list) { | |
| 4702 | − if (probe->probe_ops == probe_ops) | |
| 4822 | + list_for_each_entry(iter, &tr->func_probes, list) { | |
| 4823 | + if (iter->probe_ops == probe_ops) { | |
| 4824 | + probe = iter; | |
| 4703 | 4825 | break; |
| 4826 | + } | |
| 4704 | 4827 | } |
| 4705 | − if (&probe->list == &tr->func_probes) | |
| 4828 | + if (!probe) | |
| 4706 | 4829 | goto err_unlock_ftrace; |
| 4707 | 4830 | |
| 4708 | 4831 | ret = -EINVAL; |
| @@ -5161,8 +5284,6 @@ int register_ftrace_direct(unsigned long ip, unsigned long addr) · 452 unmodified lines | ||
| 5161 | 5284 | goto out_unlock; |
| 5162 | 5285 | |
| 5163 | 5286 | ret = ftrace_set_filter_ip(&direct_ops, ip, 0, 0); |
| 5164 | − if (ret) | |
| 5165 | − remove_hash_entry(direct_functions, entry); | |
| 5166 | 5287 | |
| 5167 | 5288 | if (!ret && !(direct_ops.flags & FTRACE_OPS_FL_ENABLED)) { |
| 5168 | 5289 | ret = register_ftrace_function(&direct_ops); |
| @@ -5171,6 +5292,7 @@ int register_ftrace_direct(unsigned long ip, unsigned long addr) · 2 unmodified lines | ||
| 5171 | 5292 | } |
| 5172 | 5293 | |
| 5173 | 5294 | if (ret) { |
| 5295 | + remove_hash_entry(direct_functions, entry); | |
| 5174 | 5296 | kfree(entry); |
| 5175 | 5297 | if (!direct->count) { |
| 5176 | 5298 | list_del_rcu(&direct->next); |
| @@ -6793,6 +6915,13 @@ void ftrace_module_enable(struct module *mod) · 1616 unmodified lines | ||
| 6793 | 6915 | !within_module_init(rec->ip, mod)) |
| 6794 | 6916 | break; |
| 6795 | 6917 | |
| 6918 | + /* Weak functions should still be ignored */ | |
| 6919 | + if (!test_for_valid_rec(rec)) { | |
| 6920 | + /* Clear all other flags. Should not be enabled anyway */ | |
| 6921 | + rec->flags = FTRACE_FL_DISABLED; | |
| 6922 | + continue; | |
| 6923 | + } | |
| 6924 | + | |
| 6796 | 6925 | cnt = 0; |
| 6797 | 6926 | |
| 6798 | 6927 | /* |
| @@ -6829,11 +6958,16 @@ void ftrace_module_enable(struct module *mod) · 30 unmodified lines | ||
| 6829 | 6958 | |
| 6830 | 6959 | void ftrace_module_init(struct module *mod) |
| 6831 | 6960 | { |
| 6961 | + int ret; | |
| 6962 | + | |
| 6832 | 6963 | if (ftrace_disabled || !mod->num_ftrace_callsites) |
| 6833 | 6964 | return; |
| 6834 | 6965 | |
| 6835 | − ftrace_process_locs(mod, mod->ftrace_callsites, | |
| 6836 | − mod->ftrace_callsites + mod->num_ftrace_callsites); | |
| 6966 | + ret = ftrace_process_locs(mod, mod->ftrace_callsites, | |
| 6967 | + mod->ftrace_callsites + mod->num_ftrace_callsites); | |
| 6968 | + if (ret) | |
| 6969 | + pr_warn("ftrace: failed to allocate entries for module '%s' functions\n", | |
| 6970 | + mod->name); | |
| 6837 | 6971 | } |
| 6838 | 6972 | |
| 6839 | 6973 | static void save_ftrace_mod_rec(struct ftrace_mod_map *mod_map, |
| @@ -7166,15 +7300,19 @@ void __init ftrace_init(void) · 326 unmodified lines | ||
| 7166 | 7300 | pr_info("ftrace: allocating %ld entries in %ld pages\n", |
| 7167 | 7301 | count, count / ENTRIES_PER_PAGE + 1); |
| 7168 | 7302 | |
| 7169 | − last_ftrace_enabled = ftrace_enabled = 1; | |
| 7170 | − | |
| 7171 | 7303 | ret = ftrace_process_locs(NULL, |
| 7172 | 7304 | __start_mcount_loc, |
| 7173 | 7305 | __stop_mcount_loc); |
| 7306 | + if (ret) { | |
| 7307 | + pr_warn("ftrace: failed to allocate entries for functions\n"); | |
| 7308 | + goto failed; | |
| 7309 | + } | |
| 7174 | 7310 | |
| 7175 | 7311 | pr_info("ftrace: allocated %ld pages with %ld groups\n", |
| 7176 | 7312 | ftrace_number_of_pages, ftrace_number_of_groups); |
| 7177 | 7313 | |
| 7314 | + last_ftrace_enabled = ftrace_enabled = 1; | |
| 7315 | + | |
| 7178 | 7316 | set_ftrace_early_filters(); |
| 7179 | 7317 | |
| 7180 | 7318 | return; |
| @@ -118,9 +118,9 @@ static inline unsigned int pid_join(unsigned int upper1, · 117 unmodified lines | ||
| 118 | 118 | /** |
| 119 | 119 | * trace_pid_list_is_set - test if the pid is set in the list |
| 120 | 120 | * @pid_list: The pid list to test |
| 121 | − * @pid: The pid to to see if set in the list. | |
| 121 | + * @pid: The pid to see if set in the list. | |
| 122 | 122 | * |
| 123 | − * Tests if @pid is is set in the @pid_list. This is usually called | |
| 123 | + * Tests if @pid is set in the @pid_list. This is usually called | |
| 124 | 124 | * from the scheduler when a task is scheduled. Its pid is checked |
| 125 | 125 | * if it should be traced or not. |
| 126 | 126 | * |
| @@ -29,6 +29,14 @@ · 28 unmodified lines | ||
| 29 | 29 | |
| 30 | 30 | #include <asm/local.h> |
| 31 | 31 | |
| 32 | +/* | |
| 33 | + * The "absolute" timestamp in the buffer is only 59 bits. | |
| 34 | + * If a clock has the 5 MSBs set, it needs to be saved and | |
| 35 | + * reinserted. | |
| 36 | + */ | |
| 37 | +#define TS_MSB (0xf8ULL << 56) | |
| 38 | +#define ABS_TS_MASK (~TS_MSB) | |
| 39 | + | |
| 32 | 40 | static void update_pages_handler(struct work_struct *work); |
| 33 | 41 | |
| 34 | 42 | /* |
| @@ -468,6 +476,7 @@ struct rb_time_struct { · 433 unmodified lines | ||
| 468 | 476 | local_t cnt; |
| 469 | 477 | local_t top; |
| 470 | 478 | local_t bottom; |
| 479 | + local_t msb; | |
| 471 | 480 | }; |
| 472 | 481 | #else |
| 473 | 482 | #include <asm/local64.h> |
| @@ -569,7 +578,6 @@ struct ring_buffer_iter { · 95 unmodified lines | ||
| 569 | 578 | * For the ring buffer, 64 bit required operations for the time is |
| 570 | 579 | * the following: |
| 571 | 580 | * |
| 572 | − * - Only need 59 bits (uses 60 to make it even). | |
| 573 | 581 | * - Reads may fail if it interrupted a modification of the time stamp. |
| 574 | 582 | * It will succeed if it did not interrupt another write even if |
| 575 | 583 | * the read itself is interrupted by a write. |
| @@ -594,6 +602,7 @@ struct ring_buffer_iter { · 18 unmodified lines | ||
| 594 | 602 | */ |
| 595 | 603 | #define RB_TIME_SHIFT 30 |
| 596 | 604 | #define RB_TIME_VAL_MASK ((1 << RB_TIME_SHIFT) - 1) |
| 605 | +#define RB_TIME_MSB_SHIFT 60 | |
| 597 | 606 | |
| 598 | 607 | static inline int rb_time_cnt(unsigned long val) |
| 599 | 608 | { |
| @@ -613,7 +622,7 @@ static inline u64 rb_time_val(unsigned long top, unsigned long bottom) · 13 unmodified lines | ||
| 613 | 622 | |
| 614 | 623 | static inline bool __rb_time_read(rb_time_t *t, u64 *ret, unsigned long *cnt) |
| 615 | 624 | { |
| 616 | − unsigned long top, bottom; | |
| 625 | + unsigned long top, bottom, msb; | |
| 617 | 626 | unsigned long c; |
| 618 | 627 | |
| 619 | 628 | /* |
| @@ -625,6 +634,7 @@ static inline bool __rb_time_read(rb_time_t *t, u64 *ret, unsigned long *cnt) · 5 unmodified lines | ||
| 625 | 634 | c = local_read(&t->cnt); |
| 626 | 635 | top = local_read(&t->top); |
| 627 | 636 | bottom = local_read(&t->bottom); |
| 637 | + msb = local_read(&t->msb); | |
| 628 | 638 | } while (c != local_read(&t->cnt)); |
| 629 | 639 | |
| 630 | 640 | *cnt = rb_time_cnt(top); |
| @@ -633,7 +643,8 @@ static inline bool __rb_time_read(rb_time_t *t, u64 *ret, unsigned long *cnt) · 2 unmodified lines | ||
| 633 | 643 | if (*cnt != rb_time_cnt(bottom)) |
| 634 | 644 | return false; |
| 635 | 645 | |
| 636 | − *ret = rb_time_val(top, bottom); | |
| 646 | + /* The shift to msb will lose its cnt bits */ | |
| 647 | + *ret = rb_time_val(top, bottom) | ((u64)msb << RB_TIME_MSB_SHIFT); | |
| 637 | 648 | return true; |
| 638 | 649 | } |
| 639 | 650 | |
| @@ -649,10 +660,12 @@ static inline unsigned long rb_time_val_cnt(unsigned long val, unsigned long cnt · 9 unmodified lines | ||
| 649 | 660 | return (val & RB_TIME_VAL_MASK) | ((cnt & 3) << RB_TIME_SHIFT); |
| 650 | 661 | } |
| 651 | 662 | |
| 652 | −static inline void rb_time_split(u64 val, unsigned long *top, unsigned long *bottom) | |
| 663 | +static inline void rb_time_split(u64 val, unsigned long *top, unsigned long *bottom, | |
| 664 | + unsigned long *msb) | |
| 653 | 665 | { |
| 654 | 666 | *top = (unsigned long)((val >> RB_TIME_SHIFT) & RB_TIME_VAL_MASK); |
| 655 | 667 | *bottom = (unsigned long)(val & RB_TIME_VAL_MASK); |
| 668 | + *msb = (unsigned long)(val >> RB_TIME_MSB_SHIFT); | |
| 656 | 669 | } |
| 657 | 670 | |
| 658 | 671 | static inline void rb_time_val_set(local_t *t, unsigned long val, unsigned long cnt) |
| @@ -663,15 +676,16 @@ static inline void rb_time_val_set(local_t *t, unsigned long val, unsigned long · 4 unmodified lines | ||
| 663 | 676 | |
| 664 | 677 | static void rb_time_set(rb_time_t *t, u64 val) |
| 665 | 678 | { |
| 666 | − unsigned long cnt, top, bottom; | |
| 679 | + unsigned long cnt, top, bottom, msb; | |
| 667 | 680 | |
| 668 | − rb_time_split(val, &top, &bottom); | |
| 681 | + rb_time_split(val, &top, &bottom, &msb); | |
| 669 | 682 | |
| 670 | 683 | /* Writes always succeed with a valid number even if it gets interrupted. */ |
| 671 | 684 | do { |
| 672 | 685 | cnt = local_inc_return(&t->cnt); |
| 673 | 686 | rb_time_val_set(&t->top, top, cnt); |
| 674 | 687 | rb_time_val_set(&t->bottom, bottom, cnt); |
| 688 | + rb_time_val_set(&t->msb, val >> RB_TIME_MSB_SHIFT, cnt); | |
| 675 | 689 | } while (cnt != local_read(&t->cnt)); |
| 676 | 690 | } |
| 677 | 691 | |
| @@ -686,8 +700,8 @@ rb_time_read_cmpxchg(local_t *l, unsigned long expect, unsigned long set) · 8 unmodified lines | ||
| 686 | 700 | |
| 687 | 701 | static int rb_time_cmpxchg(rb_time_t *t, u64 expect, u64 set) |
| 688 | 702 | { |
| 689 | − unsigned long cnt, top, bottom; | |
| 690 | − unsigned long cnt2, top2, bottom2; | |
| 703 | + unsigned long cnt, top, bottom, msb; | |
| 704 | + unsigned long cnt2, top2, bottom2, msb2; | |
| 691 | 705 | u64 val; |
| 692 | 706 | |
| 693 | 707 | /* The cmpxchg always fails if it interrupted an update */ |
| @@ -703,16 +717,18 @@ static int rb_time_cmpxchg(rb_time_t *t, u64 expect, u64 set) · 9 unmodified lines | ||
| 703 | 717 | |
| 704 | 718 | cnt2 = cnt + 1; |
| 705 | 719 | |
| 706 | − rb_time_split(val, &top, &bottom); | |
| 720 | + rb_time_split(val, &top, &bottom, &msb); | |
| 707 | 721 | top = rb_time_val_cnt(top, cnt); |
| 708 | 722 | bottom = rb_time_val_cnt(bottom, cnt); |
| 709 | 723 | |
| 710 | − rb_time_split(set, &top2, &bottom2); | |
| 724 | + rb_time_split(set, &top2, &bottom2, &msb2); | |
| 711 | 725 | top2 = rb_time_val_cnt(top2, cnt2); |
| 712 | 726 | bottom2 = rb_time_val_cnt(bottom2, cnt2); |
| 713 | 727 | |
| 714 | 728 | if (!rb_time_read_cmpxchg(&t->cnt, cnt, cnt2)) |
| 715 | 729 | return false; |
| 730 | + if (!rb_time_read_cmpxchg(&t->msb, msb, msb2)) | |
| 731 | + return false; | |
| 716 | 732 | if (!rb_time_read_cmpxchg(&t->top, top, top2)) |
| 717 | 733 | return false; |
| 718 | 734 | if (!rb_time_read_cmpxchg(&t->bottom, bottom, bottom2)) |
| @@ -783,6 +799,24 @@ static inline void verify_event(struct ring_buffer_per_cpu *cpu_buffer, · 64 unmodified lines | ||
| 783 | 799 | } |
| 784 | 800 | #endif |
| 785 | 801 | |
| 802 | +/* | |
| 803 | + * The absolute time stamp drops the 5 MSBs and some clocks may | |
| 804 | + * require them. The rb_fix_abs_ts() will take a previous full | |
| 805 | + * time stamp, and add the 5 MSB of that time stamp on to the | |
| 806 | + * saved absolute time stamp. Then they are compared in case of | |
| 807 | + * the unlikely event that the latest time stamp incremented | |
| 808 | + * the 5 MSB. | |
| 809 | + */ | |
| 810 | +static inline u64 rb_fix_abs_ts(u64 abs, u64 save_ts) | |
| 811 | +{ | |
| 812 | + if (save_ts & TS_MSB) { | |
| 813 | + abs |= save_ts & TS_MSB; | |
| 814 | + /* Check for overflow */ | |
| 815 | + if (unlikely(abs < save_ts)) | |
| 816 | + abs += 1ULL << 59; | |
| 817 | + } | |
| 818 | + return abs; | |
| 819 | +} | |
| 786 | 820 | |
| 787 | 821 | static inline u64 rb_time_stamp(struct trace_buffer *buffer); |
| 788 | 822 | |
| @@ -811,8 +845,10 @@ u64 ring_buffer_event_time_stamp(struct trace_buffer *buffer, · 22 unmodified lines | ||
| 811 | 845 | u64 ts; |
| 812 | 846 | |
| 813 | 847 | /* If the event includes an absolute time, then just use that */ |
| 814 | − if (event->type_len == RINGBUF_TYPE_TIME_STAMP) | |
| 815 | − return rb_event_time_stamp(event); | |
| 848 | + if (event->type_len == RINGBUF_TYPE_TIME_STAMP) { | |
| 849 | + ts = rb_event_time_stamp(event); | |
| 850 | + return rb_fix_abs_ts(ts, cpu_buffer->tail_page->page->time_stamp); | |
| 851 | + } | |
| 816 | 852 | |
| 817 | 853 | nest = local_read(&cpu_buffer->committing); |
| 818 | 854 | verify_event(cpu_buffer, event); |
| @@ -2754,8 +2790,15 @@ static void rb_add_timestamp(struct ring_buffer_per_cpu *cpu_buffer, · 1935 unmodified lines | ||
| 2754 | 2790 | (RB_ADD_STAMP_FORCE | RB_ADD_STAMP_ABSOLUTE); |
| 2755 | 2791 | |
| 2756 | 2792 | if (unlikely(info->delta > (1ULL << 59))) { |
| 2793 | + /* | |
| 2794 | + * Some timers can use more than 59 bits, and when a timestamp | |
| 2795 | + * is added to the buffer, it will lose those bits. | |
| 2796 | + */ | |
| 2797 | + if (abs && (info->ts & TS_MSB)) { | |
| 2798 | + info->delta &= ABS_TS_MASK; | |
| 2799 | + | |
| 2757 | 2800 | /* did the clock go backwards */ |
| 2758 | − if (info->before == info->after && info->before > info->ts) { | |
| 2801 | + } else if (info->before == info->after && info->before > info->ts) { | |
| 2759 | 2802 | /* not interrupted */ |
| 2760 | 2803 | static int once; |
| 2761 | 2804 | |
| @@ -3304,7 +3347,7 @@ static void dump_buffer_page(struct buffer_data_page *bpage, · 542 unmodified lines | ||
| 3304 | 3347 | |
| 3305 | 3348 | case RINGBUF_TYPE_TIME_STAMP: |
| 3306 | 3349 | delta = rb_event_time_stamp(event); |
| 3307 | − ts = delta; | |
| 3350 | + ts = rb_fix_abs_ts(delta, ts); | |
| 3308 | 3351 | pr_warn(" [%lld] absolute:%lld TIME STAMP\n", ts, delta); |
| 3309 | 3352 | break; |
| 3310 | 3353 | |
| @@ -3380,7 +3423,7 @@ static void check_buffer(struct ring_buffer_per_cpu *cpu_buffer, · 69 unmodified lines | ||
| 3380 | 3423 | |
| 3381 | 3424 | case RINGBUF_TYPE_TIME_STAMP: |
| 3382 | 3425 | delta = rb_event_time_stamp(event); |
| 3383 | − ts = delta; | |
| 3426 | + ts = rb_fix_abs_ts(delta, ts); | |
| 3384 | 3427 | break; |
| 3385 | 3428 | |
| 3386 | 3429 | case RINGBUF_TYPE_PADDING: |
| @@ -4367,6 +4410,7 @@ rb_update_read_stamp(struct ring_buffer_per_cpu *cpu_buffer, · 980 unmodified lines | ||
| 4367 | 4410 | |
| 4368 | 4411 | case RINGBUF_TYPE_TIME_STAMP: |
| 4369 | 4412 | delta = rb_event_time_stamp(event); |
| 4413 | + delta = rb_fix_abs_ts(delta, cpu_buffer->read_stamp); | |
| 4370 | 4414 | cpu_buffer->read_stamp = delta; |
| 4371 | 4415 | return; |
| 4372 | 4416 | |
| @@ -4397,6 +4441,7 @@ rb_update_iter_read_stamp(struct ring_buffer_iter *iter, · 24 unmodified lines | ||
| 4397 | 4441 | |
| 4398 | 4442 | case RINGBUF_TYPE_TIME_STAMP: |
| 4399 | 4443 | delta = rb_event_time_stamp(event); |
| 4444 | + delta = rb_fix_abs_ts(delta, iter->read_stamp); | |
| 4400 | 4445 | iter->read_stamp = delta; |
| 4401 | 4446 | return; |
| 4402 | 4447 | |
| @@ -4650,6 +4695,7 @@ rb_buffer_peek(struct ring_buffer_per_cpu *cpu_buffer, u64 *ts, · 247 unmodified lines | ||
| 4650 | 4695 | case RINGBUF_TYPE_TIME_STAMP: |
| 4651 | 4696 | if (ts) { |
| 4652 | 4697 | *ts = rb_event_time_stamp(event); |
| 4698 | + *ts = rb_fix_abs_ts(*ts, reader->page->time_stamp); | |
| 4653 | 4699 | ring_buffer_normalize_time_stamp(cpu_buffer->buffer, |
| 4654 | 4700 | cpu_buffer->cpu, ts); |
| 4655 | 4701 | } |
| @@ -4741,6 +4787,7 @@ rb_iter_peek(struct ring_buffer_iter *iter, u64 *ts) · 85 unmodified lines | ||
| 4741 | 4787 | case RINGBUF_TYPE_TIME_STAMP: |
| 4742 | 4788 | if (ts) { |
| 4743 | 4789 | *ts = rb_event_time_stamp(event); |
| 4790 | + *ts = rb_fix_abs_ts(*ts, iter->head_page->page->time_stamp); | |
| 4744 | 4791 | ring_buffer_normalize_time_stamp(cpu_buffer->buffer, |
| 4745 | 4792 | cpu_buffer->cpu, ts); |
| 4746 | 4793 | } |
| @@ -6011,10 +6058,10 @@ static __init int test_ringbuffer(void) · 1264 unmodified lines | ||
| 6011 | 6058 | pr_info(" total events: %ld\n", total_lost + total_read); |
| 6012 | 6059 | pr_info(" recorded len bytes: %ld\n", total_len); |
| 6013 | 6060 | pr_info(" recorded size bytes: %ld\n", total_size); |
| 6014 | − if (total_lost) | |
| 6061 | + if (total_lost) { | |
| 6015 | 6062 | pr_info(" With dropped events, record len and size may not match\n" |
| 6016 | 6063 | " alloced and written from above\n"); |
| 6017 | − if (!total_lost) { | |
| 6064 | + } else { | |
| 6018 | 6065 | if (RB_WARN_ON(buffer, total_len != total_alloc || |
| 6019 | 6066 | total_size != total_written)) |
| 6020 | 6067 | break; |
| @@ -721,13 +721,16 @@ int trace_pid_write(struct trace_pid_list *filtered_pids, · 720 unmodified lines | ||
| 721 | 721 | pos = 0; |
| 722 | 722 | |
| 723 | 723 | ret = trace_get_user(&parser, ubuf, cnt, &pos); |
| 724 | − if (ret < 0 || !trace_parser_loaded(&parser)) | |
| 724 | + if (ret < 0) | |
| 725 | 725 | break; |
| 726 | 726 | |
| 727 | 727 | read += ret; |
| 728 | 728 | ubuf += ret; |
| 729 | 729 | cnt -= ret; |
| 730 | 730 | |
| 731 | + if (!trace_parser_loaded(&parser)) | |
| 732 | + break; | |
| 733 | + | |
| 731 | 734 | ret = -EINVAL; |
| 732 | 735 | if (kstrtoul(parser.buffer, 0, &val)) |
| 733 | 736 | break; |
| @@ -753,7 +756,6 @@ int trace_pid_write(struct trace_pid_list *filtered_pids, · 19 unmodified lines | ||
| 753 | 756 | if (!nr_pids) { |
| 754 | 757 | /* Cleared the list of pids */ |
| 755 | 758 | trace_pid_list_free(pid_list); |
| 756 | − read = ret; | |
| 757 | 759 | pid_list = NULL; |
| 758 | 760 | } |
| 759 | 761 | |
| @@ -1174,7 +1176,7 @@ void tracing_snapshot_cond(struct trace_array *tr, void *cond_data) · 414 unmodified lines | ||
| 1174 | 1176 | EXPORT_SYMBOL_GPL(tracing_snapshot_cond); |
| 1175 | 1177 | |
| 1176 | 1178 | /** |
| 1177 | − * tracing_snapshot_cond_data - get the user data associated with a snapshot | |
| 1179 | + * tracing_cond_snapshot_data - get the user data associated with a snapshot | |
| 1178 | 1180 | * @tr: The tracing instance |
| 1179 | 1181 | * |
| 1180 | 1182 | * When the user enables a conditional snapshot using |
| @@ -1542,6 +1544,7 @@ static struct { · 361 unmodified lines | ||
| 1542 | 1544 | { ktime_get_mono_fast_ns, "mono", 1 }, |
| 1543 | 1545 | { ktime_get_raw_fast_ns, "mono_raw", 1 }, |
| 1544 | 1546 | { ktime_get_boot_fast_ns, "boot", 1 }, |
| 1547 | + { ktime_get_tai_fast_ns, "tai", 1 }, | |
| 1545 | 1548 | ARCH_TRACE_CLOCKS |
| 1546 | 1549 | }; |
| 1547 | 1550 | |
| @@ -2835,7 +2838,7 @@ trace_event_buffer_lock_reserve(struct trace_buffer **current_rb, · 1287 unmodified lines | ||
| 2835 | 2838 | } |
| 2836 | 2839 | EXPORT_SYMBOL_GPL(trace_event_buffer_lock_reserve); |
| 2837 | 2840 | |
| 2838 | −static DEFINE_SPINLOCK(tracepoint_iter_lock); | |
| 2841 | +static DEFINE_RAW_SPINLOCK(tracepoint_iter_lock); | |
| 2839 | 2842 | static DEFINE_MUTEX(tracepoint_printk_mutex); |
| 2840 | 2843 | |
| 2841 | 2844 | static void output_printk(struct trace_event_buffer *fbuffer) |
| @@ -2863,14 +2866,14 @@ static void output_printk(struct trace_event_buffer *fbuffer) · 21 unmodified lines | ||
| 2863 | 2866 | |
| 2864 | 2867 | event = &fbuffer->trace_file->event_call->event; |
| 2865 | 2868 | |
| 2866 | − spin_lock_irqsave(&tracepoint_iter_lock, flags); | |
| 2869 | + raw_spin_lock_irqsave(&tracepoint_iter_lock, flags); | |
| 2867 | 2870 | trace_seq_init(&iter->seq); |
| 2868 | 2871 | iter->ent = fbuffer->entry; |
| 2869 | 2872 | event_call->event.funcs->trace(iter, 0, event); |
| 2870 | 2873 | trace_seq_putc(&iter->seq, 0); |
| 2871 | 2874 | printk("%s", iter->seq.buffer); |
| 2872 | 2875 | |
| 2873 | − spin_unlock_irqrestore(&tracepoint_iter_lock, flags); | |
| 2876 | + raw_spin_unlock_irqrestore(&tracepoint_iter_lock, flags); | |
| 2874 | 2877 | } |
| 2875 | 2878 | |
| 2876 | 2879 | int tracepoint_printk_sysctl(struct ctl_table *table, int write, |
| @@ -4249,7 +4252,7 @@ static void print_func_help_header_irq(struct array_buffer *buf, struct seq_file · 1372 unmodified lines | ||
| 4249 | 4252 | unsigned int flags) |
| 4250 | 4253 | { |
| 4251 | 4254 | bool tgid = flags & TRACE_ITER_RECORD_TGID; |
| 4252 | − const char *space = " "; | |
| 4255 | + static const char space[] = " "; | |
| 4253 | 4256 | int prec = tgid ? 12 : 2; |
| 4254 | 4257 | |
| 4255 | 4258 | print_event_info(buf, m); |
| @@ -4273,9 +4276,7 @@ print_trace_header(struct seq_file *m, struct trace_iterator *iter) · 17 unmodified lines | ||
| 4273 | 4276 | struct tracer *type = iter->trace; |
| 4274 | 4277 | unsigned long entries; |
| 4275 | 4278 | unsigned long total; |
| 4276 | − const char *name = "preemption"; | |
| 4277 | − | |
| 4278 | − name = type->name; | |
| 4279 | + const char *name = type->name; | |
| 4279 | 4280 | |
| 4280 | 4281 | get_total_entries(buf, &total, &entries); |
| 4281 | 4282 | |
| @@ -5469,7 +5470,7 @@ static const char readme_msg[] = · 1187 unmodified lines | ||
| 5469 | 5470 | " error_log\t- error log for failed commands (that support it)\n" |
| 5470 | 5471 | " buffer_size_kb\t- view and modify size of per cpu buffer\n" |
| 5471 | 5472 | " buffer_total_size_kb - view total size of all cpu buffers\n\n" |
| 5472 | − " trace_clock\t\t-change the clock used to order events\n" | |
| 5473 | + " trace_clock\t\t- change the clock used to order events\n" | |
| 5473 | 5474 | " local: Per cpu clock but may not be synced across CPUs\n" |
| 5474 | 5475 | " global: Synced across CPUs but slows tracing down.\n" |
| 5475 | 5476 | " counter: Not a clock, but just an increment\n" |
| @@ -5478,7 +5479,7 @@ static const char readme_msg[] = · 2 unmodified lines | ||
| 5478 | 5479 | #ifdef CONFIG_X86_64 |
| 5479 | 5480 | " x86-tsc: TSC cycle counter\n" |
| 5480 | 5481 | #endif |
| 5481 | − "\n timestamp_mode\t-view the mode used to timestamp events\n" | |
| 5482 | + "\n timestamp_mode\t- view the mode used to timestamp events\n" | |
| 5482 | 5483 | " delta: Delta difference against a buffer-wide timestamp\n" |
| 5483 | 5484 | " absolute: Absolute (standalone) timestamp\n" |
| 5484 | 5485 | "\n trace_marker\t\t- Writes into this file writes into the kernel buffer\n" |
| @@ -6326,12 +6327,18 @@ static void tracing_set_nop(struct trace_array *tr) · 841 unmodified lines | ||
| 6326 | 6327 | tr->current_trace = &nop_trace; |
| 6327 | 6328 | } |
| 6328 | 6329 | |
| 6330 | +static bool tracer_options_updated; | |
| 6331 | + | |
| 6329 | 6332 | static void add_tracer_options(struct trace_array *tr, struct tracer *t) |
| 6330 | 6333 | { |
| 6331 | 6334 | /* Only enable if the directory has been created already. */ |
| 6332 | 6335 | if (!tr->dir) |
| 6333 | 6336 | return; |
| 6334 | 6337 | |
| 6338 | + /* Only create trace option files after update_tracer_options finish */ | |
| 6339 | + if (!tracer_options_updated) | |
| 6340 | + return; | |
| 6341 | + | |
| 6335 | 6342 | create_trace_option_files(tr, t); |
| 6336 | 6343 | } |
| 6337 | 6344 | |
| @@ -6448,7 +6455,7 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf, · 110 unmodified lines | ||
| 6448 | 6455 | { |
| 6449 | 6456 | struct trace_array *tr = filp->private_data; |
| 6450 | 6457 | char buf[MAX_TRACER_SIZE+1]; |
| 6451 | − int i; | |
| 6458 | + char *name; | |
| 6452 | 6459 | size_t ret; |
| 6453 | 6460 | int err; |
| 6454 | 6461 | |
| @@ -6462,11 +6469,9 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf, · 7 unmodified lines | ||
| 6462 | 6469 | |
| 6463 | 6470 | buf[cnt] = 0; |
| 6464 | 6471 | |
| 6465 | − /* strip ending whitespace. */ | |
| 6466 | − for (i = cnt - 1; i > 0 && isspace(buf[i]); i--) | |
| 6467 | − buf[i] = 0; | |
| 6472 | + name = strim(buf); | |
| 6468 | 6473 | |
| 6469 | − err = tracing_set_tracer(tr, buf); | |
| 6474 | + err = tracing_set_tracer(tr, name); | |
| 6470 | 6475 | if (err) |
| 6471 | 6476 | return err; |
| 6472 | 6477 | |
| @@ -9170,6 +9175,7 @@ static void __update_tracer_options(struct trace_array *tr) · 2697 unmodified lines | ||
| 9170 | 9175 | static void update_tracer_options(struct trace_array *tr) |
| 9171 | 9176 | { |
| 9172 | 9177 | mutex_lock(&trace_types_lock); |
| 9178 | + tracer_options_updated = true; | |
| 9173 | 9179 | __update_tracer_options(tr); |
| 9174 | 9180 | mutex_unlock(&trace_types_lock); |
| 9175 | 9181 | } |
| @@ -9602,6 +9608,7 @@ extern struct trace_eval_map *__stop_ftrace_eval_maps[]; · 426 unmodified lines | ||
| 9602 | 9608 | |
| 9603 | 9609 | static struct workqueue_struct *eval_map_wq __initdata; |
| 9604 | 9610 | static struct work_struct eval_map_work __initdata; |
| 9611 | +static struct work_struct tracerfs_init_work __initdata; | |
| 9605 | 9612 | |
| 9606 | 9613 | static void __init eval_map_work_func(struct work_struct *work) |
| 9607 | 9614 | { |
| @@ -9627,6 +9634,8 @@ static int __init trace_eval_init(void) · 19 unmodified lines | ||
| 9627 | 9634 | return 0; |
| 9628 | 9635 | } |
| 9629 | 9636 | |
| 9637 | +subsys_initcall(trace_eval_init); | |
| 9638 | + | |
| 9630 | 9639 | static int __init trace_eval_sync(void) |
| 9631 | 9640 | { |
| 9632 | 9641 | /* Make sure the eval map updates are finished */ |
| @@ -9709,15 +9718,8 @@ static struct notifier_block trace_module_nb = { · 76 unmodified lines | ||
| 9709 | 9718 | }; |
| 9710 | 9719 | #endif /* CONFIG_MODULES */ |
| 9711 | 9720 | |
| 9712 | −static __init int tracer_init_tracefs(void) | |
| 9721 | +static __init void tracer_init_tracefs_work_func(struct work_struct *work) | |
| 9713 | 9722 | { |
| 9714 | − int ret; | |
| 9715 | − | |
| 9716 | − trace_access_lock_init(); | |
| 9717 | − | |
| 9718 | − ret = tracing_init_dentry(); | |
| 9719 | − if (ret) | |
| 9720 | − return 0; | |
| 9721 | 9723 | |
| 9722 | 9724 | event_trace_init(); |
| 9723 | 9725 | |
| @@ -9739,8 +9741,6 @@ static __init int tracer_init_tracefs(void) · 15 unmodified lines | ||
| 9739 | 9741 | trace_create_file("saved_tgids", TRACE_MODE_READ, NULL, |
| 9740 | 9742 | NULL, &tracing_saved_tgids_fops); |
| 9741 | 9743 | |
| 9742 | − trace_eval_init(); | |
| 9743 | − | |
| 9744 | 9744 | trace_create_eval_file(NULL); |
| 9745 | 9745 | |
| 9746 | 9746 | #ifdef CONFIG_MODULES |
| @@ -9755,6 +9755,24 @@ static __init int tracer_init_tracefs(void) · 8 unmodified lines | ||
| 9755 | 9755 | create_trace_instances(NULL); |
| 9756 | 9756 | |
| 9757 | 9757 | update_tracer_options(&global_trace); |
| 9758 | +} | |
| 9759 | + | |
| 9760 | +static __init int tracer_init_tracefs(void) | |
| 9761 | +{ | |
| 9762 | + int ret; | |
| 9763 | + | |
| 9764 | + trace_access_lock_init(); | |
| 9765 | + | |
| 9766 | + ret = tracing_init_dentry(); | |
| 9767 | + if (ret) | |
| 9768 | + return 0; | |
| 9769 | + | |
| 9770 | + if (eval_map_wq) { | |
| 9771 | + INIT_WORK(&tracerfs_init_work, tracer_init_tracefs_work_func); | |
| 9772 | + queue_work(eval_map_wq, &tracerfs_init_work); | |
| 9773 | + } else { | |
| 9774 | + tracer_init_tracefs_work_func(NULL); | |
| 9775 | + } | |
| 9758 | 9776 | |
| 9759 | 9777 | return 0; |
| 9760 | 9778 | } |
| @@ -1573,13 +1573,12 @@ struct enable_trigger_data { · 1572 unmodified lines | ||
| 1573 | 1573 | }; |
| 1574 | 1574 | |
| 1575 | 1575 | extern int event_enable_trigger_print(struct seq_file *m, |
| 1576 | − struct event_trigger_ops *ops, | |
| 1577 | − struct event_trigger_data *data); | |
| 1578 | −extern void event_enable_trigger_free(struct event_trigger_ops *ops, | |
| 1579 | 1576 | struct event_trigger_data *data); |
| 1577 | +extern void event_enable_trigger_free(struct event_trigger_data *data); | |
| 1580 | 1578 | extern int event_enable_trigger_parse(struct event_command *cmd_ops, |
| 1581 | 1579 | struct trace_event_file *file, |
| 1582 | − char *glob, char *cmd, char *param); | |
| 1580 | + char *glob, char *cmd, | |
| 1581 | + char *param_and_filter); | |
| 1583 | 1582 | extern int event_enable_register_trigger(char *glob, |
| 1584 | 1583 | struct event_trigger_data *data, |
| 1585 | 1584 | struct trace_event_file *file); |
| @@ -1587,8 +1586,7 @@ extern void event_enable_unregister_trigger(char *glob, · 1 unmodified line | ||
| 1587 | 1586 | struct event_trigger_data *test, |
| 1588 | 1587 | struct trace_event_file *file); |
| 1589 | 1588 | extern void trigger_data_free(struct event_trigger_data *data); |
| 1590 | −extern int event_trigger_init(struct event_trigger_ops *ops, | |
| 1591 | − struct event_trigger_data *data); | |
| 1589 | +extern int event_trigger_init(struct event_trigger_data *data); | |
| 1592 | 1590 | extern int trace_event_trigger_enable_disable(struct trace_event_file *file, |
| 1593 | 1591 | int trigger_enable); |
| 1594 | 1592 | extern void update_cond_flag(struct trace_event_file *file); |
| @@ -1629,10 +1627,11 @@ extern void event_trigger_reset_filter(struct event_command *cmd_ops, · 34 unmodified lines | ||
| 1629 | 1627 | extern int event_trigger_register(struct event_command *cmd_ops, |
| 1630 | 1628 | struct trace_event_file *file, |
| 1631 | 1629 | char *glob, |
| 1632 | − char *cmd, | |
| 1633 | − char *trigger, | |
| 1634 | − struct event_trigger_data *trigger_data, | |
| 1635 | − int *n_registered); | |
| 1630 | + struct event_trigger_data *trigger_data); | |
| 1631 | +extern void event_trigger_unregister(struct event_command *cmd_ops, | |
| 1632 | + struct trace_event_file *file, | |
| 1633 | + char *glob, | |
| 1634 | + struct event_trigger_data *trigger_data); | |
| 1636 | 1635 | |
| 1637 | 1636 | /** |
| 1638 | 1637 | * struct event_trigger_ops - callbacks for trace event triggers |
| @@ -1686,12 +1685,9 @@ struct event_trigger_ops { · 47 unmodified lines | ||
| 1686 | 1685 | struct trace_buffer *buffer, |
| 1687 | 1686 | void *rec, |
| 1688 | 1687 | struct ring_buffer_event *rbe); |
| 1689 | − int (*init)(struct event_trigger_ops *ops, | |
| 1690 | − struct event_trigger_data *data); | |
| 1691 | − void (*free)(struct event_trigger_ops *ops, | |
| 1692 | − struct event_trigger_data *data); | |
| 1688 | + int (*init)(struct event_trigger_data *data); | |
| 1689 | + void (*free)(struct event_trigger_data *data); | |
| 1693 | 1690 | int (*print)(struct seq_file *m, |
| 1694 | − struct event_trigger_ops *ops, | |
| 1695 | 1691 | struct event_trigger_data *data); |
| 1696 | 1692 | }; |
| 1697 | 1693 | |
| @@ -300,7 +300,7 @@ trace_boot_hist_add_handlers(struct xbc_node *hnode, char **bufp, · 299 unmodified lines | ||
| 300 | 300 | { |
| 301 | 301 | struct xbc_node *node; |
| 302 | 302 | const char *p, *handler; |
| 303 | − int ret; | |
| 303 | + int ret = 0; | |
| 304 | 304 | |
| 305 | 305 | handler = xbc_node_get_data(hnode); |
| 306 | 306 | |
| @@ -255,19 +255,14 @@ static const struct file_operations dynamic_events_ops = { · 254 unmodified lines | ||
| 255 | 255 | /* Make a tracefs interface for controlling dynamic events */ |
| 256 | 256 | static __init int init_dynamic_event(void) |
| 257 | 257 | { |
| 258 | − struct dentry *entry; | |
| 259 | 258 | int ret; |
| 260 | 259 | |
| 261 | 260 | ret = tracing_init_dentry(); |
| 262 | 261 | if (ret) |
| 263 | 262 | return 0; |
| 264 | 263 | |
| 265 | − entry = tracefs_create_file("dynamic_events", TRACE_MODE_WRITE, NULL, | |
| 266 | − NULL, &dynamic_events_ops); | |
| 267 | − | |
| 268 | − /* Event list interface */ | |
| 269 | − if (!entry) | |
| 270 | − pr_warn("Could not create tracefs 'dynamic_events' entry\n"); | |
| 264 | + trace_create_file("dynamic_events", TRACE_MODE_WRITE, NULL, | |
| 265 | + NULL, &dynamic_events_ops); | |
| 271 | 266 | |
| 272 | 267 | return 0; |
| 273 | 268 | } |
| @@ -511,20 +511,17 @@ __eprobe_trace_func(struct eprobe_data *edata, void *rec) · 510 unmodified lines | ||
| 511 | 511 | * functions are just stubs to fulfill what is needed to use the trigger |
| 512 | 512 | * infrastructure. |
| 513 | 513 | */ |
| 514 | −static int eprobe_trigger_init(struct event_trigger_ops *ops, | |
| 515 | − struct event_trigger_data *data) | |
| 514 | +static int eprobe_trigger_init(struct event_trigger_data *data) | |
| 516 | 515 | { |
| 517 | 516 | return 0; |
| 518 | 517 | } |
| 519 | 518 | |
| 520 | −static void eprobe_trigger_free(struct event_trigger_ops *ops, | |
| 521 | − struct event_trigger_data *data) | |
| 519 | +static void eprobe_trigger_free(struct event_trigger_data *data) | |
| 522 | 520 | { |
| 523 | 521 | |
| 524 | 522 | } |
| 525 | 523 | |
| 526 | 524 | static int eprobe_trigger_print(struct seq_file *m, |
| 527 | − struct event_trigger_ops *ops, | |
| 528 | 525 | struct event_trigger_data *data) |
| 529 | 526 | { |
| 530 | 527 | /* Do not print eprobe event triggers */ |
| @@ -549,7 +546,8 @@ static struct event_trigger_ops eprobe_trigger_ops = { · 18 unmodified lines | ||
| 549 | 546 | |
| 550 | 547 | static int eprobe_trigger_cmd_parse(struct event_command *cmd_ops, |
| 551 | 548 | struct trace_event_file *file, |
| 552 | − char *glob, char *cmd, char *param) | |
| 549 | + char *glob, char *cmd, | |
| 550 | + char *param_and_filter) | |
| 553 | 551 | { |
| 554 | 552 | return -1; |
| 555 | 553 | } |
| @@ -650,7 +648,7 @@ static struct trace_event_functions eprobe_funcs = { · 94 unmodified lines | ||
| 650 | 648 | static int disable_eprobe(struct trace_eprobe *ep, |
| 651 | 649 | struct trace_array *tr) |
| 652 | 650 | { |
| 653 | − struct event_trigger_data *trigger; | |
| 651 | + struct event_trigger_data *trigger = NULL, *iter; | |
| 654 | 652 | struct trace_event_file *file; |
| 655 | 653 | struct eprobe_data *edata; |
| 656 | 654 | |
| @@ -658,14 +656,16 @@ static int disable_eprobe(struct trace_eprobe *ep, · 1 unmodified line | ||
| 658 | 656 | if (!file) |
| 659 | 657 | return -ENOENT; |
| 660 | 658 | |
| 661 | − list_for_each_entry(trigger, &file->triggers, list) { | |
| 662 | − if (!(trigger->flags & EVENT_TRIGGER_FL_PROBE)) | |
| 659 | + list_for_each_entry(iter, &file->triggers, list) { | |
| 660 | + if (!(iter->flags & EVENT_TRIGGER_FL_PROBE)) | |
| 663 | 661 | continue; |
| 664 | − edata = trigger->private_data; | |
| 665 | − if (edata->ep == ep) | |
| 662 | + edata = iter->private_data; | |
| 663 | + if (edata->ep == ep) { | |
| 664 | + trigger = iter; | |
| 666 | 665 | break; |
| 666 | + } | |
| 667 | 667 | } |
| 668 | − if (list_entry_is_head(trigger, &file->triggers, list)) | |
| 668 | + if (!trigger) | |
| 669 | 669 | return -ENODEV; |
| 670 | 670 | |
| 671 | 671 | list_del_rcu(&trigger->list); |
| @@ -392,12 +392,6 @@ static void test_event_printk(struct trace_event_call *call) · 391 unmodified lines | ||
| 392 | 392 | if (!(dereference_flags & (1ULL << arg))) |
| 393 | 393 | goto next_arg; |
| 394 | 394 | |
| 395 | − /* Check for __get_sockaddr */; | |
| 396 | − if (str_has_prefix(fmt + i, "__get_sockaddr(")) { | |
| 397 | − dereference_flags &= ~(1ULL << arg); | |
| 398 | − goto next_arg; | |
| 399 | − } | |
| 400 | − | |
| 401 | 395 | /* Find the REC-> in the argument */ |
| 402 | 396 | c = strchr(fmt + i, ','); |
| 403 | 397 | r = strstr(fmt + i, "REC->"); |
| @@ -413,7 +407,14 @@ static void test_event_printk(struct trace_event_call *call) · 9 unmodified lines | ||
| 413 | 407 | a = strchr(fmt + i, '&'); |
| 414 | 408 | if ((a && (a < r)) || test_field(r, call)) |
| 415 | 409 | dereference_flags &= ~(1ULL << arg); |
| 410 | + } else if ((r = strstr(fmt + i, "__get_dynamic_array(")) && | |
| 411 | + (!c || r < c)) { | |
| 412 | + dereference_flags &= ~(1ULL << arg); | |
| 413 | + } else if ((r = strstr(fmt + i, "__get_sockaddr(")) && | |
| 414 | + (!c || r < c)) { | |
| 415 | + dereference_flags &= ~(1ULL << arg); | |
| 416 | 416 | } |
| 417 | + | |
| 417 | 418 | next_arg: |
| 418 | 419 | i--; |
| 419 | 420 | arg++; |
| @@ -1723,9 +1724,9 @@ static LIST_HEAD(event_subsystems); · 1303 unmodified lines | ||
| 1723 | 1724 | |
| 1724 | 1725 | static int subsystem_open(struct inode *inode, struct file *filp) |
| 1725 | 1726 | { |
| 1727 | + struct trace_subsystem_dir *dir = NULL, *iter_dir; | |
| 1728 | + struct trace_array *tr = NULL, *iter_tr; | |
| 1726 | 1729 | struct event_subsystem *system = NULL; |
| 1727 | − struct trace_subsystem_dir *dir = NULL; /* Initialize for gcc */ | |
| 1728 | − struct trace_array *tr; | |
| 1729 | 1730 | int ret; |
| 1730 | 1731 | |
| 1731 | 1732 | if (tracing_is_disabled()) |
| @@ -1734,10 +1735,12 @@ static int subsystem_open(struct inode *inode, struct file *filp) · 2 unmodified lines | ||
| 1734 | 1735 | /* Make sure the system still exists */ |
| 1735 | 1736 | mutex_lock(&event_mutex); |
| 1736 | 1737 | mutex_lock(&trace_types_lock); |
| 1737 | − list_for_each_entry(tr, &ftrace_trace_arrays, list) { | |
| 1738 | − list_for_each_entry(dir, &tr->systems, list) { | |
| 1739 | − if (dir == inode->i_private) { | |
| 1738 | + list_for_each_entry(iter_tr, &ftrace_trace_arrays, list) { | |
| 1739 | + list_for_each_entry(iter_dir, &iter_tr->systems, list) { | |
| 1740 | + if (iter_dir == inode->i_private) { | |
| 1740 | 1741 | /* Don't open systems with no events */ |
| 1742 | + tr = iter_tr; | |
| 1743 | + dir = iter_dir; | |
| 1741 | 1744 | if (dir->nr_events) { |
| 1742 | 1745 | __get_system_dir(dir); |
| 1743 | 1746 | system = dir->subsystem; |
| @@ -1753,9 +1756,6 @@ static int subsystem_open(struct inode *inode, struct file *filp) · 9 unmodified lines | ||
| 1753 | 1756 | if (!system) |
| 1754 | 1757 | return -ENODEV; |
| 1755 | 1758 | |
| 1756 | − /* Some versions of gcc think dir can be uninitialized here */ | |
| 1757 | − WARN_ON(!dir); | |
| 1758 | − | |
| 1759 | 1759 | /* Still need to increment the ref count of the system */ |
| 1760 | 1760 | if (trace_array_get(tr) < 0) { |
| 1761 | 1761 | put_system(dir); |
| @@ -2280,8 +2280,8 @@ static struct dentry * · 518 unmodified lines | ||
| 2280 | 2280 | event_subsystem_dir(struct trace_array *tr, const char *name, |
| 2281 | 2281 | struct trace_event_file *file, struct dentry *parent) |
| 2282 | 2282 | { |
| 2283 | + struct event_subsystem *system, *iter; | |
| 2283 | 2284 | struct trace_subsystem_dir *dir; |
| 2284 | − struct event_subsystem *system; | |
| 2285 | 2285 | struct dentry *entry; |
| 2286 | 2286 | |
| 2287 | 2287 | /* First see if we did not already create this dir */ |
| @@ -2295,13 +2295,13 @@ event_subsystem_dir(struct trace_array *tr, const char *name, · 7 unmodified lines | ||
| 2295 | 2295 | } |
| 2296 | 2296 | |
| 2297 | 2297 | /* Now see if the system itself exists. */ |
| 2298 | − list_for_each_entry(system, &event_subsystems, list) { | |
| 2299 | − if (strcmp(system->name, name) == 0) | |
| 2298 | + system = NULL; | |
| 2299 | + list_for_each_entry(iter, &event_subsystems, list) { | |
| 2300 | + if (strcmp(iter->name, name) == 0) { | |
| 2301 | + system = iter; | |
| 2300 | 2302 | break; |
| 2303 | + } | |
| 2301 | 2304 | } |
| 2302 | − /* Reset system variable when not found */ | |
| 2303 | − if (&system->list == &event_subsystems) | |
| 2304 | − system = NULL; | |
| 2305 | 2305 | |
| 2306 | 2306 | dir = kmalloc(sizeof(*dir), GFP_KERNEL); |
| 2307 | 2307 | if (!dir) |
| @@ -3546,12 +3546,10 @@ create_event_toplevel_files(struct dentry *parent, struct trace_array *tr) · 1238 unmodified lines | ||
| 3546 | 3546 | struct dentry *d_events; |
| 3547 | 3547 | struct dentry *entry; |
| 3548 | 3548 | |
| 3549 | − entry = tracefs_create_file("set_event", TRACE_MODE_WRITE, parent, | |
| 3550 | − tr, &ftrace_set_event_fops); | |
| 3551 | − if (!entry) { | |
| 3552 | − pr_warn("Could not create tracefs 'set_event' entry\n"); | |
| 3549 | + entry = trace_create_file("set_event", TRACE_MODE_WRITE, parent, | |
| 3550 | + tr, &ftrace_set_event_fops); | |
| 3551 | + if (!entry) | |
| 3553 | 3552 | return -ENOMEM; |
| 3554 | − } | |
| 3555 | 3553 | |
| 3556 | 3554 | d_events = tracefs_create_dir("events", parent); |
| 3557 | 3555 | if (!d_events) { |
| @@ -3566,16 +3564,12 @@ create_event_toplevel_files(struct dentry *parent, struct trace_array *tr) · 8 unmodified lines | ||
| 3566 | 3564 | |
| 3567 | 3565 | /* There are not as crucial, just warn if they are not created */ |
| 3568 | 3566 | |
| 3569 | − entry = tracefs_create_file("set_event_pid", TRACE_MODE_WRITE, parent, | |
| 3570 | − tr, &ftrace_set_event_pid_fops); | |
| 3571 | − if (!entry) | |
| 3572 | − pr_warn("Could not create tracefs 'set_event_pid' entry\n"); | |
| 3567 | + trace_create_file("set_event_pid", TRACE_MODE_WRITE, parent, | |
| 3568 | + tr, &ftrace_set_event_pid_fops); | |
| 3573 | 3569 | |
| 3574 | − entry = tracefs_create_file("set_event_notrace_pid", | |
| 3575 | − TRACE_MODE_WRITE, parent, tr, | |
| 3576 | − &ftrace_set_event_notrace_pid_fops); | |
| 3577 | − if (!entry) | |
| 3578 | − pr_warn("Could not create tracefs 'set_event_notrace_pid' entry\n"); | |
| 3570 | + trace_create_file("set_event_notrace_pid", | |
| 3571 | + TRACE_MODE_WRITE, parent, tr, | |
| 3572 | + &ftrace_set_event_notrace_pid_fops); | |
| 3579 | 3573 | |
| 3580 | 3574 | /* ring buffer internal formats */ |
| 3581 | 3575 | trace_create_file("header_page", TRACE_MODE_READ, d_events, |
| @@ -3790,17 +3784,14 @@ static __init int event_trace_init_fields(void) · 208 unmodified lines | ||
| 3790 | 3784 | __init int event_trace_init(void) |
| 3791 | 3785 | { |
| 3792 | 3786 | struct trace_array *tr; |
| 3793 | − struct dentry *entry; | |
| 3794 | 3787 | int ret; |
| 3795 | 3788 | |
| 3796 | 3789 | tr = top_trace_array(); |
| 3797 | 3790 | if (!tr) |
| 3798 | 3791 | return -ENODEV; |
| 3799 | 3792 | |
| 3800 | − entry = tracefs_create_file("available_events", TRACE_MODE_READ, | |
| 3801 | − NULL, tr, &ftrace_avail_fops); | |
| 3802 | − if (!entry) | |
| 3803 | − pr_warn("Could not create tracefs 'available_events' entry\n"); | |
| 3793 | + trace_create_file("available_events", TRACE_MODE_READ, | |
| 3794 | + NULL, tr, &ftrace_avail_fops); | |
| 3804 | 3795 | |
| 3805 | 3796 | ret = early_event_add_tracer(NULL, tr); |
| 3806 | 3797 | if (ret) |
| @@ -1816,7 +1816,7 @@ static void create_filter_finish(struct filter_parse_error *pe) · 1815 unmodified lines | ||
| 1816 | 1816 | * create_filter - create a filter for a trace_event_call |
| 1817 | 1817 | * @tr: the trace array associated with these events |
| 1818 | 1818 | * @call: trace_event_call to create a filter for |
| 1819 | − * @filter_str: filter string | |
| 1819 | + * @filter_string: filter string | |
| 1820 | 1820 | * @set_str: remember @filter_str and enable detailed error in filter |
| 1821 | 1821 | * @filterp: out param for created filter (always updated on return) |
| 1822 | 1822 | * Must be a pointer that references a NULL pointer. |
| @@ -2093,8 +2093,11 @@ static int init_var_ref(struct hist_field *ref_field, · 2092 unmodified lines | ||
| 2093 | 2093 | return err; |
| 2094 | 2094 | free: |
| 2095 | 2095 | kfree(ref_field->system); |
| 2096 | + ref_field->system = NULL; | |
| 2096 | 2097 | kfree(ref_field->event_name); |
| 2098 | + ref_field->event_name = NULL; | |
| 2097 | 2099 | kfree(ref_field->name); |
| 2100 | + ref_field->name = NULL; | |
| 2098 | 2101 | |
| 2099 | 2102 | goto out; |
| 2100 | 2103 | } |
| @@ -2785,7 +2788,8 @@ static char *find_trigger_filter(struct hist_trigger_data *hist_data, · 684 unmodified lines | ||
| 2785 | 2788 | static struct event_command trigger_hist_cmd; |
| 2786 | 2789 | static int event_hist_trigger_parse(struct event_command *cmd_ops, |
| 2787 | 2790 | struct trace_event_file *file, |
| 2788 | − char *glob, char *cmd, char *param); | |
| 2791 | + char *glob, char *cmd, | |
| 2792 | + char *param_and_filter); | |
| 2789 | 2793 | |
| 2790 | 2794 | static bool compatible_keys(struct hist_trigger_data *target_hist_data, |
| 2791 | 2795 | struct hist_trigger_data *hist_data, |
| @@ -4161,7 +4165,7 @@ static int create_val_field(struct hist_trigger_data *hist_data, · 1369 unmodified lines | ||
| 4161 | 4165 | return __create_val_field(hist_data, val_idx, file, NULL, field_str, 0); |
| 4162 | 4166 | } |
| 4163 | 4167 | |
| 4164 | −static const char *no_comm = "(no comm)"; | |
| 4168 | +static const char no_comm[] = "(no comm)"; | |
| 4165 | 4169 | |
| 4166 | 4170 | static u64 hist_field_execname(struct hist_field *hist_field, |
| 4167 | 4171 | struct tracing_map_elt *elt, |
| @@ -5252,7 +5256,7 @@ static void hist_trigger_show(struct seq_file *m, · 1084 unmodified lines | ||
| 5252 | 5256 | seq_puts(m, "\n\n"); |
| 5253 | 5257 | |
| 5254 | 5258 | seq_puts(m, "# event histogram\n#\n# trigger info: "); |
| 5255 | − data->ops->print(m, data->ops, data); | |
| 5259 | + data->ops->print(m, data); | |
| 5256 | 5260 | seq_puts(m, "#\n\n"); |
| 5257 | 5261 | |
| 5258 | 5262 | hist_data = data->private_data; |
| @@ -5484,7 +5488,7 @@ static void hist_trigger_debug_show(struct seq_file *m, · 225 unmodified lines | ||
| 5484 | 5488 | seq_puts(m, "\n\n"); |
| 5485 | 5489 | |
| 5486 | 5490 | seq_puts(m, "# event histogram\n#\n# trigger info: "); |
| 5487 | − data->ops->print(m, data->ops, data); | |
| 5491 | + data->ops->print(m, data); | |
| 5488 | 5492 | seq_puts(m, "#\n\n"); |
| 5489 | 5493 | |
| 5490 | 5494 | hist_data = data->private_data; |
| @@ -5621,7 +5625,6 @@ static void hist_field_print(struct seq_file *m, struct hist_field *hist_field) · 130 unmodified lines | ||
| 5621 | 5625 | } |
| 5622 | 5626 | |
| 5623 | 5627 | static int event_hist_trigger_print(struct seq_file *m, |
| 5624 | − struct event_trigger_ops *ops, | |
| 5625 | 5628 | struct event_trigger_data *data) |
| 5626 | 5629 | { |
| 5627 | 5630 | struct hist_trigger_data *hist_data = data->private_data; |
| @@ -5729,8 +5732,7 @@ static int event_hist_trigger_print(struct seq_file *m, · 101 unmodified lines | ||
| 5729 | 5732 | return 0; |
| 5730 | 5733 | } |
| 5731 | 5734 | |
| 5732 | −static int event_hist_trigger_init(struct event_trigger_ops *ops, | |
| 5733 | − struct event_trigger_data *data) | |
| 5735 | +static int event_hist_trigger_init(struct event_trigger_data *data) | |
| 5734 | 5736 | { |
| 5735 | 5737 | struct hist_trigger_data *hist_data = data->private_data; |
| 5736 | 5738 | |
| @@ -5758,8 +5760,7 @@ static void unregister_field_var_hists(struct hist_trigger_data *hist_data) · 21 unmodified lines | ||
| 5758 | 5760 | } |
| 5759 | 5761 | } |
| 5760 | 5762 | |
| 5761 | −static void event_hist_trigger_free(struct event_trigger_ops *ops, | |
| 5762 | − struct event_trigger_data *data) | |
| 5763 | +static void event_hist_trigger_free(struct event_trigger_data *data) | |
| 5763 | 5764 | { |
| 5764 | 5765 | struct hist_trigger_data *hist_data = data->private_data; |
| 5765 | 5766 | |
| @@ -5788,25 +5789,23 @@ static struct event_trigger_ops event_hist_trigger_ops = { · 22 unmodified lines | ||
| 5788 | 5789 | .free = event_hist_trigger_free, |
| 5789 | 5790 | }; |
| 5790 | 5791 | |
| 5791 | −static int event_hist_trigger_named_init(struct event_trigger_ops *ops, | |
| 5792 | − struct event_trigger_data *data) | |
| 5792 | +static int event_hist_trigger_named_init(struct event_trigger_data *data) | |
| 5793 | 5793 | { |
| 5794 | 5794 | data->ref++; |
| 5795 | 5795 | |
| 5796 | 5796 | save_named_trigger(data->named_data->name, data); |
| 5797 | 5797 | |
| 5798 | − event_hist_trigger_init(ops, data->named_data); | |
| 5798 | + event_hist_trigger_init(data->named_data); | |
| 5799 | 5799 | |
| 5800 | 5800 | return 0; |
| 5801 | 5801 | } |
| 5802 | 5802 | |
| 5803 | −static void event_hist_trigger_named_free(struct event_trigger_ops *ops, | |
| 5804 | − struct event_trigger_data *data) | |
| 5803 | +static void event_hist_trigger_named_free(struct event_trigger_data *data) | |
| 5805 | 5804 | { |
| 5806 | 5805 | if (WARN_ON_ONCE(data->ref <= 0)) |
| 5807 | 5806 | return; |
| 5808 | 5807 | |
| 5809 | − event_hist_trigger_free(ops, data->named_data); | |
| 5808 | + event_hist_trigger_free(data->named_data); | |
| 5810 | 5809 | |
| 5811 | 5810 | data->ref--; |
| 5812 | 5811 | if (!data->ref) { |
| @@ -5933,6 +5932,48 @@ static bool hist_trigger_match(struct event_trigger_data *data, · 120 unmodified lines | ||
| 5933 | 5932 | return true; |
| 5934 | 5933 | } |
| 5935 | 5934 | |
| 5935 | +static bool existing_hist_update_only(char *glob, | |
| 5936 | + struct event_trigger_data *data, | |
| 5937 | + struct trace_event_file *file) | |
| 5938 | +{ | |
| 5939 | + struct hist_trigger_data *hist_data = data->private_data; | |
| 5940 | + struct event_trigger_data *test, *named_data = NULL; | |
| 5941 | + bool updated = false; | |
| 5942 | + | |
| 5943 | + if (!hist_data->attrs->pause && !hist_data->attrs->cont && | |
| 5944 | + !hist_data->attrs->clear) | |
| 5945 | + goto out; | |
| 5946 | + | |
| 5947 | + if (hist_data->attrs->name) { | |
| 5948 | + named_data = find_named_trigger(hist_data->attrs->name); | |
| 5949 | + if (named_data) { | |
| 5950 | + if (!hist_trigger_match(data, named_data, named_data, | |
| 5951 | + true)) | |
| 5952 | + goto out; | |
| 5953 | + } | |
| 5954 | + } | |
| 5955 | + | |
| 5956 | + if (hist_data->attrs->name && !named_data) | |
| 5957 | + goto out; | |
| 5958 | + | |
| 5959 | + list_for_each_entry(test, &file->triggers, list) { | |
| 5960 | + if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) { | |
| 5961 | + if (!hist_trigger_match(data, test, named_data, false)) | |
| 5962 | + continue; | |
| 5963 | + if (hist_data->attrs->pause) | |
| 5964 | + test->paused = true; | |
| 5965 | + else if (hist_data->attrs->cont) | |
| 5966 | + test->paused = false; | |
| 5967 | + else if (hist_data->attrs->clear) | |
| 5968 | + hist_clear(test); | |
| 5969 | + updated = true; | |
| 5970 | + goto out; | |
| 5971 | + } | |
| 5972 | + } | |
| 5973 | + out: | |
| 5974 | + return updated; | |
| 5975 | +} | |
| 5976 | + | |
| 5936 | 5977 | static int hist_register_trigger(char *glob, |
| 5937 | 5978 | struct event_trigger_data *data, |
| 5938 | 5979 | struct trace_event_file *file) |
| @@ -5961,19 +6002,11 @@ static int hist_register_trigger(char *glob, · 22 unmodified lines | ||
| 5961 | 6002 | |
| 5962 | 6003 | list_for_each_entry(test, &file->triggers, list) { |
| 5963 | 6004 | if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) { |
| 5964 | − if (!hist_trigger_match(data, test, named_data, false)) | |
| 5965 | − continue; | |
| 5966 | − if (hist_data->attrs->pause) | |
| 5967 | − test->paused = true; | |
| 5968 | − else if (hist_data->attrs->cont) | |
| 5969 | − test->paused = false; | |
| 5970 | − else if (hist_data->attrs->clear) | |
| 5971 | − hist_clear(test); | |
| 5972 | − else { | |
| 6005 | + if (hist_trigger_match(data, test, named_data, false)) { | |
| 5973 | 6006 | hist_err(tr, HIST_ERR_TRIGGER_EEXIST, 0); |
| 5974 | 6007 | ret = -EEXIST; |
| 6008 | + goto out; | |
| 5975 | 6009 | } |
| 5976 | − goto out; | |
| 5977 | 6010 | } |
| 5978 | 6011 | } |
| 5979 | 6012 | new: |
| @@ -5993,7 +6026,7 @@ static int hist_register_trigger(char *glob, · 13 unmodified lines | ||
| 5993 | 6026 | } |
| 5994 | 6027 | |
| 5995 | 6028 | if (data->ops->init) { |
| 5996 | − ret = data->ops->init(data->ops, data); | |
| 6029 | + ret = data->ops->init(data); | |
| 5997 | 6030 | if (ret < 0) |
| 5998 | 6031 | goto out; |
| 5999 | 6032 | } |
| @@ -6012,8 +6045,6 @@ static int hist_register_trigger(char *glob, · 12 unmodified lines | ||
| 6012 | 6045 | |
| 6013 | 6046 | if (named_data) |
| 6014 | 6047 | destroy_hist_data(hist_data); |
| 6015 | − | |
| 6016 | − ret++; | |
| 6017 | 6048 | out: |
| 6018 | 6049 | return ret; |
| 6019 | 6050 | } |
| @@ -6089,20 +6120,19 @@ static void hist_unregister_trigger(char *glob, · 69 unmodified lines | ||
| 6089 | 6120 | struct event_trigger_data *data, |
| 6090 | 6121 | struct trace_event_file *file) |
| 6091 | 6122 | { |
| 6123 | + struct event_trigger_data *test = NULL, *iter, *named_data = NULL; | |
| 6092 | 6124 | struct hist_trigger_data *hist_data = data->private_data; |
| 6093 | − struct event_trigger_data *test, *named_data = NULL; | |
| 6094 | − bool unregistered = false; | |
| 6095 | 6125 | |
| 6096 | 6126 | lockdep_assert_held(&event_mutex); |
| 6097 | 6127 | |
| 6098 | 6128 | if (hist_data->attrs->name) |
| 6099 | 6129 | named_data = find_named_trigger(hist_data->attrs->name); |
| 6100 | 6130 | |
| 6101 | − list_for_each_entry(test, &file->triggers, list) { | |
| 6102 | − if (test->cmd_ops->trigger_type == ETT_EVENT_HIST) { | |
| 6103 | − if (!hist_trigger_match(data, test, named_data, false)) | |
| 6131 | + list_for_each_entry(iter, &file->triggers, list) { | |
| 6132 | + if (iter->cmd_ops->trigger_type == ETT_EVENT_HIST) { | |
| 6133 | + if (!hist_trigger_match(data, iter, named_data, false)) | |
| 6104 | 6134 | continue; |
| 6105 | − unregistered = true; | |
| 6135 | + test = iter; | |
| 6106 | 6136 | list_del_rcu(&test->list); |
| 6107 | 6137 | trace_event_trigger_enable_disable(file, 0); |
| 6108 | 6138 | update_cond_flag(file); |
| @@ -6110,11 +6140,11 @@ static void hist_unregister_trigger(char *glob, · 1 unmodified line | ||
| 6110 | 6140 | } |
| 6111 | 6141 | } |
| 6112 | 6142 | |
| 6113 | − if (unregistered && test->ops->free) | |
| 6114 | − test->ops->free(test->ops, test); | |
| 6143 | + if (test && test->ops->free) | |
| 6144 | + test->ops->free(test); | |
| 6115 | 6145 | |
| 6116 | 6146 | if (hist_data->enable_timestamps) { |
| 6117 | − if (!hist_data->remove || unregistered) | |
| 6147 | + if (!hist_data->remove || test) | |
| 6118 | 6148 | tracing_set_filter_buffering(file->tr, false); |
| 6119 | 6149 | } |
| 6120 | 6150 | } |
| @@ -6164,57 +6194,57 @@ static void hist_unreg_all(struct trace_event_file *file) · 43 unmodified lines | ||
| 6164 | 6194 | if (hist_data->enable_timestamps) |
| 6165 | 6195 | tracing_set_filter_buffering(file->tr, false); |
| 6166 | 6196 | if (test->ops->free) |
| 6167 | − test->ops->free(test->ops, test); | |
| 6197 | + test->ops->free(test); | |
| 6168 | 6198 | } |
| 6169 | 6199 | } |
| 6170 | 6200 | } |
| 6171 | 6201 | |
| 6172 | 6202 | static int event_hist_trigger_parse(struct event_command *cmd_ops, |
| 6173 | 6203 | struct trace_event_file *file, |
| 6174 | − char *glob, char *cmd, char *param) | |
| 6204 | + char *glob, char *cmd, | |
| 6205 | + char *param_and_filter) | |
| 6175 | 6206 | { |
| 6176 | 6207 | unsigned int hist_trigger_bits = TRACING_MAP_BITS_DEFAULT; |
| 6177 | 6208 | struct event_trigger_data *trigger_data; |
| 6178 | 6209 | struct hist_trigger_attrs *attrs; |
| 6179 | − struct event_trigger_ops *trigger_ops; | |
| 6180 | 6210 | struct hist_trigger_data *hist_data; |
| 6211 | + char *param, *filter, *p, *start; | |
| 6181 | 6212 | struct synth_event *se; |
| 6182 | 6213 | const char *se_name; |
| 6183 | − bool remove = false; | |
| 6184 | − char *trigger, *p, *start; | |
| 6214 | + bool remove; | |
| 6185 | 6215 | int ret = 0; |
| 6186 | 6216 | |
| 6187 | 6217 | lockdep_assert_held(&event_mutex); |
| 6188 | 6218 | |
| 6189 | − WARN_ON(!glob); | |
| 6219 | + if (WARN_ON(!glob)) | |
| 6220 | + return -EINVAL; | |
| 6190 | 6221 | |
| 6191 | − if (strlen(glob)) { | |
| 6222 | + if (glob[0]) { | |
| 6192 | 6223 | hist_err_clear(); |
| 6193 | − last_cmd_set(file, param); | |
| 6224 | + last_cmd_set(file, param_and_filter); | |
| 6194 | 6225 | } |
| 6195 | 6226 | |
| 6196 | − if (!param) | |
| 6197 | − return -EINVAL; | |
| 6227 | + remove = event_trigger_check_remove(glob); | |
| 6198 | 6228 | |
| 6199 | − if (glob[0] == '!') | |
| 6200 | − remove = true; | |
| 6229 | + if (event_trigger_empty_param(param_and_filter)) | |
| 6230 | + return -EINVAL; | |
| 6201 | 6231 | |
| 6202 | 6232 | /* |
| 6203 | 6233 | * separate the trigger from the filter (k:v [if filter]) |
| 6204 | 6234 | * allowing for whitespace in the trigger |
| 6205 | 6235 | */ |
| 6206 | − p = trigger = param; | |
| 6236 | + p = param = param_and_filter; | |
| 6207 | 6237 | do { |
| 6208 | 6238 | p = strstr(p, "if"); |
| 6209 | 6239 | if (!p) |
| 6210 | 6240 | break; |
| 6211 | − if (p == param) | |
| 6241 | + if (p == param_and_filter) | |
| 6212 | 6242 | return -EINVAL; |
| 6213 | 6243 | if (*(p - 1) != ' ' && *(p - 1) != '\t') { |
| 6214 | 6244 | p++; |
| 6215 | 6245 | continue; |
| 6216 | 6246 | } |
| 6217 | − if (p >= param + strlen(param) - (sizeof("if") - 1) - 1) | |
| 6247 | + if (p >= param_and_filter + strlen(param_and_filter) - (sizeof("if") - 1) - 1) | |
| 6218 | 6248 | return -EINVAL; |
| 6219 | 6249 | if (*(p + sizeof("if") - 1) != ' ' && *(p + sizeof("if") - 1) != '\t') { |
| 6220 | 6250 | p++; |
| @@ -6224,24 +6254,24 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops, · 3 unmodified lines | ||
| 6224 | 6254 | } while (1); |
| 6225 | 6255 | |
| 6226 | 6256 | if (!p) |
| 6227 | − param = NULL; | |
| 6257 | + filter = NULL; | |
| 6228 | 6258 | else { |
| 6229 | 6259 | *(p - 1) = '\0'; |
| 6230 | − param = strstrip(p); | |
| 6231 | − trigger = strstrip(trigger); | |
| 6260 | + filter = strstrip(p); | |
| 6261 | + param = strstrip(param); | |
| 6232 | 6262 | } |
| 6233 | 6263 | |
| 6234 | 6264 | /* |
| 6235 | 6265 | * To simplify arithmetic expression parsing, replace occurrences of |
| 6236 | 6266 | * '.sym-offset' modifier with '.symXoffset' |
| 6237 | 6267 | */ |
| 6238 | − start = strstr(trigger, ".sym-offset"); | |
| 6268 | + start = strstr(param, ".sym-offset"); | |
| 6239 | 6269 | while (start) { |
| 6240 | 6270 | *(start + 4) = 'X'; |
| 6241 | 6271 | start = strstr(start + 11, ".sym-offset"); |
| 6242 | 6272 | } |
| 6243 | 6273 | |
| 6244 | − attrs = parse_hist_trigger_attrs(file->tr, trigger); | |
| 6274 | + attrs = parse_hist_trigger_attrs(file->tr, param); | |
| 6245 | 6275 | if (IS_ERR(attrs)) |
| 6246 | 6276 | return PTR_ERR(attrs); |
| 6247 | 6277 | |
| @@ -6254,29 +6284,15 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops, · 6 unmodified lines | ||
| 6254 | 6284 | return PTR_ERR(hist_data); |
| 6255 | 6285 | } |
| 6256 | 6286 | |
| 6257 | − trigger_ops = cmd_ops->get_trigger_ops(cmd, trigger); | |
| 6258 | − | |
| 6259 | − trigger_data = kzalloc(sizeof(*trigger_data), GFP_KERNEL); | |
| 6287 | + trigger_data = event_trigger_alloc(cmd_ops, cmd, param, hist_data); | |
| 6260 | 6288 | if (!trigger_data) { |
| 6261 | 6289 | ret = -ENOMEM; |
| 6262 | 6290 | goto out_free; |
| 6263 | 6291 | } |
| 6264 | 6292 | |
| 6265 | − trigger_data->count = -1; | |
| 6266 | − trigger_data->ops = trigger_ops; | |
| 6267 | − trigger_data->cmd_ops = cmd_ops; | |
| 6268 | − | |
| 6269 | − INIT_LIST_HEAD(&trigger_data->list); | |
| 6270 | − RCU_INIT_POINTER(trigger_data->filter, NULL); | |
| 6271 | − | |
| 6272 | − trigger_data->private_data = hist_data; | |
| 6273 | − | |
| 6274 | − /* if param is non-empty, it's supposed to be a filter */ | |
| 6275 | − if (param && cmd_ops->set_filter) { | |
| 6276 | − ret = cmd_ops->set_filter(param, trigger_data, file); | |
| 6277 | − if (ret < 0) | |
| 6278 | − goto out_free; | |
| 6279 | − } | |
| 6293 | + ret = event_trigger_set_filter(cmd_ops, file, filter, trigger_data); | |
| 6294 | + if (ret < 0) | |
| 6295 | + goto out_free; | |
| 6280 | 6296 | |
| 6281 | 6297 | if (remove) { |
| 6282 | 6298 | if (!have_hist_trigger_match(trigger_data, file)) |
| @@ -6287,7 +6303,7 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops, · 4 unmodified lines | ||
| 6287 | 6303 | goto out_free; |
| 6288 | 6304 | } |
| 6289 | 6305 | |
| 6290 | − cmd_ops->unreg(glob+1, trigger_data, file); | |
| 6306 | + event_trigger_unregister(cmd_ops, file, glob+1, trigger_data); | |
| 6291 | 6307 | se_name = trace_event_name(file->event_call); |
| 6292 | 6308 | se = find_synth_event(se_name); |
| 6293 | 6309 | if (se) |
| @@ -6296,17 +6312,11 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops, · 2 unmodified lines | ||
| 6296 | 6312 | goto out_free; |
| 6297 | 6313 | } |
| 6298 | 6314 | |
| 6299 | − ret = cmd_ops->reg(glob, trigger_data, file); | |
| 6300 | − /* | |
| 6301 | − * The above returns on success the # of triggers registered, | |
| 6302 | − * but if it didn't register any it returns zero. Consider no | |
| 6303 | − * triggers registered a failure too. | |
| 6304 | − */ | |
| 6305 | − if (!ret) { | |
| 6306 | − if (!(attrs->pause || attrs->cont || attrs->clear)) | |
| 6307 | − ret = -ENOENT; | |
| 6315 | + if (existing_hist_update_only(glob, trigger_data, file)) | |
| 6308 | 6316 | goto out_free; |
| 6309 | − } else if (ret < 0) | |
| 6317 | + | |
| 6318 | + ret = event_trigger_register(cmd_ops, file, glob, trigger_data); | |
| 6319 | + if (ret < 0) | |
| 6310 | 6320 | goto out_free; |
| 6311 | 6321 | |
| 6312 | 6322 | if (get_named_trigger_data(trigger_data)) |
| @@ -6331,18 +6341,15 @@ enable: · 18 unmodified lines | ||
| 6331 | 6341 | se = find_synth_event(se_name); |
| 6332 | 6342 | if (se) |
| 6333 | 6343 | se->ref++; |
| 6334 | − /* Just return zero, not the number of registered triggers */ | |
| 6335 | − ret = 0; | |
| 6336 | 6344 | out: |
| 6337 | 6345 | if (ret == 0) |
| 6338 | 6346 | hist_err_clear(); |
| 6339 | 6347 | |
| 6340 | 6348 | return ret; |
| 6341 | 6349 | out_unreg: |
| 6342 | − cmd_ops->unreg(glob+1, trigger_data, file); | |
| 6350 | + event_trigger_unregister(cmd_ops, file, glob+1, trigger_data); | |
| 6343 | 6351 | out_free: |
| 6344 | − if (cmd_ops->set_filter) | |
| 6345 | − cmd_ops->set_filter(NULL, trigger_data, NULL); | |
| 6352 | + event_trigger_reset_filter(cmd_ops, trigger_data); | |
| 6346 | 6353 | |
| 6347 | 6354 | remove_hist_vars(hist_data); |
| 6348 | 6355 | |
| @@ -6463,7 +6470,7 @@ static void hist_enable_unreg_all(struct trace_event_file *file) · 114 unmodified lines | ||
| 6463 | 6470 | update_cond_flag(file); |
| 6464 | 6471 | trace_event_trigger_enable_disable(file, 0); |
| 6465 | 6472 | if (test->ops->free) |
| 6466 | − test->ops->free(test->ops, test); | |
| 6473 | + test->ops->free(test); | |
| 6467 | 6474 | } |
| 6468 | 6475 | } |
| 6469 | 6476 | } |
| @@ -188,7 +188,7 @@ static int trigger_show(struct seq_file *m, void *v) · 187 unmodified lines | ||
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | data = list_entry(v, struct event_trigger_data, list); |
| 191 | − data->ops->print(m, data->ops, data); | |
| 191 | + data->ops->print(m, data); | |
| 192 | 192 | |
| 193 | 193 | return 0; |
| 194 | 194 | } |
| @@ -432,7 +432,6 @@ event_trigger_print(const char *name, struct seq_file *m, · 237 unmodified lines | ||
| 432 | 432 | |
| 433 | 433 | /** |
| 434 | 434 | * event_trigger_init - Generic event_trigger_ops @init implementation |
| 435 | − * @ops: The trigger ops associated with the trigger | |
| 436 | 435 | * @data: Trigger-specific data |
| 437 | 436 | * |
| 438 | 437 | * Common implementation of event trigger initialization. |
| @@ -442,8 +441,7 @@ event_trigger_print(const char *name, struct seq_file *m, · 3 unmodified lines | ||
| 442 | 441 | * |
| 443 | 442 | * Return: 0 on success, errno otherwise |
| 444 | 443 | */ |
| 445 | −int event_trigger_init(struct event_trigger_ops *ops, | |
| 446 | − struct event_trigger_data *data) | |
| 444 | +int event_trigger_init(struct event_trigger_data *data) | |
| 447 | 445 | { |
| 448 | 446 | data->ref++; |
| 449 | 447 | return 0; |
| @@ -451,7 +449,6 @@ int event_trigger_init(struct event_trigger_ops *ops, · 1 unmodified line | ||
| 451 | 449 | |
| 452 | 450 | /** |
| 453 | 451 | * event_trigger_free - Generic event_trigger_ops @free implementation |
| 454 | − * @ops: The trigger ops associated with the trigger | |
| 455 | 452 | * @data: Trigger-specific data |
| 456 | 453 | * |
| 457 | 454 | * Common implementation of event trigger de-initialization. |
| @@ -460,8 +457,7 @@ int event_trigger_init(struct event_trigger_ops *ops, · 2 unmodified lines | ||
| 460 | 457 | * implementations. |
| 461 | 458 | */ |
| 462 | 459 | static void |
| 463 | −event_trigger_free(struct event_trigger_ops *ops, | |
| 464 | − struct event_trigger_data *data) | |
| 460 | +event_trigger_free(struct event_trigger_data *data) | |
| 465 | 461 | { |
| 466 | 462 | if (WARN_ON_ONCE(data->ref <= 0)) |
| 467 | 463 | return; |
| @@ -515,7 +511,7 @@ clear_event_triggers(struct trace_array *tr) · 47 unmodified lines | ||
| 515 | 511 | trace_event_trigger_enable_disable(file, 0); |
| 516 | 512 | list_del_rcu(&data->list); |
| 517 | 513 | if (data->ops->free) |
| 518 | − data->ops->free(data->ops, data); | |
| 514 | + data->ops->free(data); | |
| 519 | 515 | } |
| 520 | 516 | } |
| 521 | 517 | } |
| @@ -581,19 +577,18 @@ static int register_trigger(char *glob, · 59 unmodified lines | ||
| 581 | 577 | } |
| 582 | 578 | |
| 583 | 579 | if (data->ops->init) { |
| 584 | − ret = data->ops->init(data->ops, data); | |
| 580 | + ret = data->ops->init(data); | |
| 585 | 581 | if (ret < 0) |
| 586 | 582 | goto out; |
| 587 | 583 | } |
| 588 | 584 | |
| 589 | 585 | list_add_rcu(&data->list, &file->triggers); |
| 590 | − ret++; | |
| 591 | 586 | |
| 592 | 587 | update_cond_flag(file); |
| 593 | − if (trace_event_trigger_enable_disable(file, 1) < 0) { | |
| 588 | + ret = trace_event_trigger_enable_disable(file, 1); | |
| 589 | + if (ret < 0) { | |
| 594 | 590 | list_del_rcu(&data->list); |
| 595 | 591 | update_cond_flag(file); |
| 596 | − ret--; | |
| 597 | 592 | } |
| 598 | 593 | out: |
| 599 | 594 | return ret; |
| @@ -614,14 +609,13 @@ static void unregister_trigger(char *glob, · 14 unmodified lines | ||
| 614 | 609 | struct event_trigger_data *test, |
| 615 | 610 | struct trace_event_file *file) |
| 616 | 611 | { |
| 617 | − struct event_trigger_data *data; | |
| 618 | − bool unregistered = false; | |
| 612 | + struct event_trigger_data *data = NULL, *iter; | |
| 619 | 613 | |
| 620 | 614 | lockdep_assert_held(&event_mutex); |
| 621 | 615 | |
| 622 | − list_for_each_entry(data, &file->triggers, list) { | |
| 623 | − if (data->cmd_ops->trigger_type == test->cmd_ops->trigger_type) { | |
| 624 | − unregistered = true; | |
| 616 | + list_for_each_entry(iter, &file->triggers, list) { | |
| 617 | + if (iter->cmd_ops->trigger_type == test->cmd_ops->trigger_type) { | |
| 618 | + data = iter; | |
| 625 | 619 | list_del_rcu(&data->list); |
| 626 | 620 | trace_event_trigger_enable_disable(file, 0); |
| 627 | 621 | update_cond_flag(file); |
| @@ -629,8 +623,8 @@ static void unregister_trigger(char *glob, · 1 unmodified line | ||
| 629 | 623 | } |
| 630 | 624 | } |
| 631 | 625 | |
| 632 | − if (unregistered && data->ops->free) | |
| 633 | − data->ops->free(data->ops, data); | |
| 626 | + if (data && data->ops->free) | |
| 627 | + data->ops->free(data); | |
| 634 | 628 | } |
| 635 | 629 | |
| 636 | 630 | /* |
| @@ -744,15 +738,15 @@ bool event_trigger_empty_param(const char *param) · 107 unmodified lines | ||
| 744 | 738 | |
| 745 | 739 | /** |
| 746 | 740 | * event_trigger_separate_filter - separate an event trigger from a filter |
| 747 | − * @param: The param string containing trigger and possibly filter | |
| 748 | − * @trigger: outparam, will be filled with a pointer to the trigger | |
| 741 | + * @param_and_filter: String containing trigger and possibly filter | |
| 742 | + * @param: outparam, will be filled with a pointer to the trigger | |
| 749 | 743 | * @filter: outparam, will be filled with a pointer to the filter |
| 750 | 744 | * @param_required: Specifies whether or not the param string is required |
| 751 | 745 | * |
| 752 | 746 | * Given a param string of the form '[trigger] [if filter]', this |
| 753 | 747 | * function separates the filter from the trigger and returns the |
| 754 | − * trigger in *trigger and the filter in *filter. Either the *trigger | |
| 755 | − * or the *filter may be set to NULL by this function - if not set to | |
| 748 | + * trigger in @param and the filter in @filter. Either the @param | |
| 749 | + * or the @filter may be set to NULL by this function - if not set to | |
| 756 | 750 | * NULL, they will contain strings corresponding to the trigger and |
| 757 | 751 | * filter. |
| 758 | 752 | * |
| @@ -927,48 +921,37 @@ void event_trigger_reset_filter(struct event_command *cmd_ops, · 168 unmodified lines | ||
| 927 | 921 | * @cmd_ops: The event_command operations for the trigger |
| 928 | 922 | * @file: The event file for the trigger's event |
| 929 | 923 | * @glob: The trigger command string, with optional remove(!) operator |
| 930 | − * @cmd: The cmd string | |
| 931 | − * @param: The param string | |
| 932 | 924 | * @trigger_data: The trigger_data for the trigger |
| 933 | − * @n_registered: optional outparam, the number of triggers registered | |
| 934 | 925 | * |
| 935 | 926 | * Register an event trigger. The @cmd_ops are used to call the |
| 936 | − * cmd_ops->reg() function which actually does the registration. The | |
| 937 | − * cmd_ops->reg() function returns the number of triggers registered, | |
| 938 | − * which is assigned to n_registered, if n_registered is non-NULL. | |
| 927 | + * cmd_ops->reg() function which actually does the registration. | |
| 939 | 928 | * |
| 940 | 929 | * Return: 0 on success, errno otherwise |
| 941 | 930 | */ |
| 942 | 931 | int event_trigger_register(struct event_command *cmd_ops, |
| 943 | 932 | struct trace_event_file *file, |
| 944 | 933 | char *glob, |
| 945 | − char *cmd, | |
| 946 | − char *param, | |
| 947 | − struct event_trigger_data *trigger_data, | |
| 948 | − int *n_registered) | |
| 934 | + struct event_trigger_data *trigger_data) | |
| 949 | 935 | { |
| 950 | − int ret; | |
| 951 | − | |
| 952 | − if (n_registered) | |
| 953 | − *n_registered = 0; | |
| 954 | − | |
| 955 | − ret = cmd_ops->reg(glob, trigger_data, file); | |
| 956 | − /* | |
| 957 | − * The above returns on success the # of functions enabled, | |
| 958 | − * but if it didn't find any functions it returns zero. | |
| 959 | − * Consider no functions a failure too. | |
| 960 | − */ | |
| 961 | − if (!ret) { | |
| 962 | − cmd_ops->unreg(glob, trigger_data, file); | |
| 963 | − ret = -ENOENT; | |
| 964 | − } else if (ret > 0) { | |
| 965 | − if (n_registered) | |
| 966 | − *n_registered = ret; | |
| 967 | − /* Just return zero, not the number of enabled functions */ | |
| 968 | − ret = 0; | |
| 969 | − } | |
| 936 | + return cmd_ops->reg(glob, trigger_data, file); | |
| 937 | +} | |
| 970 | 938 | |
| 971 | − return ret; | |
| 939 | +/** | |
| 940 | + * event_trigger_unregister - unregister an event trigger | |
| 941 | + * @cmd_ops: The event_command operations for the trigger | |
| 942 | + * @file: The event file for the trigger's event | |
| 943 | + * @glob: The trigger command string, with optional remove(!) operator | |
| 944 | + * @trigger_data: The trigger_data for the trigger | |
| 945 | + * | |
| 946 | + * Unregister an event trigger. The @cmd_ops are used to call the | |
| 947 | + * cmd_ops->unreg() function which actually does the unregistration. | |
| 948 | + */ | |
| 949 | +void event_trigger_unregister(struct event_command *cmd_ops, | |
| 950 | + struct trace_event_file *file, | |
| 951 | + char *glob, | |
| 952 | + struct event_trigger_data *trigger_data) | |
| 953 | +{ | |
| 954 | + cmd_ops->unreg(glob, trigger_data, file); | |
| 972 | 955 | } |
| 973 | 956 | |
| 974 | 957 | /* |
| @@ -981,7 +964,7 @@ int event_trigger_register(struct event_command *cmd_ops, · 6 unmodified lines | ||
| 981 | 964 | * @file: The trace_event_file associated with the event |
| 982 | 965 | * @glob: The raw string used to register the trigger |
| 983 | 966 | * @cmd: The cmd portion of the string used to register the trigger |
| 984 | − * @param: The params portion of the string used to register the trigger | |
| 967 | + * @param_and_filter: The param and filter portion of the string used to register the trigger | |
| 985 | 968 | * |
| 986 | 969 | * Common implementation for event command parsing and trigger |
| 987 | 970 | * instantiation. |
| @@ -994,94 +977,53 @@ int event_trigger_register(struct event_command *cmd_ops, · 6 unmodified lines | ||
| 994 | 977 | static int |
| 995 | 978 | event_trigger_parse(struct event_command *cmd_ops, |
| 996 | 979 | struct trace_event_file *file, |
| 997 | − char *glob, char *cmd, char *param) | |
| 980 | + char *glob, char *cmd, char *param_and_filter) | |
| 998 | 981 | { |
| 999 | 982 | struct event_trigger_data *trigger_data; |
| 1000 | − struct event_trigger_ops *trigger_ops; | |
| 1001 | − char *trigger = NULL; | |
| 1002 | − char *number; | |
| 983 | + char *param, *filter; | |
| 984 | + bool remove; | |
| 1003 | 985 | int ret; |
| 1004 | 986 | |
| 1005 | − /* separate the trigger from the filter (t:n [if filter]) */ | |
| 1006 | − if (param && isdigit(param[0])) { | |
| 1007 | − trigger = strsep(¶m, " \t"); | |
| 1008 | − if (param) { | |
| 1009 | − param = skip_spaces(param); | |
| 1010 | − if (!*param) | |
| 1011 | − param = NULL; | |
| 1012 | − } | |
| 1013 | − } | |
| 987 | + remove = event_trigger_check_remove(glob); | |
| 1014 | 988 | |
| 1015 | − trigger_ops = cmd_ops->get_trigger_ops(cmd, trigger); | |
| 989 | + ret = event_trigger_separate_filter(param_and_filter, ¶m, &filter, false); | |
| 990 | + if (ret) | |
| 991 | + return ret; | |
| 1016 | 992 | |
| 1017 | 993 | ret = -ENOMEM; |
| 1018 | − trigger_data = kzalloc(sizeof(*trigger_data), GFP_KERNEL); | |
| 994 | + trigger_data = event_trigger_alloc(cmd_ops, cmd, param, file); | |
| 1019 | 995 | if (!trigger_data) |
| 1020 | 996 | goto out; |
| 1021 | 997 | |
| 1022 | − trigger_data->count = -1; | |
| 1023 | − trigger_data->ops = trigger_ops; | |
| 1024 | − trigger_data->cmd_ops = cmd_ops; | |
| 1025 | − trigger_data->private_data = file; | |
| 1026 | − INIT_LIST_HEAD(&trigger_data->list); | |
| 1027 | − INIT_LIST_HEAD(&trigger_data->named_list); | |
| 1028 | − | |
| 1029 | − if (glob[0] == '!') { | |
| 1030 | − cmd_ops->unreg(glob+1, trigger_data, file); | |
| 998 | + if (remove) { | |
| 999 | + event_trigger_unregister(cmd_ops, file, glob+1, trigger_data); | |
| 1031 | 1000 | kfree(trigger_data); |
| 1032 | 1001 | ret = 0; |
| 1033 | 1002 | goto out; |
| 1034 | 1003 | } |
| 1035 | 1004 | |
| 1036 | − if (trigger) { | |
| 1037 | − number = strsep(&trigger, ":"); | |
| 1038 | − | |
| 1039 | − ret = -EINVAL; | |
| 1040 | − if (!strlen(number)) | |
| 1041 | − goto out_free; | |
| 1042 | − | |
| 1043 | − /* | |
| 1044 | − * We use the callback data field (which is a pointer) | |
| 1045 | − * as our counter. | |
| 1046 | − */ | |
| 1047 | − ret = kstrtoul(number, 0, &trigger_data->count); | |
| 1048 | − if (ret) | |
| 1049 | − goto out_free; | |
| 1050 | − } | |
| 1051 | − | |
| 1052 | − if (!param) /* if param is non-empty, it's supposed to be a filter */ | |
| 1053 | − goto out_reg; | |
| 1054 | − | |
| 1055 | − if (!cmd_ops->set_filter) | |
| 1056 | − goto out_reg; | |
| 1005 | + ret = event_trigger_parse_num(param, trigger_data); | |
| 1006 | + if (ret) | |
| 1007 | + goto out_free; | |
| 1057 | 1008 | |
| 1058 | − ret = cmd_ops->set_filter(param, trigger_data, file); | |
| 1009 | + ret = event_trigger_set_filter(cmd_ops, file, filter, trigger_data); | |
| 1059 | 1010 | if (ret < 0) |
| 1060 | 1011 | goto out_free; |
| 1061 | 1012 | |
| 1062 | − out_reg: | |
| 1063 | 1013 | /* Up the trigger_data count to make sure reg doesn't free it on failure */ |
| 1064 | − event_trigger_init(trigger_ops, trigger_data); | |
| 1065 | − ret = cmd_ops->reg(glob, trigger_data, file); | |
| 1066 | − /* | |
| 1067 | − * The above returns on success the # of functions enabled, | |
| 1068 | − * but if it didn't find any functions it returns zero. | |
| 1069 | − * Consider no functions a failure too. | |
| 1070 | − */ | |
| 1071 | − if (!ret) { | |
| 1072 | − cmd_ops->unreg(glob, trigger_data, file); | |
| 1073 | − ret = -ENOENT; | |
| 1074 | − } else if (ret > 0) | |
| 1075 | − ret = 0; | |
| 1014 | + event_trigger_init(trigger_data); | |
| 1015 | + | |
| 1016 | + ret = event_trigger_register(cmd_ops, file, glob, trigger_data); | |
| 1017 | + if (ret) | |
| 1018 | + goto out_free; | |
| 1076 | 1019 | |
| 1077 | 1020 | /* Down the counter of trigger_data or free it if not used anymore */ |
| 1078 | − event_trigger_free(trigger_ops, trigger_data); | |
| 1021 | + event_trigger_free(trigger_data); | |
| 1079 | 1022 | out: |
| 1080 | 1023 | return ret; |
| 1081 | 1024 | |
| 1082 | 1025 | out_free: |
| 1083 | − if (cmd_ops->set_filter) | |
| 1084 | − cmd_ops->set_filter(NULL, trigger_data, NULL); | |
| 1026 | + event_trigger_reset_filter(cmd_ops, trigger_data); | |
| 1085 | 1027 | kfree(trigger_data); |
| 1086 | 1028 | goto out; |
| 1087 | 1029 | } |
| @@ -1401,16 +1343,14 @@ traceoff_count_trigger(struct event_trigger_data *data, · 313 unmodified lines | ||
| 1401 | 1343 | } |
| 1402 | 1344 | |
| 1403 | 1345 | static int |
| 1404 | −traceon_trigger_print(struct seq_file *m, struct event_trigger_ops *ops, | |
| 1405 | − struct event_trigger_data *data) | |
| 1346 | +traceon_trigger_print(struct seq_file *m, struct event_trigger_data *data) | |
| 1406 | 1347 | { |
| 1407 | 1348 | return event_trigger_print("traceon", m, (void *)data->count, |
| 1408 | 1349 | data->filter_str); |
| 1409 | 1350 | } |
| 1410 | 1351 | |
| 1411 | 1352 | static int |
| 1412 | −traceoff_trigger_print(struct seq_file *m, struct event_trigger_ops *ops, | |
| 1413 | − struct event_trigger_data *data) | |
| 1353 | +traceoff_trigger_print(struct seq_file *m, struct event_trigger_data *data) | |
| 1414 | 1354 | { |
| 1415 | 1355 | return event_trigger_print("traceoff", m, (void *)data->count, |
| 1416 | 1356 | data->filter_str); |
| @@ -1521,8 +1461,7 @@ register_snapshot_trigger(char *glob, · 104 unmodified lines | ||
| 1521 | 1461 | } |
| 1522 | 1462 | |
| 1523 | 1463 | static int |
| 1524 | −snapshot_trigger_print(struct seq_file *m, struct event_trigger_ops *ops, | |
| 1525 | − struct event_trigger_data *data) | |
| 1464 | +snapshot_trigger_print(struct seq_file *m, struct event_trigger_data *data) | |
| 1526 | 1465 | { |
| 1527 | 1466 | return event_trigger_print("snapshot", m, (void *)data->count, |
| 1528 | 1467 | data->filter_str); |
| @@ -1617,8 +1556,7 @@ stacktrace_count_trigger(struct event_trigger_data *data, · 88 unmodified lines | ||
| 1617 | 1556 | } |
| 1618 | 1557 | |
| 1619 | 1558 | static int |
| 1620 | −stacktrace_trigger_print(struct seq_file *m, struct event_trigger_ops *ops, | |
| 1621 | − struct event_trigger_data *data) | |
| 1559 | +stacktrace_trigger_print(struct seq_file *m, struct event_trigger_data *data) | |
| 1622 | 1560 | { |
| 1623 | 1561 | return event_trigger_print("stacktrace", m, (void *)data->count, |
| 1624 | 1562 | data->filter_str); |
| @@ -1708,7 +1646,6 @@ event_enable_count_trigger(struct event_trigger_data *data, · 83 unmodified lines | ||
| 1708 | 1646 | } |
| 1709 | 1647 | |
| 1710 | 1648 | int event_enable_trigger_print(struct seq_file *m, |
| 1711 | − struct event_trigger_ops *ops, | |
| 1712 | 1649 | struct event_trigger_data *data) |
| 1713 | 1650 | { |
| 1714 | 1651 | struct enable_trigger_data *enable_data = data->private_data; |
| @@ -1733,8 +1670,7 @@ int event_enable_trigger_print(struct seq_file *m, · 18 unmodified lines | ||
| 1733 | 1670 | return 0; |
| 1734 | 1671 | } |
| 1735 | 1672 | |
| 1736 | −void event_enable_trigger_free(struct event_trigger_ops *ops, | |
| 1737 | − struct event_trigger_data *data) | |
| 1673 | +void event_enable_trigger_free(struct event_trigger_data *data) | |
| 1738 | 1674 | { |
| 1739 | 1675 | struct enable_trigger_data *enable_data = data->private_data; |
| 1740 | 1676 | |
| @@ -1781,39 +1717,33 @@ static struct event_trigger_ops event_disable_count_trigger_ops = { · 40 unmodified lines | ||
| 1781 | 1717 | |
| 1782 | 1718 | int event_enable_trigger_parse(struct event_command *cmd_ops, |
| 1783 | 1719 | struct trace_event_file *file, |
| 1784 | − char *glob, char *cmd, char *param) | |
| 1720 | + char *glob, char *cmd, char *param_and_filter) | |
| 1785 | 1721 | { |
| 1786 | 1722 | struct trace_event_file *event_enable_file; |
| 1787 | 1723 | struct enable_trigger_data *enable_data; |
| 1788 | 1724 | struct event_trigger_data *trigger_data; |
| 1789 | − struct event_trigger_ops *trigger_ops; | |
| 1790 | 1725 | struct trace_array *tr = file->tr; |
| 1726 | + char *param, *filter; | |
| 1727 | + bool enable, remove; | |
| 1791 | 1728 | const char *system; |
| 1792 | 1729 | const char *event; |
| 1793 | 1730 | bool hist = false; |
| 1794 | − char *trigger; | |
| 1795 | − char *number; | |
| 1796 | − bool enable; | |
| 1797 | 1731 | int ret; |
| 1798 | 1732 | |
| 1799 | − if (!param) | |
| 1800 | − return -EINVAL; | |
| 1733 | + remove = event_trigger_check_remove(glob); | |
| 1801 | 1734 | |
| 1802 | − /* separate the trigger from the filter (s:e:n [if filter]) */ | |
| 1803 | − trigger = strsep(¶m, " \t"); | |
| 1804 | − if (!trigger) | |
| 1735 | + if (event_trigger_empty_param(param_and_filter)) | |
| 1805 | 1736 | return -EINVAL; |
| 1806 | − if (param) { | |
| 1807 | − param = skip_spaces(param); | |
| 1808 | − if (!*param) | |
| 1809 | − param = NULL; | |
| 1810 | − } | |
| 1811 | 1737 | |
| 1812 | − system = strsep(&trigger, ":"); | |
| 1813 | − if (!trigger) | |
| 1738 | + ret = event_trigger_separate_filter(param_and_filter, ¶m, &filter, true); | |
| 1739 | + if (ret) | |
| 1740 | + return ret; | |
| 1741 | + | |
| 1742 | + system = strsep(¶m, ":"); | |
| 1743 | + if (!param) | |
| 1814 | 1744 | return -EINVAL; |
| 1815 | 1745 | |
| 1816 | − event = strsep(&trigger, ":"); | |
| 1746 | + event = strsep(¶m, ":"); | |
| 1817 | 1747 | |
| 1818 | 1748 | ret = -EINVAL; |
| 1819 | 1749 | event_enable_file = find_event_file(tr, system, event); |
| @@ -1829,32 +1759,24 @@ int event_enable_trigger_parse(struct event_command *cmd_ops, · 9 unmodified lines | ||
| 1829 | 1759 | #else |
| 1830 | 1760 | enable = strcmp(cmd, ENABLE_EVENT_STR) == 0; |
| 1831 | 1761 | #endif |
| 1832 | − trigger_ops = cmd_ops->get_trigger_ops(cmd, trigger); | |
| 1833 | − | |
| 1834 | 1762 | ret = -ENOMEM; |
| 1835 | − trigger_data = kzalloc(sizeof(*trigger_data), GFP_KERNEL); | |
| 1836 | − if (!trigger_data) | |
| 1837 | − goto out; | |
| 1838 | 1763 | |
| 1839 | 1764 | enable_data = kzalloc(sizeof(*enable_data), GFP_KERNEL); |
| 1840 | − if (!enable_data) { | |
| 1841 | − kfree(trigger_data); | |
| 1765 | + if (!enable_data) | |
| 1842 | 1766 | goto out; |
| 1843 | − } | |
| 1844 | − | |
| 1845 | − trigger_data->count = -1; | |
| 1846 | − trigger_data->ops = trigger_ops; | |
| 1847 | − trigger_data->cmd_ops = cmd_ops; | |
| 1848 | − INIT_LIST_HEAD(&trigger_data->list); | |
| 1849 | − RCU_INIT_POINTER(trigger_data->filter, NULL); | |
| 1850 | 1767 | |
| 1851 | 1768 | enable_data->hist = hist; |
| 1852 | 1769 | enable_data->enable = enable; |
| 1853 | 1770 | enable_data->file = event_enable_file; |
| 1854 | − trigger_data->private_data = enable_data; | |
| 1855 | 1771 | |
| 1856 | − if (glob[0] == '!') { | |
| 1857 | − cmd_ops->unreg(glob+1, trigger_data, file); | |
| 1772 | + trigger_data = event_trigger_alloc(cmd_ops, cmd, param, enable_data); | |
| 1773 | + if (!trigger_data) { | |
| 1774 | + kfree(enable_data); | |
| 1775 | + goto out; | |
| 1776 | + } | |
| 1777 | + | |
| 1778 | + if (remove) { | |
| 1779 | + event_trigger_unregister(cmd_ops, file, glob+1, trigger_data); | |
| 1858 | 1780 | kfree(trigger_data); |
| 1859 | 1781 | kfree(enable_data); |
| 1860 | 1782 | ret = 0; |
| @@ -1862,35 +1784,16 @@ int event_enable_trigger_parse(struct event_command *cmd_ops, · 1 unmodified line | ||
| 1862 | 1784 | } |
| 1863 | 1785 | |
| 1864 | 1786 | /* Up the trigger_data count to make sure nothing frees it on failure */ |
| 1865 | − event_trigger_init(trigger_ops, trigger_data); | |
| 1866 | − | |
| 1867 | − if (trigger) { | |
| 1868 | − number = strsep(&trigger, ":"); | |
| 1869 | − | |
| 1870 | − ret = -EINVAL; | |
| 1871 | − if (!strlen(number)) | |
| 1872 | − goto out_free; | |
| 1873 | − | |
| 1874 | − /* | |
| 1875 | − * We use the callback data field (which is a pointer) | |
| 1876 | − * as our counter. | |
| 1877 | − */ | |
| 1878 | − ret = kstrtoul(number, 0, &trigger_data->count); | |
| 1879 | − if (ret) | |
| 1880 | − goto out_free; | |
| 1881 | − } | |
| 1787 | + event_trigger_init(trigger_data); | |
| 1882 | 1788 | |
| 1883 | − if (!param) /* if param is non-empty, it's supposed to be a filter */ | |
| 1884 | − goto out_reg; | |
| 1885 | − | |
| 1886 | − if (!cmd_ops->set_filter) | |
| 1887 | − goto out_reg; | |
| 1789 | + ret = event_trigger_parse_num(param, trigger_data); | |
| 1790 | + if (ret) | |
| 1791 | + goto out_free; | |
| 1888 | 1792 | |
| 1889 | − ret = cmd_ops->set_filter(param, trigger_data, file); | |
| 1793 | + ret = event_trigger_set_filter(cmd_ops, file, filter, trigger_data); | |
| 1890 | 1794 | if (ret < 0) |
| 1891 | 1795 | goto out_free; |
| 1892 | 1796 | |
| 1893 | − out_reg: | |
| 1894 | 1797 | /* Don't let event modules unload while probe registered */ |
| 1895 | 1798 | ret = trace_event_try_get_ref(event_enable_file->event_call); |
| 1896 | 1799 | if (!ret) { |
| @@ -1901,32 +1804,23 @@ int event_enable_trigger_parse(struct event_command *cmd_ops, · 4 unmodified lines | ||
| 1901 | 1804 | ret = trace_event_enable_disable(event_enable_file, 1, 1); |
| 1902 | 1805 | if (ret < 0) |
| 1903 | 1806 | goto out_put; |
| 1904 | − ret = cmd_ops->reg(glob, trigger_data, file); | |
| 1905 | − /* | |
| 1906 | − * The above returns on success the # of functions enabled, | |
| 1907 | − * but if it didn't find any functions it returns zero. | |
| 1908 | − * Consider no functions a failure too. | |
| 1909 | − */ | |
| 1910 | − if (!ret) { | |
| 1911 | − ret = -ENOENT; | |
| 1912 | − goto out_disable; | |
| 1913 | − } else if (ret < 0) | |
| 1807 | + | |
| 1808 | + ret = event_trigger_register(cmd_ops, file, glob, trigger_data); | |
| 1809 | + if (ret) | |
| 1914 | 1810 | goto out_disable; |
| 1915 | − /* Just return zero, not the number of enabled functions */ | |
| 1916 | − ret = 0; | |
| 1917 | − event_trigger_free(trigger_ops, trigger_data); | |
| 1811 | + | |
| 1812 | + event_trigger_free(trigger_data); | |
| 1918 | 1813 | out: |
| 1919 | 1814 | return ret; |
| 1920 | − | |
| 1921 | 1815 | out_disable: |
| 1922 | 1816 | trace_event_enable_disable(event_enable_file, 0, 1); |
| 1923 | 1817 | out_put: |
| 1924 | 1818 | trace_event_put_ref(event_enable_file->event_call); |
| 1925 | 1819 | out_free: |
| 1926 | − if (cmd_ops->set_filter) | |
| 1927 | − cmd_ops->set_filter(NULL, trigger_data, NULL); | |
| 1928 | − event_trigger_free(trigger_ops, trigger_data); | |
| 1820 | + event_trigger_reset_filter(cmd_ops, trigger_data); | |
| 1821 | + event_trigger_free(trigger_data); | |
| 1929 | 1822 | kfree(enable_data); |
| 1823 | + | |
| 1930 | 1824 | goto out; |
| 1931 | 1825 | } |
| 1932 | 1826 | |
| @@ -1953,19 +1847,18 @@ int event_enable_register_trigger(char *glob, · 20 unmodified lines | ||
| 1953 | 1847 | } |
| 1954 | 1848 | |
| 1955 | 1849 | if (data->ops->init) { |
| 1956 | − ret = data->ops->init(data->ops, data); | |
| 1850 | + ret = data->ops->init(data); | |
| 1957 | 1851 | if (ret < 0) |
| 1958 | 1852 | goto out; |
| 1959 | 1853 | } |
| 1960 | 1854 | |
| 1961 | 1855 | list_add_rcu(&data->list, &file->triggers); |
| 1962 | − ret++; | |
| 1963 | 1856 | |
| 1964 | 1857 | update_cond_flag(file); |
| 1965 | − if (trace_event_trigger_enable_disable(file, 1) < 0) { | |
| 1858 | + ret = trace_event_trigger_enable_disable(file, 1); | |
| 1859 | + if (ret < 0) { | |
| 1966 | 1860 | list_del_rcu(&data->list); |
| 1967 | 1861 | update_cond_flag(file); |
| 1968 | − ret--; | |
| 1969 | 1862 | } |
| 1970 | 1863 | out: |
| 1971 | 1864 | return ret; |
| @@ -1976,19 +1869,18 @@ void event_enable_unregister_trigger(char *glob, · 4 unmodified lines | ||
| 1976 | 1869 | struct trace_event_file *file) |
| 1977 | 1870 | { |
| 1978 | 1871 | struct enable_trigger_data *test_enable_data = test->private_data; |
| 1872 | + struct event_trigger_data *data = NULL, *iter; | |
| 1979 | 1873 | struct enable_trigger_data *enable_data; |
| 1980 | − struct event_trigger_data *data; | |
| 1981 | − bool unregistered = false; | |
| 1982 | 1874 | |
| 1983 | 1875 | lockdep_assert_held(&event_mutex); |
| 1984 | 1876 | |
| 1985 | − list_for_each_entry(data, &file->triggers, list) { | |
| 1986 | − enable_data = data->private_data; | |
| 1877 | + list_for_each_entry(iter, &file->triggers, list) { | |
| 1878 | + enable_data = iter->private_data; | |
| 1987 | 1879 | if (enable_data && |
| 1988 | − (data->cmd_ops->trigger_type == | |
| 1880 | + (iter->cmd_ops->trigger_type == | |
| 1989 | 1881 | test->cmd_ops->trigger_type) && |
| 1990 | 1882 | (enable_data->file == test_enable_data->file)) { |
| 1991 | − unregistered = true; | |
| 1883 | + data = iter; | |
| 1992 | 1884 | list_del_rcu(&data->list); |
| 1993 | 1885 | trace_event_trigger_enable_disable(file, 0); |
| 1994 | 1886 | update_cond_flag(file); |
| @@ -1996,8 +1888,8 @@ void event_enable_unregister_trigger(char *glob, · 1 unmodified line | ||
| 1996 | 1888 | } |
| 1997 | 1889 | } |
| 1998 | 1890 | |
| 1999 | − if (unregistered && data->ops->free) | |
| 2000 | − data->ops->free(data->ops, data); | |
| 1891 | + if (data && data->ops->free) | |
| 1892 | + data->ops->free(data); | |
| 2001 | 1893 | } |
| 2002 | 1894 | |
| 2003 | 1895 | static struct event_trigger_ops * |
| @@ -1907,25 +1907,18 @@ core_initcall(init_kprobe_trace_early); · 1906 unmodified lines | ||
| 1907 | 1907 | static __init int init_kprobe_trace(void) |
| 1908 | 1908 | { |
| 1909 | 1909 | int ret; |
| 1910 | − struct dentry *entry; | |
| 1911 | 1910 | |
| 1912 | 1911 | ret = tracing_init_dentry(); |
| 1913 | 1912 | if (ret) |
| 1914 | 1913 | return 0; |
| 1915 | 1914 | |
| 1916 | − entry = tracefs_create_file("kprobe_events", TRACE_MODE_WRITE, | |
| 1917 | − NULL, NULL, &kprobe_events_ops); | |
| 1918 | − | |
| 1919 | 1915 | /* Event list interface */ |
| 1920 | − if (!entry) | |
| 1921 | − pr_warn("Could not create tracefs 'kprobe_events' entry\n"); | |
| 1916 | + trace_create_file("kprobe_events", TRACE_MODE_WRITE, | |
| 1917 | + NULL, NULL, &kprobe_events_ops); | |
| 1922 | 1918 | |
| 1923 | 1919 | /* Profile interface */ |
| 1924 | − entry = tracefs_create_file("kprobe_profile", TRACE_MODE_READ, | |
| 1925 | − NULL, NULL, &kprobe_profile_ops); | |
| 1926 | − | |
| 1927 | − if (!entry) | |
| 1928 | − pr_warn("Could not create tracefs 'kprobe_profile' entry\n"); | |
| 1920 | + trace_create_file("kprobe_profile", TRACE_MODE_READ, | |
| 1921 | + NULL, NULL, &kprobe_profile_ops); | |
| 1929 | 1922 | |
| 1930 | 1923 | setup_boot_kprobe_events(); |
| 1931 | 1924 | |
| @@ -1578,11 +1578,27 @@ static enum hrtimer_restart timerlat_irq(struct hrtimer *timer) · 1577 unmodified lines | ||
| 1578 | 1578 | |
| 1579 | 1579 | trace_timerlat_sample(&s); |
| 1580 | 1580 | |
| 1581 | − notify_new_max_latency(diff); | |
| 1581 | + if (osnoise_data.stop_tracing) { | |
| 1582 | + if (time_to_us(diff) >= osnoise_data.stop_tracing) { | |
| 1583 | + | |
| 1584 | + /* | |
| 1585 | + * At this point, if stop_tracing is set and <= print_stack, | |
| 1586 | + * print_stack is set and would be printed in the thread handler. | |
| 1587 | + * | |
| 1588 | + * Thus, print the stack trace as it is helpful to define the | |
| 1589 | + * root cause of an IRQ latency. | |
| 1590 | + */ | |
| 1591 | + if (osnoise_data.stop_tracing <= osnoise_data.print_stack) { | |
| 1592 | + timerlat_save_stack(0); | |
| 1593 | + timerlat_dump_stack(time_to_us(diff)); | |
| 1594 | + } | |
| 1582 | 1595 | |
| 1583 | − if (osnoise_data.stop_tracing) | |
| 1584 | − if (time_to_us(diff) >= osnoise_data.stop_tracing) | |
| 1585 | 1596 | osnoise_stop_tracing(); |
| 1597 | + notify_new_max_latency(diff); | |
| 1598 | + | |
| 1599 | + return HRTIMER_NORESTART; | |
| 1600 | + } | |
| 1601 | + } | |
| 1586 | 1602 | |
| 1587 | 1603 | wake_up_process(tlat->kthread); |
| 1588 | 1604 | |
| @@ -692,7 +692,7 @@ static LIST_HEAD(ftrace_event_list); · 691 unmodified lines | ||
| 692 | 692 | |
| 693 | 693 | static int trace_search_list(struct list_head **list) |
| 694 | 694 | { |
| 695 | − struct trace_event *e; | |
| 695 | + struct trace_event *e = NULL, *iter; | |
| 696 | 696 | int next = __TRACE_LAST_TYPE; |
| 697 | 697 | |
| 698 | 698 | if (list_empty(&ftrace_event_list)) { |
| @@ -704,9 +704,11 @@ static int trace_search_list(struct list_head **list) · 5 unmodified lines | ||
| 704 | 704 | * We used up all possible max events, |
| 705 | 705 | * lets see if somebody freed one. |
| 706 | 706 | */ |
| 707 | − list_for_each_entry(e, &ftrace_event_list, list) { | |
| 708 | − if (e->type != next) | |
| 707 | + list_for_each_entry(iter, &ftrace_event_list, list) { | |
| 708 | + if (iter->type != next) { | |
| 709 | + e = iter; | |
| 709 | 710 | break; |
| 711 | + } | |
| 710 | 712 | next++; |
| 711 | 713 | } |
| 712 | 714 | |
| @@ -714,7 +716,10 @@ static int trace_search_list(struct list_head **list) · 1 unmodified line | ||
| 714 | 716 | if (next > TRACE_EVENT_TYPE_MAX) |
| 715 | 717 | return 0; |
| 716 | 718 | |
| 717 | − *list = &e->list; | |
| 719 | + if (e) | |
| 720 | + *list = &e->list; | |
| 721 | + else | |
| 722 | + *list = &ftrace_event_list; | |
| 718 | 723 | return next; |
| 719 | 724 | } |
| 720 | 725 | |
| @@ -778,9 +783,8 @@ int register_trace_event(struct trace_event *event) · 57 unmodified lines | ||
| 778 | 783 | |
| 779 | 784 | list_add_tail(&event->list, list); |
| 780 | 785 | |
| 781 | − } else if (event->type > __TRACE_LAST_TYPE) { | |
| 782 | − printk(KERN_WARNING "Need to add type to trace.h\n"); | |
| 783 | − WARN_ON(1); | |
| 786 | + } else if (WARN(event->type > __TRACE_LAST_TYPE, | |
| 787 | + "Need to add type to trace.h")) { | |
| 784 | 788 | goto out; |
| 785 | 789 | } else { |
| 786 | 790 | /* Is this event already used */ |
| @@ -1571,13 +1575,8 @@ __init static int init_events(void) · 784 unmodified lines | ||
| 1571 | 1575 | |
| 1572 | 1576 | for (i = 0; events[i]; i++) { |
| 1573 | 1577 | event = events[i]; |
| 1574 | − | |
| 1575 | 1578 | ret = register_trace_event(event); |
| 1576 | − if (!ret) { | |
| 1577 | − printk(KERN_WARNING "event %d failed to register\n", | |
| 1578 | − event->type); | |
| 1579 | − WARN_ON_ONCE(1); | |
| 1580 | − } | |
| 1579 | + WARN_ONCE(!ret, "event %d failed to register", event->type); | |
| 1581 | 1580 | } |
| 1582 | 1581 | |
| 1583 | 1582 | return 0; |
| @@ -224,12 +224,9 @@ static const struct file_operations recursed_functions_fops = { · 223 unmodified lines | ||
| 224 | 224 | |
| 225 | 225 | __init static int create_recursed_functions(void) |
| 226 | 226 | { |
| 227 | − struct dentry *dentry; | |
| 228 | 227 | |
| 229 | − dentry = trace_create_file("recursed_functions", TRACE_MODE_WRITE, | |
| 230 | − NULL, NULL, &recursed_functions_fops); | |
| 231 | − if (!dentry) | |
| 232 | − pr_warn("WARNING: Failed to create recursed_functions\n"); | |
| 228 | + trace_create_file("recursed_functions", TRACE_MODE_WRITE, | |
| 229 | + NULL, NULL, &recursed_functions_fops); | |
| 233 | 230 | return 0; |
| 234 | 231 | } |
| 235 | 232 | |
| @@ -895,6 +895,9 @@ trace_selftest_startup_function_graph(struct tracer *trace, · 894 unmodified lines | ||
| 895 | 895 | ret = -1; |
| 896 | 896 | goto out; |
| 897 | 897 | } |
| 898 | + | |
| 899 | + /* Enable tracing on all functions again */ | |
| 900 | + ftrace_set_global_filter(NULL, 0, 1); | |
| 898 | 901 | #endif |
| 899 | 902 | |
| 900 | 903 | /* Don't test dynamic tracing, the function tracer already did */ |
| @@ -154,7 +154,7 @@ print_syscall_enter(struct trace_iterator *iter, int flags, · 153 unmodified lines | ||
| 154 | 154 | goto end; |
| 155 | 155 | |
| 156 | 156 | /* parameter types */ |
| 157 | − if (tr->trace_flags & TRACE_ITER_VERBOSE) | |
| 157 | + if (tr && tr->trace_flags & TRACE_ITER_VERBOSE) | |
| 158 | 158 | trace_seq_printf(s, "%s ", entry->types[i]); |
| 159 | 159 | |
| 160 | 160 | /* parameter values */ |
| @@ -296,9 +296,7 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id) · 135 unmodified lines | ||
| 296 | 296 | struct trace_event_file *trace_file; |
| 297 | 297 | struct syscall_trace_enter *entry; |
| 298 | 298 | struct syscall_metadata *sys_data; |
| 299 | − struct ring_buffer_event *event; | |
| 300 | − struct trace_buffer *buffer; | |
| 301 | − unsigned int trace_ctx; | |
| 299 | + struct trace_event_buffer fbuffer; | |
| 302 | 300 | unsigned long args[6]; |
| 303 | 301 | int syscall_nr; |
| 304 | 302 | int size; |
| @@ -321,20 +319,16 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id) · 16 unmodified lines | ||
| 321 | 319 | |
| 322 | 320 | size = sizeof(*entry) + sizeof(unsigned long) * sys_data->nb_args; |
| 323 | 321 | |
| 324 | − trace_ctx = tracing_gen_ctx(); | |
| 325 | − | |
| 326 | − event = trace_event_buffer_lock_reserve(&buffer, trace_file, | |
| 327 | − sys_data->enter_event->event.type, size, trace_ctx); | |
| 328 | − if (!event) | |
| 322 | + entry = trace_event_buffer_reserve(&fbuffer, trace_file, size); | |
| 323 | + if (!entry) | |
| 329 | 324 | return; |
| 330 | 325 | |
| 331 | − entry = ring_buffer_event_data(event); | |
| 326 | + entry = ring_buffer_event_data(fbuffer.event); | |
| 332 | 327 | entry->nr = syscall_nr; |
| 333 | 328 | syscall_get_arguments(current, regs, args); |
| 334 | 329 | memcpy(entry->args, args, sizeof(unsigned long) * sys_data->nb_args); |
| 335 | 330 | |
| 336 | − event_trigger_unlock_commit(trace_file, buffer, event, entry, | |
| 337 | − trace_ctx); | |
| 331 | + trace_event_buffer_commit(&fbuffer); | |
| 338 | 332 | } |
| 339 | 333 | |
| 340 | 334 | static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret) |
| @@ -343,9 +337,7 @@ static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret) · 2 unmodified lines | ||
| 343 | 337 | struct trace_event_file *trace_file; |
| 344 | 338 | struct syscall_trace_exit *entry; |
| 345 | 339 | struct syscall_metadata *sys_data; |
| 346 | − struct ring_buffer_event *event; | |
| 347 | − struct trace_buffer *buffer; | |
| 348 | − unsigned int trace_ctx; | |
| 340 | + struct trace_event_buffer fbuffer; | |
| 349 | 341 | int syscall_nr; |
| 350 | 342 | |
| 351 | 343 | syscall_nr = trace_get_syscall_nr(current, regs); |
| @@ -364,20 +356,15 @@ static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret) · 12 unmodified lines | ||
| 364 | 356 | if (!sys_data) |
| 365 | 357 | return; |
| 366 | 358 | |
| 367 | − trace_ctx = tracing_gen_ctx(); | |
| 368 | − | |
| 369 | − event = trace_event_buffer_lock_reserve(&buffer, trace_file, | |
| 370 | − sys_data->exit_event->event.type, sizeof(*entry), | |
| 371 | − trace_ctx); | |
| 372 | − if (!event) | |
| 359 | + entry = trace_event_buffer_reserve(&fbuffer, trace_file, sizeof(*entry)); | |
| 360 | + if (!entry) | |
| 373 | 361 | return; |
| 374 | 362 | |
| 375 | − entry = ring_buffer_event_data(event); | |
| 363 | + entry = ring_buffer_event_data(fbuffer.event); | |
| 376 | 364 | entry->nr = syscall_nr; |
| 377 | 365 | entry->ret = syscall_get_return_value(current, regs); |
| 378 | 366 | |
| 379 | − event_trigger_unlock_commit(trace_file, buffer, event, entry, | |
| 380 | − trace_ctx); | |
| 367 | + trace_event_buffer_commit(&fbuffer); | |
| 381 | 368 | } |
| 382 | 369 | |
| 383 | 370 | static int reg_event_syscall_enter(struct trace_event_file *file, |
| @@ -1045,7 +1045,8 @@ static void sort_secondary(struct tracing_map *map, · 1044 unmodified lines | ||
| 1045 | 1045 | /** |
| 1046 | 1046 | * tracing_map_sort_entries - Sort the current set of tracing_map_elts in a map |
| 1047 | 1047 | * @map: The tracing_map |
| 1048 | − * @sort_key: The sort key to use for sorting | |
| 1048 | + * @sort_keys: The sort key to use for sorting | |
| 1049 | + * @n_sort_keys: hitcount, always have at least one | |
| 1049 | 1050 | * @sort_entries: outval: pointer to allocated and sorted array of entries |
| 1050 | 1051 | * |
| 1051 | 1052 | * tracing_map_sort_entries() sorts the current set of entries in the |