From patchwork Mon Dec 6 15:08:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 12658707 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD8E3C43217 for ; Mon, 6 Dec 2021 15:14:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357157AbhLFPRy (ORCPT ); Mon, 6 Dec 2021 10:17:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358287AbhLFPQc (ORCPT ); Mon, 6 Dec 2021 10:16:32 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61301C08EACB for ; Mon, 6 Dec 2021 07:09:10 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id a9so23035001wrr.8 for ; Mon, 06 Dec 2021 07:09:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4W12fV+NtHd0BChwAsmuBju1L/2hdDUrECESygVCeco=; b=OFlZJvgR/HdNoIXpApHHd6gkms39lMNkLOsgQpbj8grWJHJB+EszxhPXYJb2dXfRtL Z+7s/2oRtF+vdiqtDE4rZo8a3Y4msm/XpggQrFQG6qZ6H31ZVImcm27nPTgh6oj6P7Cl LMikmGSn+xnVCP8vNwk7t+pIMSBjS2UlTTXcqMWlA5JK2PsKJ6gK1XOfrOYvq0+pUbNq 344BNkO2IGIzF8CUDb3As+ndmWSeEuu89qzOKXMNE3Hbs/G/eUux0iUHchxqYG65u4FQ BMMerF14P1JNUt9KPt28yqnW6sUE+paYASGfZrZ7b4d0C2h0VXooHFfjyxW0C+plHF2I UfOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4W12fV+NtHd0BChwAsmuBju1L/2hdDUrECESygVCeco=; b=e6Ti6rvcqxQ9cr+ICSrzDXNVjdq51ZdRKLgQU7zx0Hxq7CP1ZsAQUr4zqfGvPjLsLD USubjQo6eJWz9p8XIe+sqbEkGwoIeQyoDlixn9RfzwIm/sIAml3KJxac4S+iI3I8zGrq y4mgNf6XvPuvOsdEdARa52dyQbWhzZ+KRqMWspPslHxp6WDGDNAPhrCqW61kVMvS0NxZ 4fYwK92rUOD1Lm99BonpKTgCVcGbd9ajfRyL+r0OON/ldTUsuO5qeyeaA81QWv4upiOb j1eOxB8HXtjFcTV2IiIjiht+r/K3mhvhRzNqI03HYFrwQTiFOcOLQELM8UQ+k+YvTgLV CYGA== X-Gm-Message-State: AOAM533rMxzR5nD42A30Bb8QxsbcLBLCyCNydJKaz/ixPg97efmVPoCI B6VVZe+hNlXJTd0C1fBOLrlumiJW+o0= X-Google-Smtp-Source: ABdhPJy+4njnVYQCpPfxYHACJbPh3Kxe6+RJgKwCc1jO80/BHMFUN3NOEIWSQtOf+JtJn6gL0uJFcQ== X-Received: by 2002:a5d:630b:: with SMTP id i11mr42748542wru.316.1638803348722; Mon, 06 Dec 2021 07:09:08 -0800 (PST) Received: from crow.. ([95.87.219.163]) by smtp.gmail.com with ESMTPSA id d6sm11782668wrn.53.2021.12.06.07.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Dec 2021 07:09:08 -0800 (PST) From: "Yordan Karadzhov (VMware)" To: linux-trace-devel@vger.kernel.org, rostedt@goodmis.org Cc: "Yordan Karadzhov (VMware)" Subject: [PATCH 1/3] libtracefs: New API for getting the raw format of a histogram Date: Mon, 6 Dec 2021 17:08:53 +0200 Message-Id: <20211206150855.361202-2-y.karadz@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211206150855.361202-1-y.karadz@gmail.com> References: <20211206150855.361202-1-y.karadz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org The new API is similar to tracefs_hist_echo_cmd(), but prints just the raw format descriptor of the histogram. It can be useful in the case whene the user wants to check what exactly gets passed to the kernel as definition of the histogram. Signed-off-by: Yordan Karadzhov (VMware) --- Documentation/libtracefs-hist.txt | 11 ++++++++-- include/tracefs.h | 3 +++ src/tracefs-hist.c | 34 +++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/Documentation/libtracefs-hist.txt b/Documentation/libtracefs-hist.txt index 2eef718..c8230e5 100644 --- a/Documentation/libtracefs-hist.txt +++ b/Documentation/libtracefs-hist.txt @@ -4,7 +4,8 @@ libtracefs(3) NAME ---- tracefs_hist_alloc, tracefs_hist_free, tracefs_hist_add_key, tracefs_hist_add_value, tracefs_hist_add_name, tracefs_hist_start, -tracefs_hist_destory, tracefs_hist_add_sort_key, tracefs_hist_set_sort_key,tracefs_hist_sort_key_direction - Create and update event histograms +tracefs_hist_destory, tracefs_hist_add_sort_key, tracefs_hist_set_sort_key, tracefs_hist_sort_key_direction +tracefs_hist_echo_cmd, tracefs_hist_echo_fmt - Create and update event histograms SYNOPSIS -------- @@ -69,6 +70,9 @@ int tracefs_hist_command(struct tracefs_instance pass:[*]instance, struct tracefs_hist pass:[*]hist, enum tracefs_hist_command command); +int tracefs_hist_echo_fmt(struct trace_seq pass:[*]s, struct tracefs_instance pass:[*]instance, + struct tracefs_hist pass:[*]hist); + -- DESCRIPTION @@ -178,11 +182,14 @@ _field_, _compare_, and _val_ are ignored unless _type_ is equal to *TRACEFS_COMPARE_AND* - _field_ & _val_ : where _field_ is a flags field. -*trace_hist_echo_cmd*() prints the commands needed to create the given histogram +*tracefs_hist_echo_cmd*() prints the commands needed to create the given histogram in the given _instance_, or NULL for the top level, into the _seq_. The command that is printed is described by _command_ and shows the functionality that would be done by *tracefs_hist_command*(3). +*tracefs_hist_echo_fmt*() prints the raw format that describes the state of the +histogram in the given _instance_, or NULL for the top level, into the _seq_. + *tracefs_hist_command*() is called to process a command on the histogram _hist_ for its event in the given _instance_, or NULL for the top level. The _cmd_ can be one of: diff --git a/include/tracefs.h b/include/tracefs.h index 3ac3d9c..c2a6db7 100644 --- a/include/tracefs.h +++ b/include/tracefs.h @@ -377,6 +377,9 @@ int tracefs_hist_echo_cmd(struct trace_seq *seq, struct tracefs_instance *insta struct tracefs_hist *hist, enum tracefs_hist_command command); int tracefs_hist_command(struct tracefs_instance *instance, struct tracefs_hist *hist, enum tracefs_hist_command cmd); +int tracefs_hist_echo_fmt(struct trace_seq *seq, + struct tracefs_instance *instance, + struct tracefs_hist *hist); /** * tracefs_hist_start - enable a histogram diff --git a/src/tracefs-hist.c b/src/tracefs-hist.c index ea9e127..9beafe0 100644 --- a/src/tracefs-hist.c +++ b/src/tracefs-hist.c @@ -142,6 +142,40 @@ tracefs_hist_echo_cmd(struct trace_seq *seq, struct tracefs_instance *instance, return 0; } +/* + * tracefs_hist_echo_fmt - show the raw format of the histogram + * @seq: A trace_seq to store the format string + * @hist: The histogram to read format from + * + * This show the raw format that describes the state of the histogram. + * + * Returns the size of the format string on succes -1 on error. + */ +int tracefs_hist_echo_fmt(struct trace_seq *seq, + struct tracefs_instance *instance, + struct tracefs_hist *hist) +{ + const char *event = hist->event_name; + const char *system = hist->system; + int fmt_size; + char *path; + char *fmt; + + path = tracefs_event_get_file(instance, system, event, "trigger"); + if (!path) + return -1; + + fmt = tracefs_event_file_read(instance, system, event, path, + &fmt_size); + if (!fmt) + return -1; + + trace_seq_puts(seq, fmt); + tracefs_put_tracing_file(path); + + return fmt_size; +} + /* * tracefs_hist_command - Create, start, pause, destroy a histogram for an event * @instance: The instance the histogram will be in (NULL for toplevel) From patchwork Mon Dec 6 15:08:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 12658709 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F636C433EF for ; Mon, 6 Dec 2021 15:15:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357979AbhLFPTV (ORCPT ); Mon, 6 Dec 2021 10:19:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358302AbhLFPQc (ORCPT ); Mon, 6 Dec 2021 10:16:32 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44211C08EACC for ; Mon, 6 Dec 2021 07:09:11 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id o19-20020a1c7513000000b0033a93202467so81072wmc.2 for ; Mon, 06 Dec 2021 07:09:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zDNZxYq7FFFHG8G4lQ77zoaB6S5yLEI1xl/wPMiLygA=; b=E3hWzwC+SR7Ik+xMUO+ObwddNzyCaRes3juJSvYD1HkVzO6uNJFTgPNux3s2nDlH2p wcuZpbXmvYn9Uxf/k6UmAjFsz27bmjOGqz3SxafwYH+DnlRtSRbpMwTU80qsramBcGnt zSOcUVUNxsNzRAFhaHjZ3OBNPHjwnRpES8i1GurBh4xlzHekF5WtLTckC9ZrRZmzZpt6 bg9pwrXDvLhdrU/F+HgsIcmnvkOJYsp4C4yb2xFygnZZw6nIM6wsuLRoSXMulLZnz8HQ +1plpDGnRFYj15HAZhl71Vcn34qXVMFFE1xkVrKo9h9kTpLIuItWgBZfsHwKZZs8lfu2 rNSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zDNZxYq7FFFHG8G4lQ77zoaB6S5yLEI1xl/wPMiLygA=; b=J5hAp9ov5r+vwg6/ETKebW4yjV7yKDtmzvjcsHUgQRRwupRMcmMLvKtHsnEFHJrV52 FHKGIwGJR4WU4sLgXtGnw3gAxLKbQ/0WHkmItN4UOW5YrA5RaszuOIBjPPiKrCUkLVZK HISjFyUZemhu527ADxO1sFUe2F66XtbsUnDgww1nNSBnURHfqbGZQVQRq/HdofZ17pME NP9YFh0GBUYUlX1urM6Bb5h6CCK8O4N8pmQ+f5e99IvEM8sCuaN0TXpWCJ4RqxL99UrB HUEeO3GkWVVOptWQjiGS+l3UgfWDt8lxW6w73lCo1yCldScLtQ6vCJHXAT41v6PxYe5w IzOQ== X-Gm-Message-State: AOAM530wcbAx16ZjMg/3I0jNWs4y02zSZUZr5O6aq0lA9524dGdoWLQd q2RwJULWKX7SjlT5VuFglZ99uoNTUyM= X-Google-Smtp-Source: ABdhPJybR3X9qnYzsOj5D8cU9xuW9c9wrw+6+1BPDS74n/xRVT/D7g73n3k/1F/3yRPYcADPjgBUqw== X-Received: by 2002:a05:600c:22cb:: with SMTP id 11mr39367343wmg.181.1638803349634; Mon, 06 Dec 2021 07:09:09 -0800 (PST) Received: from crow.. ([95.87.219.163]) by smtp.gmail.com with ESMTPSA id d6sm11782668wrn.53.2021.12.06.07.09.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Dec 2021 07:09:09 -0800 (PST) From: "Yordan Karadzhov (VMware)" To: linux-trace-devel@vger.kernel.org, rostedt@goodmis.org Cc: "Yordan Karadzhov (VMware)" Subject: [PATCH 2/3] libtracefs: Rename the 'tracefs_get_hist_*()' APIs Date: Mon, 6 Dec 2021 17:08:54 +0200 Message-Id: <20211206150855.361202-3-y.karadz@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211206150855.361202-1-y.karadz@gmail.com> References: <20211206150855.361202-1-y.karadz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org The APIs are renamed in order to match the naming convention used in the library. The patch adds documentation add well. Signed-off-by: Yordan Karadzhov (VMware) --- Documentation/libtracefs-hist.txt | 15 ++++++++++++++- include/tracefs.h | 6 +++--- src/tracefs-hist.c | 24 +++++++++++++++++++++--- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/Documentation/libtracefs-hist.txt b/Documentation/libtracefs-hist.txt index c8230e5..e3145c9 100644 --- a/Documentation/libtracefs-hist.txt +++ b/Documentation/libtracefs-hist.txt @@ -5,7 +5,8 @@ NAME ---- tracefs_hist_alloc, tracefs_hist_free, tracefs_hist_add_key, tracefs_hist_add_value, tracefs_hist_add_name, tracefs_hist_start, tracefs_hist_destory, tracefs_hist_add_sort_key, tracefs_hist_set_sort_key, tracefs_hist_sort_key_direction -tracefs_hist_echo_cmd, tracefs_hist_echo_fmt - Create and update event histograms +tracefs_hist_echo_cmd, tracefs_hist_echo_fmt, tracefs_hist_get_name, tracefs_hist_get_event, +tracefs_hist_get_system - Create, update and describe event histograms SYNOPSIS -------- @@ -73,6 +74,12 @@ int tracefs_hist_command(struct tracefs_instance pass:[*]instance, int tracefs_hist_echo_fmt(struct trace_seq pass:[*]s, struct tracefs_instance pass:[*]instance, struct tracefs_hist pass:[*]hist); +tracefs_hist_get_name(struct tracefs_hist pass:[*]hist); + +tracefs_hist_get_event(struct tracefs_hist pass:[*]hist); + +tracefs_hist_get_system(struct tracefs_hist pass:[*]hist); + -- DESCRIPTION @@ -190,6 +197,12 @@ that would be done by *tracefs_hist_command*(3). *tracefs_hist_echo_fmt*() prints the raw format that describes the state of the histogram in the given _instance_, or NULL for the top level, into the _seq_. +*tracefs_hist_get_name*() prints the name of the histogram. + +*tracefs_hist_get_event*() prints the event name of the histogram. + +*tracefs_hist_get_system*() prints the system name of the histogram. + *tracefs_hist_command*() is called to process a command on the histogram _hist_ for its event in the given _instance_, or NULL for the top level. The _cmd_ can be one of: diff --git a/include/tracefs.h b/include/tracefs.h index c2a6db7..7c03086 100644 --- a/include/tracefs.h +++ b/include/tracefs.h @@ -354,9 +354,9 @@ struct tracefs_hist * tracefs_hist_alloc_nd(struct tep_handle *tep, const char *system, const char *event_name, struct tracefs_hist_axis *axes); -const char *tracefs_get_hist_name(struct tracefs_hist *hist); -const char *tracefs_get_hist_event(struct tracefs_hist *hist); -const char *tracefs_get_hist_system(struct tracefs_hist *hist); +const char *tracefs_hist_get_name(struct tracefs_hist *hist); +const char *tracefs_hist_get_event(struct tracefs_hist *hist); +const char *tracefs_hist_get_system(struct tracefs_hist *hist); int tracefs_hist_add_key(struct tracefs_hist *hist, const char *key, enum tracefs_hist_key_type type); int tracefs_hist_add_value(struct tracefs_hist *hist, const char *value); diff --git a/src/tracefs-hist.c b/src/tracefs-hist.c index 9beafe0..837d4e1 100644 --- a/src/tracefs-hist.c +++ b/src/tracefs-hist.c @@ -41,17 +41,35 @@ struct tracefs_hist { unsigned int filter_state; }; -const char *tracefs_get_hist_name(struct tracefs_hist *hist) +/* + * tracefs_hist_get_name - get the name of the histogram + * @hist: The histogram to get the name for + * + * Returns name string on succes or NULL on error. + */ +const char *tracefs_hist_get_name(struct tracefs_hist *hist) { return hist ? hist->name : NULL; } -const char *tracefs_get_hist_event(struct tracefs_hist *hist) +/* + * tracefs_hist_get_event - get the event name of the histogram + * @hist: The histogram to get the event name for + * + * Returns event name string on succes or NULL on error. + */ +const char *tracefs_hist_get_event(struct tracefs_hist *hist) { return hist ? hist->event_name : NULL; } -const char *tracefs_get_hist_system(struct tracefs_hist *hist) +/* + * tracefs_hist_get_system - get the system name of the histogram + * @hist: The histogram to get the system name for + * + * Returns system name string on succes or NULL on error. + */ +const char *tracefs_hist_get_system(struct tracefs_hist *hist) { return hist ? hist->system : NULL; } From patchwork Mon Dec 6 15:08:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 12658711 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8042C433F5 for ; Mon, 6 Dec 2021 15:16:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349535AbhLFPTY (ORCPT ); Mon, 6 Dec 2021 10:19:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358323AbhLFPQe (ORCPT ); Mon, 6 Dec 2021 10:16:34 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73CF2C08EACD for ; Mon, 6 Dec 2021 07:09:12 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id q3so23076131wru.5 for ; Mon, 06 Dec 2021 07:09:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R+nEydAK1dzYxRBMivuniekVKeQIralV5GkyLM6IaIA=; b=B7fWPxS1H0SGSL0pyJ4S5oX6yCIGkxkrQPxdZwxrqfn/l5yatsu8ofrWzaC5gnMonx 7cdLYgEVwvGPPeX/Ut+185EzAmLQEywA1ufQ6/z6MA76+Xh1RLC3DmZzqYOSCXhgFxgl 7YWd55PEQa/UFm6HHRBuzGHxuTPPyoZ+zS1n7yikphPfXEWQY+7Nn/Eb3oqh9UuomrYD WX4y/dKoS0Dz06lJLj9rsoSCtNCEFVKllGHuyTCvCGq0JLTiojfLx4oR6/kSJUr71RIq RBj7lIloJsuN2g0jTohEBjVXMqvztgw/qCAaImW1QV8FdHlgV8zpq1ucAcZsJaeXPmZ0 XWTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R+nEydAK1dzYxRBMivuniekVKeQIralV5GkyLM6IaIA=; b=KRnZrMHNT8WdxQcJQIXu/wOe3VTC68T6xejVzaExcAOgws4XvSAachNJ6weqeeeST9 DbRtu9vMjHS8gNAax+VKJtExv/MnGXPfHGYb0oULdAOa8zemi6cB+vZzw2fuh7hv3OxV zMb5k+ErrPiCW2uJnsOY2ry9U/Q3D/xg9GFsWrsTE+bWcFmWxFuaykhz6pYaigKm/Bky 8A98Zd67E4IiXdJptLAHS0LQjCwNxofAkueoG9LMgKhOAxOjYsyPNrsfmZIDdWcoy6hn GHtlhFXZZ3tJH7KnBr8ETBmyViMYErYdYG15DGvmOpd+J0AvPJ4tJVYazq3hQPHqQeEE jE/Q== X-Gm-Message-State: AOAM533yvFxtotnP1CP8LeB6MgKv8ZOjVQ0yOKcGpLAyJBRS7n69Sywh uhtx5Fz3KmXoKsEgEnZ/C5Oxw8WwAP8= X-Google-Smtp-Source: ABdhPJyu4zI33tNMFnYxgSUN9jwJyKAXC57V2vJybM6jZUlXLHMIzm8hfNBzmGJW4xbWC35sLfKgCQ== X-Received: by 2002:a5d:456e:: with SMTP id a14mr43039388wrc.256.1638803350451; Mon, 06 Dec 2021 07:09:10 -0800 (PST) Received: from crow.. ([95.87.219.163]) by smtp.gmail.com with ESMTPSA id d6sm11782668wrn.53.2021.12.06.07.09.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Dec 2021 07:09:10 -0800 (PST) From: "Yordan Karadzhov (VMware)" To: linux-trace-devel@vger.kernel.org, rostedt@goodmis.org Cc: "Yordan Karadzhov (VMware)" Subject: [PATCH 3/3] libtracefs: Add new API for getting synth event name WiP Date: Mon, 6 Dec 2021 17:08:55 +0200 Message-Id: <20211206150855.361202-4-y.karadz@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211206150855.361202-1-y.karadz@gmail.com> References: <20211206150855.361202-1-y.karadz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Signed-off-by: Yordan Karadzhov (VMware) --- Documentation/libtracefs-synth2.txt | 8 ++++++-- include/tracefs.h | 1 + src/tracefs-hist.c | 11 +++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Documentation/libtracefs-synth2.txt b/Documentation/libtracefs-synth2.txt index 1cb07c8..2439a54 100644 --- a/Documentation/libtracefs-synth2.txt +++ b/Documentation/libtracefs-synth2.txt @@ -3,8 +3,9 @@ libtracefs(3) NAME ---- -tracefs_synth_create, tracefs_synth_destroy, tracefs_synth_echo_cmd,tracefs_synth_complete, -tracefs_synth_get_start_hist,tracefs_synth_trace,tracefs_synth_snapshot - Creation of synthetic events +tracefs_synth_create, tracefs_synth_destroy, tracefs_synth_echo_cmd, tracefs_synth_complete, +tracefs_synth_get_start_hist, tracefs_synth_trace, tracefs_synth_snapshot, +tracefs_synth_get_name - Creation of synthetic events SYNOPSIS -------- @@ -25,6 +26,7 @@ int tracefs_synth_snapshot(struct tracefs_synth pass:[*]synth, int tracefs_synth_save(struct tracefs_synth pass:[*]synth, enum tracefs_synth_handler type, const char pass:[*]var, char pass:[**]save_fields); +tracefs_synth_get_name(struct tracefs_synth pass:[*]synth); -- DESCRIPTION @@ -87,6 +89,8 @@ then saven the given _save_fields_ list. The fields will be stored in the histog "hist" file of the event that can be retrieved with *tracefs_event_file_read*(3). _var_ changes. _var_ must be one of the _name_ elements used in *tracefs_synth_add_end_field*(3). +*tracefs_synth_get_name*() get the name of the synthetic event. + RETURN VALUE ------------ Returns zero on success or -1 on error. diff --git a/include/tracefs.h b/include/tracefs.h index 7c03086..804d738 100644 --- a/include/tracefs.h +++ b/include/tracefs.h @@ -505,6 +505,7 @@ enum tracefs_synth_handler { TRACEFS_SYNTH_HANDLE_CHANGE, }; +const char *tracefs_synth_get_name(struct tracefs_synth *synth); struct tracefs_synth *tracefs_synth_alloc(struct tep_handle *tep, const char *name, const char *start_system, diff --git a/src/tracefs-hist.c b/src/tracefs-hist.c index 837d4e1..41c88d1 100644 --- a/src/tracefs-hist.c +++ b/src/tracefs-hist.c @@ -736,6 +736,17 @@ struct tracefs_synth { int arg_cnt; }; + /* + * tracefs_synth_get_name - get the name of the synthetic event + * @synth: The synthetic event to get the name for + * + * Returns name string on succes or NULL on error. + */ +const char *tracefs_synth_get_name(struct tracefs_synth *synth) +{ + return synth ? synth->name : NULL; +} + static void action_free(struct action *action) { free(action->handle_field);