From patchwork Wed Jan 30 10:44:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10788205 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 2F859184E for ; Wed, 30 Jan 2019 10:44:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D3752E452 for ; Wed, 30 Jan 2019 10:44:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10F312E460; Wed, 30 Jan 2019 10:44:31 +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=-7.9 required=2.0 tests=BAYES_00,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 8C3852E45E for ; Wed, 30 Jan 2019 10:44:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729299AbfA3Koa (ORCPT ); Wed, 30 Jan 2019 05:44:30 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:52000 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726713AbfA3Koa (ORCPT ); Wed, 30 Jan 2019 05:44:30 -0500 Received: by mail-wm1-f65.google.com with SMTP id b11so21116027wmj.1 for ; Wed, 30 Jan 2019 02:44:29 -0800 (PST) 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=JralAxeVGx+pGJ06i5VjKWmYVAl7H1mEusrh+LLkpuE=; b=P9/BzXNdQzY7vtgB8RxnIUaQ/A/wZfZOo5teVqZh8FImD81ZJgOuFdOqkoxFOLW6Ba JKHxMQPt57rZ/QHFXvjZUK+wmMCIREJJLkeaeC3d9RGU9CVK93ygsoz6d8Cfy7lDJcv8 3EFIQuc+B81yiV4XOuVDI0aI/N/oB+3sgKZ9QKzJD5rY3L9IakVxcaXVPYPJ87LxaxpQ hrumLT7Pvkx4t73IhiHHBeAnelKFWbNPYgmBsf2XEe2iaz6QdeU9k0uj8EeyFmsKRjIq 2q7SNWT2I79oKP//45+8DCdUcg4uDLpalrWros2i3kF5T1WSN4tHHD8UqWruRe/fJJ5K Izaw== X-Gm-Message-State: AJcUukcO6yrotZ0NBaZq4gbSzy984slKwGToxnlxluuHPGE8KU9jOkHI x7g65EMYUSEjkRLZ22Wf3oE= X-Google-Smtp-Source: ALg8bN7eh3ajNBbwjgYlVSz+VGm0mhioI7dD/8uGyHzwyKqubHE2W3NTUxOBOKL7RllroCG6fcXazg== X-Received: by 2002:a7b:c44d:: with SMTP id l13mr25131475wmi.144.1548845068485; Wed, 30 Jan 2019 02:44:28 -0800 (PST) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id w12sm503079wrr.23.2019.01.30.02.44.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Jan 2019 02:44:27 -0800 (PST) From: Tzvetomir Stoyanov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, Andrew Morton , Jiri Olsa , Namhyung Kim , Arnaldo Carvalho de Melo Subject: [PATCH 1/6] trace-cmd: Initialize host_bigendian at tep_handle allocation Date: Wed, 30 Jan 2019 12:44:20 +0200 Message-Id: <20190130104425.8813-2-tstoyanov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190130104425.8813-1-tstoyanov@vmware.com> References: <20190130104425.8813-1-tstoyanov@vmware.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 This patch initializes the host_bigendian member of the tep_handle structure with the byte order of the current host, when this handler is created - in tep_alloc() API. We need this in order to remove the tep_set_host_bigendian() API. Signed-off-by: Tzvetomir Stoyanov Cc: Andrew Morton Cc: Jiri Olsa Cc: Namhyung Kim Link: http://lkml.kernel.org/r/20181201040852.216292134@goodmis.org Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Arnaldo Carvalho de Melo --- lib/traceevent/event-parse.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/traceevent/event-parse.c b/lib/traceevent/event-parse.c index 3f85b94..b506dc7 100644 --- a/lib/traceevent/event-parse.c +++ b/lib/traceevent/event-parse.c @@ -6829,8 +6829,10 @@ struct tep_handle *tep_alloc(void) { struct tep_handle *pevent = calloc(1, sizeof(*pevent)); - if (pevent) + if (pevent) { pevent->ref_count = 1; + pevent->host_bigendian = tep_host_bigendian(); + } return pevent; } From patchwork Wed Jan 30 10:44:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10788207 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 E684913B4 for ; Wed, 30 Jan 2019 10:44:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2B492E452 for ; Wed, 30 Jan 2019 10:44:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C74152E478; Wed, 30 Jan 2019 10:44:32 +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=-7.9 required=2.0 tests=BAYES_00,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 1D0BB2E452 for ; Wed, 30 Jan 2019 10:44:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729498AbfA3Koc (ORCPT ); Wed, 30 Jan 2019 05:44:32 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:41468 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726548AbfA3Kob (ORCPT ); Wed, 30 Jan 2019 05:44:31 -0500 Received: by mail-wr1-f68.google.com with SMTP id x10so25432592wrs.8 for ; Wed, 30 Jan 2019 02:44:30 -0800 (PST) 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=hp78ZfnBwjZGta5mALPAnQjOB/5k6jNLjv6/AK8elN4=; b=K60E2yA8x7Ua5FLZ9BJwvXugTtXKCPprla3rTS9eu/zZqZE/cXkabLl4+9JOoppOdb rE3NaN/Mh4dgAe6Fb5HiajxJRkFuxFzH9IwNhgGtl3ZHtUEve1Y8JLlIqhKcfzRTpF/L D+uimdE7y2ErjeNm9jDfX6RRzlsMJLZlpsgZxOwmHvBhkaJice0joA718R+K0w/VOpzP Rtr8V1SZDwSFd8dqbV0ExvXwyH+w2l0hLFUPHwz1wzZ2v1I6QON2NYlOevdT/wfkHJFR fyGrZ3NmLMNBchidNn0LVdbmBue/WfM5nCjur9RUa9sYuralMlhDkik088Xp921WNTfg eynw== X-Gm-Message-State: AJcUukfcvtd/Z/yY5yYjMTZj5vOSK9xUz4z8pc+LC9Sj3MXkR2DVCuCS pH1VoNILgJmUbcpocSeagOzaKl1v X-Google-Smtp-Source: ALg8bN7jKRb8oo7E1tkrh5JXVVoa7EogekCDc4H9mqjptxLGDclEXsjNFj2WzdiuCJAwWpfXZASGVw== X-Received: by 2002:adf:891a:: with SMTP id s26mr29360303wrs.44.1548845069539; Wed, 30 Jan 2019 02:44:29 -0800 (PST) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id w12sm503079wrr.23.2019.01.30.02.44.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Jan 2019 02:44:29 -0800 (PST) From: Tzvetomir Stoyanov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, Andrew Morton , Jiri Olsa , Namhyung Kim , Arnaldo Carvalho de Melo Subject: [PATCH 2/6] trace_cmd: Rename struct cmdline to struct tep_cmdline Date: Wed, 30 Jan 2019 12:44:21 +0200 Message-Id: <20190130104425.8813-3-tstoyanov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190130104425.8813-1-tstoyanov@vmware.com> References: <20190130104425.8813-1-tstoyanov@vmware.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 In order to make libtraceevent a proper library, variables, data structures and functions should have a unique prefix to prevent name space conflicts. That prefix will be "tep_". This patch renames 'struct cmdline' to 'struct tep_cmdline'. Signed-off-by: Tzvetomir Stoyanov Cc: Andrew Morton Cc: Jiri Olsa Cc: Namhyung Kim Link: http://lkml.kernel.org/r/20181201040852.358871851@goodmis.org Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Arnaldo Carvalho de Melo --- include/traceevent/event-parse.h | 8 +++---- lib/traceevent/event-parse-local.h | 4 ++-- lib/traceevent/event-parse.c | 36 +++++++++++++++--------------- tracecmd/trace-read.c | 3 ++- 4 files changed, 26 insertions(+), 25 deletions(-) diff --git a/include/traceevent/event-parse.h b/include/traceevent/event-parse.h index 3f2ae80..426b7eb 100644 --- a/include/traceevent/event-parse.h +++ b/include/traceevent/event-parse.h @@ -515,10 +515,10 @@ int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec); int tep_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec); int tep_data_flags(struct tep_handle *pevent, struct tep_record *rec); const char *tep_data_comm_from_pid(struct tep_handle *pevent, int pid); -struct cmdline; -struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm, - struct cmdline *next); -int tep_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline); +struct tep_cmdline; +struct tep_cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm, + struct tep_cmdline *next); +int tep_cmdline_pid(struct tep_handle *pevent, struct tep_cmdline *cmdline); void tep_print_field(struct trace_seq *s, void *data, struct tep_format_field *field); diff --git a/lib/traceevent/event-parse-local.h b/lib/traceevent/event-parse-local.h index 70693b8..c5c8eb4 100644 --- a/lib/traceevent/event-parse-local.h +++ b/lib/traceevent/event-parse-local.h @@ -7,7 +7,7 @@ #ifndef _PARSE_EVENTS_INT_H #define _PARSE_EVENTS_INT_H -struct cmdline; +struct tep_cmdline; struct cmdline_list; struct func_map; struct func_list; @@ -36,7 +36,7 @@ struct tep_handle { int long_size; int page_size; - struct cmdline *cmdlines; + struct tep_cmdline *cmdlines; struct cmdline_list *cmdlist; int cmdline_count; diff --git a/lib/traceevent/event-parse.c b/lib/traceevent/event-parse.c index b506dc7..1f1821d 100644 --- a/lib/traceevent/event-parse.c +++ b/lib/traceevent/event-parse.c @@ -124,15 +124,15 @@ struct tep_print_arg *alloc_arg(void) return calloc(1, sizeof(struct tep_print_arg)); } -struct cmdline { +struct tep_cmdline { char *comm; int pid; }; static int cmdline_cmp(const void *a, const void *b) { - const struct cmdline *ca = a; - const struct cmdline *cb = b; + const struct tep_cmdline *ca = a; + const struct tep_cmdline *cb = b; if (ca->pid < cb->pid) return -1; @@ -152,7 +152,7 @@ static int cmdline_init(struct tep_handle *pevent) { struct cmdline_list *cmdlist = pevent->cmdlist; struct cmdline_list *item; - struct cmdline *cmdlines; + struct tep_cmdline *cmdlines; int i; cmdlines = malloc(sizeof(*cmdlines) * pevent->cmdline_count); @@ -179,8 +179,8 @@ static int cmdline_init(struct tep_handle *pevent) static const char *find_cmdline(struct tep_handle *pevent, int pid) { - const struct cmdline *comm; - struct cmdline key; + const struct tep_cmdline *comm; + struct tep_cmdline key; if (!pid) return ""; @@ -208,8 +208,8 @@ static const char *find_cmdline(struct tep_handle *pevent, int pid) */ int tep_pid_is_registered(struct tep_handle *pevent, int pid) { - const struct cmdline *comm; - struct cmdline key; + const struct tep_cmdline *comm; + struct tep_cmdline key; if (!pid) return 1; @@ -235,9 +235,9 @@ int tep_pid_is_registered(struct tep_handle *pevent, int pid) static int add_new_comm(struct tep_handle *pevent, const char *comm, int pid, bool override) { - struct cmdline *cmdlines = pevent->cmdlines; - struct cmdline *cmdline; - struct cmdline key; + struct tep_cmdline *cmdlines = pevent->cmdlines; + struct tep_cmdline *cmdline; + struct tep_cmdline key; char *new_comm; if (!pid) @@ -5332,8 +5332,8 @@ const char *tep_data_comm_from_pid(struct tep_handle *pevent, int pid) return comm; } -static struct cmdline * -pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *next) +static struct tep_cmdline * +pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct tep_cmdline *next) { struct cmdline_list *cmdlist = (struct cmdline_list *)next; @@ -5345,7 +5345,7 @@ pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *ne while (cmdlist && strcmp(cmdlist->comm, comm) != 0) cmdlist = cmdlist->next; - return (struct cmdline *)cmdlist; + return (struct tep_cmdline *)cmdlist; } /** @@ -5361,10 +5361,10 @@ pid_from_cmdlist(struct tep_handle *pevent, const char *comm, struct cmdline *ne * next pid. * Also, it does a linear search, so it may be slow. */ -struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm, - struct cmdline *next) +struct tep_cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *comm, + struct tep_cmdline *next) { - struct cmdline *cmdline; + struct tep_cmdline *cmdline; /* * If the cmdlines have not been converted yet, then use @@ -5403,7 +5403,7 @@ struct cmdline *tep_data_pid_from_comm(struct tep_handle *pevent, const char *co * Returns the pid for a give cmdline. If @cmdline is NULL, then * -1 is returned. */ -int tep_cmdline_pid(struct tep_handle *pevent, struct cmdline *cmdline) +int tep_cmdline_pid(struct tep_handle *pevent, struct tep_cmdline *cmdline) { struct cmdline_list *cmdlist = (struct cmdline_list *)cmdline; diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c index 804022a..4cc1f61 100644 --- a/tracecmd/trace-read.c +++ b/tracecmd/trace-read.c @@ -419,9 +419,10 @@ static char *append_pid_filter(char *curr_filter, char *pid) static void convert_comm_filter(struct tracecmd_input *handle) { + struct tep_cmdline *cmdline; struct tep_handle *pevent; struct pid_list *list; - struct cmdline *cmdline; + char pidstr[100]; if (!comm_list) From patchwork Wed Jan 30 10:44:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10788209 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 6584F184E for ; Wed, 30 Jan 2019 10:44:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5280F2E452 for ; Wed, 30 Jan 2019 10:44:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 474A52E45E; Wed, 30 Jan 2019 10:44:33 +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=-7.9 required=2.0 tests=BAYES_00,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 DAEDA2E6A4 for ; Wed, 30 Jan 2019 10:44:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730475AbfA3Koc (ORCPT ); Wed, 30 Jan 2019 05:44:32 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:33363 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726713AbfA3Koc (ORCPT ); Wed, 30 Jan 2019 05:44:32 -0500 Received: by mail-wm1-f65.google.com with SMTP id r24so15141869wmh.0 for ; Wed, 30 Jan 2019 02:44:31 -0800 (PST) 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=oDePjZsBlUkGv8i5axMEwFpCZSBLwXX9Yi3vtL/fVV4=; b=RRJVlKaSNlZ3CRPkGVSEbZCxgU+2g8SbXCxE7xmyDOjlR9rw7h2xrSz5by64gAEpcj o9qRO7eY2gnzET21ntLpb/PYX7Zrg+fv9BJE5YynvkiehFkMLqKdYOJ8/ktnlhlbrWBZ YkeT5+VAV1UnvU3sJuQ/6v8fGvGXSrNVu8kxsETX3l4aYoUQ3D27pdIwmyy0wO/NJL8V JOJ9ubXbPxScwa6K1qPn4eh+FMrvh7W+aCabjLhoqHd7STieYMOOxxstgXj8AmeuIvxJ PVkGMd68LXySjPOzA2/Vtl9zlqN7F0SyHlgqqY1Uf1teJ8b3I0FDWst5xleWmWzQFu9h lwXw== X-Gm-Message-State: AJcUukfETPhc3Jjs8SqStmm17z1HGOYMGBk5hdG1BJaBrkisYzGFUGsg k6KLoCcHpMQnRlL7oJXUVX4= X-Google-Smtp-Source: ALg8bN7UHFp9Kjp0gAcf5A4/bzImO8o5rLVkQzhBg1OQHOtQsUpRmHeVravfMZiVHrT0N4/OUbNyiw== X-Received: by 2002:a1c:e1d5:: with SMTP id y204mr24730079wmg.65.1548845070652; Wed, 30 Jan 2019 02:44:30 -0800 (PST) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id w12sm503079wrr.23.2019.01.30.02.44.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Jan 2019 02:44:30 -0800 (PST) From: Tzvetomir Stoyanov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, Andrew Morton , Jiri Olsa , Namhyung Kim , Arnaldo Carvalho de Melo Subject: [PATCH 3/6] trace-cmd: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs Date: Wed, 30 Jan 2019 12:44:22 +0200 Message-Id: <20190130104425.8813-4-tstoyanov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190130104425.8813-1-tstoyanov@vmware.com> References: <20190130104425.8813-1-tstoyanov@vmware.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 In order to make libtraceevent into a proper library, its API should be straightforward. The trace_seq_printf() and trace_seq_vprintf() APIs have inconsistent returned values with the other trace_seq_* APIs. This path changes the return logic of trace_seq_printf() and trace_seq_vprintf() to return the number of printed characters, as the other trace_seq_* related APIs. Signed-off-by: Tzvetomir Stoyanov Cc: Andrew Morton Cc: Jiri Olsa Cc: Namhyung Kim Link: http://lkml.kernel.org/r/20181201040852.485792891@goodmis.org Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Arnaldo Carvalho de Melo --- lib/traceevent/trace-seq.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/traceevent/trace-seq.c b/lib/traceevent/trace-seq.c index 7f0c2f0..a20dab1 100644 --- a/lib/traceevent/trace-seq.c +++ b/lib/traceevent/trace-seq.c @@ -100,7 +100,8 @@ static void expand_buffer(struct trace_seq *s) * @fmt: printf format string * * It returns 0 if the trace oversizes the buffer's free - * space, 1 otherwise. + * space, the number of characters printed, or a negative + * value in case of an error. * * The tracer may use either sequence operations or its own * copy to user routines. To simplify formating of a trace @@ -129,9 +130,10 @@ trace_seq_printf(struct trace_seq *s, const char *fmt, ...) goto try_again; } - s->len += ret; + if (ret > 0) + s->len += ret; - return 1; + return ret; } /** @@ -139,6 +141,10 @@ trace_seq_printf(struct trace_seq *s, const char *fmt, ...) * @s: trace sequence descriptor * @fmt: printf format string * + * It returns 0 if the trace oversizes the buffer's free + * space, the number of characters printed, or a negative + * value in case of an error. + * * * The tracer may use either sequence operations or its own * copy to user routines. To simplify formating of a trace * trace_seq_printf is used to store strings into a special @@ -163,9 +169,10 @@ trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args) goto try_again; } - s->len += ret; + if (ret > 0) + s->len += ret; - return len; + return ret; } /** From patchwork Wed Jan 30 10:44:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10788211 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 1EFA86C2 for ; Wed, 30 Jan 2019 10:44:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C8282E452 for ; Wed, 30 Jan 2019 10:44:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00BB42E478; Wed, 30 Jan 2019 10:44:33 +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=-7.9 required=2.0 tests=BAYES_00,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 8D1A52E452 for ; Wed, 30 Jan 2019 10:44:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726713AbfA3Kod (ORCPT ); Wed, 30 Jan 2019 05:44:33 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:38765 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726548AbfA3Kod (ORCPT ); Wed, 30 Jan 2019 05:44:33 -0500 Received: by mail-wr1-f65.google.com with SMTP id v13so25440759wrw.5 for ; Wed, 30 Jan 2019 02:44:32 -0800 (PST) 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=X1p0J0O2F41sMT9Os/4Rv1FgYkr1f9hXI6aZCcKN5+I=; b=hNQ2ExpGWVHuwpuUiMJo+MfKx1JLdRDRDfImwzwJbi52jHzRNn+NijZ89daRAGqH7e fYpZJmOJGCs83EMuwHaaJStfuBYfeq++O/yU4vdCKi4PjxJ+l6Qp8Bk/028wgoYtgIzK VV+FVQ6Xgy6l56Q8amcB0RwDgPsaXxLU5/DbwekWc98Y5nTyXSavFDPxCnaoT8KNuNJr gCUu7aH5ez0PM+Tw8q5cUHuzTr4sSSl2ti6qfh1aHBJ14bvvNW+g8nCkRKS+FFcVtt5q +cZjw5ZYAk/xXxG4/xwIzLsOyPGsvPG4TZi/eFl8BOPtGDyijjFs93gOejCQ0VtgFRyh ockw== X-Gm-Message-State: AJcUukdw6uiHqNEfLoaz1d6bytMhoMSQ/a3pobtG0/pzG9GQRmrmwFMc r7pFbzRpNlPDSIKbXhGwxEd4fC1Q X-Google-Smtp-Source: ALg8bN6O2ddklWrslx8X4l0z7yp9qJKpE7nzQb5NE38LtOUICG/Q+UgPV7KxGkRd2hFgzDIUia1X9A== X-Received: by 2002:adf:8544:: with SMTP id 62mr30955120wrh.1.1548845071752; Wed, 30 Jan 2019 02:44:31 -0800 (PST) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id w12sm503079wrr.23.2019.01.30.02.44.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Jan 2019 02:44:31 -0800 (PST) From: Tzvetomir Stoyanov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, Andrew Morton , Jiri Olsa , Namhyung Kim , Arnaldo Carvalho de Melo Subject: [PATCH 4/6] trace-cmd: Changed return logic of tep_register_event_handler() API Date: Wed, 30 Jan 2019 12:44:23 +0200 Message-Id: <20190130104425.8813-5-tstoyanov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190130104425.8813-1-tstoyanov@vmware.com> References: <20190130104425.8813-1-tstoyanov@vmware.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 In order to make libtraceevent into a proper library, its API should be straightforward. The tep_register_event_handler() functions returns -1 in case it successfully registers the new event handler. Such return code is used by the other library APIs in case of an error. To unify the return logic of tep_register_event_handler() with the other APIs, this patch introduces enum tep_reg_handler, which is used by this function as return value, to handle all possible successful return cases. Signed-off-by: Tzvetomir Stoyanov Cc: Andrew Morton Cc: Jiri Olsa Cc: Namhyung Kim Link: http://lkml.kernel.org/r/20181201040852.628034497@goodmis.org Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Arnaldo Carvalho de Melo --- include/traceevent/event-parse.h | 5 +++++ lib/traceevent/event-parse.c | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/traceevent/event-parse.h b/include/traceevent/event-parse.h index 426b7eb..b4fa2c7 100644 --- a/include/traceevent/event-parse.h +++ b/include/traceevent/event-parse.h @@ -473,6 +473,11 @@ int tep_print_func_field(struct trace_seq *s, const char *fmt, struct tep_event *event, const char *name, struct tep_record *record, int err); +enum tep_reg_handler { + TEP_REGISTER_SUCCESS = 0, + TEP_REGISTER_SUCCESS_OVERWRITE, +}; + int tep_register_event_handler(struct tep_handle *pevent, int id, const char *sys_name, const char *event_name, tep_event_handler_func func, void *context); diff --git a/lib/traceevent/event-parse.c b/lib/traceevent/event-parse.c index 1f1821d..8cdb5a3 100644 --- a/lib/traceevent/event-parse.c +++ b/lib/traceevent/event-parse.c @@ -6699,6 +6699,12 @@ static struct tep_event *search_event(struct tep_handle *pevent, int id, * * If @id is >= 0, then it is used to find the event. * else @sys_name and @event_name are used. + * + * Returns: + * TEP_REGISTER_SUCCESS_OVERWRITE if an existing handler is overwritten + * TEP_REGISTER_SUCCESS if a new handler is registered successfully + * negative TEP_ERRNO_... in case of an error + * */ int tep_register_event_handler(struct tep_handle *pevent, int id, const char *sys_name, const char *event_name, @@ -6716,7 +6722,7 @@ int tep_register_event_handler(struct tep_handle *pevent, int id, event->handler = func; event->context = context; - return 0; + return TEP_REGISTER_SUCCESS_OVERWRITE; not_found: /* Save for later use. */ @@ -6746,7 +6752,7 @@ int tep_register_event_handler(struct tep_handle *pevent, int id, pevent->handlers = handle; handle->context = context; - return -1; + return TEP_REGISTER_SUCCESS; } static int handle_matches(struct event_handler *handler, int id, From patchwork Wed Jan 30 10:44:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10788213 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 A4ABB6C2 for ; Wed, 30 Jan 2019 10:44:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 914AC2E452 for ; Wed, 30 Jan 2019 10:44:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8600A2E478; Wed, 30 Jan 2019 10:44:36 +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=-7.9 required=2.0 tests=BAYES_00,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 F1D362E452 for ; Wed, 30 Jan 2019 10:44:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730515AbfA3Kof (ORCPT ); Wed, 30 Jan 2019 05:44:35 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:52574 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726548AbfA3Kof (ORCPT ); Wed, 30 Jan 2019 05:44:35 -0500 Received: by mail-wm1-f68.google.com with SMTP id m1so21102621wml.2 for ; Wed, 30 Jan 2019 02:44:33 -0800 (PST) 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=rCb3NGXA7lesF5jBW/ahfTz3WfjpVWV5itGnytj9UmE=; b=a9kyXyZuU++ld/yPc4eQeOEwRQWOcLrpuKaRJeHwlEzFVGLih34Ao+JNR2xbQNIcAv nIWR3cvrvJDRvQ5SHbVuoEfn9kY7dCyMWgtn9lCHwijJs5r761Q4KQ+F1EbbgvT2LyTe 7kPs2Zy1b4xP5hpC1eu91NEyhATA82VEJpXyAQ8z41QExUomD3KP3w777mugG/2cIPdg q09xTYRoSYuUKIobtwmMbSRDhwlMx8Bo2csGnlCDiV9pJ451RCurrQfXcebSLcOEaQP7 yerQMIBBLXtNTGpGQJn4H76yu3DGBsk9Az7mLGUcuK1owKyDfBPS7YTFt4OCAjcsrC9S xyaA== X-Gm-Message-State: AJcUukcyVAXw7J+FZanK8qV1Qrd0F9dVIivnp04w/BUkkzUhULmPOEz5 fdatYiQAuMW83IZXkNBachw= X-Google-Smtp-Source: ALg8bN5fprINCUoQQxUqmoFA1+nm33Knj6GZxWh0AlhmlJGE6e8QUdxTnX8LSQQVr7fS4dB4x8Vf4A== X-Received: by 2002:a1c:8c05:: with SMTP id o5mr23752489wmd.29.1548845072778; Wed, 30 Jan 2019 02:44:32 -0800 (PST) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id w12sm503079wrr.23.2019.01.30.02.44.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Jan 2019 02:44:32 -0800 (PST) From: Tzvetomir Stoyanov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, Andrew Morton , Jiri Olsa , Namhyung Kim , Arnaldo Carvalho de Melo Subject: [PATCH 5/6] trace-cmd: Rename tep_is_file_bigendian() to tep_file_bigendian() Date: Wed, 30 Jan 2019 12:44:24 +0200 Message-Id: <20190130104425.8813-6-tstoyanov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190130104425.8813-1-tstoyanov@vmware.com> References: <20190130104425.8813-1-tstoyanov@vmware.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 In order to make libtraceevent into a proper library, its API should be straightforward. After a discussion with Steven Rostedt, we decided to rename a few APIs, to have more intuitive names. This patch renames tep_is_file_bigendian() to tep_file_bigendian(). Signed-off-by: Tzvetomir Stoyanov Cc: Andrew Morton Cc: Jiri Olsa Cc: Namhyung Kim Link: http://lkml.kernel.org/r/20181201040852.767549746@goodmis.org Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Arnaldo Carvalho de Melo --- include/traceevent/event-parse.h | 2 +- lib/trace-cmd/trace-input.c | 8 ++++---- lib/traceevent/event-parse-api.c | 4 ++-- plugins/plugin_kvm.c | 2 +- python/tracecmd.py | 2 +- tracecmd/trace-output.c | 2 +- tracecmd/trace-read.c | 4 ++-- tracecmd/trace-split.c | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/traceevent/event-parse.h b/include/traceevent/event-parse.h index b4fa2c7..2dc5822 100644 --- a/include/traceevent/event-parse.h +++ b/include/traceevent/event-parse.h @@ -551,7 +551,7 @@ int tep_get_long_size(struct tep_handle *pevent); void tep_set_long_size(struct tep_handle *pevent, int long_size); int tep_get_page_size(struct tep_handle *pevent); void tep_set_page_size(struct tep_handle *pevent, int _page_size); -int tep_is_file_bigendian(struct tep_handle *pevent); +int tep_file_bigendian(struct tep_handle *pevent); void tep_set_file_bigendian(struct tep_handle *pevent, enum tep_endian endian); int tep_is_host_bigendian(struct tep_handle *pevent); void tep_set_host_bigendian(struct tep_handle *pevent, enum tep_endian endian); diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c index b628570..b161c75 100644 --- a/lib/trace-cmd/trace-input.c +++ b/lib/trace-cmd/trace-input.c @@ -1619,7 +1619,7 @@ tracecmd_translate_data(struct tracecmd_input *handle, memset(record, 0, sizeof(*record)); record->ref_count = 1; - if (tep_is_host_bigendian(pevent) == tep_is_file_bigendian(pevent)) + if (tep_is_host_bigendian(pevent) == tep_file_bigendian(pevent)) swap = 0; record->data = kbuffer_translate_data(swap, ptr, &length); record->size = length; @@ -1661,7 +1661,7 @@ tracecmd_read_page_record(struct tep_handle *pevent, void *page, int size, enum kbuffer_endian endian; void *ptr; - if (tep_is_file_bigendian(pevent)) + if (tep_file_bigendian(pevent)) endian = KBUFFER_ENDIAN_BIG; else endian = KBUFFER_ENDIAN_LITTLE; @@ -2266,7 +2266,7 @@ static int read_cpu_data(struct tracecmd_input *handle) else long_size = KBUFFER_LSIZE_4; - if (tep_is_file_bigendian(handle->pevent)) + if (tep_file_bigendian(handle->pevent)) endian = KBUFFER_ENDIAN_BIG; else endian = KBUFFER_ENDIAN_LITTLE; @@ -2475,7 +2475,7 @@ int tracecmd_make_pipe(struct tracecmd_input *handle, int cpu, int fd, int cpus) else long_size = KBUFFER_LSIZE_4; - if (tep_is_file_bigendian(handle->pevent)) + if (tep_file_bigendian(handle->pevent)) endian = KBUFFER_ENDIAN_BIG; else endian = KBUFFER_ENDIAN_LITTLE; diff --git a/lib/traceevent/event-parse-api.c b/lib/traceevent/event-parse-api.c index 347ff10..afafbc8 100644 --- a/lib/traceevent/event-parse-api.c +++ b/lib/traceevent/event-parse-api.c @@ -250,13 +250,13 @@ void tep_set_page_size(struct tep_handle *pevent, int _page_size) } /** - * tep_is_file_bigendian - get if the file is in big endian order + * tep_file_bigendian - get if the file is in big endian order * @pevent: a handle to the tep_handle * * This returns if the file is in big endian order * If @pevent is NULL, 0 is returned. */ -int tep_is_file_bigendian(struct tep_handle *pevent) +int tep_file_bigendian(struct tep_handle *pevent) { if (pevent) return pevent->file_bigendian; diff --git a/plugins/plugin_kvm.c b/plugins/plugin_kvm.c index f81d3c5..ddac21a 100644 --- a/plugins/plugin_kvm.c +++ b/plugins/plugin_kvm.c @@ -386,7 +386,7 @@ static int kvm_mmu_print_role(struct trace_seq *s, struct tep_record *record, * We can only use the structure if file is of the same * endianness. */ - if (tep_is_file_bigendian(event->pevent) == + if (tep_file_bigendian(event->pevent) == tep_is_host_bigendian(event->pevent)) { trace_seq_printf(s, "%u/%u q%u%s %s%s %spge %snxe", diff --git a/python/tracecmd.py b/python/tracecmd.py index f4f241e..60a0d3e 100644 --- a/python/tracecmd.py +++ b/python/tracecmd.py @@ -166,7 +166,7 @@ class PEvent(object): @cached_property def file_endian(self): - if tep_is_file_bigendian(self._pevent): + if tep_file_bigendian(self._pevent): return '>' return '<' diff --git a/tracecmd/trace-output.c b/tracecmd/trace-output.c index 33d6ce3..1c2e92c 100644 --- a/tracecmd/trace-output.c +++ b/tracecmd/trace-output.c @@ -808,7 +808,7 @@ create_file_fd(int fd, struct tracecmd_input *ihandle, /* Use the pevent of the ihandle for later writes */ handle->pevent = tracecmd_get_pevent(ihandle); tep_ref(pevent); - if (tep_is_file_bigendian(pevent)) + if (tep_file_bigendian(pevent)) buf[0] = 1; else buf[0] = 0; diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c index 4cc1f61..03c0978 100644 --- a/tracecmd/trace-read.c +++ b/tracecmd/trace-read.c @@ -1700,8 +1700,8 @@ void trace_report (int argc, char **argv) if (show_endian) { printf("file is %s endian and host is %s endian\n", - tep_is_file_bigendian(pevent) ? "big" : "little", - tep_is_host_bigendian(pevent) ? "big" : "little"); + tep_file_bigendian(pevent) ? "big" : "little", + tep_is_host_bigendian(pevent) ? "big" : "little"); return; } diff --git a/tracecmd/trace-split.c b/tracecmd/trace-split.c index d27b3c6..6043e97 100644 --- a/tracecmd/trace-split.c +++ b/tracecmd/trace-split.c @@ -64,7 +64,7 @@ static int create_type_len(struct tep_handle *pevent, int time, int len) bigendian = 1; } - if (tep_is_file_bigendian(pevent)) + if (tep_file_bigendian(pevent)) time |= (len << 27); else time = (time << 5) | len; From patchwork Wed Jan 30 10:44:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10788215 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 78C4E13B4 for ; Wed, 30 Jan 2019 10:44:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 64A532E452 for ; Wed, 30 Jan 2019 10:44:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58F062E45E; Wed, 30 Jan 2019 10:44:38 +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=-7.9 required=2.0 tests=BAYES_00,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 AE7422E6A4 for ; Wed, 30 Jan 2019 10:44:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726548AbfA3Koh (ORCPT ); Wed, 30 Jan 2019 05:44:37 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:53594 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730502AbfA3Koh (ORCPT ); Wed, 30 Jan 2019 05:44:37 -0500 Received: by mail-wm1-f66.google.com with SMTP id d15so21101743wmb.3 for ; Wed, 30 Jan 2019 02:44:34 -0800 (PST) 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=uUa6UOGfwFpW6lYT2yG1h1I9hSAzhtNgvqLBL5MAm2s=; b=fs3LYQf9l+qbZ8Cli10PhiLwg3n53+ZHzp0VIKPh0KVbM5PJ5/m96V6MJxOftCy82a V04CTcjC9P4mZ1Z04cxapDxMOtxGObjrzBgbrZDrWO1vu9EGuxmXsW3d9R7yJdTFzJUe 3vNBByST4WyvwmTdn9n7N4i+Co+IN0wGqad+TR2OZ0m/tT+HwmoRvyfqXZmUSLYRh2z+ lzr9MFMfKzpX27lo3iJwHv75ZZrLdzhm3tnFEkk9ta6ilpF+t3Z1vKhmoArylJnNoNHu J2cuAuKkjxkwXgYZ6qRGpJOsJhTu912ZYGhjuJDlnmoYBRWu1ls0JIc47LkJ8chr7qos AjVA== X-Gm-Message-State: AJcUukc8yg/lQKa4GJHO+QE03eww6hke3SwrmHAPVXWPJss/SEYxVOqD BwUtcQggp4/Gn49/YIDejrk= X-Google-Smtp-Source: ALg8bN4tN2GP3SyLqoGws2/rhYeTKvxah9heFU2AFSq0/KKGAx9wFalnZe1L7txAvl5CXWyKBsIVZg== X-Received: by 2002:a1c:8c13:: with SMTP id o19mr23729321wmd.56.1548845073935; Wed, 30 Jan 2019 02:44:33 -0800 (PST) Received: from oberon.eng.vmware.com ([146.247.46.5]) by smtp.gmail.com with ESMTPSA id w12sm503079wrr.23.2019.01.30.02.44.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 Jan 2019 02:44:33 -0800 (PST) From: Tzvetomir Stoyanov To: rostedt@goodmis.org Cc: linux-trace-devel@vger.kernel.org, Andrew Morton , Jiri Olsa , Namhyung Kim , Arnaldo Carvalho de Melo Subject: [PATCH 6/6] trace-cmd: Remove tep_data_event_from_type() API Date: Wed, 30 Jan 2019 12:44:25 +0200 Message-Id: <20190130104425.8813-7-tstoyanov@vmware.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190130104425.8813-1-tstoyanov@vmware.com> References: <20190130104425.8813-1-tstoyanov@vmware.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 In order to make libtraceevent into a proper library, its API should be straightforward. After discussion with Steven Rostedt, we decided to remove the tep_data_event_from_type() API and to replace it with tep_find_event(), as it does the same. Signed-off-by: Tzvetomir Stoyanov Cc: Andrew Morton Cc: Jiri Olsa Cc: Namhyung Kim Link: http://lkml.kernel.org/r/20181201040852.913841066@goodmis.org Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Arnaldo Carvalho de Melo --- include/traceevent/event-parse.h | 1 - kernel-shark/src/libkshark.c | 7 +++---- lib/traceevent/event-parse.c | 12 ------------ python/tracecmd.py | 8 ++++---- tracecmd/trace-hist.c | 4 ++-- tracecmd/trace-mem.c | 2 +- tracecmd/trace-record.c | 2 +- 7 files changed, 11 insertions(+), 25 deletions(-) diff --git a/include/traceevent/event-parse.h b/include/traceevent/event-parse.h index 2dc5822..bdc6101 100644 --- a/include/traceevent/event-parse.h +++ b/include/traceevent/event-parse.h @@ -515,7 +515,6 @@ tep_find_event_by_record(struct tep_handle *pevent, struct tep_record *record); void tep_data_lat_fmt(struct tep_handle *pevent, struct trace_seq *s, struct tep_record *record); int tep_data_type(struct tep_handle *pevent, struct tep_record *rec); -struct tep_event *tep_data_event_from_type(struct tep_handle *pevent, int type); int tep_data_pid(struct tep_handle *pevent, struct tep_record *rec); int tep_data_preempt_count(struct tep_handle *pevent, struct tep_record *rec); int tep_data_flags(struct tep_handle *pevent, struct tep_record *rec); diff --git a/kernel-shark/src/libkshark.c b/kernel-shark/src/libkshark.c index 5033e47..6a26f28 100644 --- a/kernel-shark/src/libkshark.c +++ b/kernel-shark/src/libkshark.c @@ -1187,7 +1187,7 @@ const char *kshark_get_event_name_easy(struct kshark_entry *entry) * Use a mutex to protect the access. */ pthread_mutex_lock(&kshark_ctx->input_mutex); - event = tep_data_event_from_type(kshark_ctx->pevent, event_id); + event = tep_find_event(kshark_ctx->pevent, event_id); pthread_mutex_unlock(&kshark_ctx->input_mutex); if (event) @@ -1236,7 +1236,7 @@ const char *kshark_get_info_easy(struct kshark_entry *entry) data = tracecmd_read_at(kshark_ctx->handle, entry->offset, NULL); event_id = tep_data_type(kshark_ctx->pevent, data); - event = tep_data_event_from_type(kshark_ctx->pevent, event_id); + event = tep_find_event(kshark_ctx->pevent, event_id); if (event) info = kshark_get_info(kshark_ctx->pevent, data, event); @@ -1330,8 +1330,7 @@ char* kshark_dump_entry(const struct kshark_entry *entry) data = tracecmd_read_at(kshark_ctx->handle, entry->offset, NULL); - event = tep_data_event_from_type(kshark_ctx->pevent, - entry->event_id); + event = tep_find_event(kshark_ctx->pevent, entry->event_id); event_name = event? event->name : "[UNKNOWN EVENT]"; lat = kshark_get_latency(kshark_ctx->pevent, data); diff --git a/lib/traceevent/event-parse.c b/lib/traceevent/event-parse.c index 8cdb5a3..ca2989b 100644 --- a/lib/traceevent/event-parse.c +++ b/lib/traceevent/event-parse.c @@ -5266,18 +5266,6 @@ int tep_data_type(struct tep_handle *pevent, struct tep_record *rec) return trace_parse_common_type(pevent, rec->data); } -/** - * tep_data_event_from_type - find the event by a given type - * @pevent: a handle to the pevent - * @type: the type of the event. - * - * This returns the event form a given @type; - */ -struct tep_event *tep_data_event_from_type(struct tep_handle *pevent, int type) -{ - return tep_find_event(pevent, type); -} - /** * tep_data_pid - parse the PID from record * @pevent: a handle to the pevent diff --git a/python/tracecmd.py b/python/tracecmd.py index 60a0d3e..a6671f6 100644 --- a/python/tracecmd.py +++ b/python/tracecmd.py @@ -204,7 +204,7 @@ class Trace(object): rec = tracecmd_read_data(self._handle, cpu) if rec: type = tep_data_type(self._pevent, rec) - format = tep_data_event_from_type(self._pevent, type) + format = tep_find_event(self._pevent, type) # rec ownership goes over to Event instance return Event(self._pevent, rec, format) return None @@ -216,7 +216,7 @@ class Trace(object): return None rec, cpu = res type = tep_data_type(self._pevent, rec) - format = tep_data_event_from_type(self._pevent, type) + format = tep_find_event(self._pevent, type) # rec ownership goes over to Event instance return Event(self._pevent, rec, format) @@ -226,7 +226,7 @@ class Trace(object): return None rec, cpu = res type = tep_data_type(self._pevent, rec) - format = tep_data_event_from_type(self._pevent, type) + format = tep_find_event(self._pevent, type) return Event(self._pevent, rec, format) def peek_event(self, cpu): @@ -234,7 +234,7 @@ class Trace(object): if rec is None: return None type = tep_data_type(self._pevent, rec) - format = tep_data_event_from_type(self._pevent, type) + format = tep_find_event(self._pevent, type) # rec ownership goes over to Event instance return Event(self._pevent, rec, format) diff --git a/tracecmd/trace-hist.c b/tracecmd/trace-hist.c index bd47163..384a7ff 100644 --- a/tracecmd/trace-hist.c +++ b/tracecmd/trace-hist.c @@ -541,7 +541,7 @@ process_event(struct tep_handle *pevent, struct tep_record *record, int type) reset_pending_stack(); } - event = tep_data_event_from_type(pevent, type); + event = tep_find_event(pevent, type); event_name = event->name; ret = tep_read_number_field(common_pid_field, record->data, &val); @@ -952,7 +952,7 @@ static void do_trace_hist(struct tracecmd_input *handle) die("No records found in file"); ret = tep_data_type(pevent, record); - event = tep_data_event_from_type(pevent, ret); + event = tep_find_event(pevent, ret); long_size = tracecmd_long_size(handle); diff --git a/tracecmd/trace-mem.c b/tracecmd/trace-mem.c index 059bf9a..078a61b 100644 --- a/tracecmd/trace-mem.c +++ b/tracecmd/trace-mem.c @@ -488,7 +488,7 @@ static void do_trace_mem(struct tracecmd_input *handle) die("No records found in file"); ret = tep_data_type(pevent, record); - event = tep_data_event_from_type(pevent, ret); + event = tep_find_event(pevent, ret); common_type_field = tep_find_common_field(event, "common_type"); if (!common_type_field) diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index 3034a4b..71a407e 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -3402,7 +3402,7 @@ find_ts_in_page(struct tep_handle *pevent, void *page, int size) break; free_record(last_record); id = tep_data_type(pevent, record); - event = tep_data_event_from_type(pevent, id); + event = tep_find_event(pevent, id); if (event) { /* Make sure this is our event */ field = tep_find_field(event, "buf");