All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Zanussi <tzanussi@gmail.com>
To: rostedt@goodmis.org
Cc: tglx@linutronix.de, mhiramat@kernel.org, namhyung@kernel.org,
	vedang.patel@intel.com, bigeasy@linutronix.de,
	joel@joelfernandes.org, mathieu.desnoyers@efficios.com,
	julia@ni.com, linux-kernel@vger.kernel.org,
	linux-rt-users@vger.kernel.org
Subject: [PATCH v2 3/7] tracing: Use var_refs[] for hist trigger reference checking
Date: Wed, 19 Dec 2018 13:09:16 -0600	[thread overview]
Message-ID: <1545246556.4239.7.camel@gmail.com> (raw)
In-Reply-To: <becb9627fb09681960f26809961b832be9591048.1545161087.git.tom.zanussi@linux.intel.com>

Since all the variable reference hist_fields are collected into
hist_data->var_refs[] array, there's no need to go through all the
fields looking for them, or in separate arrays like synth_var_refs[],
which will be going away soon anyway.

This also allows us to get rid of some unnecessary code and functions
currently used for the same purpose.

Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
---
 kernel/trace/trace_events_hist.c | 68 +++++++---------------------------------
 1 file changed, 11 insertions(+), 57 deletions(-)

diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 25d06b3ae1f6..f3caf6e484f4 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -1297,75 +1297,29 @@ check_field_for_var_ref(struct hist_field *hist_field,
 			struct hist_trigger_data *var_data,
 			unsigned int var_idx)
 {
-	struct hist_field *found = NULL;
-
-	if (hist_field && hist_field->flags & HIST_FIELD_FL_VAR_REF) {
-		if (hist_field->var.idx == var_idx &&
-		    hist_field->var.hist_data == var_data) {
-			found = hist_field;
-		}
-	}
-
-	return found;
-}
-
-static struct hist_field *
-check_field_for_var_refs(struct hist_trigger_data *hist_data,
-			 struct hist_field *hist_field,
-			 struct hist_trigger_data *var_data,
-			 unsigned int var_idx,
-			 unsigned int level)
-{
-	struct hist_field *found = NULL;
-	unsigned int i;
-
-	if (level > 3)
-		return found;
-
-	if (!hist_field)
-		return found;
-
-	found = check_field_for_var_ref(hist_field, var_data, var_idx);
-	if (found)
-		return found;
-
-	for (i = 0; i < HIST_FIELD_OPERANDS_MAX; i++) {
-		struct hist_field *operand;
+	WARN_ON(!(hist_field && hist_field->flags & HIST_FIELD_FL_VAR_REF));
 
-		operand = hist_field->operands[i];
-		found = check_field_for_var_refs(hist_data, operand, var_data,
-						 var_idx, level + 1);
-		if (found)
-			return found;
-	}
+	if (hist_field && hist_field->var.idx == var_idx &&
+	    hist_field->var.hist_data == var_data)
+		return hist_field;
 
-	return found;
+	return NULL;
 }
 
 static struct hist_field *find_var_ref(struct hist_trigger_data *hist_data,
 				       struct hist_trigger_data *var_data,
 				       unsigned int var_idx)
 {
-	struct hist_field *hist_field, *found = NULL;
+	struct hist_field *hist_field;
 	unsigned int i;
 
-	for_each_hist_field(i, hist_data) {
-		hist_field = hist_data->fields[i];
-		found = check_field_for_var_refs(hist_data, hist_field,
-						 var_data, var_idx, 0);
-		if (found)
-			return found;
-	}
-
-	for (i = 0; i < hist_data->n_synth_var_refs; i++) {
-		hist_field = hist_data->synth_var_refs[i];
-		found = check_field_for_var_refs(hist_data, hist_field,
-						 var_data, var_idx, 0);
-		if (found)
-			return found;
+	for (i = 0; i < hist_data->n_var_refs; i++) {
+		hist_field = hist_data->var_refs[i];
+		if (check_field_for_var_ref(hist_field, var_data, var_idx))
+			return hist_field;
 	}
 
-	return found;
+	return NULL;
 }
 
 static struct hist_field *find_any_var_ref(struct hist_trigger_data *hist_data,
-- 
2.14.1


  parent reply	other threads:[~2018-12-19 19:09 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-18 20:33 [PATCH 0/7] tracing: Hist trigger var-ref cleanup and comments Tom Zanussi
2018-12-18 20:33 ` [PATCH 1/7] tracing: Remove unnecessary hist trigger struct field Tom Zanussi
2018-12-18 20:33 ` [PATCH 2/7] tracing: Change strlen to sizeof for hist trigger static strings Tom Zanussi
2018-12-19 19:40   ` Steven Rostedt
2018-12-19 19:46     ` Tom Zanussi
2018-12-19 20:16       ` Tom Zanussi
2018-12-19 20:22         ` Joe Perches
2018-12-19 20:34           ` Steven Rostedt
2018-12-19 20:51             ` Joe Perches
2018-12-19 21:03               ` Steven Rostedt
2018-12-19 20:28         ` Steven Rostedt
2018-12-19 20:20       ` Joe Perches
2018-12-19 20:30         ` Steven Rostedt
2018-12-19 20:38           ` Tom Zanussi
2018-12-19 21:01             ` Steven Rostedt
2018-12-19 21:08               ` Joe Perches
2018-12-19 20:27       ` Steven Rostedt
2018-12-19 20:27         ` Steven Rostedt
2018-12-18 20:33 ` [PATCH 3/7] tracing: Use var_refs[] for hist trigger reference checking Tom Zanussi
2018-12-19 12:22   ` Masami Hiramatsu
2018-12-19 15:01     ` Tom Zanussi
2018-12-19 15:36       ` Steven Rostedt
2018-12-19 19:08         ` Tom Zanussi
2018-12-19 19:09   ` Tom Zanussi [this message]
2018-12-18 20:33 ` [PATCH 4/7] tracing: Remove open-coding of hist trigger var_ref management Tom Zanussi
2018-12-18 20:33 ` [PATCH 5/7] tracing: Use hist trigger's var_ref array to destroy var_refs Tom Zanussi
2018-12-18 20:33 ` [PATCH 6/7] tracing: Remove hist trigger synth_var_refs Tom Zanussi
2018-12-18 20:33 ` [PATCH 7/7] tracing: Add hist trigger comments for variable-related fields Tom Zanussi
2018-12-19 11:45 ` [PATCH 0/7] tracing: Hist trigger var-ref cleanup and comments Namhyung Kim
2018-12-19 15:00   ` Tom Zanussi
2018-12-19 12:27 ` Masami Hiramatsu
2018-12-19 15:02   ` Tom Zanussi

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=1545246556.4239.7.camel@gmail.com \
    --to=tzanussi@gmail.com \
    --cc=bigeasy@linutronix.de \
    --cc=joel@joelfernandes.org \
    --cc=julia@ni.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=vedang.patel@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.