mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yang Jihong <yangjihong@bytedance.com>
To: peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
	namhyung@kernel.org, mark.rutland@arm.com,
	alexander.shishkin@linux.intel.com, jolsa@kernel.org,
	irogers@google.com, adrian.hunter@intel.com,
	kan.liang@linux.intel.com, james.clark@arm.com,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: yangjihong@bytedance.com
Subject: [RFC 02/12] perf event action: Add parsing const expr support
Date: Thu, 28 Nov 2024 21:35:43 +0800	[thread overview]
Message-ID: <20241128133553.823722-3-yangjihong@bytedance.com> (raw)
In-Reply-To: <20241128133553.823722-1-yangjihong@bytedance.com>

Event action requires constant expression parsing support,
which include constant integer and constant string.

Signed-off-by: Yang Jihong <yangjihong@bytedance.com>
---
 tools/perf/util/parse-action.c | 27 +++++++++++++++++++++++++++
 tools/perf/util/parse-action.h |  5 +++++
 2 files changed, 32 insertions(+)

diff --git a/tools/perf/util/parse-action.c b/tools/perf/util/parse-action.c
index 01c8c7fdea59..391546bf3d73 100644
--- a/tools/perf/util/parse-action.c
+++ b/tools/perf/util/parse-action.c
@@ -4,6 +4,9 @@
  * Actions are the programs that run when the sampling event is triggered.
  * The action is a list of expressions separated by semicolons (;).
  * Each action is an expression, added to actions_head node as list_head node.
+ *
+ * Supported expressions:
+ *   - constant:
  */
 
 #include "util/debug.h"
@@ -115,7 +118,31 @@ void event_actions__free(void)
 	(void)event_actions__for_each_expr_safe(do_action_free, NULL, false);
 }
 
+static struct evtact_expr_ops *expr_const_ops_list[EVTACT_EXPR_CONST_TYPE_MAX] = {
+};
+
+static int expr_const_set_ops(struct evtact_expr *expr, u32 opcode)
+{
+	if (opcode >= EVTACT_EXPR_CONST_TYPE_MAX) {
+		pr_err("expr_const opcode invalid: %u\n", opcode);
+		return -EINVAL;
+	}
+
+	if (expr_const_ops_list[opcode] == NULL) {
+		pr_err("expr_const opcode not supported: %u\n", opcode);
+		return -ENOTSUP;
+	}
+
+	expr->ops = expr_const_ops_list[opcode];
+	return 0;
+}
+
+static struct evtact_expr_class expr_const = {
+	.set_ops = expr_const_set_ops,
+};
+
 static struct evtact_expr_class *expr_class_list[EVTACT_EXPR_TYPE_MAX] = {
+	[EVTACT_EXPR_TYPE_CONST]   = &expr_const,
 };
 
 int parse_action_expr__set_class(enum evtact_expr_type type,
diff --git a/tools/perf/util/parse-action.h b/tools/perf/util/parse-action.h
index 71a0a166959e..47bd75264dee 100644
--- a/tools/perf/util/parse-action.h
+++ b/tools/perf/util/parse-action.h
@@ -9,9 +9,14 @@
 #include "evlist.h"
 
 enum evtact_expr_type {
+	EVTACT_EXPR_TYPE_CONST,
 	EVTACT_EXPR_TYPE_MAX,
 };
 
+enum evtact_expr_const_type {
+	EVTACT_EXPR_CONST_TYPE_MAX,
+};
+
 struct evtact_expr;
 struct evtact_expr_ops {
 	int (*new)(struct evtact_expr *expr, void *data, int size);
-- 
2.25.1


  parent reply	other threads:[~2024-11-28 13:36 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-28 13:35 [RFC 00/12] perf record: Add event action support Yang Jihong
2024-11-28 13:35 ` [RFC 01/12] " Yang Jihong
2024-11-28 20:19   ` Arnaldo Carvalho de Melo
2024-12-04  8:24     ` [External] " Yang Jihong
2024-11-28 13:35 ` Yang Jihong [this message]
2024-11-28 20:23   ` [RFC 02/12] perf event action: Add parsing const expr support Arnaldo Carvalho de Melo
2024-12-04  8:29     ` [External] " Yang Jihong
2024-11-28 13:35 ` [RFC 03/12] perf event action: Add parsing const integer " Yang Jihong
2024-11-28 20:25   ` Arnaldo Carvalho de Melo
2024-12-04  8:32     ` [External] " Yang Jihong
2024-11-28 13:35 ` [RFC 04/12] perf event action: Add parsing const string " Yang Jihong
2024-11-28 13:35 ` [RFC 05/12] perf event action: Add parsing call " Yang Jihong
2024-11-28 13:35 ` [RFC 06/12] perf event action: Add parsing print() " Yang Jihong
2024-11-28 13:35 ` [RFC 07/12] perf event action: Add parsing builtin " Yang Jihong
2024-11-28 13:35 ` [RFC 08/12] perf event action: Add parsing builtin cpu " Yang Jihong
2024-11-28 13:35 ` [RFC 09/12] perf event action: Add parsing builtin pid " Yang Jihong
2024-11-28 13:35 ` [RFC 10/12] perf event action: Add parsing builtin tid " Yang Jihong
2024-11-28 13:35 ` [RFC 11/12] perf event action: Add parsing builtin comm " Yang Jihong
2024-11-28 13:35 ` [RFC 12/12] perf event action: Add parsing builtin time " Yang Jihong
2024-11-28 13:53 ` [RFC 00/12] perf record: Add event action support Adrian Hunter
2024-12-04  8:07   ` [External] " Yang Jihong
2024-11-28 20:14 ` Arnaldo Carvalho de Melo
2024-12-02 21:46   ` Namhyung Kim
2024-12-04  8:35     ` [External] " Yang Jihong
2024-12-04 19:54       ` Ian Rogers
2024-12-05 14:01         ` Yang Jihong
2024-12-04  8:21   ` Yang Jihong

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=20241128133553.823722-3-yangjihong@bytedance.com \
    --to=yangjihong@bytedance.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=james.clark@arm.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.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

all inboxes | Powered by JetHome®