From patchwork Fri Aug 2 11:00:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 11073177 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BD351399 for ; Fri, 2 Aug 2019 11:01:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36E3028451 for ; Fri, 2 Aug 2019 11:01:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 285EC286F3; Fri, 2 Aug 2019 11:01:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE59D28451 for ; Fri, 2 Aug 2019 11:01:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729582AbfHBLBJ (ORCPT ); Fri, 2 Aug 2019 07:01:09 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:40124 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729419AbfHBLBJ (ORCPT ); Fri, 2 Aug 2019 07:01:09 -0400 Received: by mail-wm1-f67.google.com with SMTP id v19so65952889wmj.5 for ; Fri, 02 Aug 2019 04:01:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=irYH6v/bkKWfW2e45xE/2hDSHX8APebDZmcLY4XqWsc=; b=M4RlNyHwbFqPq3uk3emK8pW8k9XQ6usbXCvlltPrV4uGwrbIHfvrmzo1zuURXzRwdV kxLeBYTH4KKFLsTizjVc50p9Jl3A5Vh39rMlxxSFlCD216FUuM/+E99ToPn6HM6/uy+2 Lz7iH65tyAX+A2nW7xHylDOKp9h9a+OMreUm/kW9PE7Low90rO9Jh89itFlwHFt79GsV tJ8ym58gK46XyOgeJhYxwcgPkjD4jASFf7uRYrOqvZ6sSkoSSHH6mx3knxKxJDGBxMW7 ySehCwvnaxtjW/s9pFFm4WgO/844+GysWuiLT7ycIkEm0BAMExvALeUjWUna/HcKhhtc 8Yzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=irYH6v/bkKWfW2e45xE/2hDSHX8APebDZmcLY4XqWsc=; b=D3qnYM2tpYXkhs1J2fTzuwTY5y80Y9GPV6gy5BUyTV8u8ynXls7LljzhpxH0WNUNCk 5ZYK95vkGQIrwrKwOUvC8q+n/TTrEJPZRewt6tXwv41LxMUorNnhJLvQjHtrtbEowfHz 0in6ZqUTHyhj3B5mu3VGx8Ig8n0aT/4Exl9BpJOdVhjKVorPSepxqYyXFr3IkErh5VUT mAY4kEsVjWIKYm1iLkFye+ZFVBeEHbAmKGYRO/AS4dnOmlntfAS7adorNKw2Bj9jwz7o +QC9jtTCsHV/Yu601NMlLudvlrlUjdTBEWE7IsQASJ28RmxfP+kJ7ob7IAVtovhUAgaU E8hw== X-Gm-Message-State: APjAAAVBfUsT5VFXYN6PxQYj27fE6TkkzlIBGQ71rNc0OtUAcjZyOBAk rtenwFZv8CgI4fHTHifwZ2U= X-Google-Smtp-Source: APXvYqzjyMx3xrLrOsBjHOvMZyNfF2mpIESBJiGC0/L/Y/MIboHq6M3JfuCwFqn4kpXP/OJcB45++Q== X-Received: by 2002:a1c:f115:: with SMTP id p21mr3814480wmh.134.1564743666202; Fri, 02 Aug 2019 04:01:06 -0700 (PDT) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id r15sm79511433wrj.68.2019.08.02.04.01.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 04:01:05 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 1/6] trace-cmd: Move kernel_stack event handler to "function" plugin. Date: Fri, 2 Aug 2019 14:00:56 +0300 Message-Id: <20190802110101.14759-2-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190802110101.14759-1-tz.stoyanov@gmail.com> References: <20190802110101.14759-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The "kernel_stack" event handler does not depend on any trace-cmd context, it can be used aside from the application. The code is moved to libtraceevent "function" plugin. Signed-off-by: Tzvetomir Stoyanov (VMware) --- lib/trace-cmd/trace-ftrace.c | 52 ------------------------------------ plugins/plugin_function.c | 41 ++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 52 deletions(-) diff --git a/lib/trace-cmd/trace-ftrace.c b/lib/trace-cmd/trace-ftrace.c index ed68099..22e5213 100644 --- a/lib/trace-cmd/trace-ftrace.c +++ b/lib/trace-cmd/trace-ftrace.c @@ -31,17 +31,6 @@ struct tep_plugin_option trace_ftrace_options[] = { static struct tep_plugin_option *fgraph_tail = &trace_ftrace_options[0]; static struct tep_plugin_option *fgraph_depth = &trace_ftrace_options[1]; -static void find_long_size(struct tracecmd_ftrace *finfo) -{ - finfo->long_size = tracecmd_long_size(finfo->handle); -} - -#define long_size_check(handle) \ - do { \ - if (!finfo->long_size) \ - find_long_size(finfo); \ - } while (0) - static int find_ret_event(struct tracecmd_ftrace *finfo, struct tep_handle *pevent) { struct tep_event *event; @@ -361,44 +350,6 @@ fgraph_ret_handler(struct trace_seq *s, struct tep_record *record, return 0; } -static int -trace_stack_handler(struct trace_seq *s, struct tep_record *record, - struct tep_event *event, void *context) -{ - struct tracecmd_ftrace *finfo = context; - struct tep_format_field *field; - unsigned long long addr; - const char *func; - void *data = record->data; - - field = tep_find_any_field(event, "caller"); - if (!field) { - trace_seq_printf(s, "", "caller"); - return 0; - } - - trace_seq_puts(s, "\n"); - - long_size_check(finfo); - - for (data += field->offset; data < record->data + record->size; - data += finfo->long_size) { - addr = tep_read_number(event->tep, data, finfo->long_size); - - if ((finfo->long_size == 8 && addr == (unsigned long long)-1) || - ((int)addr == -1)) - break; - - func = tep_find_function(event->tep, addr); - if (func) - trace_seq_printf(s, "=> %s (%llx)\n", func, addr); - else - trace_seq_printf(s, "=> %llx\n", addr); - } - - return 0; -} - /** * tracecmd_ftrace_load_options - load the ftrace options * @@ -430,9 +381,6 @@ int tracecmd_ftrace_overrides(struct tracecmd_input *handle, tep_register_event_handler(pevent, -1, "ftrace", "funcgraph_exit", fgraph_ret_handler, finfo); - tep_register_event_handler(pevent, -1, "ftrace", "kernel_stack", - trace_stack_handler, finfo); - trace_util_add_options("ftrace", trace_ftrace_options); /* Store the func ret id and event for later use */ diff --git a/plugins/plugin_function.c b/plugins/plugin_function.c index 91beb74..21ee531 100644 --- a/plugins/plugin_function.c +++ b/plugins/plugin_function.c @@ -169,11 +169,52 @@ static int function_handler(struct trace_seq *s, struct tep_record *record, return 0; } +static int +trace_stack_handler(struct trace_seq *s, struct tep_record *record, + struct tep_event *event, void *context) +{ + struct tep_format_field *field; + unsigned long long addr; + const char *func; + int long_size; + void *data = record->data; + + field = tep_find_any_field(event, "caller"); + if (!field) { + trace_seq_printf(s, "", "caller"); + return 0; + } + + trace_seq_puts(s, "\n"); + + long_size = tep_get_long_size(event->tep); + + for (data += field->offset; data < record->data + record->size; + data += long_size) { + addr = tep_read_number(event->tep, data, long_size); + + if ((long_size == 8 && addr == (unsigned long long)-1) || + ((int)addr == -1)) + break; + + func = tep_find_function(event->tep, addr); + if (func) + trace_seq_printf(s, "=> %s (%llx)\n", func, addr); + else + trace_seq_printf(s, "=> %llx\n", addr); + } + + return 0; +} + int TEP_PLUGIN_LOADER(struct tep_handle *tep) { tep_register_event_handler(tep, -1, "ftrace", "function", function_handler, NULL); + tep_register_event_handler(tep, -1, "ftrace", "kernel_stack", + trace_stack_handler, NULL); + trace_util_add_options("ftrace", plugin_options); return 0; From patchwork Fri Aug 2 11:00:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Tzvetomir Stoyanov (VMware)" X-Patchwork-Id: 11073183 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D2F191399 for ; Fri, 2 Aug 2019 11:01:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD1F328451 for ; Fri, 2 Aug 2019 11:01:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B15D328712; Fri, 2 Aug 2019 11:01:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8F8828451 for ; Fri, 2 Aug 2019 11:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729797AbfHBLBM (ORCPT ); Fri, 2 Aug 2019 07:01:12 -0400 Received: from mail-wr1-f43.google.com ([209.85.221.43]:34523 "EHLO mail-wr1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729430AbfHBLBM (ORCPT ); Fri, 2 Aug 2019 07:01:12 -0400 Received: by mail-wr1-f43.google.com with SMTP id 31so76753083wrm.1 for ; Fri, 02 Aug 2019 04:01:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=op5qMTCmnobHOHUOYgemlbsXJr25MTo6R85Nb11EB5E=; b=NIjm0eYmXpJA7o7ypfOzMCZrHCNxzqmTKp8tblACQ/f+4wQLIL15p8ndWU/LojNPEC 6v3R9+Vr263NtbKix0WJ11VoxDJfXftZKBHLIHSGOayFrNgLeATef++tkc+8c0JeDmuu FCJxDmz7TLLUb+AZS3hlXAqUvzujm5jCEDwrh+E1lHkzH8Qq7J0UsO/OZNPX8qMsGGFM Uzmiv9WP8s6rJzMOej883Wr7XBcgYIAwCk3ajTrpSuL+kMv1XYDbGD4XAJpuOSiJVCE1 O61qFMIJvd1Xbk01NNTJLq1CBLNKsX3efJLnc6A/xhnAn8OoYPmih6osgOJWRBOO0hGK WM3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=op5qMTCmnobHOHUOYgemlbsXJr25MTo6R85Nb11EB5E=; b=lLu36gDxcNImA4qVFbbOe8Rc20HtonRIQEitjUyoMSShv6i5/Lj25jYzUT4fTi1HxX wXO3ovY0dxFb7qtUh6gcisgDRbUA5ar0k4CibEl8xTuB6SnAAxSZXZVrO3Tts/Qpp6fm mQhR+lKFvsM3y7dxuLi1oabFj6HRYnx/Bk1QxosURz8T4tjUUasQWsqXRhCn/Z0UBdkV faA5zMxl4mp3/6Xa+tkDD0vJtcxGZRxYfH7ktT7mvNIKAf+JgKDO+xUc5U/b3FzgNZiI wRzvE4kIi89ec7YaudfO3+pUwdGXQbQ9AoVanZWYHp5AiUphfLatpQojxxubUzFCFhRU scHg== X-Gm-Message-State: APjAAAVBJhhMn5rSXMNXsZcRVqTsDClALm/izBANGijCSMvfgRlrtd1D xNGKmoAXUkJ8W95Swg5PLfEoEvqRICY= X-Google-Smtp-Source: APXvYqwrrTsc3KaqEm6VfAfXgVowCyibx11Mp6OEBdG6zkF1gW2xv1fEgQO1BL5/9ut+yGjuvfTYqA== X-Received: by 2002:a05:6000:187:: with SMTP id p7mr22271342wrx.189.1564743667364; Fri, 02 Aug 2019 04:01:07 -0700 (PDT) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id r15sm79511433wrj.68.2019.08.02.04.01.06 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 02 Aug 2019 04:01:06 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH v2 2/6] trace-cmd: Move plugin options from trace-cmd to libtraceevent. Date: Fri, 2 Aug 2019 14:00:57 +0300 Message-Id: <20190802110101.14759-3-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190802110101.14759-1-tz.stoyanov@gmail.com> References: <20190802110101.14759-1-tz.stoyanov@gmail.com> MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are two different implementations of plugin options, which work in parallel - one in trace-cmd and the other one in libtraceevent. Both have the same functionality and most of the implementation is the same, duplicated. As currently there are only libtraceevent plugins,the implementation plugin options should be in libtraceevent only. Signed-off-by: Tzvetomir Stoyanov (VMware) --- include/trace-cmd/trace-cmd.h | 6 - include/traceevent/event-parse.h | 2 + kernel-shark/src/libkshark.c | 4 +- lib/trace-cmd/trace-ftrace.c | 4 +- lib/trace-cmd/trace-util.c | 422 ------------------------------- lib/traceevent/event-plugin.c | 173 +++++++++++++ plugins/plugin_function.c | 4 +- tracecmd/trace-list.c | 2 +- tracecmd/trace-read.c | 2 +- 9 files changed, 183 insertions(+), 436 deletions(-) diff --git a/include/trace-cmd/trace-cmd.h b/include/trace-cmd/trace-cmd.h index 6f62ab9..c06067e 100644 --- a/include/trace-cmd/trace-cmd.h +++ b/include/trace-cmd/trace-cmd.h @@ -337,9 +337,6 @@ void tracecmd_msg_set_done(struct tracecmd_msg_handle *msg_handle); /* --- Plugin handling --- */ extern struct tep_plugin_option trace_ftrace_options[]; -int trace_util_add_options(const char *name, struct tep_plugin_option *options); -void trace_util_remove_options(struct tep_plugin_option *options); -int trace_util_add_option(const char *name, const char *val); int trace_util_load_plugins(struct tep_handle *pevent, const char *suffix, int (*load_plugin)(struct tep_handle *pevent, const char *path, @@ -352,10 +349,7 @@ char **trace_util_find_plugin_files(const char *suffix); void trace_util_free_plugin_files(char **files); void trace_util_print_plugins(struct trace_seq *s, const char *prefix, const char *suffix, const struct tep_plugin_list *list); -void trace_util_print_plugin_options(struct trace_seq *s); -char **trace_util_list_plugin_options(void); void trace_util_free_plugin_options_list(char **list); -const char *trace_util_plugin_option_value(const char *name); /* Used for trace-cmd list */ void tracecmd_ftrace_load_options(void); diff --git a/include/traceevent/event-parse.h b/include/traceevent/event-parse.h index 65cabd9..a51b73f 100644 --- a/include/traceevent/event-parse.h +++ b/include/traceevent/event-parse.h @@ -386,7 +386,9 @@ char **tep_plugin_list_options(void); void tep_plugin_free_options_list(char **list); int tep_plugin_add_options(const char *name, struct tep_plugin_option *options); +int tep_plugin_add_option(const char *name, const char *val); void tep_plugin_remove_options(struct tep_plugin_option *options); +void tep_plugin_print_options(struct trace_seq *s); void tep_print_plugins(struct trace_seq *s, const char *prefix, const char *suffix, const struct tep_plugin_list *list); diff --git a/kernel-shark/src/libkshark.c b/kernel-shark/src/libkshark.c index 4201fa0..47ec9c2 100644 --- a/kernel-shark/src/libkshark.c +++ b/kernel-shark/src/libkshark.c @@ -160,8 +160,8 @@ bool kshark_open(struct kshark_context *kshark_ctx, const char *file) * Turn off function trace indent and turn on show parent * if possible. */ - trace_util_add_option("ftrace:parent", "1"); - trace_util_add_option("ftrace:indent", "0"); + tep_plugin_add_option("ftrace:parent", "1"); + tep_plugin_add_option("ftrace:indent", "0"); return true; } diff --git a/lib/trace-cmd/trace-ftrace.c b/lib/trace-cmd/trace-ftrace.c index 22e5213..20bf71f 100644 --- a/lib/trace-cmd/trace-ftrace.c +++ b/lib/trace-cmd/trace-ftrace.c @@ -359,7 +359,7 @@ fgraph_ret_handler(struct trace_seq *s, struct tep_record *record, */ void tracecmd_ftrace_load_options(void) { - trace_util_add_options("ftrace", trace_ftrace_options); + tep_plugin_add_options("ftrace", trace_ftrace_options); } int tracecmd_ftrace_overrides(struct tracecmd_input *handle, @@ -381,7 +381,7 @@ int tracecmd_ftrace_overrides(struct tracecmd_input *handle, tep_register_event_handler(pevent, -1, "ftrace", "funcgraph_exit", fgraph_ret_handler, finfo); - trace_util_add_options("ftrace", trace_ftrace_options); + tep_plugin_add_options("ftrace", trace_ftrace_options); /* Store the func ret id and event for later use */ event = tep_find_event_by_name(pevent, "ftrace", "funcgraph_exit"); diff --git a/lib/trace-cmd/trace-util.c b/lib/trace-cmd/trace-util.c index 7c74bae..910c6c5 100644 --- a/lib/trace-cmd/trace-util.c +++ b/lib/trace-cmd/trace-util.c @@ -29,18 +29,6 @@ int tracecmd_disable_sys_plugins; int tracecmd_disable_plugins; -static struct registered_plugin_options { - struct registered_plugin_options *next; - struct tep_plugin_option *options; -} *registered_options; - -static struct trace_plugin_options { - struct trace_plugin_options *next; - char *plugin; - char *option; - char *value; -} *trace_plugin_options; - #define _STR(x) #x #define STR(x) _STR(x) @@ -50,108 +38,11 @@ struct tep_plugin_list { void *handle; }; -/** - * trace_util_list_plugin_options - get list of plugin options - * - * Returns an array of char strings that list the currently registered - * plugin options in the format of :