26
26
27
27
struct hist_field ;
28
28
29
- typedef u64 (* hist_field_fn_t ) (struct hist_field * field , void * event ,
30
- struct ring_buffer_event * rbe );
29
+ typedef u64 (* hist_field_fn_t ) (struct hist_field * field ,
30
+ struct tracing_map_elt * elt ,
31
+ struct ring_buffer_event * rbe ,
32
+ void * event );
31
33
32
34
#define HIST_FIELD_OPERANDS_MAX 2
33
35
#define HIST_FIELDS_MAX (TRACING_MAP_FIELDS_MAX + TRACING_MAP_VARS_MAX)
@@ -59,28 +61,36 @@ struct hist_field {
59
61
char * name ;
60
62
};
61
63
62
- static u64 hist_field_none (struct hist_field * field , void * event ,
63
- struct ring_buffer_event * rbe )
64
+ static u64 hist_field_none (struct hist_field * field ,
65
+ struct tracing_map_elt * elt ,
66
+ struct ring_buffer_event * rbe ,
67
+ void * event )
64
68
{
65
69
return 0 ;
66
70
}
67
71
68
- static u64 hist_field_counter (struct hist_field * field , void * event ,
69
- struct ring_buffer_event * rbe )
72
+ static u64 hist_field_counter (struct hist_field * field ,
73
+ struct tracing_map_elt * elt ,
74
+ struct ring_buffer_event * rbe ,
75
+ void * event )
70
76
{
71
77
return 1 ;
72
78
}
73
79
74
- static u64 hist_field_string (struct hist_field * hist_field , void * event ,
75
- struct ring_buffer_event * rbe )
80
+ static u64 hist_field_string (struct hist_field * hist_field ,
81
+ struct tracing_map_elt * elt ,
82
+ struct ring_buffer_event * rbe ,
83
+ void * event )
76
84
{
77
85
char * addr = (char * )(event + hist_field -> field -> offset );
78
86
79
87
return (u64 )(unsigned long )addr ;
80
88
}
81
89
82
- static u64 hist_field_dynstring (struct hist_field * hist_field , void * event ,
83
- struct ring_buffer_event * rbe )
90
+ static u64 hist_field_dynstring (struct hist_field * hist_field ,
91
+ struct tracing_map_elt * elt ,
92
+ struct ring_buffer_event * rbe ,
93
+ void * event )
84
94
{
85
95
u32 str_item = * (u32 * )(event + hist_field -> field -> offset );
86
96
int str_loc = str_item & 0xffff ;
@@ -89,63 +99,74 @@ static u64 hist_field_dynstring(struct hist_field *hist_field, void *event,
89
99
return (u64 )(unsigned long )addr ;
90
100
}
91
101
92
- static u64 hist_field_pstring (struct hist_field * hist_field , void * event ,
93
- struct ring_buffer_event * rbe )
102
+ static u64 hist_field_pstring (struct hist_field * hist_field ,
103
+ struct tracing_map_elt * elt ,
104
+ struct ring_buffer_event * rbe ,
105
+ void * event )
94
106
{
95
107
char * * addr = (char * * )(event + hist_field -> field -> offset );
96
108
97
109
return (u64 )(unsigned long )* addr ;
98
110
}
99
111
100
- static u64 hist_field_log2 (struct hist_field * hist_field , void * event ,
101
- struct ring_buffer_event * rbe )
112
+ static u64 hist_field_log2 (struct hist_field * hist_field ,
113
+ struct tracing_map_elt * elt ,
114
+ struct ring_buffer_event * rbe ,
115
+ void * event )
102
116
{
103
117
struct hist_field * operand = hist_field -> operands [0 ];
104
118
105
- u64 val = operand -> fn (operand , event , rbe );
119
+ u64 val = operand -> fn (operand , elt , rbe , event );
106
120
107
121
return (u64 ) ilog2 (roundup_pow_of_two (val ));
108
122
}
109
123
110
- static u64 hist_field_plus (struct hist_field * hist_field , void * event ,
111
- struct ring_buffer_event * rbe )
124
+ static u64 hist_field_plus (struct hist_field * hist_field ,
125
+ struct tracing_map_elt * elt ,
126
+ struct ring_buffer_event * rbe ,
127
+ void * event )
112
128
{
113
129
struct hist_field * operand1 = hist_field -> operands [0 ];
114
130
struct hist_field * operand2 = hist_field -> operands [1 ];
115
131
116
- u64 val1 = operand1 -> fn (operand1 , event , rbe );
117
- u64 val2 = operand2 -> fn (operand2 , event , rbe );
132
+ u64 val1 = operand1 -> fn (operand1 , elt , rbe , event );
133
+ u64 val2 = operand2 -> fn (operand2 , elt , rbe , event );
118
134
119
135
return val1 + val2 ;
120
136
}
121
137
122
- static u64 hist_field_minus (struct hist_field * hist_field , void * event ,
123
- struct ring_buffer_event * rbe )
138
+ static u64 hist_field_minus (struct hist_field * hist_field ,
139
+ struct tracing_map_elt * elt ,
140
+ struct ring_buffer_event * rbe ,
141
+ void * event )
124
142
{
125
143
struct hist_field * operand1 = hist_field -> operands [0 ];
126
144
struct hist_field * operand2 = hist_field -> operands [1 ];
127
145
128
- u64 val1 = operand1 -> fn (operand1 , event , rbe );
129
- u64 val2 = operand2 -> fn (operand2 , event , rbe );
146
+ u64 val1 = operand1 -> fn (operand1 , elt , rbe , event );
147
+ u64 val2 = operand2 -> fn (operand2 , elt , rbe , event );
130
148
131
149
return val1 - val2 ;
132
150
}
133
151
134
- static u64 hist_field_unary_minus (struct hist_field * hist_field , void * event ,
135
- struct ring_buffer_event * rbe )
152
+ static u64 hist_field_unary_minus (struct hist_field * hist_field ,
153
+ struct tracing_map_elt * elt ,
154
+ struct ring_buffer_event * rbe ,
155
+ void * event )
136
156
{
137
157
struct hist_field * operand = hist_field -> operands [0 ];
138
158
139
- s64 sval = (s64 )operand -> fn (operand , event , rbe );
159
+ s64 sval = (s64 )operand -> fn (operand , elt , rbe , event );
140
160
u64 val = (u64 )- sval ;
141
161
142
162
return val ;
143
163
}
144
164
145
165
#define DEFINE_HIST_FIELD_FN (type ) \
146
166
static u64 hist_field_##type(struct hist_field *hist_field, \
147
- void *event, \
148
- struct ring_buffer_event *rbe) \
167
+ struct tracing_map_elt *elt, \
168
+ struct ring_buffer_event *rbe, \
169
+ void *event) \
149
170
{ \
150
171
type *addr = (type *)(event + hist_field->field->offset); \
151
172
\
@@ -233,8 +254,10 @@ struct hist_trigger_data {
233
254
bool remove ;
234
255
};
235
256
236
- static u64 hist_field_timestamp (struct hist_field * hist_field , void * event ,
237
- struct ring_buffer_event * rbe )
257
+ static u64 hist_field_timestamp (struct hist_field * hist_field ,
258
+ struct tracing_map_elt * elt ,
259
+ struct ring_buffer_event * rbe ,
260
+ void * event )
238
261
{
239
262
struct hist_trigger_data * hist_data = hist_field -> hist_data ;
240
263
struct trace_array * tr = hist_data -> event_file -> tr ;
@@ -1570,7 +1593,7 @@ static void hist_trigger_elt_update(struct hist_trigger_data *hist_data,
1570
1593
1571
1594
for_each_hist_val_field (i , hist_data ) {
1572
1595
hist_field = hist_data -> fields [i ];
1573
- hist_val = hist_field -> fn (hist_field , rec , rbe );
1596
+ hist_val = hist_field -> fn (hist_field , elt , rbe , rec );
1574
1597
if (hist_field -> flags & HIST_FIELD_FL_VAR ) {
1575
1598
var_idx = hist_field -> var .idx ;
1576
1599
tracing_map_set_var (elt , var_idx , hist_val );
@@ -1582,7 +1605,7 @@ static void hist_trigger_elt_update(struct hist_trigger_data *hist_data,
1582
1605
for_each_hist_key_field (i , hist_data ) {
1583
1606
hist_field = hist_data -> fields [i ];
1584
1607
if (hist_field -> flags & HIST_FIELD_FL_VAR ) {
1585
- hist_val = hist_field -> fn (hist_field , rec , rbe );
1608
+ hist_val = hist_field -> fn (hist_field , elt , rbe , rec );
1586
1609
var_idx = hist_field -> var .idx ;
1587
1610
tracing_map_set_var (elt , var_idx , hist_val );
1588
1611
}
@@ -1620,9 +1643,9 @@ static void event_hist_trigger(struct event_trigger_data *data, void *rec,
1620
1643
bool use_compound_key = (hist_data -> n_keys > 1 );
1621
1644
unsigned long entries [HIST_STACKTRACE_DEPTH ];
1622
1645
char compound_key [HIST_KEY_SIZE_MAX ];
1646
+ struct tracing_map_elt * elt = NULL ;
1623
1647
struct stack_trace stacktrace ;
1624
1648
struct hist_field * key_field ;
1625
- struct tracing_map_elt * elt ;
1626
1649
u64 field_contents ;
1627
1650
void * key = NULL ;
1628
1651
unsigned int i ;
@@ -1643,7 +1666,7 @@ static void event_hist_trigger(struct event_trigger_data *data, void *rec,
1643
1666
1644
1667
key = entries ;
1645
1668
} else {
1646
- field_contents = key_field -> fn (key_field , rec , rbe );
1669
+ field_contents = key_field -> fn (key_field , elt , rbe , rec );
1647
1670
if (key_field -> flags & HIST_FIELD_FL_STRING ) {
1648
1671
key = (void * )(unsigned long )field_contents ;
1649
1672
use_compound_key = true;
0 commit comments