Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tracing: uprobe: eprobes: Allocate traceprobe_parse_context per probe

Since traceprobe_parse_context is reusable among a probe arguments,
it is more efficient to allocate it outside of the loop for parsing
probe argument as kprobe and fprobe events do.

Link: https://lore.kernel.org/all/175509541393.193596.16330324746701582114.stgit@devnote2/

Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

+18 -26
+12 -20
kernel/trace/trace_eprobe.c
··· 801 801 return NULL; 802 802 } 803 803 804 - static int trace_eprobe_tp_update_arg(struct trace_eprobe *ep, const char *argv[], int i) 805 - { 806 - struct traceprobe_parse_context *ctx __free(traceprobe_parse_context) = NULL; 807 - int ret; 808 - 809 - ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 810 - if (!ctx) 811 - return -ENOMEM; 812 - ctx->event = ep->event; 813 - ctx->flags = TPARG_FL_KERNEL | TPARG_FL_TEVENT; 814 - 815 - ret = traceprobe_parse_probe_arg(&ep->tp, i, argv[i], ctx); 816 - /* Handle symbols "@" */ 817 - if (!ret) 818 - ret = traceprobe_update_arg(&ep->tp.args[i]); 819 - 820 - return ret; 821 - } 822 - 823 804 static int trace_eprobe_parse_filter(struct trace_eprobe *ep, int argc, const char *argv[]) 824 805 { 825 806 struct event_filter *dummy = NULL; ··· 852 871 * Fetch args (no space): 853 872 * <name>=$<field>[:TYPE] 854 873 */ 874 + struct traceprobe_parse_context *ctx __free(traceprobe_parse_context) = NULL; 855 875 struct trace_eprobe *ep __free(trace_event_probe_cleanup) = NULL; 856 876 const char *trlog __free(trace_probe_log_clear) = NULL; 857 877 const char *event = NULL, *group = EPROBE_EVENT_SYSTEM; ··· 938 956 } else 939 957 ep->filter_str = NULL; 940 958 959 + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 960 + if (!ctx) 961 + return -ENOMEM; 962 + ctx->event = ep->event; 963 + ctx->flags = TPARG_FL_KERNEL | TPARG_FL_TEVENT; 964 + 941 965 argc -= 2; argv += 2; 942 966 /* parse arguments */ 943 967 for (i = 0; i < argc; i++) { 944 968 trace_probe_log_set_index(i + 2); 945 - ret = trace_eprobe_tp_update_arg(ep, argv, i); 969 + 970 + ret = traceprobe_parse_probe_arg(&ep->tp, i, argv[i], ctx); 971 + /* Handle symbols "@" */ 972 + if (!ret) 973 + ret = traceprobe_update_arg(&ep->tp.args[i]); 946 974 if (ret) 947 975 return ret; 948 976 }
+6 -6
kernel/trace/trace_uprobe.c
··· 541 541 */ 542 542 static int __trace_uprobe_create(int argc, const char **argv) 543 543 { 544 + struct traceprobe_parse_context *ctx __free(traceprobe_parse_context) = NULL; 544 545 struct trace_uprobe *tu __free(free_trace_uprobe) = NULL; 545 546 const char *trlog __free(trace_probe_log_clear) = NULL; 546 547 const char *event = NULL, *group = UPROBE_EVENT_SYSTEM; ··· 699 698 memset(&path, 0, sizeof(path)); 700 699 tu->filename = no_free_ptr(filename); 701 700 701 + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 702 + if (!ctx) 703 + return -ENOMEM; 704 + ctx->flags = (is_return ? TPARG_FL_RETURN : 0) | TPARG_FL_USER; 705 + 702 706 /* parse arguments */ 703 707 for (i = 0; i < argc; i++) { 704 - struct traceprobe_parse_context *ctx __free(traceprobe_parse_context) 705 - = kzalloc(sizeof(*ctx), GFP_KERNEL); 706 - 707 - if (!ctx) 708 - return -ENOMEM; 709 - ctx->flags = (is_return ? TPARG_FL_RETURN : 0) | TPARG_FL_USER; 710 708 trace_probe_log_set_index(i + 2); 711 709 ret = traceprobe_parse_probe_arg(&tu->tp, i, argv[i], ctx); 712 710 if (ret)