From patchwork Fri Jul 26 12:43:06 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: 11060947 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 13B9A14DB for ; Fri, 26 Jul 2019 12:43:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0161628A8E for ; Fri, 26 Jul 2019 12:43:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9C0D28AA0; Fri, 26 Jul 2019 12:43: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 74D5628AB7 for ; Fri, 26 Jul 2019 12:43:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726555AbfGZMnO (ORCPT ); Fri, 26 Jul 2019 08:43:14 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:40884 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726385AbfGZMnN (ORCPT ); Fri, 26 Jul 2019 08:43:13 -0400 Received: by mail-wr1-f68.google.com with SMTP id r1so54297602wrl.7 for ; Fri, 26 Jul 2019 05:43:11 -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=vSMgTZBnebrioM963b7y1qQNs74OBJ4QHjcJ1c9PTg6Cq+0HZcwXpqPBFQahubxX1m 1wSGXrhAVjQFtLVf3hDpYgywJdehxPe67ldr+5qN4fYEbjXct8YeThwEwzTYOaO09jef VSF8U5Er8sV6B+XNJiviCUAeER/waUsHNoMhPJRHbDwce2HRuUvoLehpFTmCVfqE8Hnw qGDQgOlur7Hd7lndZ8ChkD57qYuh2swbMF9GD6lvubTOA0E5fNKE8y965mpTHZB2z0xa 97FwC0TolXlidohhj2ZAVB/Dx3CO4LOX55qpaJzpYN6H0hNkzpwHPzVF5pcGdcAhEOn7 CZfw== 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=CGjATmUOkOVzYpYyF2gQDUgwSq/7wdBS//y7LG8x/F62UQ4lUG4ETd83wTxabDXowM tt2t54ehJS54D06WvmrVEMtcHoFEKZrhWBOZpHEEoP1kx2ixiniziMdaeDyLV7LKJYH8 zJTdxpANVdEeVXzicy6dBqLiarNcJf+kfsmXybzK+Cs0+/TJw9HvZT1YnCUgaCa+lOWz ODrqvOKHIO/Qa2dmB/Nuz3K1nSySfhbc7/ZYzeFfpcRBp5vSeATP4wzVtLIcvNahz/Wh OdVRjvA0lG5pV7xzgBUZNk8VeY2E44X5gGeb54bw3eycaFCZxlhVN+UtBagIVTiz3kc4 1XtQ== X-Gm-Message-State: APjAAAXvhzaFeHbJ9drdt0oMyHtkNT+ivOv1+DfviymK2gWfwpU4zNaG QPhKa+HfTH2Aw5DCAsKIGM4= X-Google-Smtp-Source: APXvYqxfcvQKlo9kKWGEWRChkd6PPgs2OeSz1akLGhSAZLPVd+GTQjLsApZe+kXJlUXtj4joKctJzA== X-Received: by 2002:adf:ed0e:: with SMTP id a14mr102706587wro.259.1564144991354; Fri, 26 Jul 2019 05:43:11 -0700 (PDT) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id o26sm105565833wro.53.2019.07.26.05.43.10 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 26 Jul 2019 05:43:10 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 1/3] trace-cmd: Move kernel_stack event handler to "function" plugin. Date: Fri, 26 Jul 2019 15:43:06 +0300 Message-Id: <20190726124308.18735-2-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190726124308.18735-1-tz.stoyanov@gmail.com> References: <20190726124308.18735-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 Jul 26 12:43:07 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: 11060949 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 A7A4013A4 for ; Fri, 26 Jul 2019 12:43:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9443228ABC for ; Fri, 26 Jul 2019 12:43:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87C1B28AC0; Fri, 26 Jul 2019 12:43:20 +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 A473C2896F for ; Fri, 26 Jul 2019 12:43:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726287AbfGZMnR (ORCPT ); Fri, 26 Jul 2019 08:43:17 -0400 Received: from mail-wm1-f47.google.com ([209.85.128.47]:52654 "EHLO mail-wm1-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726277AbfGZMnR (ORCPT ); Fri, 26 Jul 2019 08:43:17 -0400 Received: by mail-wm1-f47.google.com with SMTP id s3so47888786wms.2 for ; Fri, 26 Jul 2019 05:43:14 -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=oM7A7XyQdnrPnTYd0apikbCIepXtezwplBu5oKy6ejNwi0vn3zhqH7RYs2xSmuRye4 z6J/z3sIbBSb96lzwg4W0w5ZNgLikWeMMg+JivPPupaL9nOILS1V2QX4/CcVVDh9CN91 oaByYf0++V2ZwPwnMGQ1hsrTpBMFg92fUlWSSC/7cEJfHOprX8p96xFVfdf/m6PJyQza GaFqE+PAS4Ep5r3mc60EEzhEjlLtqkNCskq/2Vym86gIFInx3dGPh34Ws00LGMMcZ8R6 QQ3frseD6DtErnqAVNgEI6e9m6TrI6JFT0JM2avavrts7WnvADG87AvyvRW42qmIc1++ b1fg== 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=iJO3uGLamqcNVs4zIfoRWKUWMLs2nsSVUCHA+K1eLyZdSX1v0azmnNotVrGkf+aX2D 64prh2V4vskGqIeButi3arNpblklK2mho1MEaWdYht26W6F0+z/KhO/UWqUKmBcdBxgQ +Zo7VsIiuap7JSs2Rryu/Ji5+96BFq/AhZemAkQJGnu11664aWFuEm1Rfj6bjGxxP2YV hAuBpZpQcnIJYybbqsKHtGhk9mBVbEJAyejzlNgE/irPoXshVAPHBZo2G6fF7/XOErp1 /Tzteryvl/aLrGM6KEMV/Z72T8F4f29hugO0A0RWniXPsFkJxOW7SM54ep6PEx9UjCDv tbow== X-Gm-Message-State: APjAAAXGOJovSjm+lwBGpGn7IXIgm2pU8Mc1pKhhvd9k2OO115Xr14Hn yd8XuRhyvmoTRoyeiWbTliI= X-Google-Smtp-Source: APXvYqxUXPvB9m8j5tuQ+8XoU2+lMTmilSjZSJHF9P22AAvNzrCvAKmDfEgaQEX+N/40mAOFuxY24w== X-Received: by 2002:a7b:ce18:: with SMTP id m24mr82538669wmc.126.1564144993028; Fri, 26 Jul 2019 05:43:13 -0700 (PDT) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id o26sm105565833wro.53.2019.07.26.05.43.11 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 26 Jul 2019 05:43:11 -0700 (PDT) From: "Tzvetomir Stoyanov (VMware)" To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org Subject: [PATCH 2/3] trace-cmd: Move plugin options from trace-cmd to libtraceevent. Date: Fri, 26 Jul 2019 15:43:07 +0300 Message-Id: <20190726124308.18735-3-tz.stoyanov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190726124308.18735-1-tz.stoyanov@gmail.com> References: <20190726124308.18735-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 :