Lines Matching refs:hist_data

119 	struct hist_trigger_data	*hist_data;  member
134 struct hist_trigger_data *hist_data; member
444 #define for_each_hist_field(i, hist_data) \ argument
445 for ((i) = 0; (i) < (hist_data)->n_fields; (i)++)
447 #define for_each_hist_val_field(i, hist_data) \ argument
448 for ((i) = 0; (i) < (hist_data)->n_vals; (i)++)
450 #define for_each_hist_key_field(i, hist_data) \ argument
451 for ((i) = (hist_data)->n_vals; (i) < (hist_data)->n_fields; (i)++)
515 struct hist_trigger_data *hist_data; member
553 typedef void (*action_fn_t) (struct hist_trigger_data *hist_data,
641 struct hist_trigger_data *hist_data; member
695 struct hist_trigger_data *hist_data) in track_data_alloc() argument
711 data->hist_data = hist_data; in track_data_alloc()
821 static void action_trace(struct hist_trigger_data *hist_data, in action_trace() argument
834 struct hist_trigger_data *hist_data; member
843 struct hist_trigger_data *hist_data = hist_field->hist_data; in hist_field_timestamp() local
844 struct trace_array *tr = hist_data->event_file->tr; in hist_field_timestamp()
848 if (hist_data->attrs->ts_in_usecs && trace_clock_in_ns(tr)) in hist_field_timestamp()
884 hist_field->var.hist_data == var_data) in check_field_for_var_ref()
902 static struct hist_field *find_var_ref(struct hist_trigger_data *hist_data, in find_var_ref() argument
909 for (i = 0; i < hist_data->n_var_refs; i++) { in find_var_ref()
910 hist_field = hist_data->var_refs[i]; in find_var_ref()
932 static struct hist_field *find_any_var_ref(struct hist_trigger_data *hist_data, in find_any_var_ref() argument
935 struct trace_array *tr = hist_data->event_file->tr; in find_any_var_ref()
940 if (var_data->hist_data == hist_data) in find_any_var_ref()
942 found = find_var_ref(var_data->hist_data, hist_data, var_idx); in find_any_var_ref()
963 static bool check_var_refs(struct hist_trigger_data *hist_data) in check_var_refs() argument
969 for_each_hist_field(i, hist_data) { in check_var_refs()
970 field = hist_data->fields[i]; in check_var_refs()
972 if (find_any_var_ref(hist_data, field->var.idx)) { in check_var_refs()
982 static struct hist_var_data *find_hist_vars(struct hist_trigger_data *hist_data) in find_hist_vars() argument
984 struct trace_array *tr = hist_data->event_file->tr; in find_hist_vars()
988 if (var_data->hist_data == hist_data) { in find_hist_vars()
1023 static bool has_hist_vars(struct hist_trigger_data *hist_data) in has_hist_vars() argument
1028 for_each_hist_field(i, hist_data) { in has_hist_vars()
1029 hist_field = hist_data->fields[i]; in has_hist_vars()
1037 static int save_hist_vars(struct hist_trigger_data *hist_data) in save_hist_vars() argument
1039 struct trace_array *tr = hist_data->event_file->tr; in save_hist_vars()
1042 var_data = find_hist_vars(hist_data); in save_hist_vars()
1055 var_data->hist_data = hist_data; in save_hist_vars()
1061 static void remove_hist_vars(struct hist_trigger_data *hist_data) in remove_hist_vars() argument
1063 struct trace_array *tr = hist_data->event_file->tr; in remove_hist_vars()
1066 var_data = find_hist_vars(hist_data); in remove_hist_vars()
1070 if (WARN_ON(check_var_refs(hist_data))) in remove_hist_vars()
1080 static struct hist_field *find_var_field(struct hist_trigger_data *hist_data, in find_var_field() argument
1086 for_each_hist_field(i, hist_data) { in find_var_field()
1087 hist_field = hist_data->fields[i]; in find_var_field()
1098 static struct hist_field *find_var(struct hist_trigger_data *hist_data, in find_var() argument
1108 hist_field = find_var_field(hist_data, var_name); in find_var()
1137 var_hist_data = var_data->hist_data; in find_var_file()
1177 find_match_var(struct hist_trigger_data *hist_data, char *var_name) in find_match_var() argument
1179 struct trace_array *tr = hist_data->event_file->tr; in find_match_var()
1184 for (i = 0; i < hist_data->n_actions; i++) { in find_match_var()
1185 struct action_data *data = hist_data->actions[i]; in find_match_var()
1209 static struct hist_field *find_event_var(struct hist_trigger_data *hist_data, in find_event_var() argument
1214 struct trace_array *tr = hist_data->event_file->tr; in find_event_var()
1219 hist_field = find_match_var(hist_data, var_name); in find_event_var()
1253 static bool resolve_var_refs(struct hist_trigger_data *hist_data, void *key, in resolve_var_refs() argument
1263 for (i = 0; i < hist_data->n_var_refs; i++) { in resolve_var_refs()
1264 hist_field = hist_data->var_refs[i]; in resolve_var_refs()
1266 var_data = hist_field->var.hist_data; in resolve_var_refs()
1273 if ((self && var_data != hist_data) || in resolve_var_refs()
1274 (!self && var_data == hist_data)) in resolve_var_refs()
1597 struct hist_trigger_data *hist_data = elt->map->private_data; in hist_trigger_elt_data_alloc() local
1607 for_each_hist_field(i, hist_data) { in hist_trigger_elt_data_alloc()
1608 hist_field = hist_data->fields[i]; in hist_trigger_elt_data_alloc()
1620 n_str = hist_data->n_field_var_str + hist_data->n_save_var_str + in hist_trigger_elt_data_alloc()
1621 hist_data->n_var_str; in hist_trigger_elt_data_alloc()
1903 static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data, in create_hist_field() argument
1919 hist_field->hist_data = hist_data; in create_hist_field()
1954 hist_field->operands[0] = create_hist_field(hist_data, field, fl, NULL); in create_hist_field()
2028 static void destroy_hist_fields(struct hist_trigger_data *hist_data) in destroy_hist_fields() argument
2033 if (hist_data->fields[i]) { in destroy_hist_fields()
2034 destroy_hist_field(hist_data->fields[i], 0); in destroy_hist_fields()
2035 hist_data->fields[i] = NULL; in destroy_hist_fields()
2039 for (i = 0; i < hist_data->n_var_refs; i++) { in destroy_hist_fields()
2040 WARN_ON(!(hist_data->var_refs[i]->flags & HIST_FIELD_FL_VAR_REF)); in destroy_hist_fields()
2041 __destroy_hist_field(hist_data->var_refs[i]); in destroy_hist_fields()
2042 hist_data->var_refs[i] = NULL; in destroy_hist_fields()
2053 ref_field->var.hist_data = var_field->hist_data; in init_var_ref()
2105 static int find_var_ref_idx(struct hist_trigger_data *hist_data, in find_var_ref_idx() argument
2111 for (i = 0; i < hist_data->n_var_refs; i++) { in find_var_ref_idx()
2112 ref_field = hist_data->var_refs[i]; in find_var_ref_idx()
2114 ref_field->var.hist_data == var_field->hist_data) in find_var_ref_idx()
2136 static struct hist_field *create_var_ref(struct hist_trigger_data *hist_data, in create_var_ref() argument
2145 for (i = 0; i < hist_data->n_var_refs; i++) { in create_var_ref()
2146 ref_field = hist_data->var_refs[i]; in create_var_ref()
2148 ref_field->var.hist_data == var_field->hist_data) { in create_var_ref()
2154 ref_field = create_hist_field(var_field->hist_data, NULL, flags, NULL); in create_var_ref()
2161 hist_data->var_refs[hist_data->n_var_refs] = ref_field; in create_var_ref()
2162 ref_field->var_ref_idx = hist_data->n_var_refs++; in create_var_ref()
2176 static char *field_name_from_var(struct hist_trigger_data *hist_data, in field_name_from_var() argument
2182 for (i = 0; i < hist_data->attrs->var_defs.n_vars; i++) { in field_name_from_var()
2183 name = hist_data->attrs->var_defs.name[i]; in field_name_from_var()
2186 field = hist_data->attrs->var_defs.expr[i]; in field_name_from_var()
2196 static char *local_field_var_ref(struct hist_trigger_data *hist_data, in local_field_var_ref() argument
2203 call = hist_data->event_file->event_call; in local_field_var_ref()
2220 return field_name_from_var(hist_data, var_name); in local_field_var_ref()
2223 static struct hist_field *parse_var_ref(struct hist_trigger_data *hist_data, in parse_var_ref() argument
2228 struct trace_array *tr = hist_data->event_file->tr; in parse_var_ref()
2235 var_field = find_event_var(hist_data, system, event_name, var_name); in parse_var_ref()
2237 ref_field = create_var_ref(hist_data, var_field, in parse_var_ref()
2247 parse_field(struct hist_trigger_data *hist_data, struct trace_event_file *file, in parse_field() argument
2303 hist_data->enable_timestamps = true; in parse_field()
2305 hist_data->attrs->ts_in_usecs = true; in parse_field()
2332 static struct hist_field *create_alias(struct hist_trigger_data *hist_data, in create_alias() argument
2339 alias = create_hist_field(hist_data, NULL, flags, var_name); in create_alias()
2356 static struct hist_field *parse_const(struct hist_trigger_data *hist_data, in parse_const() argument
2360 struct trace_array *tr = hist_data->event_file->tr; in parse_const()
2370 field = create_hist_field(hist_data, NULL, *flags, var_name); in parse_const()
2379 static struct hist_field *parse_atom(struct hist_trigger_data *hist_data, in parse_atom() argument
2390 hist_field = parse_const(hist_data, str, var_name, flags); in parse_atom()
2416 s = local_field_var_ref(hist_data, ref_system, ref_event, ref_var); in parse_atom()
2418 hist_field = parse_var_ref(hist_data, ref_system, in parse_atom()
2422 hist_field = create_alias(hist_data, hist_field, var_name); in parse_atom()
2433 field = parse_field(hist_data, file, str, flags, &buckets); in parse_atom()
2439 hist_field = create_hist_field(hist_data, field, *flags, var_name); in parse_atom()
2451 static struct hist_field *parse_expr(struct hist_trigger_data *hist_data,
2456 static struct hist_field *parse_unary(struct hist_trigger_data *hist_data, in parse_unary() argument
2504 expr = create_hist_field(hist_data, NULL, flags, var_name); in parse_unary()
2511 operand1 = parse_expr(hist_data, file, str, operand_flags, NULL, n_subexprs); in parse_unary()
2561 var = find_var_field(operand1->var.hist_data, operand1->name); in check_expr_operands()
2572 var = find_var_field(operand2->var.hist_data, operand2->name); in check_expr_operands()
2588 static struct hist_field *parse_expr(struct hist_trigger_data *hist_data, in parse_expr() argument
2609 return parse_atom(hist_data, file, str, &flags, var_name); in parse_expr()
2612 return parse_unary(hist_data, file, str, flags, var_name, n_subexprs); in parse_expr()
2632 operand1 = parse_expr(hist_data, file, operand1_str, operand_flags, NULL, n_subexprs); in parse_expr()
2644 operand2 = parse_expr(hist_data, file, str, operand_flags, NULL, n_subexprs); in parse_expr()
2691 expr = create_hist_field(hist_data, NULL, flags, var_name); in parse_expr()
2771 static char *find_trigger_filter(struct hist_trigger_data *hist_data, in find_trigger_filter() argument
2780 if (test->private_data == hist_data) in find_trigger_filter()
2795 struct hist_trigger_data *hist_data, in compatible_keys() argument
2801 if (hist_data->n_fields - hist_data->n_vals != n_keys) in compatible_keys()
2804 i = hist_data->n_vals; in compatible_keys()
2808 hist_field = hist_data->fields[i + n]; in compatible_keys()
2826 struct hist_trigger_data *hist_data; in find_compatible_hist() local
2836 hist_data = test->private_data; in find_compatible_hist()
2838 if (compatible_keys(target_hist_data, hist_data, n_keys)) in find_compatible_hist()
2839 return hist_data; in find_compatible_hist()
2909 struct hist_trigger_data *hist_data; in create_field_var_hist() local
2938 hist_data = find_compatible_hist(target_hist_data, file); in create_field_var_hist()
2939 if (!hist_data) { in create_field_var_hist()
2963 for_each_hist_key_field(i, hist_data) { in create_field_var_hist()
2964 key_field = hist_data->fields[i]; in create_field_var_hist()
2978 saved_filter = find_trigger_filter(hist_data, file); in create_field_var_hist()
2992 var_hist->hist_data = hist_data; in create_field_var_hist()
3025 find_target_event_var(struct hist_trigger_data *hist_data, in find_target_event_var() argument
3028 struct trace_event_file *file = hist_data->event_file; in find_target_event_var()
3046 hist_field = find_var_field(hist_data, var_name); in find_target_event_var()
3084 static void update_field_vars(struct hist_trigger_data *hist_data, in update_field_vars() argument
3090 __update_field_vars(elt, buffer, rbe, rec, hist_data->field_vars, in update_field_vars()
3091 hist_data->n_field_vars, 0); in update_field_vars()
3094 static void save_track_data_vars(struct hist_trigger_data *hist_data, in save_track_data_vars() argument
3100 __update_field_vars(elt, buffer, rbe, rec, hist_data->save_vars, in save_track_data_vars()
3101 hist_data->n_save_vars, hist_data->n_field_var_str); in save_track_data_vars()
3104 static struct hist_field *create_var(struct hist_trigger_data *hist_data, in create_var() argument
3111 if (find_var(hist_data, file, name) && !hist_data->remove) { in create_var()
3122 idx = tracing_map_add_var(hist_data->map); in create_var()
3132 var->var.hist_data = var->hist_data = hist_data; in create_var()
3146 static struct field_var *create_field_var(struct hist_trigger_data *hist_data, in create_field_var() argument
3156 if (hist_data->n_field_vars >= SYNTH_FIELDS_MAX) { in create_field_var()
3162 val = parse_atom(hist_data, file, field_name, &flags, NULL); in create_field_var()
3169 var = create_var(hist_data, file, field_name, val->size, val->type); in create_field_var()
3254 static u64 get_track_val(struct hist_trigger_data *hist_data, in get_track_val() argument
3266 static void save_track_val(struct hist_trigger_data *hist_data, in save_track_val() argument
3275 static void save_track_data(struct hist_trigger_data *hist_data, in save_track_data() argument
3282 data->track_data.save_data(hist_data, elt, buffer, rec, rbe, in save_track_data()
3290 struct hist_trigger_data *hist_data; in check_track_val() local
3293 hist_data = data->track_data.track_var->hist_data; in check_track_val()
3294 track_val = get_track_val(hist_data, elt, data); in check_track_val()
3314 track_val = get_track_val(track_data->hist_data, context->elt, in cond_snapshot_update()
3333 static void save_track_data_snapshot(struct hist_trigger_data *hist_data, in save_track_data_snapshot() argument
3340 struct trace_event_file *file = hist_data->event_file; in save_track_data_snapshot()
3350 struct hist_trigger_data *hist_data,
3354 static struct action_data *snapshot_action(struct hist_trigger_data *hist_data) in snapshot_action() argument
3358 if (!hist_data->n_actions) in snapshot_action()
3361 for (i = 0; i < hist_data->n_actions; i++) { in snapshot_action()
3362 struct action_data *data = hist_data->actions[i]; in snapshot_action()
3372 struct hist_trigger_data *hist_data) in track_data_snapshot_print() argument
3374 struct trace_event_file *file = hist_data->event_file; in track_data_snapshot_print()
3385 action = snapshot_action(hist_data); in track_data_snapshot_print()
3395 hist_trigger_print_key(m, hist_data, track_data->key, &track_data->elt); in track_data_snapshot_print()
3403 static void save_track_data_snapshot(struct hist_trigger_data *hist_data, in save_track_data_snapshot() argument
3410 struct hist_trigger_data *hist_data) {} in track_data_snapshot_print() argument
3414 struct hist_trigger_data *hist_data, in track_data_print() argument
3418 u64 track_val = get_track_val(hist_data, elt, data); in track_data_print()
3429 for (i = 0; i < hist_data->n_save_vars; i++) { in track_data_print()
3430 struct hist_field *save_val = hist_data->save_vars[i]->val; in track_data_print()
3431 struct hist_field *save_var = hist_data->save_vars[i]->var; in track_data_print()
3446 static void ontrack_action(struct hist_trigger_data *hist_data, in ontrack_action() argument
3455 save_track_val(hist_data, elt, data, var_val); in ontrack_action()
3456 save_track_data(hist_data, elt, buffer, rec, rbe, in ontrack_action()
3480 static void track_data_destroy(struct hist_trigger_data *hist_data, in track_data_destroy() argument
3483 struct trace_event_file *file = hist_data->event_file; in track_data_destroy()
3491 if (track_data && track_data->hist_data == hist_data) { in track_data_destroy()
3502 static int action_create(struct hist_trigger_data *hist_data,
3505 static int track_data_create(struct hist_trigger_data *hist_data, in track_data_create() argument
3509 struct trace_event_file *file = hist_data->event_file; in track_data_create()
3521 var_field = find_target_event_var(hist_data, NULL, NULL, track_data_var_str); in track_data_create()
3527 ref_field = create_var_ref(hist_data, var_field, NULL, NULL); in track_data_create()
3534 track_var = create_var(hist_data, file, "__max", sizeof(u64), "u64"); in track_data_create()
3542 track_var = create_var(hist_data, file, "__change", sizeof(u64), "u64"); in track_data_create()
3550 ret = action_create(hist_data, data); in track_data_create()
3706 static struct action_data *track_data_parse(struct hist_trigger_data *hist_data, in track_data_parse() argument
3729 ret = action_parse(hist_data->event_file->tr, str, data, handler); in track_data_parse()
3735 track_data_destroy(hist_data, data); in track_data_parse()
3759 static void destroy_field_vars(struct hist_trigger_data *hist_data) in destroy_field_vars() argument
3763 for (i = 0; i < hist_data->n_field_vars; i++) in destroy_field_vars()
3764 destroy_field_var(hist_data->field_vars[i]); in destroy_field_vars()
3766 for (i = 0; i < hist_data->n_save_vars; i++) in destroy_field_vars()
3767 destroy_field_var(hist_data->save_vars[i]); in destroy_field_vars()
3770 static void save_field_var(struct hist_trigger_data *hist_data, in save_field_var() argument
3773 hist_data->field_vars[hist_data->n_field_vars++] = field_var; in save_field_var()
3776 hist_data->n_field_var_str++; in save_field_var()
3810 trace_action_find_var(struct hist_trigger_data *hist_data, in trace_action_find_var() argument
3814 struct trace_array *tr = hist_data->event_file->tr; in trace_action_find_var()
3819 hist_field = find_target_event_var(hist_data, system, event, var); in trace_action_find_var()
3826 hist_field = find_event_var(hist_data, system, event, var); in trace_action_find_var()
3836 trace_action_create_field_var(struct hist_trigger_data *hist_data, in trace_action_create_field_var() argument
3849 field_var = create_target_field_var(hist_data, system, event, var); in trace_action_create_field_var()
3852 save_field_var(hist_data, field_var); in trace_action_create_field_var()
3875 hist_field = create_field_var_hist(hist_data, system, event, var); in trace_action_create_field_var()
3887 static int trace_action_create(struct hist_trigger_data *hist_data, in trace_action_create() argument
3890 struct trace_array *tr = hist_data->event_file->tr; in trace_action_create()
3937 hist_field = trace_action_find_var(hist_data, data, in trace_action_create()
3941 hist_field = trace_action_create_field_var(hist_data, in trace_action_create()
3954 var_ref = create_var_ref(hist_data, hist_field, in trace_action_create()
3962 var_ref_idx = find_var_ref_idx(hist_data, var_ref); in trace_action_create()
3997 static int action_create(struct hist_trigger_data *hist_data, in action_create() argument
4000 struct trace_event_file *file = hist_data->event_file; in action_create()
4009 return trace_action_create(hist_data, data); in action_create()
4012 track_data = track_data_alloc(hist_data->key_size, data, hist_data); in action_create()
4027 if (hist_data->n_save_vars) { in action_create()
4040 field_var = create_target_field_var(hist_data, NULL, NULL, param); in action_create()
4049 hist_data->save_vars[hist_data->n_save_vars++] = field_var; in action_create()
4051 hist_data->n_save_var_str++; in action_create()
4059 static int onmatch_create(struct hist_trigger_data *hist_data, in onmatch_create() argument
4062 return action_create(hist_data, data); in onmatch_create()
4115 static int create_hitcount_val(struct hist_trigger_data *hist_data) in create_hitcount_val() argument
4117 hist_data->fields[HITCOUNT_IDX] = in create_hitcount_val()
4118 create_hist_field(hist_data, NULL, HIST_FIELD_FL_HITCOUNT, NULL); in create_hitcount_val()
4119 if (!hist_data->fields[HITCOUNT_IDX]) in create_hitcount_val()
4122 hist_data->n_vals++; in create_hitcount_val()
4123 hist_data->n_fields++; in create_hitcount_val()
4125 if (WARN_ON(hist_data->n_vals > TRACING_MAP_VALS_MAX)) in create_hitcount_val()
4131 static int __create_val_field(struct hist_trigger_data *hist_data, in __create_val_field() argument
4140 hist_field = parse_expr(hist_data, file, field_str, flags, var_name, &n_subexprs); in __create_val_field()
4146 hist_data->fields[val_idx] = hist_field; in __create_val_field()
4148 ++hist_data->n_vals; in __create_val_field()
4149 ++hist_data->n_fields; in __create_val_field()
4151 if (WARN_ON(hist_data->n_vals > TRACING_MAP_VALS_MAX + TRACING_MAP_VARS_MAX)) in __create_val_field()
4157 static int create_val_field(struct hist_trigger_data *hist_data, in create_val_field() argument
4165 return __create_val_field(hist_data, val_idx, file, NULL, field_str, 0); in create_val_field()
4203 static int create_var_field(struct hist_trigger_data *hist_data, in create_var_field() argument
4208 struct trace_array *tr = hist_data->event_file->tr; in create_var_field()
4215 if (find_var(hist_data, file, var_name) && !hist_data->remove) { in create_var_field()
4221 hist_data->n_vars++; in create_var_field()
4222 if (WARN_ON(hist_data->n_vars > TRACING_MAP_VARS_MAX)) in create_var_field()
4225 ret = __create_val_field(hist_data, val_idx, file, var_name, expr_str, flags); in create_var_field()
4227 if (!ret && hist_data->fields[val_idx]->flags & HIST_FIELD_FL_EXECNAME) in create_var_field()
4228 update_var_execname(hist_data->fields[val_idx]); in create_var_field()
4230 if (!ret && hist_data->fields[val_idx]->flags & HIST_FIELD_FL_STRING) in create_var_field()
4231 hist_data->fields[val_idx]->var_str_idx = hist_data->n_var_str++; in create_var_field()
4236 static int create_val_fields(struct hist_trigger_data *hist_data, in create_val_fields() argument
4243 ret = create_hitcount_val(hist_data); in create_val_fields()
4247 fields_str = hist_data->attrs->vals_str; in create_val_fields()
4260 ret = create_val_field(hist_data, j++, file, field_str); in create_val_fields()
4271 static int create_key_field(struct hist_trigger_data *hist_data, in create_key_field() argument
4277 struct trace_array *tr = hist_data->event_file->tr; in create_key_field()
4291 hist_field = create_hist_field(hist_data, NULL, flags, NULL); in create_key_field()
4293 hist_field = parse_expr(hist_data, file, field_str, flags, in create_key_field()
4310 hist_data->fields[key_idx] = hist_field; in create_key_field()
4313 hist_data->fields[key_idx]->size = key_size; in create_key_field()
4314 hist_data->fields[key_idx]->offset = key_offset; in create_key_field()
4316 hist_data->key_size += key_size; in create_key_field()
4318 if (hist_data->key_size > HIST_KEY_SIZE_MAX) { in create_key_field()
4323 hist_data->n_keys++; in create_key_field()
4324 hist_data->n_fields++; in create_key_field()
4326 if (WARN_ON(hist_data->n_keys > TRACING_MAP_KEYS_MAX)) in create_key_field()
4334 static int create_key_fields(struct hist_trigger_data *hist_data, in create_key_fields() argument
4337 unsigned int i, key_offset = 0, n_vals = hist_data->n_vals; in create_key_fields()
4341 fields_str = hist_data->attrs->keys_str; in create_key_fields()
4349 ret = create_key_field(hist_data, i, key_offset, in create_key_fields()
4364 static int create_var_fields(struct hist_trigger_data *hist_data, in create_var_fields() argument
4367 unsigned int i, j = hist_data->n_vals; in create_var_fields()
4370 unsigned int n_vars = hist_data->attrs->var_defs.n_vars; in create_var_fields()
4373 char *var_name = hist_data->attrs->var_defs.name[i]; in create_var_fields()
4374 char *expr = hist_data->attrs->var_defs.expr[i]; in create_var_fields()
4376 ret = create_var_field(hist_data, j++, file, var_name, expr); in create_var_fields()
4384 static void free_var_defs(struct hist_trigger_data *hist_data) in free_var_defs() argument
4388 for (i = 0; i < hist_data->attrs->var_defs.n_vars; i++) { in free_var_defs()
4389 kfree(hist_data->attrs->var_defs.name[i]); in free_var_defs()
4390 kfree(hist_data->attrs->var_defs.expr[i]); in free_var_defs()
4393 hist_data->attrs->var_defs.n_vars = 0; in free_var_defs()
4396 static int parse_var_defs(struct hist_trigger_data *hist_data) in parse_var_defs() argument
4398 struct trace_array *tr = hist_data->event_file->tr; in parse_var_defs()
4403 for (i = 0; i < hist_data->attrs->n_assignments; i++) { in parse_var_defs()
4404 str = hist_data->attrs->assignment_str[i]; in parse_var_defs()
4429 hist_data->attrs->var_defs.name[n_vars] = s; in parse_var_defs()
4433 kfree(hist_data->attrs->var_defs.name[n_vars]); in parse_var_defs()
4434 hist_data->attrs->var_defs.name[n_vars] = NULL; in parse_var_defs()
4438 hist_data->attrs->var_defs.expr[n_vars++] = s; in parse_var_defs()
4440 hist_data->attrs->var_defs.n_vars = n_vars; in parse_var_defs()
4446 free_var_defs(hist_data); in parse_var_defs()
4451 static int create_hist_fields(struct hist_trigger_data *hist_data, in create_hist_fields() argument
4456 ret = parse_var_defs(hist_data); in create_hist_fields()
4460 ret = create_val_fields(hist_data, file); in create_hist_fields()
4464 ret = create_var_fields(hist_data, file); in create_hist_fields()
4468 ret = create_key_fields(hist_data, file); in create_hist_fields()
4472 free_var_defs(hist_data); in create_hist_fields()
4493 static int create_sort_keys(struct hist_trigger_data *hist_data) in create_sort_keys() argument
4495 struct trace_array *tr = hist_data->event_file->tr; in create_sort_keys()
4496 char *fields_str = hist_data->attrs->sort_key_str; in create_sort_keys()
4501 hist_data->n_sort_keys = 1; /* we always have at least one, hitcount */ in create_sort_keys()
4511 sort_key = &hist_data->sort_keys[i]; in create_sort_keys()
4546 for (j = 1, k = 1; j < hist_data->n_fields; j++) { in create_sort_keys()
4549 hist_field = hist_data->fields[j]; in create_sort_keys()
4568 if (j == hist_data->n_fields) { in create_sort_keys()
4575 hist_data->n_sort_keys = i; in create_sort_keys()
4580 static void destroy_actions(struct hist_trigger_data *hist_data) in destroy_actions() argument
4584 for (i = 0; i < hist_data->n_actions; i++) { in destroy_actions()
4585 struct action_data *data = hist_data->actions[i]; in destroy_actions()
4591 track_data_destroy(hist_data, data); in destroy_actions()
4597 static int parse_actions(struct hist_trigger_data *hist_data) in parse_actions() argument
4599 struct trace_array *tr = hist_data->event_file->tr; in parse_actions()
4606 for (i = 0; i < hist_data->attrs->n_actions; i++) { in parse_actions()
4607 str = hist_data->attrs->action_str[i]; in parse_actions()
4620 data = track_data_parse(hist_data, action_str, in parse_actions()
4629 data = track_data_parse(hist_data, action_str, in parse_actions()
4640 hist_data->actions[hist_data->n_actions++] = data; in parse_actions()
4646 static int create_actions(struct hist_trigger_data *hist_data) in create_actions() argument
4652 for (i = 0; i < hist_data->attrs->n_actions; i++) { in create_actions()
4653 data = hist_data->actions[i]; in create_actions()
4656 ret = onmatch_create(hist_data, data); in create_actions()
4661 ret = track_data_create(hist_data, data); in create_actions()
4674 struct hist_trigger_data *hist_data, in print_actions() argument
4679 for (i = 0; i < hist_data->n_actions; i++) { in print_actions()
4680 struct action_data *data = hist_data->actions[i]; in print_actions()
4687 track_data_print(m, hist_data, elt, data); in print_actions()
4692 struct hist_trigger_data *hist_data, in print_action_spec() argument
4698 for (i = 0; i < hist_data->n_save_vars; i++) { in print_action_spec()
4699 seq_printf(m, "%s", hist_data->save_vars[i]->var->var.name); in print_action_spec()
4700 if (i < hist_data->n_save_vars - 1) in print_action_spec()
4715 struct hist_trigger_data *hist_data, in print_track_data_spec() argument
4725 print_action_spec(m, hist_data, data); in print_track_data_spec()
4731 struct hist_trigger_data *hist_data, in print_onmatch_spec() argument
4739 print_action_spec(m, hist_data, data); in print_onmatch_spec()
4744 static bool actions_match(struct hist_trigger_data *hist_data, in actions_match() argument
4749 if (hist_data->n_actions != hist_data_test->n_actions) in actions_match()
4752 for (i = 0; i < hist_data->n_actions; i++) { in actions_match()
4753 struct action_data *data = hist_data->actions[i]; in actions_match()
4803 struct hist_trigger_data *hist_data) in print_actions_spec() argument
4807 for (i = 0; i < hist_data->n_actions; i++) { in print_actions_spec()
4808 struct action_data *data = hist_data->actions[i]; in print_actions_spec()
4811 print_onmatch_spec(m, hist_data, data); in print_actions_spec()
4814 print_track_data_spec(m, hist_data, data); in print_actions_spec()
4818 static void destroy_field_var_hists(struct hist_trigger_data *hist_data) in destroy_field_var_hists() argument
4822 for (i = 0; i < hist_data->n_field_var_hists; i++) { in destroy_field_var_hists()
4823 kfree(hist_data->field_var_hists[i]->cmd); in destroy_field_var_hists()
4824 kfree(hist_data->field_var_hists[i]); in destroy_field_var_hists()
4828 static void destroy_hist_data(struct hist_trigger_data *hist_data) in destroy_hist_data() argument
4830 if (!hist_data) in destroy_hist_data()
4833 destroy_hist_trigger_attrs(hist_data->attrs); in destroy_hist_data()
4834 destroy_hist_fields(hist_data); in destroy_hist_data()
4835 tracing_map_destroy(hist_data->map); in destroy_hist_data()
4837 destroy_actions(hist_data); in destroy_hist_data()
4838 destroy_field_vars(hist_data); in destroy_hist_data()
4839 destroy_field_var_hists(hist_data); in destroy_hist_data()
4841 kfree(hist_data); in destroy_hist_data()
4844 static int create_tracing_map_fields(struct hist_trigger_data *hist_data) in create_tracing_map_fields() argument
4846 struct tracing_map *map = hist_data->map; in create_tracing_map_fields()
4851 for_each_hist_field(i, hist_data) { in create_tracing_map_fields()
4852 hist_field = hist_data->fields[i]; in create_tracing_map_fields()
4882 hist_field->var.hist_data = hist_data; in create_tracing_map_fields()
4896 struct hist_trigger_data *hist_data; in create_hist_data() local
4899 hist_data = kzalloc(sizeof(*hist_data), GFP_KERNEL); in create_hist_data()
4900 if (!hist_data) in create_hist_data()
4903 hist_data->attrs = attrs; in create_hist_data()
4904 hist_data->remove = remove; in create_hist_data()
4905 hist_data->event_file = file; in create_hist_data()
4907 ret = parse_actions(hist_data); in create_hist_data()
4911 ret = create_hist_fields(hist_data, file); in create_hist_data()
4915 ret = create_sort_keys(hist_data); in create_hist_data()
4921 hist_data->map = tracing_map_create(map_bits, hist_data->key_size, in create_hist_data()
4922 map_ops, hist_data); in create_hist_data()
4923 if (IS_ERR(hist_data->map)) { in create_hist_data()
4924 ret = PTR_ERR(hist_data->map); in create_hist_data()
4925 hist_data->map = NULL; in create_hist_data()
4929 ret = create_tracing_map_fields(hist_data); in create_hist_data()
4933 return hist_data; in create_hist_data()
4935 hist_data->attrs = NULL; in create_hist_data()
4937 destroy_hist_data(hist_data); in create_hist_data()
4939 hist_data = ERR_PTR(ret); in create_hist_data()
4944 static void hist_trigger_elt_update(struct hist_trigger_data *hist_data, in hist_trigger_elt_update() argument
4958 for_each_hist_val_field(i, hist_data) { in hist_trigger_elt_update()
4959 hist_field = hist_data->fields[i]; in hist_trigger_elt_update()
4969 str_start = hist_data->n_field_var_str + in hist_trigger_elt_update()
4970 hist_data->n_save_var_str; in hist_trigger_elt_update()
4988 for_each_hist_key_field(i, hist_data) { in hist_trigger_elt_update()
4989 hist_field = hist_data->fields[i]; in hist_trigger_elt_update()
4997 update_field_vars(hist_data, elt, buffer, rbe, rec); in hist_trigger_elt_update()
5025 hist_trigger_actions(struct hist_trigger_data *hist_data, in hist_trigger_actions() argument
5034 for (i = 0; i < hist_data->n_actions; i++) { in hist_trigger_actions()
5035 data = hist_data->actions[i]; in hist_trigger_actions()
5036 data->fn(hist_data, elt, buffer, rec, rbe, key, data, var_ref_vals); in hist_trigger_actions()
5044 struct hist_trigger_data *hist_data = data->private_data; in event_hist_trigger() local
5045 bool use_compound_key = (hist_data->n_keys > 1); in event_hist_trigger()
5055 memset(compound_key, 0, hist_data->key_size); in event_hist_trigger()
5057 for_each_hist_key_field(i, hist_data) { in event_hist_trigger()
5058 key_field = hist_data->fields[i]; in event_hist_trigger()
5081 if (hist_data->n_var_refs && in event_hist_trigger()
5082 !resolve_var_refs(hist_data, key, var_ref_vals, false)) in event_hist_trigger()
5085 elt = tracing_map_insert(hist_data->map, key); in event_hist_trigger()
5089 hist_trigger_elt_update(hist_data, elt, buffer, rec, rbe, var_ref_vals); in event_hist_trigger()
5091 if (resolve_var_refs(hist_data, key, var_ref_vals, true)) in event_hist_trigger()
5092 hist_trigger_actions(hist_data, elt, buffer, rec, rbe, key, var_ref_vals); in event_hist_trigger()
5112 struct hist_trigger_data *hist_data, in hist_trigger_print_key() argument
5124 for_each_hist_key_field(i, hist_data) { in hist_trigger_print_key()
5125 key_field = hist_data->fields[i]; in hist_trigger_print_key()
5127 if (i > hist_data->n_vals) in hist_trigger_print_key()
5195 struct hist_trigger_data *hist_data, in hist_trigger_entry_print() argument
5202 hist_trigger_print_key(m, hist_data, key, elt); in hist_trigger_entry_print()
5207 for (i = 1; i < hist_data->n_vals; i++) { in hist_trigger_entry_print()
5208 field_name = hist_field_name(hist_data->fields[i], 0); in hist_trigger_entry_print()
5210 if (hist_data->fields[i]->flags & HIST_FIELD_FL_VAR || in hist_trigger_entry_print()
5211 hist_data->fields[i]->flags & HIST_FIELD_FL_EXPR) in hist_trigger_entry_print()
5214 if (hist_data->fields[i]->flags & HIST_FIELD_FL_HEX) { in hist_trigger_entry_print()
5223 print_actions(m, hist_data, elt); in hist_trigger_entry_print()
5229 struct hist_trigger_data *hist_data) in print_entries() argument
5232 struct tracing_map *map = hist_data->map; in print_entries()
5235 n_entries = tracing_map_sort_entries(map, hist_data->sort_keys, in print_entries()
5236 hist_data->n_sort_keys, in print_entries()
5242 hist_trigger_entry_print(m, hist_data, in print_entries()
5254 struct hist_trigger_data *hist_data; in hist_trigger_show() local
5264 hist_data = data->private_data; in hist_trigger_show()
5265 n_entries = print_entries(m, hist_data); in hist_trigger_show()
5269 track_data_snapshot_print(m, hist_data); in hist_trigger_show()
5272 (u64)atomic64_read(&hist_data->map->hits), in hist_trigger_show()
5273 n_entries, (u64)atomic64_read(&hist_data->map->drops)); in hist_trigger_show()
5372 seq_printf(m, " var.hist_data: %p\n", field->var.hist_data); in hist_field_debug_show()
5456 struct hist_trigger_data *hist_data) in hist_actions_debug_show() argument
5460 if (hist_data->n_actions) in hist_actions_debug_show()
5463 for (i = 0; i < hist_data->n_actions; i++) { in hist_actions_debug_show()
5464 struct action_data *action = hist_data->actions[i]; in hist_actions_debug_show()
5471 if (hist_data->n_save_vars) in hist_actions_debug_show()
5474 for (i = 0; i < hist_data->n_save_vars; i++) { in hist_actions_debug_show()
5475 ret = field_var_debug_show(m, hist_data->save_vars[i], i, true); in hist_actions_debug_show()
5486 struct hist_trigger_data *hist_data; in hist_trigger_debug_show() local
5496 hist_data = data->private_data; in hist_trigger_debug_show()
5498 seq_printf(m, "hist_data: %p\n\n", hist_data); in hist_trigger_debug_show()
5499 seq_printf(m, " n_vals: %u\n", hist_data->n_vals); in hist_trigger_debug_show()
5500 seq_printf(m, " n_keys: %u\n", hist_data->n_keys); in hist_trigger_debug_show()
5501 seq_printf(m, " n_fields: %u\n", hist_data->n_fields); in hist_trigger_debug_show()
5506 ret = hist_field_debug_show(m, hist_data->fields[0], in hist_trigger_debug_show()
5511 for (i = 1; i < hist_data->n_vals; i++) { in hist_trigger_debug_show()
5513 ret = hist_field_debug_show(m, hist_data->fields[i], 0); in hist_trigger_debug_show()
5520 for (i = hist_data->n_vals; i < hist_data->n_fields; i++) { in hist_trigger_debug_show()
5522 ret = hist_field_debug_show(m, hist_data->fields[i], in hist_trigger_debug_show()
5528 if (hist_data->n_var_refs) in hist_trigger_debug_show()
5531 for (i = 0; i < hist_data->n_var_refs; i++) { in hist_trigger_debug_show()
5533 ret = hist_field_debug_show(m, hist_data->var_refs[i], in hist_trigger_debug_show()
5539 if (hist_data->n_field_vars) in hist_trigger_debug_show()
5542 for (i = 0; i < hist_data->n_field_vars; i++) { in hist_trigger_debug_show()
5543 ret = field_var_debug_show(m, hist_data->field_vars[i], i, false); in hist_trigger_debug_show()
5548 ret = hist_actions_debug_show(m, hist_data); in hist_trigger_debug_show()
5632 struct hist_trigger_data *hist_data = data->private_data; in event_hist_trigger_print() local
5644 for_each_hist_key_field(i, hist_data) { in event_hist_trigger_print()
5645 field = hist_data->fields[i]; in event_hist_trigger_print()
5647 if (i > hist_data->n_vals) in event_hist_trigger_print()
5658 for_each_hist_val_field(i, hist_data) { in event_hist_trigger_print()
5659 field = hist_data->fields[i]; in event_hist_trigger_print()
5678 for_each_hist_val_field(i, hist_data) { in event_hist_trigger_print()
5679 field = hist_data->fields[i]; in event_hist_trigger_print()
5691 for (i = 0; i < hist_data->n_sort_keys; i++) { in event_hist_trigger_print()
5696 first_key_idx = hist_data->n_vals - hist_data->n_vars; in event_hist_trigger_print()
5698 sort_key = &hist_data->sort_keys[i]; in event_hist_trigger_print()
5711 idx += hist_data->n_vars; in event_hist_trigger_print()
5712 hist_field_print(m, hist_data->fields[idx]); in event_hist_trigger_print()
5718 seq_printf(m, ":size=%u", (1 << hist_data->map->map_bits)); in event_hist_trigger_print()
5719 if (hist_data->enable_timestamps) in event_hist_trigger_print()
5720 seq_printf(m, ":clock=%s", hist_data->attrs->clock); in event_hist_trigger_print()
5722 print_actions_spec(m, hist_data); in event_hist_trigger_print()
5739 struct hist_trigger_data *hist_data = data->private_data; in event_hist_trigger_init() local
5741 if (!data->ref && hist_data->attrs->name) in event_hist_trigger_init()
5742 save_named_trigger(hist_data->attrs->name, data); in event_hist_trigger_init()
5749 static void unregister_field_var_hists(struct hist_trigger_data *hist_data) in unregister_field_var_hists() argument
5756 for (i = 0; i < hist_data->n_field_var_hists; i++) { in unregister_field_var_hists()
5757 file = hist_data->field_var_hists[i]->hist_data->event_file; in unregister_field_var_hists()
5758 cmd = hist_data->field_var_hists[i]->cmd; in unregister_field_var_hists()
5767 struct hist_trigger_data *hist_data = data->private_data; in event_hist_trigger_free() local
5779 remove_hist_vars(hist_data); in event_hist_trigger_free()
5781 unregister_field_var_hists(hist_data); in event_hist_trigger_free()
5783 destroy_hist_data(hist_data); in event_hist_trigger_free()
5834 struct hist_trigger_data *hist_data = data->private_data; in hist_clear() local
5841 tracing_map_clear(hist_data->map); in hist_clear()
5872 struct hist_trigger_data *hist_data, *hist_data_test; in hist_trigger_match() local
5883 hist_data = data->private_data; in hist_trigger_match()
5886 if (hist_data->n_vals != hist_data_test->n_vals || in hist_trigger_match()
5887 hist_data->n_fields != hist_data_test->n_fields || in hist_trigger_match()
5888 hist_data->n_sort_keys != hist_data_test->n_sort_keys) in hist_trigger_match()
5897 for_each_hist_field(i, hist_data) { in hist_trigger_match()
5898 key_field = hist_data->fields[i]; in hist_trigger_match()
5918 for (i = 0; i < hist_data->n_sort_keys; i++) { in hist_trigger_match()
5919 sort_key = &hist_data->sort_keys[i]; in hist_trigger_match()
5931 if (!actions_match(hist_data, hist_data_test)) in hist_trigger_match()
5941 struct hist_trigger_data *hist_data = data->private_data; in existing_hist_update_only() local
5945 if (!hist_data->attrs->pause && !hist_data->attrs->cont && in existing_hist_update_only()
5946 !hist_data->attrs->clear) in existing_hist_update_only()
5949 if (hist_data->attrs->name) { in existing_hist_update_only()
5950 named_data = find_named_trigger(hist_data->attrs->name); in existing_hist_update_only()
5958 if (hist_data->attrs->name && !named_data) in existing_hist_update_only()
5965 if (hist_data->attrs->pause) in existing_hist_update_only()
5967 else if (hist_data->attrs->cont) in existing_hist_update_only()
5969 else if (hist_data->attrs->clear) in existing_hist_update_only()
5983 struct hist_trigger_data *hist_data = data->private_data; in hist_register_trigger() local
5988 if (hist_data->attrs->name) { in hist_register_trigger()
5989 named_data = find_named_trigger(hist_data->attrs->name); in hist_register_trigger()
5993 hist_err(tr, HIST_ERR_NAMED_MISMATCH, errpos(hist_data->attrs->name)); in hist_register_trigger()
6000 if (hist_data->attrs->name && !named_data) in hist_register_trigger()
6015 if (hist_data->attrs->cont || hist_data->attrs->clear) { in hist_register_trigger()
6021 if (hist_data->attrs->pause) in hist_register_trigger()
6036 if (hist_data->enable_timestamps) { in hist_register_trigger()
6037 char *clock = hist_data->attrs->clock; in hist_register_trigger()
6039 ret = tracing_set_clock(file->tr, hist_data->attrs->clock); in hist_register_trigger()
6049 destroy_hist_data(hist_data); in hist_register_trigger()
6075 struct hist_trigger_data *hist_data = data->private_data; in have_hist_trigger_match() local
6081 if (hist_data->attrs->name) in have_hist_trigger_match()
6082 named_data = find_named_trigger(hist_data->attrs->name); in have_hist_trigger_match()
6099 struct hist_trigger_data *hist_data = data->private_data; in hist_trigger_check_refs() local
6104 if (hist_data->attrs->name) in hist_trigger_check_refs()
6105 named_data = find_named_trigger(hist_data->attrs->name); in hist_trigger_check_refs()
6111 hist_data = test->private_data; in hist_trigger_check_refs()
6112 if (check_var_refs(hist_data)) in hist_trigger_check_refs()
6126 struct hist_trigger_data *hist_data = data->private_data; in hist_unregister_trigger() local
6130 if (hist_data->attrs->name) in hist_unregister_trigger()
6131 named_data = find_named_trigger(hist_data->attrs->name); in hist_unregister_trigger()
6148 if (hist_data->enable_timestamps) { in hist_unregister_trigger()
6149 if (!hist_data->remove || test) in hist_unregister_trigger()
6156 struct hist_trigger_data *hist_data; in hist_file_check_refs() local
6163 hist_data = test->private_data; in hist_file_check_refs()
6164 if (check_var_refs(hist_data)) in hist_file_check_refs()
6175 struct hist_trigger_data *hist_data; in hist_unreg_all() local
6186 hist_data = test->private_data; in hist_unreg_all()
6196 if (hist_data->enable_timestamps) in hist_unreg_all()
6212 struct hist_trigger_data *hist_data; in event_hist_trigger_parse() local
6283 hist_data = create_hist_data(hist_trigger_bits, attrs, file, remove); in event_hist_trigger_parse()
6284 if (IS_ERR(hist_data)) { in event_hist_trigger_parse()
6286 return PTR_ERR(hist_data); in event_hist_trigger_parse()
6289 trigger_data = event_trigger_alloc(cmd_ops, cmd, param, hist_data); in event_hist_trigger_parse()
6327 if (has_hist_vars(hist_data)) in event_hist_trigger_parse()
6328 save_hist_vars(hist_data); in event_hist_trigger_parse()
6330 ret = create_actions(hist_data); in event_hist_trigger_parse()
6334 ret = tracing_map_init(hist_data->map); in event_hist_trigger_parse()
6356 remove_hist_vars(hist_data); in event_hist_trigger_parse()
6360 destroy_hist_data(hist_data); in event_hist_trigger_parse()