linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: linux-trace-devel@vger.kernel.org, rostedt@goodmis.org
Cc: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH v2] libtracefs: New API for clearing filter on event
Date: Thu,  2 Dec 2021 19:43:45 +0200	[thread overview]
Message-ID: <20211202174345.229200-1-y.karadz@gmail.com> (raw)

There is no API for clearing filter from event. After adding an API that
applys a filter we must provide an identical API for clearing the filter.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 Documentation/libtracefs-filter.txt |  8 +++++++-
 include/tracefs.h                   |  3 ++-
 src/tracefs-filter.c                | 14 ++++++++++++++
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/Documentation/libtracefs-filter.txt b/Documentation/libtracefs-filter.txt
index 7db3d60..f7bbb17 100644
--- a/Documentation/libtracefs-filter.txt
+++ b/Documentation/libtracefs-filter.txt
@@ -3,7 +3,7 @@ libtracefs(3)
 
 NAME
 ----
-tracefs_filter_string_append, tracefs_filter_string_verify, tracefs_event_apply_filter -
+tracefs_filter_string_append, tracefs_filter_string_verify, tracefs_event_filter_apply tracefs_event_filter_clear -
 Add, verify and apply event filters
 
 SYNOPSIS
@@ -17,6 +17,8 @@ int tracefs_filter_string_append(struct tep_event pass:[*]event, char pass:[**]
 				 enum tracefs_synth_compare compare, const char pass:[*]val);
 int tracefs_filter_string_verify(struct tep_event pass:[*]event, const char pass:[*]filter, char pass:[**]err);
 int tracefs_event_filter_apply(struct tracefs_instance pass:[*]instance, struct tep_event pass:[*]event, const char pass:[*]filter);
+int tracefs_event_filter_clear(struct tracefs_instance pass:[*]instance, struct tep_event pass:[*]event);
+
 --
 
 DESCRIPTION
@@ -69,6 +71,8 @@ with *free*().
 
 *tracefs_event_filter_apply*() applies given _filter_ string on _event_ in given _instance_.
 
+*tracefs_event_filter_clear*() clear all filters on _event_ in given _instance_.
+
 RETURN VALUE
 ------------
 *tracefs_filter_string_append*() returns 0 on success and -1 on error.
@@ -80,6 +84,8 @@ freed with *free*().
 
 *tracefs_event_filter_apply*() returns 0 on success and -1 on error.
 
+*tracefs_event_filter_clear*() returns 0 on success and -1 on error.
+
 EXAMPLE
 -------
 [source,c]
diff --git a/include/tracefs.h b/include/tracefs.h
index ac92dca..3ac3d9c 100644
--- a/include/tracefs.h
+++ b/include/tracefs.h
@@ -479,6 +479,8 @@ int tracefs_filter_string_verify(struct tep_event *event, const char *filter,
 int tracefs_event_filter_apply(struct tracefs_instance *instance,
 			       struct tep_event *event, const char *filter);
 
+int tracefs_event_filter_clear(struct tracefs_instance *instance,
+			       struct tep_event *event);
 
 /** Deprecated do not use: Instead use tracefs_filter_string_append() **/
 int tracefs_event_append_filter(struct tep_event *event, char **filter,
@@ -490,7 +492,6 @@ int tracefs_event_append_filter(struct tep_event *event, char **filter,
 int tracefs_event_verify_filter(struct tep_event *event, const char *filter,
 				char **err);
 
-
 #define TRACEFS_TIMESTAMP "common_timestamp"
 #define TRACEFS_TIMESTAMP_USECS "common_timestamp.usecs"
 
diff --git a/src/tracefs-filter.c b/src/tracefs-filter.c
index 7bc36fe..85d0be1 100644
--- a/src/tracefs-filter.c
+++ b/src/tracefs-filter.c
@@ -764,6 +764,20 @@ int tracefs_event_filter_apply(struct tracefs_instance *instance,
 					"filter", filter);
 }
 
+/**
+ * tracefs_event_filter_clear - clear the filter on event in given instance
+ * @instance: The instance in which the filter will be applied (NULL for toplevel).
+ * @event: The event to apply the filter on.
+ *
+ * Returns 0 on succes and -1 on error.
+ */
+int tracefs_event_filter_clear(struct tracefs_instance *instance,
+			       struct tep_event *event)
+{
+	return tracefs_event_file_write(instance, event->system, event->name,
+					"filter", "0");
+}
+
 /** Deprecated **/
 int tracefs_event_append_filter(struct tep_event *event, char **filter,
 				enum tracefs_filter type,
-- 
2.32.0


                 reply	other threads:[~2021-12-02 17:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211202174345.229200-1-y.karadz@gmail.com \
    --to=y.karadz@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).