From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Tom Zanussi <tom.zanussi@linux.intel.com>
Subject: [for-next][PATCH 11/16] tracing: Reimplement log2
Date: Fri, 06 Oct 2017 14:07:06 -0400 [thread overview]
Message-ID: <20171006180729.870575846@goodmis.org> (raw)
In-Reply-To: 20171006180655.935479946@goodmis.org
[-- Attachment #1: 0011-tracing-Reimplement-log2.patch --]
[-- Type: text/plain, Size: 3864 bytes --]
From: Tom Zanussi <tom.zanussi@linux.intel.com>
log2 as currently implemented applies only to u64 trace_event_field
derived fields, and assumes that anything it's applied to is a u64
field.
To prepare for synthetic fields like latencies, log2 should be
applicable to those as well, so take the opportunity now to fix the
current problems as well as expand to more general uses.
log2 should be thought of as a chaining function rather than a field
type. To enable this as well as possible future function
implementations, add a hist_field operand array into the hist_field
definition for this purpose, and make use of it to implement the log2
'function'.
Link: http://lkml.kernel.org/r/b47f93fc0b87b36eccf716b0c018f3a71e1f1111.1506105045.git.tom.zanussi@linux.intel.com
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
kernel/trace/trace_events_hist.c | 31 +++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 34edf5fd85fd..1e1558c99d56 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -28,12 +28,16 @@ struct hist_field;
typedef u64 (*hist_field_fn_t) (struct hist_field *field, void *event);
+#define HIST_FIELD_OPERANDS_MAX 2
+
struct hist_field {
struct ftrace_event_field *field;
unsigned long flags;
hist_field_fn_t fn;
unsigned int size;
unsigned int offset;
+ unsigned int is_signed;
+ struct hist_field *operands[HIST_FIELD_OPERANDS_MAX];
};
static u64 hist_field_none(struct hist_field *field, void *event)
@@ -71,7 +75,9 @@ static u64 hist_field_pstring(struct hist_field *hist_field, void *event)
static u64 hist_field_log2(struct hist_field *hist_field, void *event)
{
- u64 val = *(u64 *)(event + hist_field->field->offset);
+ struct hist_field *operand = hist_field->operands[0];
+
+ u64 val = operand->fn(operand, event);
return (u64) ilog2(roundup_pow_of_two(val));
}
@@ -156,6 +162,8 @@ static const char *hist_field_name(struct hist_field *field,
if (field->field)
field_name = field->field->name;
+ else if (field->flags & HIST_FIELD_FL_LOG2)
+ field_name = hist_field_name(field->operands[0], ++level);
if (field_name == NULL)
field_name = "";
@@ -357,8 +365,20 @@ static const struct tracing_map_ops hist_trigger_elt_comm_ops = {
.elt_init = hist_trigger_elt_comm_init,
};
-static void destroy_hist_field(struct hist_field *hist_field)
+static void destroy_hist_field(struct hist_field *hist_field,
+ unsigned int level)
{
+ unsigned int i;
+
+ if (level > 2)
+ return;
+
+ if (!hist_field)
+ return;
+
+ for (i = 0; i < HIST_FIELD_OPERANDS_MAX; i++)
+ destroy_hist_field(hist_field->operands[i], level + 1);
+
kfree(hist_field);
}
@@ -385,7 +405,10 @@ static struct hist_field *create_hist_field(struct ftrace_event_field *field,
}
if (flags & HIST_FIELD_FL_LOG2) {
+ unsigned long fl = flags & ~HIST_FIELD_FL_LOG2;
hist_field->fn = hist_field_log2;
+ hist_field->operands[0] = create_hist_field(field, fl);
+ hist_field->size = hist_field->operands[0]->size;
goto out;
}
@@ -405,7 +428,7 @@ static struct hist_field *create_hist_field(struct ftrace_event_field *field,
hist_field->fn = select_value_fn(field->size,
field->is_signed);
if (!hist_field->fn) {
- destroy_hist_field(hist_field);
+ destroy_hist_field(hist_field, 0);
return NULL;
}
}
@@ -422,7 +445,7 @@ static void destroy_hist_fields(struct hist_trigger_data *hist_data)
for (i = 0; i < TRACING_MAP_FIELDS_MAX; i++) {
if (hist_data->fields[i]) {
- destroy_hist_field(hist_data->fields[i]);
+ destroy_hist_field(hist_data->fields[i], 0);
hist_data->fields[i] = NULL;
}
}
--
2.13.2
next prev parent reply other threads:[~2017-10-06 18:09 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-06 18:06 [for-next][PATCH 00/16] tracing: Updates for 4.15 Steven Rostedt
2017-10-06 18:06 ` [for-next][PATCH 01/16] tracing: Remove obsolete sched_switch tracer selftest Steven Rostedt
2017-10-06 18:06 ` [for-next][PATCH 02/16] tracing: Remove redundant unread variable ret Steven Rostedt
2017-10-06 18:06 ` [for-next][PATCH 03/16] tracing: Reverse the order of trace_types_lock and event_mutex Steven Rostedt
2017-10-06 18:06 ` [for-next][PATCH 04/16] ring-buffer: Rewrite trace_recursive_(un)lock() to be simpler Steven Rostedt
2017-10-06 18:07 ` [for-next][PATCH 05/16] tracing: Exclude generic fields from histograms Steven Rostedt
2017-10-06 18:07 ` [for-next][PATCH 06/16] tracing: Remove lookups from tracing_map hitcount Steven Rostedt
2017-10-06 18:07 ` [for-next][PATCH 07/16] tracing: Increase tracing map KEYS_MAX size Steven Rostedt
2017-10-06 18:07 ` [for-next][PATCH 08/16] tracing: Make traceprobe parsing code reusable Steven Rostedt
2017-10-06 18:07 ` [for-next][PATCH 09/16] tracing: Clean up hist_field_flags enum Steven Rostedt
2017-10-06 18:07 ` [for-next][PATCH 10/16] tracing: Add hist_field_name() accessor Steven Rostedt
2017-10-06 18:07 ` Steven Rostedt [this message]
2017-10-06 18:07 ` [for-next][PATCH 12/16] ftrace: Add a ftrace_free_mem() function for modules to use Steven Rostedt
2017-10-06 18:07 ` [for-next][PATCH 13/16] ftrace: Allow module init functions to be traced Steven Rostedt
2017-10-06 18:07 ` [for-next][PATCH 14/16] ftrace: Save module init functions kallsyms symbols for tracing Steven Rostedt
2017-10-06 18:07 ` [for-next][PATCH 15/16] ftrace: Add freeing algorithm to free ftrace_mod_maps Steven Rostedt
2017-10-07 6:41 ` Joel Fernandes (Google)
2017-10-07 13:32 ` Steven Rostedt
2017-10-08 4:52 ` Joel Fernandes (Google)
2017-10-08 8:42 ` Joel Fernandes
2017-10-08 18:42 ` Steven Rostedt
2017-10-08 18:56 ` Joel Fernandes
2017-10-09 6:07 ` Joel Fernandes
2017-10-09 6:02 ` Joel Fernandes
2017-10-06 18:07 ` [for-next][PATCH 16/16] ftrace/kallsyms: Have /proc/kallsyms show saved mod init functions Steven Rostedt
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=20171006180729.870575846@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tom.zanussi@linux.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.