Commit fbd302cb authored by Tom Zanussi's avatar Tom Zanussi Committed by Steven Rostedt (VMware)

tracing: Add ring buffer event param to hist field functions

Some events such as timestamps require access to a ring_buffer_event
struct; add a param so that hist field functions can access that.

Link: http://lkml.kernel.org/r/2ff4af18e72b6002eb86b26b2a7f39cef7d1dfe4.1516069914.git.tom.zanussi@linux.intel.comSigned-off-by: default avatarTom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent 1ac4f51c
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
struct hist_field; struct hist_field;
typedef u64 (*hist_field_fn_t) (struct hist_field *field, void *event); typedef u64 (*hist_field_fn_t) (struct hist_field *field, void *event,
struct ring_buffer_event *rbe);
#define HIST_FIELD_OPERANDS_MAX 2 #define HIST_FIELD_OPERANDS_MAX 2
...@@ -40,24 +41,28 @@ struct hist_field { ...@@ -40,24 +41,28 @@ struct hist_field {
struct hist_field *operands[HIST_FIELD_OPERANDS_MAX]; struct hist_field *operands[HIST_FIELD_OPERANDS_MAX];
}; };
static u64 hist_field_none(struct hist_field *field, void *event) static u64 hist_field_none(struct hist_field *field, void *event,
struct ring_buffer_event *rbe)
{ {
return 0; return 0;
} }
static u64 hist_field_counter(struct hist_field *field, void *event) static u64 hist_field_counter(struct hist_field *field, void *event,
struct ring_buffer_event *rbe)
{ {
return 1; return 1;
} }
static u64 hist_field_string(struct hist_field *hist_field, void *event) static u64 hist_field_string(struct hist_field *hist_field, void *event,
struct ring_buffer_event *rbe)
{ {
char *addr = (char *)(event + hist_field->field->offset); char *addr = (char *)(event + hist_field->field->offset);
return (u64)(unsigned long)addr; return (u64)(unsigned long)addr;
} }
static u64 hist_field_dynstring(struct hist_field *hist_field, void *event) static u64 hist_field_dynstring(struct hist_field *hist_field, void *event,
struct ring_buffer_event *rbe)
{ {
u32 str_item = *(u32 *)(event + hist_field->field->offset); u32 str_item = *(u32 *)(event + hist_field->field->offset);
int str_loc = str_item & 0xffff; int str_loc = str_item & 0xffff;
...@@ -66,24 +71,28 @@ static u64 hist_field_dynstring(struct hist_field *hist_field, void *event) ...@@ -66,24 +71,28 @@ static u64 hist_field_dynstring(struct hist_field *hist_field, void *event)
return (u64)(unsigned long)addr; return (u64)(unsigned long)addr;
} }
static u64 hist_field_pstring(struct hist_field *hist_field, void *event) static u64 hist_field_pstring(struct hist_field *hist_field, void *event,
struct ring_buffer_event *rbe)
{ {
char **addr = (char **)(event + hist_field->field->offset); char **addr = (char **)(event + hist_field->field->offset);
return (u64)(unsigned long)*addr; return (u64)(unsigned long)*addr;
} }
static u64 hist_field_log2(struct hist_field *hist_field, void *event) static u64 hist_field_log2(struct hist_field *hist_field, void *event,
struct ring_buffer_event *rbe)
{ {
struct hist_field *operand = hist_field->operands[0]; struct hist_field *operand = hist_field->operands[0];
u64 val = operand->fn(operand, event); u64 val = operand->fn(operand, event, rbe);
return (u64) ilog2(roundup_pow_of_two(val)); return (u64) ilog2(roundup_pow_of_two(val));
} }
#define DEFINE_HIST_FIELD_FN(type) \ #define DEFINE_HIST_FIELD_FN(type) \
static u64 hist_field_##type(struct hist_field *hist_field, void *event)\ static u64 hist_field_##type(struct hist_field *hist_field, \
void *event, \
struct ring_buffer_event *rbe) \
{ \ { \
type *addr = (type *)(event + hist_field->field->offset); \ type *addr = (type *)(event + hist_field->field->offset); \
\ \
...@@ -871,8 +880,8 @@ create_hist_data(unsigned int map_bits, ...@@ -871,8 +880,8 @@ create_hist_data(unsigned int map_bits,
} }
static void hist_trigger_elt_update(struct hist_trigger_data *hist_data, static void hist_trigger_elt_update(struct hist_trigger_data *hist_data,
struct tracing_map_elt *elt, struct tracing_map_elt *elt, void *rec,
void *rec) struct ring_buffer_event *rbe)
{ {
struct hist_field *hist_field; struct hist_field *hist_field;
unsigned int i; unsigned int i;
...@@ -880,7 +889,7 @@ static void hist_trigger_elt_update(struct hist_trigger_data *hist_data, ...@@ -880,7 +889,7 @@ static void hist_trigger_elt_update(struct hist_trigger_data *hist_data,
for_each_hist_val_field(i, hist_data) { for_each_hist_val_field(i, hist_data) {
hist_field = hist_data->fields[i]; hist_field = hist_data->fields[i];
hist_val = hist_field->fn(hist_field, rec); hist_val = hist_field->fn(hist_field, rec, rbe);
tracing_map_update_sum(elt, i, hist_val); tracing_map_update_sum(elt, i, hist_val);
} }
} }
...@@ -910,7 +919,7 @@ static inline void add_to_key(char *compound_key, void *key, ...@@ -910,7 +919,7 @@ static inline void add_to_key(char *compound_key, void *key,
} }
static void event_hist_trigger(struct event_trigger_data *data, void *rec, static void event_hist_trigger(struct event_trigger_data *data, void *rec,
struct ring_buffer_event *event) struct ring_buffer_event *rbe)
{ {
struct hist_trigger_data *hist_data = data->private_data; struct hist_trigger_data *hist_data = data->private_data;
bool use_compound_key = (hist_data->n_keys > 1); bool use_compound_key = (hist_data->n_keys > 1);
...@@ -939,7 +948,7 @@ static void event_hist_trigger(struct event_trigger_data *data, void *rec, ...@@ -939,7 +948,7 @@ static void event_hist_trigger(struct event_trigger_data *data, void *rec,
key = entries; key = entries;
} else { } else {
field_contents = key_field->fn(key_field, rec); field_contents = key_field->fn(key_field, rec, rbe);
if (key_field->flags & HIST_FIELD_FL_STRING) { if (key_field->flags & HIST_FIELD_FL_STRING) {
key = (void *)(unsigned long)field_contents; key = (void *)(unsigned long)field_contents;
use_compound_key = true; use_compound_key = true;
...@@ -956,7 +965,7 @@ static void event_hist_trigger(struct event_trigger_data *data, void *rec, ...@@ -956,7 +965,7 @@ static void event_hist_trigger(struct event_trigger_data *data, void *rec,
elt = tracing_map_insert(hist_data->map, key); elt = tracing_map_insert(hist_data->map, key);
if (elt) if (elt)
hist_trigger_elt_update(hist_data, elt, rec); hist_trigger_elt_update(hist_data, elt, rec, rbe);
} }
static void hist_trigger_stacktrace_print(struct seq_file *m, static void hist_trigger_stacktrace_print(struct seq_file *m,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment