2626
2727struct hist_field ;
2828
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 );
3133
3234#define HIST_FIELD_OPERANDS_MAX 2
3335#define HIST_FIELDS_MAX (TRACING_MAP_FIELDS_MAX + TRACING_MAP_VARS_MAX)
@@ -59,28 +61,36 @@ struct hist_field {
5961 char * name ;
6062};
6163
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 )
6468{
6569 return 0 ;
6670}
6771
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 )
7076{
7177 return 1 ;
7278}
7379
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 )
7684{
7785 char * addr = (char * )(event + hist_field -> field -> offset );
7886
7987 return (u64 )(unsigned long )addr ;
8088}
8189
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 )
8494{
8595 u32 str_item = * (u32 * )(event + hist_field -> field -> offset );
8696 int str_loc = str_item & 0xffff ;
@@ -89,63 +99,74 @@ static u64 hist_field_dynstring(struct hist_field *hist_field, void *event,
8999 return (u64 )(unsigned long )addr ;
90100}
91101
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 )
94106{
95107 char * * addr = (char * * )(event + hist_field -> field -> offset );
96108
97109 return (u64 )(unsigned long )* addr ;
98110}
99111
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 )
102116{
103117 struct hist_field * operand = hist_field -> operands [0 ];
104118
105- u64 val = operand -> fn (operand , event , rbe );
119+ u64 val = operand -> fn (operand , elt , rbe , event );
106120
107121 return (u64 ) ilog2 (roundup_pow_of_two (val ));
108122}
109123
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 )
112128{
113129 struct hist_field * operand1 = hist_field -> operands [0 ];
114130 struct hist_field * operand2 = hist_field -> operands [1 ];
115131
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 );
118134
119135 return val1 + val2 ;
120136}
121137
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 )
124142{
125143 struct hist_field * operand1 = hist_field -> operands [0 ];
126144 struct hist_field * operand2 = hist_field -> operands [1 ];
127145
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 );
130148
131149 return val1 - val2 ;
132150}
133151
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 )
136156{
137157 struct hist_field * operand = hist_field -> operands [0 ];
138158
139- s64 sval = (s64 )operand -> fn (operand , event , rbe );
159+ s64 sval = (s64 )operand -> fn (operand , elt , rbe , event );
140160 u64 val = (u64 )- sval ;
141161
142162 return val ;
143163}
144164
145165#define DEFINE_HIST_FIELD_FN (type ) \
146166 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) \
149170{ \
150171 type *addr = (type *)(event + hist_field->field->offset); \
151172 \
@@ -233,8 +254,10 @@ struct hist_trigger_data {
233254 bool remove ;
234255};
235256
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 )
238261{
239262 struct hist_trigger_data * hist_data = hist_field -> hist_data ;
240263 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,
15701593
15711594 for_each_hist_val_field (i , hist_data ) {
15721595 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 );
15741597 if (hist_field -> flags & HIST_FIELD_FL_VAR ) {
15751598 var_idx = hist_field -> var .idx ;
15761599 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,
15821605 for_each_hist_key_field (i , hist_data ) {
15831606 hist_field = hist_data -> fields [i ];
15841607 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 );
15861609 var_idx = hist_field -> var .idx ;
15871610 tracing_map_set_var (elt , var_idx , hist_val );
15881611 }
@@ -1620,9 +1643,9 @@ static void event_hist_trigger(struct event_trigger_data *data, void *rec,
16201643 bool use_compound_key = (hist_data -> n_keys > 1 );
16211644 unsigned long entries [HIST_STACKTRACE_DEPTH ];
16221645 char compound_key [HIST_KEY_SIZE_MAX ];
1646+ struct tracing_map_elt * elt = NULL ;
16231647 struct stack_trace stacktrace ;
16241648 struct hist_field * key_field ;
1625- struct tracing_map_elt * elt ;
16261649 u64 field_contents ;
16271650 void * key = NULL ;
16281651 unsigned int i ;
@@ -1643,7 +1666,7 @@ static void event_hist_trigger(struct event_trigger_data *data, void *rec,
16431666
16441667 key = entries ;
16451668 } else {
1646- field_contents = key_field -> fn (key_field , rec , rbe );
1669+ field_contents = key_field -> fn (key_field , elt , rbe , rec );
16471670 if (key_field -> flags & HIST_FIELD_FL_STRING ) {
16481671 key = (void * )(unsigned long )field_contents ;
16491672 use_compound_key = true;
0 commit comments