2 * trace_events_hist - trace event hist triggers
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * Copyright (C) 2015 Tom Zanussi <tom.zanussi@linux.intel.com>
17 #include <linux/module.h>
18 #include <linux/kallsyms.h>
19 #include <linux/mutex.h>
20 #include <linux/slab.h>
21 #include <linux/stacktrace.h>
22 #include <linux/rculist.h>
24 #include "tracing_map.h"
29 typedef u64 (*hist_field_fn_t
) (struct hist_field
*field
, void *event
);
31 #define HIST_FIELD_OPERANDS_MAX 2
34 struct ftrace_event_field
*field
;
39 unsigned int is_signed
;
40 struct hist_field
*operands
[HIST_FIELD_OPERANDS_MAX
];
43 static u64
hist_field_none(struct hist_field
*field
, void *event
)
48 static u64
hist_field_counter(struct hist_field
*field
, void *event
)
53 static u64
hist_field_string(struct hist_field
*hist_field
, void *event
)
55 char *addr
= (char *)(event
+ hist_field
->field
->offset
);
57 return (u64
)(unsigned long)addr
;
60 static u64
hist_field_dynstring(struct hist_field
*hist_field
, void *event
)
62 u32 str_item
= *(u32
*)(event
+ hist_field
->field
->offset
);
63 int str_loc
= str_item
& 0xffff;
64 char *addr
= (char *)(event
+ str_loc
);
66 return (u64
)(unsigned long)addr
;
69 static u64
hist_field_pstring(struct hist_field
*hist_field
, void *event
)
71 char **addr
= (char **)(event
+ hist_field
->field
->offset
);
73 return (u64
)(unsigned long)*addr
;
76 static u64
hist_field_log2(struct hist_field
*hist_field
, void *event
)
78 struct hist_field
*operand
= hist_field
->operands
[0];
80 u64 val
= operand
->fn(operand
, event
);
82 return (u64
) ilog2(roundup_pow_of_two(val
));
85 #define DEFINE_HIST_FIELD_FN(type) \
86 static u64 hist_field_##type(struct hist_field *hist_field, void *event)\
88 type *addr = (type *)(event + hist_field->field->offset); \
90 return (u64)(unsigned long)*addr; \
93 DEFINE_HIST_FIELD_FN(s64
);
94 DEFINE_HIST_FIELD_FN(u64
);
95 DEFINE_HIST_FIELD_FN(s32
);
96 DEFINE_HIST_FIELD_FN(u32
);
97 DEFINE_HIST_FIELD_FN(s16
);
98 DEFINE_HIST_FIELD_FN(u16
);
99 DEFINE_HIST_FIELD_FN(s8
);
100 DEFINE_HIST_FIELD_FN(u8
);
102 #define for_each_hist_field(i, hist_data) \
103 for ((i) = 0; (i) < (hist_data)->n_fields; (i)++)
105 #define for_each_hist_val_field(i, hist_data) \
106 for ((i) = 0; (i) < (hist_data)->n_vals; (i)++)
108 #define for_each_hist_key_field(i, hist_data) \
109 for ((i) = (hist_data)->n_vals; (i) < (hist_data)->n_fields; (i)++)
111 #define HIST_STACKTRACE_DEPTH 16
112 #define HIST_STACKTRACE_SIZE (HIST_STACKTRACE_DEPTH * sizeof(unsigned long))
113 #define HIST_STACKTRACE_SKIP 5
115 #define HITCOUNT_IDX 0
116 #define HIST_KEY_SIZE_MAX (MAX_FILTER_STR_VAL + HIST_STACKTRACE_SIZE)
118 enum hist_field_flags
{
119 HIST_FIELD_FL_HITCOUNT
= 1 << 0,
120 HIST_FIELD_FL_KEY
= 1 << 1,
121 HIST_FIELD_FL_STRING
= 1 << 2,
122 HIST_FIELD_FL_HEX
= 1 << 3,
123 HIST_FIELD_FL_SYM
= 1 << 4,
124 HIST_FIELD_FL_SYM_OFFSET
= 1 << 5,
125 HIST_FIELD_FL_EXECNAME
= 1 << 6,
126 HIST_FIELD_FL_SYSCALL
= 1 << 7,
127 HIST_FIELD_FL_STACKTRACE
= 1 << 8,
128 HIST_FIELD_FL_LOG2
= 1 << 9,
131 struct hist_trigger_attrs
{
139 unsigned int map_bits
;
142 struct hist_trigger_data
{
143 struct hist_field
*fields
[TRACING_MAP_FIELDS_MAX
];
146 unsigned int n_fields
;
147 unsigned int key_size
;
148 struct tracing_map_sort_key sort_keys
[TRACING_MAP_SORT_KEYS_MAX
];
149 unsigned int n_sort_keys
;
150 struct trace_event_file
*event_file
;
151 struct hist_trigger_attrs
*attrs
;
152 struct tracing_map
*map
;
155 static const char *hist_field_name(struct hist_field
*field
,
158 const char *field_name
= "";
164 field_name
= field
->field
->name
;
165 else if (field
->flags
& HIST_FIELD_FL_LOG2
)
166 field_name
= hist_field_name(field
->operands
[0], ++level
);
168 if (field_name
== NULL
)
174 static hist_field_fn_t
select_value_fn(int field_size
, int field_is_signed
)
176 hist_field_fn_t fn
= NULL
;
178 switch (field_size
) {
208 static int parse_map_size(char *str
)
210 unsigned long size
, map_bits
;
219 ret
= kstrtoul(str
, 0, &size
);
223 map_bits
= ilog2(roundup_pow_of_two(size
));
224 if (map_bits
< TRACING_MAP_BITS_MIN
||
225 map_bits
> TRACING_MAP_BITS_MAX
)
233 static void destroy_hist_trigger_attrs(struct hist_trigger_attrs
*attrs
)
239 kfree(attrs
->sort_key_str
);
240 kfree(attrs
->keys_str
);
241 kfree(attrs
->vals_str
);
245 static struct hist_trigger_attrs
*parse_hist_trigger_attrs(char *trigger_str
)
247 struct hist_trigger_attrs
*attrs
;
250 attrs
= kzalloc(sizeof(*attrs
), GFP_KERNEL
);
252 return ERR_PTR(-ENOMEM
);
254 while (trigger_str
) {
255 char *str
= strsep(&trigger_str
, ":");
257 if ((strncmp(str
, "key=", strlen("key=")) == 0) ||
258 (strncmp(str
, "keys=", strlen("keys=")) == 0))
259 attrs
->keys_str
= kstrdup(str
, GFP_KERNEL
);
260 else if ((strncmp(str
, "val=", strlen("val=")) == 0) ||
261 (strncmp(str
, "vals=", strlen("vals=")) == 0) ||
262 (strncmp(str
, "values=", strlen("values=")) == 0))
263 attrs
->vals_str
= kstrdup(str
, GFP_KERNEL
);
264 else if (strncmp(str
, "sort=", strlen("sort=")) == 0)
265 attrs
->sort_key_str
= kstrdup(str
, GFP_KERNEL
);
266 else if (strncmp(str
, "name=", strlen("name=")) == 0)
267 attrs
->name
= kstrdup(str
, GFP_KERNEL
);
268 else if (strcmp(str
, "pause") == 0)
270 else if ((strcmp(str
, "cont") == 0) ||
271 (strcmp(str
, "continue") == 0))
273 else if (strcmp(str
, "clear") == 0)
275 else if (strncmp(str
, "size=", strlen("size=")) == 0) {
276 int map_bits
= parse_map_size(str
);
282 attrs
->map_bits
= map_bits
;
289 if (!attrs
->keys_str
) {
296 destroy_hist_trigger_attrs(attrs
);
301 static inline void save_comm(char *comm
, struct task_struct
*task
)
304 strcpy(comm
, "<idle>");
308 if (WARN_ON_ONCE(task
->pid
< 0)) {
309 strcpy(comm
, "<XXX>");
313 memcpy(comm
, task
->comm
, TASK_COMM_LEN
);
316 static void hist_trigger_elt_comm_free(struct tracing_map_elt
*elt
)
318 kfree((char *)elt
->private_data
);
321 static int hist_trigger_elt_comm_alloc(struct tracing_map_elt
*elt
)
323 struct hist_trigger_data
*hist_data
= elt
->map
->private_data
;
324 struct hist_field
*key_field
;
327 for_each_hist_key_field(i
, hist_data
) {
328 key_field
= hist_data
->fields
[i
];
330 if (key_field
->flags
& HIST_FIELD_FL_EXECNAME
) {
331 unsigned int size
= TASK_COMM_LEN
+ 1;
333 elt
->private_data
= kzalloc(size
, GFP_KERNEL
);
334 if (!elt
->private_data
)
343 static void hist_trigger_elt_comm_copy(struct tracing_map_elt
*to
,
344 struct tracing_map_elt
*from
)
346 char *comm_from
= from
->private_data
;
347 char *comm_to
= to
->private_data
;
350 memcpy(comm_to
, comm_from
, TASK_COMM_LEN
+ 1);
353 static void hist_trigger_elt_comm_init(struct tracing_map_elt
*elt
)
355 char *comm
= elt
->private_data
;
358 save_comm(comm
, current
);
361 static const struct tracing_map_ops hist_trigger_elt_comm_ops
= {
362 .elt_alloc
= hist_trigger_elt_comm_alloc
,
363 .elt_copy
= hist_trigger_elt_comm_copy
,
364 .elt_free
= hist_trigger_elt_comm_free
,
365 .elt_init
= hist_trigger_elt_comm_init
,
368 static void destroy_hist_field(struct hist_field
*hist_field
,
379 for (i
= 0; i
< HIST_FIELD_OPERANDS_MAX
; i
++)
380 destroy_hist_field(hist_field
->operands
[i
], level
+ 1);
385 static struct hist_field
*create_hist_field(struct ftrace_event_field
*field
,
388 struct hist_field
*hist_field
;
390 if (field
&& is_function_field(field
))
393 hist_field
= kzalloc(sizeof(struct hist_field
), GFP_KERNEL
);
397 if (flags
& HIST_FIELD_FL_HITCOUNT
) {
398 hist_field
->fn
= hist_field_counter
;
402 if (flags
& HIST_FIELD_FL_STACKTRACE
) {
403 hist_field
->fn
= hist_field_none
;
407 if (flags
& HIST_FIELD_FL_LOG2
) {
408 unsigned long fl
= flags
& ~HIST_FIELD_FL_LOG2
;
409 hist_field
->fn
= hist_field_log2
;
410 hist_field
->operands
[0] = create_hist_field(field
, fl
);
411 hist_field
->size
= hist_field
->operands
[0]->size
;
415 if (WARN_ON_ONCE(!field
))
418 if (is_string_field(field
)) {
419 flags
|= HIST_FIELD_FL_STRING
;
421 if (field
->filter_type
== FILTER_STATIC_STRING
)
422 hist_field
->fn
= hist_field_string
;
423 else if (field
->filter_type
== FILTER_DYN_STRING
)
424 hist_field
->fn
= hist_field_dynstring
;
426 hist_field
->fn
= hist_field_pstring
;
428 hist_field
->fn
= select_value_fn(field
->size
,
430 if (!hist_field
->fn
) {
431 destroy_hist_field(hist_field
, 0);
436 hist_field
->field
= field
;
437 hist_field
->flags
= flags
;
442 static void destroy_hist_fields(struct hist_trigger_data
*hist_data
)
446 for (i
= 0; i
< TRACING_MAP_FIELDS_MAX
; i
++) {
447 if (hist_data
->fields
[i
]) {
448 destroy_hist_field(hist_data
->fields
[i
], 0);
449 hist_data
->fields
[i
] = NULL
;
454 static int create_hitcount_val(struct hist_trigger_data
*hist_data
)
456 hist_data
->fields
[HITCOUNT_IDX
] =
457 create_hist_field(NULL
, HIST_FIELD_FL_HITCOUNT
);
458 if (!hist_data
->fields
[HITCOUNT_IDX
])
463 if (WARN_ON(hist_data
->n_vals
> TRACING_MAP_VALS_MAX
))
469 static int create_val_field(struct hist_trigger_data
*hist_data
,
470 unsigned int val_idx
,
471 struct trace_event_file
*file
,
474 struct ftrace_event_field
*field
= NULL
;
475 unsigned long flags
= 0;
479 if (WARN_ON(val_idx
>= TRACING_MAP_VALS_MAX
))
482 field_name
= strsep(&field_str
, ".");
484 if (strcmp(field_str
, "hex") == 0)
485 flags
|= HIST_FIELD_FL_HEX
;
492 field
= trace_find_event_field(file
->event_call
, field_name
);
493 if (!field
|| !field
->size
) {
498 hist_data
->fields
[val_idx
] = create_hist_field(field
, flags
);
499 if (!hist_data
->fields
[val_idx
]) {
506 if (WARN_ON(hist_data
->n_vals
> TRACING_MAP_VALS_MAX
))
512 static int create_val_fields(struct hist_trigger_data
*hist_data
,
513 struct trace_event_file
*file
)
515 char *fields_str
, *field_str
;
519 ret
= create_hitcount_val(hist_data
);
523 fields_str
= hist_data
->attrs
->vals_str
;
527 strsep(&fields_str
, "=");
531 for (i
= 0, j
= 1; i
< TRACING_MAP_VALS_MAX
&&
532 j
< TRACING_MAP_VALS_MAX
; i
++) {
533 field_str
= strsep(&fields_str
, ",");
536 if (strcmp(field_str
, "hitcount") == 0)
538 ret
= create_val_field(hist_data
, j
++, file
, field_str
);
542 if (fields_str
&& (strcmp(fields_str
, "hitcount") != 0))
548 static int create_key_field(struct hist_trigger_data
*hist_data
,
549 unsigned int key_idx
,
550 unsigned int key_offset
,
551 struct trace_event_file
*file
,
554 struct ftrace_event_field
*field
= NULL
;
555 unsigned long flags
= 0;
556 unsigned int key_size
;
559 if (WARN_ON(key_idx
>= TRACING_MAP_FIELDS_MAX
))
562 flags
|= HIST_FIELD_FL_KEY
;
564 if (strcmp(field_str
, "stacktrace") == 0) {
565 flags
|= HIST_FIELD_FL_STACKTRACE
;
566 key_size
= sizeof(unsigned long) * HIST_STACKTRACE_DEPTH
;
568 char *field_name
= strsep(&field_str
, ".");
571 if (strcmp(field_str
, "hex") == 0)
572 flags
|= HIST_FIELD_FL_HEX
;
573 else if (strcmp(field_str
, "sym") == 0)
574 flags
|= HIST_FIELD_FL_SYM
;
575 else if (strcmp(field_str
, "sym-offset") == 0)
576 flags
|= HIST_FIELD_FL_SYM_OFFSET
;
577 else if ((strcmp(field_str
, "execname") == 0) &&
578 (strcmp(field_name
, "common_pid") == 0))
579 flags
|= HIST_FIELD_FL_EXECNAME
;
580 else if (strcmp(field_str
, "syscall") == 0)
581 flags
|= HIST_FIELD_FL_SYSCALL
;
582 else if (strcmp(field_str
, "log2") == 0)
583 flags
|= HIST_FIELD_FL_LOG2
;
590 field
= trace_find_event_field(file
->event_call
, field_name
);
591 if (!field
|| !field
->size
) {
596 if (is_string_field(field
))
597 key_size
= MAX_FILTER_STR_VAL
;
599 key_size
= field
->size
;
602 hist_data
->fields
[key_idx
] = create_hist_field(field
, flags
);
603 if (!hist_data
->fields
[key_idx
]) {
608 key_size
= ALIGN(key_size
, sizeof(u64
));
609 hist_data
->fields
[key_idx
]->size
= key_size
;
610 hist_data
->fields
[key_idx
]->offset
= key_offset
;
611 hist_data
->key_size
+= key_size
;
612 if (hist_data
->key_size
> HIST_KEY_SIZE_MAX
) {
619 if (WARN_ON(hist_data
->n_keys
> TRACING_MAP_KEYS_MAX
))
627 static int create_key_fields(struct hist_trigger_data
*hist_data
,
628 struct trace_event_file
*file
)
630 unsigned int i
, key_offset
= 0, n_vals
= hist_data
->n_vals
;
631 char *fields_str
, *field_str
;
634 fields_str
= hist_data
->attrs
->keys_str
;
638 strsep(&fields_str
, "=");
642 for (i
= n_vals
; i
< n_vals
+ TRACING_MAP_KEYS_MAX
; i
++) {
643 field_str
= strsep(&fields_str
, ",");
646 ret
= create_key_field(hist_data
, i
, key_offset
,
661 static int create_hist_fields(struct hist_trigger_data
*hist_data
,
662 struct trace_event_file
*file
)
666 ret
= create_val_fields(hist_data
, file
);
670 ret
= create_key_fields(hist_data
, file
);
674 hist_data
->n_fields
= hist_data
->n_vals
+ hist_data
->n_keys
;
679 static int is_descending(const char *str
)
684 if (strcmp(str
, "descending") == 0)
687 if (strcmp(str
, "ascending") == 0)
693 static int create_sort_keys(struct hist_trigger_data
*hist_data
)
695 char *fields_str
= hist_data
->attrs
->sort_key_str
;
696 struct tracing_map_sort_key
*sort_key
;
697 int descending
, ret
= 0;
700 hist_data
->n_sort_keys
= 1; /* we always have at least one, hitcount */
705 strsep(&fields_str
, "=");
711 for (i
= 0; i
< TRACING_MAP_SORT_KEYS_MAX
; i
++) {
712 struct hist_field
*hist_field
;
713 char *field_str
, *field_name
;
714 const char *test_name
;
716 sort_key
= &hist_data
->sort_keys
[i
];
718 field_str
= strsep(&fields_str
, ",");
725 if ((i
== TRACING_MAP_SORT_KEYS_MAX
- 1) && fields_str
) {
730 field_name
= strsep(&field_str
, ".");
736 if (strcmp(field_name
, "hitcount") == 0) {
737 descending
= is_descending(field_str
);
738 if (descending
< 0) {
742 sort_key
->descending
= descending
;
746 for (j
= 1; j
< hist_data
->n_fields
; j
++) {
747 hist_field
= hist_data
->fields
[j
];
748 test_name
= hist_field_name(hist_field
, 0);
750 if (strcmp(field_name
, test_name
) == 0) {
751 sort_key
->field_idx
= j
;
752 descending
= is_descending(field_str
);
753 if (descending
< 0) {
757 sort_key
->descending
= descending
;
761 if (j
== hist_data
->n_fields
) {
766 hist_data
->n_sort_keys
= i
;
771 static void destroy_hist_data(struct hist_trigger_data
*hist_data
)
773 destroy_hist_trigger_attrs(hist_data
->attrs
);
774 destroy_hist_fields(hist_data
);
775 tracing_map_destroy(hist_data
->map
);
779 static int create_tracing_map_fields(struct hist_trigger_data
*hist_data
)
781 struct tracing_map
*map
= hist_data
->map
;
782 struct ftrace_event_field
*field
;
783 struct hist_field
*hist_field
;
786 for_each_hist_field(i
, hist_data
) {
787 hist_field
= hist_data
->fields
[i
];
788 if (hist_field
->flags
& HIST_FIELD_FL_KEY
) {
789 tracing_map_cmp_fn_t cmp_fn
;
791 field
= hist_field
->field
;
793 if (hist_field
->flags
& HIST_FIELD_FL_STACKTRACE
)
794 cmp_fn
= tracing_map_cmp_none
;
795 else if (is_string_field(field
))
796 cmp_fn
= tracing_map_cmp_string
;
798 cmp_fn
= tracing_map_cmp_num(field
->size
,
800 idx
= tracing_map_add_key_field(map
,
805 idx
= tracing_map_add_sum_field(map
);
814 static bool need_tracing_map_ops(struct hist_trigger_data
*hist_data
)
816 struct hist_field
*key_field
;
819 for_each_hist_key_field(i
, hist_data
) {
820 key_field
= hist_data
->fields
[i
];
822 if (key_field
->flags
& HIST_FIELD_FL_EXECNAME
)
829 static struct hist_trigger_data
*
830 create_hist_data(unsigned int map_bits
,
831 struct hist_trigger_attrs
*attrs
,
832 struct trace_event_file
*file
)
834 const struct tracing_map_ops
*map_ops
= NULL
;
835 struct hist_trigger_data
*hist_data
;
838 hist_data
= kzalloc(sizeof(*hist_data
), GFP_KERNEL
);
840 return ERR_PTR(-ENOMEM
);
842 hist_data
->attrs
= attrs
;
844 ret
= create_hist_fields(hist_data
, file
);
848 ret
= create_sort_keys(hist_data
);
852 if (need_tracing_map_ops(hist_data
))
853 map_ops
= &hist_trigger_elt_comm_ops
;
855 hist_data
->map
= tracing_map_create(map_bits
, hist_data
->key_size
,
857 if (IS_ERR(hist_data
->map
)) {
858 ret
= PTR_ERR(hist_data
->map
);
859 hist_data
->map
= NULL
;
863 ret
= create_tracing_map_fields(hist_data
);
867 ret
= tracing_map_init(hist_data
->map
);
871 hist_data
->event_file
= file
;
875 hist_data
->attrs
= NULL
;
877 destroy_hist_data(hist_data
);
879 hist_data
= ERR_PTR(ret
);
884 static void hist_trigger_elt_update(struct hist_trigger_data
*hist_data
,
885 struct tracing_map_elt
*elt
,
888 struct hist_field
*hist_field
;
892 for_each_hist_val_field(i
, hist_data
) {
893 hist_field
= hist_data
->fields
[i
];
894 hist_val
= hist_field
->fn(hist_field
, rec
);
895 tracing_map_update_sum(elt
, i
, hist_val
);
899 static inline void add_to_key(char *compound_key
, void *key
,
900 struct hist_field
*key_field
, void *rec
)
902 size_t size
= key_field
->size
;
904 if (key_field
->flags
& HIST_FIELD_FL_STRING
) {
905 struct ftrace_event_field
*field
;
907 field
= key_field
->field
;
908 if (field
->filter_type
== FILTER_DYN_STRING
)
909 size
= *(u32
*)(rec
+ field
->offset
) >> 16;
910 else if (field
->filter_type
== FILTER_PTR_STRING
)
912 else if (field
->filter_type
== FILTER_STATIC_STRING
)
915 /* ensure NULL-termination */
916 if (size
> key_field
->size
- 1)
917 size
= key_field
->size
- 1;
920 memcpy(compound_key
+ key_field
->offset
, key
, size
);
923 static void event_hist_trigger(struct event_trigger_data
*data
, void *rec
)
925 struct hist_trigger_data
*hist_data
= data
->private_data
;
926 bool use_compound_key
= (hist_data
->n_keys
> 1);
927 unsigned long entries
[HIST_STACKTRACE_DEPTH
];
928 char compound_key
[HIST_KEY_SIZE_MAX
];
929 struct stack_trace stacktrace
;
930 struct hist_field
*key_field
;
931 struct tracing_map_elt
*elt
;
936 memset(compound_key
, 0, hist_data
->key_size
);
938 for_each_hist_key_field(i
, hist_data
) {
939 key_field
= hist_data
->fields
[i
];
941 if (key_field
->flags
& HIST_FIELD_FL_STACKTRACE
) {
942 stacktrace
.max_entries
= HIST_STACKTRACE_DEPTH
;
943 stacktrace
.entries
= entries
;
944 stacktrace
.nr_entries
= 0;
945 stacktrace
.skip
= HIST_STACKTRACE_SKIP
;
947 memset(stacktrace
.entries
, 0, HIST_STACKTRACE_SIZE
);
948 save_stack_trace(&stacktrace
);
952 field_contents
= key_field
->fn(key_field
, rec
);
953 if (key_field
->flags
& HIST_FIELD_FL_STRING
) {
954 key
= (void *)(unsigned long)field_contents
;
955 use_compound_key
= true;
957 key
= (void *)&field_contents
;
960 if (use_compound_key
)
961 add_to_key(compound_key
, key
, key_field
, rec
);
964 if (use_compound_key
)
967 elt
= tracing_map_insert(hist_data
->map
, key
);
969 hist_trigger_elt_update(hist_data
, elt
, rec
);
972 static void hist_trigger_stacktrace_print(struct seq_file
*m
,
973 unsigned long *stacktrace_entries
,
974 unsigned int max_entries
)
976 char str
[KSYM_SYMBOL_LEN
];
977 unsigned int spaces
= 8;
980 for (i
= 0; i
< max_entries
; i
++) {
981 if (stacktrace_entries
[i
] == ULONG_MAX
)
984 seq_printf(m
, "%*c", 1 + spaces
, ' ');
985 sprint_symbol(str
, stacktrace_entries
[i
]);
986 seq_printf(m
, "%s\n", str
);
991 hist_trigger_entry_print(struct seq_file
*m
,
992 struct hist_trigger_data
*hist_data
, void *key
,
993 struct tracing_map_elt
*elt
)
995 struct hist_field
*key_field
;
996 char str
[KSYM_SYMBOL_LEN
];
997 bool multiline
= false;
998 const char *field_name
;
1004 for_each_hist_key_field(i
, hist_data
) {
1005 key_field
= hist_data
->fields
[i
];
1007 if (i
> hist_data
->n_vals
)
1010 field_name
= hist_field_name(key_field
, 0);
1012 if (key_field
->flags
& HIST_FIELD_FL_HEX
) {
1013 uval
= *(u64
*)(key
+ key_field
->offset
);
1014 seq_printf(m
, "%s: %llx", field_name
, uval
);
1015 } else if (key_field
->flags
& HIST_FIELD_FL_SYM
) {
1016 uval
= *(u64
*)(key
+ key_field
->offset
);
1017 sprint_symbol_no_offset(str
, uval
);
1018 seq_printf(m
, "%s: [%llx] %-45s", field_name
,
1020 } else if (key_field
->flags
& HIST_FIELD_FL_SYM_OFFSET
) {
1021 uval
= *(u64
*)(key
+ key_field
->offset
);
1022 sprint_symbol(str
, uval
);
1023 seq_printf(m
, "%s: [%llx] %-55s", field_name
,
1025 } else if (key_field
->flags
& HIST_FIELD_FL_EXECNAME
) {
1026 char *comm
= elt
->private_data
;
1028 uval
= *(u64
*)(key
+ key_field
->offset
);
1029 seq_printf(m
, "%s: %-16s[%10llu]", field_name
,
1031 } else if (key_field
->flags
& HIST_FIELD_FL_SYSCALL
) {
1032 const char *syscall_name
;
1034 uval
= *(u64
*)(key
+ key_field
->offset
);
1035 syscall_name
= get_syscall_name(uval
);
1037 syscall_name
= "unknown_syscall";
1039 seq_printf(m
, "%s: %-30s[%3llu]", field_name
,
1040 syscall_name
, uval
);
1041 } else if (key_field
->flags
& HIST_FIELD_FL_STACKTRACE
) {
1042 seq_puts(m
, "stacktrace:\n");
1043 hist_trigger_stacktrace_print(m
,
1044 key
+ key_field
->offset
,
1045 HIST_STACKTRACE_DEPTH
);
1047 } else if (key_field
->flags
& HIST_FIELD_FL_LOG2
) {
1048 seq_printf(m
, "%s: ~ 2^%-2llu", field_name
,
1049 *(u64
*)(key
+ key_field
->offset
));
1050 } else if (key_field
->flags
& HIST_FIELD_FL_STRING
) {
1051 seq_printf(m
, "%s: %-50s", field_name
,
1052 (char *)(key
+ key_field
->offset
));
1054 uval
= *(u64
*)(key
+ key_field
->offset
);
1055 seq_printf(m
, "%s: %10llu", field_name
, uval
);
1064 seq_printf(m
, " hitcount: %10llu",
1065 tracing_map_read_sum(elt
, HITCOUNT_IDX
));
1067 for (i
= 1; i
< hist_data
->n_vals
; i
++) {
1068 field_name
= hist_field_name(hist_data
->fields
[i
], 0);
1070 if (hist_data
->fields
[i
]->flags
& HIST_FIELD_FL_HEX
) {
1071 seq_printf(m
, " %s: %10llx", field_name
,
1072 tracing_map_read_sum(elt
, i
));
1074 seq_printf(m
, " %s: %10llu", field_name
,
1075 tracing_map_read_sum(elt
, i
));
1082 static int print_entries(struct seq_file
*m
,
1083 struct hist_trigger_data
*hist_data
)
1085 struct tracing_map_sort_entry
**sort_entries
= NULL
;
1086 struct tracing_map
*map
= hist_data
->map
;
1089 n_entries
= tracing_map_sort_entries(map
, hist_data
->sort_keys
,
1090 hist_data
->n_sort_keys
,
1095 for (i
= 0; i
< n_entries
; i
++)
1096 hist_trigger_entry_print(m
, hist_data
,
1097 sort_entries
[i
]->key
,
1098 sort_entries
[i
]->elt
);
1100 tracing_map_destroy_sort_entries(sort_entries
, n_entries
);
1105 static void hist_trigger_show(struct seq_file
*m
,
1106 struct event_trigger_data
*data
, int n
)
1108 struct hist_trigger_data
*hist_data
;
1112 seq_puts(m
, "\n\n");
1114 seq_puts(m
, "# event histogram\n#\n# trigger info: ");
1115 data
->ops
->print(m
, data
->ops
, data
);
1116 seq_puts(m
, "#\n\n");
1118 hist_data
= data
->private_data
;
1119 n_entries
= print_entries(m
, hist_data
);
1123 seq_printf(m
, "\nTotals:\n Hits: %llu\n Entries: %u\n Dropped: %llu\n",
1124 (u64
)atomic64_read(&hist_data
->map
->hits
),
1125 n_entries
, (u64
)atomic64_read(&hist_data
->map
->drops
));
1128 static int hist_show(struct seq_file
*m
, void *v
)
1130 struct event_trigger_data
*data
;
1131 struct trace_event_file
*event_file
;
1134 mutex_lock(&event_mutex
);
1136 event_file
= event_file_data(m
->private);
1137 if (unlikely(!event_file
)) {
1142 list_for_each_entry_rcu(data
, &event_file
->triggers
, list
) {
1143 if (data
->cmd_ops
->trigger_type
== ETT_EVENT_HIST
)
1144 hist_trigger_show(m
, data
, n
++);
1148 mutex_unlock(&event_mutex
);
1153 static int event_hist_open(struct inode
*inode
, struct file
*file
)
1155 return single_open(file
, hist_show
, file
);
1158 const struct file_operations event_hist_fops
= {
1159 .open
= event_hist_open
,
1161 .llseek
= seq_lseek
,
1162 .release
= single_release
,
1165 static const char *get_hist_field_flags(struct hist_field
*hist_field
)
1167 const char *flags_str
= NULL
;
1169 if (hist_field
->flags
& HIST_FIELD_FL_HEX
)
1171 else if (hist_field
->flags
& HIST_FIELD_FL_SYM
)
1173 else if (hist_field
->flags
& HIST_FIELD_FL_SYM_OFFSET
)
1174 flags_str
= "sym-offset";
1175 else if (hist_field
->flags
& HIST_FIELD_FL_EXECNAME
)
1176 flags_str
= "execname";
1177 else if (hist_field
->flags
& HIST_FIELD_FL_SYSCALL
)
1178 flags_str
= "syscall";
1179 else if (hist_field
->flags
& HIST_FIELD_FL_LOG2
)
1185 static void hist_field_print(struct seq_file
*m
, struct hist_field
*hist_field
)
1187 const char *field_name
= hist_field_name(hist_field
, 0);
1189 seq_printf(m
, "%s", field_name
);
1190 if (hist_field
->flags
) {
1191 const char *flags_str
= get_hist_field_flags(hist_field
);
1194 seq_printf(m
, ".%s", flags_str
);
1198 static int event_hist_trigger_print(struct seq_file
*m
,
1199 struct event_trigger_ops
*ops
,
1200 struct event_trigger_data
*data
)
1202 struct hist_trigger_data
*hist_data
= data
->private_data
;
1203 struct hist_field
*key_field
;
1206 seq_puts(m
, "hist:");
1209 seq_printf(m
, "%s:", data
->name
);
1211 seq_puts(m
, "keys=");
1213 for_each_hist_key_field(i
, hist_data
) {
1214 key_field
= hist_data
->fields
[i
];
1216 if (i
> hist_data
->n_vals
)
1219 if (key_field
->flags
& HIST_FIELD_FL_STACKTRACE
)
1220 seq_puts(m
, "stacktrace");
1222 hist_field_print(m
, key_field
);
1225 seq_puts(m
, ":vals=");
1227 for_each_hist_val_field(i
, hist_data
) {
1228 if (i
== HITCOUNT_IDX
)
1229 seq_puts(m
, "hitcount");
1232 hist_field_print(m
, hist_data
->fields
[i
]);
1236 seq_puts(m
, ":sort=");
1238 for (i
= 0; i
< hist_data
->n_sort_keys
; i
++) {
1239 struct tracing_map_sort_key
*sort_key
;
1241 sort_key
= &hist_data
->sort_keys
[i
];
1246 if (sort_key
->field_idx
== HITCOUNT_IDX
)
1247 seq_puts(m
, "hitcount");
1249 unsigned int idx
= sort_key
->field_idx
;
1251 if (WARN_ON(idx
>= TRACING_MAP_FIELDS_MAX
))
1254 hist_field_print(m
, hist_data
->fields
[idx
]);
1257 if (sort_key
->descending
)
1258 seq_puts(m
, ".descending");
1261 seq_printf(m
, ":size=%u", (1 << hist_data
->map
->map_bits
));
1263 if (data
->filter_str
)
1264 seq_printf(m
, " if %s", data
->filter_str
);
1267 seq_puts(m
, " [paused]");
1269 seq_puts(m
, " [active]");
1276 static int event_hist_trigger_init(struct event_trigger_ops
*ops
,
1277 struct event_trigger_data
*data
)
1279 struct hist_trigger_data
*hist_data
= data
->private_data
;
1281 if (!data
->ref
&& hist_data
->attrs
->name
)
1282 save_named_trigger(hist_data
->attrs
->name
, data
);
1289 static void event_hist_trigger_free(struct event_trigger_ops
*ops
,
1290 struct event_trigger_data
*data
)
1292 struct hist_trigger_data
*hist_data
= data
->private_data
;
1294 if (WARN_ON_ONCE(data
->ref
<= 0))
1300 del_named_trigger(data
);
1301 trigger_data_free(data
);
1302 destroy_hist_data(hist_data
);
1306 static struct event_trigger_ops event_hist_trigger_ops
= {
1307 .func
= event_hist_trigger
,
1308 .print
= event_hist_trigger_print
,
1309 .init
= event_hist_trigger_init
,
1310 .free
= event_hist_trigger_free
,
1313 static int event_hist_trigger_named_init(struct event_trigger_ops
*ops
,
1314 struct event_trigger_data
*data
)
1318 save_named_trigger(data
->named_data
->name
, data
);
1320 event_hist_trigger_init(ops
, data
->named_data
);
1325 static void event_hist_trigger_named_free(struct event_trigger_ops
*ops
,
1326 struct event_trigger_data
*data
)
1328 if (WARN_ON_ONCE(data
->ref
<= 0))
1331 event_hist_trigger_free(ops
, data
->named_data
);
1335 del_named_trigger(data
);
1336 trigger_data_free(data
);
1340 static struct event_trigger_ops event_hist_trigger_named_ops
= {
1341 .func
= event_hist_trigger
,
1342 .print
= event_hist_trigger_print
,
1343 .init
= event_hist_trigger_named_init
,
1344 .free
= event_hist_trigger_named_free
,
1347 static struct event_trigger_ops
*event_hist_get_trigger_ops(char *cmd
,
1350 return &event_hist_trigger_ops
;
1353 static void hist_clear(struct event_trigger_data
*data
)
1355 struct hist_trigger_data
*hist_data
= data
->private_data
;
1358 pause_named_trigger(data
);
1360 synchronize_sched();
1362 tracing_map_clear(hist_data
->map
);
1365 unpause_named_trigger(data
);
1368 static bool compatible_field(struct ftrace_event_field
*field
,
1369 struct ftrace_event_field
*test_field
)
1371 if (field
== test_field
)
1373 if (field
== NULL
|| test_field
== NULL
)
1375 if (strcmp(field
->name
, test_field
->name
) != 0)
1377 if (strcmp(field
->type
, test_field
->type
) != 0)
1379 if (field
->size
!= test_field
->size
)
1381 if (field
->is_signed
!= test_field
->is_signed
)
1387 static bool hist_trigger_match(struct event_trigger_data
*data
,
1388 struct event_trigger_data
*data_test
,
1389 struct event_trigger_data
*named_data
,
1392 struct tracing_map_sort_key
*sort_key
, *sort_key_test
;
1393 struct hist_trigger_data
*hist_data
, *hist_data_test
;
1394 struct hist_field
*key_field
, *key_field_test
;
1397 if (named_data
&& (named_data
!= data_test
) &&
1398 (named_data
!= data_test
->named_data
))
1401 if (!named_data
&& is_named_trigger(data_test
))
1404 hist_data
= data
->private_data
;
1405 hist_data_test
= data_test
->private_data
;
1407 if (hist_data
->n_vals
!= hist_data_test
->n_vals
||
1408 hist_data
->n_fields
!= hist_data_test
->n_fields
||
1409 hist_data
->n_sort_keys
!= hist_data_test
->n_sort_keys
)
1412 if (!ignore_filter
) {
1413 if ((data
->filter_str
&& !data_test
->filter_str
) ||
1414 (!data
->filter_str
&& data_test
->filter_str
))
1418 for_each_hist_field(i
, hist_data
) {
1419 key_field
= hist_data
->fields
[i
];
1420 key_field_test
= hist_data_test
->fields
[i
];
1422 if (key_field
->flags
!= key_field_test
->flags
)
1424 if (!compatible_field(key_field
->field
, key_field_test
->field
))
1426 if (key_field
->offset
!= key_field_test
->offset
)
1430 for (i
= 0; i
< hist_data
->n_sort_keys
; i
++) {
1431 sort_key
= &hist_data
->sort_keys
[i
];
1432 sort_key_test
= &hist_data_test
->sort_keys
[i
];
1434 if (sort_key
->field_idx
!= sort_key_test
->field_idx
||
1435 sort_key
->descending
!= sort_key_test
->descending
)
1439 if (!ignore_filter
&& data
->filter_str
&&
1440 (strcmp(data
->filter_str
, data_test
->filter_str
) != 0))
1446 static int hist_register_trigger(char *glob
, struct event_trigger_ops
*ops
,
1447 struct event_trigger_data
*data
,
1448 struct trace_event_file
*file
)
1450 struct hist_trigger_data
*hist_data
= data
->private_data
;
1451 struct event_trigger_data
*test
, *named_data
= NULL
;
1454 if (hist_data
->attrs
->name
) {
1455 named_data
= find_named_trigger(hist_data
->attrs
->name
);
1457 if (!hist_trigger_match(data
, named_data
, named_data
,
1465 if (hist_data
->attrs
->name
&& !named_data
)
1468 list_for_each_entry_rcu(test
, &file
->triggers
, list
) {
1469 if (test
->cmd_ops
->trigger_type
== ETT_EVENT_HIST
) {
1470 if (!hist_trigger_match(data
, test
, named_data
, false))
1472 if (hist_data
->attrs
->pause
)
1473 test
->paused
= true;
1474 else if (hist_data
->attrs
->cont
)
1475 test
->paused
= false;
1476 else if (hist_data
->attrs
->clear
)
1484 if (hist_data
->attrs
->cont
|| hist_data
->attrs
->clear
) {
1489 if (hist_data
->attrs
->pause
)
1490 data
->paused
= true;
1493 destroy_hist_data(data
->private_data
);
1494 data
->private_data
= named_data
->private_data
;
1495 set_named_trigger_data(data
, named_data
);
1496 data
->ops
= &event_hist_trigger_named_ops
;
1499 if (data
->ops
->init
) {
1500 ret
= data
->ops
->init(data
->ops
, data
);
1505 list_add_rcu(&data
->list
, &file
->triggers
);
1508 update_cond_flag(file
);
1510 if (trace_event_trigger_enable_disable(file
, 1) < 0) {
1511 list_del_rcu(&data
->list
);
1512 update_cond_flag(file
);
1519 static void hist_unregister_trigger(char *glob
, struct event_trigger_ops
*ops
,
1520 struct event_trigger_data
*data
,
1521 struct trace_event_file
*file
)
1523 struct hist_trigger_data
*hist_data
= data
->private_data
;
1524 struct event_trigger_data
*test
, *named_data
= NULL
;
1525 bool unregistered
= false;
1527 if (hist_data
->attrs
->name
)
1528 named_data
= find_named_trigger(hist_data
->attrs
->name
);
1530 list_for_each_entry_rcu(test
, &file
->triggers
, list
) {
1531 if (test
->cmd_ops
->trigger_type
== ETT_EVENT_HIST
) {
1532 if (!hist_trigger_match(data
, test
, named_data
, false))
1534 unregistered
= true;
1535 list_del_rcu(&test
->list
);
1536 trace_event_trigger_enable_disable(file
, 0);
1537 update_cond_flag(file
);
1542 if (unregistered
&& test
->ops
->free
)
1543 test
->ops
->free(test
->ops
, test
);
1546 static void hist_unreg_all(struct trace_event_file
*file
)
1548 struct event_trigger_data
*test
, *n
;
1550 list_for_each_entry_safe(test
, n
, &file
->triggers
, list
) {
1551 if (test
->cmd_ops
->trigger_type
== ETT_EVENT_HIST
) {
1552 list_del_rcu(&test
->list
);
1553 trace_event_trigger_enable_disable(file
, 0);
1554 update_cond_flag(file
);
1555 if (test
->ops
->free
)
1556 test
->ops
->free(test
->ops
, test
);
1561 static int event_hist_trigger_func(struct event_command
*cmd_ops
,
1562 struct trace_event_file
*file
,
1563 char *glob
, char *cmd
, char *param
)
1565 unsigned int hist_trigger_bits
= TRACING_MAP_BITS_DEFAULT
;
1566 struct event_trigger_data
*trigger_data
;
1567 struct hist_trigger_attrs
*attrs
;
1568 struct event_trigger_ops
*trigger_ops
;
1569 struct hist_trigger_data
*hist_data
;
1576 /* separate the trigger from the filter (k:v [if filter]) */
1577 trigger
= strsep(¶m
, " \t");
1581 attrs
= parse_hist_trigger_attrs(trigger
);
1583 return PTR_ERR(attrs
);
1585 if (attrs
->map_bits
)
1586 hist_trigger_bits
= attrs
->map_bits
;
1588 hist_data
= create_hist_data(hist_trigger_bits
, attrs
, file
);
1589 if (IS_ERR(hist_data
)) {
1590 destroy_hist_trigger_attrs(attrs
);
1591 return PTR_ERR(hist_data
);
1594 trigger_ops
= cmd_ops
->get_trigger_ops(cmd
, trigger
);
1597 trigger_data
= kzalloc(sizeof(*trigger_data
), GFP_KERNEL
);
1601 trigger_data
->count
= -1;
1602 trigger_data
->ops
= trigger_ops
;
1603 trigger_data
->cmd_ops
= cmd_ops
;
1605 INIT_LIST_HEAD(&trigger_data
->list
);
1606 RCU_INIT_POINTER(trigger_data
->filter
, NULL
);
1608 trigger_data
->private_data
= hist_data
;
1610 /* if param is non-empty, it's supposed to be a filter */
1611 if (param
&& cmd_ops
->set_filter
) {
1612 ret
= cmd_ops
->set_filter(param
, trigger_data
, file
);
1617 if (glob
[0] == '!') {
1618 cmd_ops
->unreg(glob
+1, trigger_ops
, trigger_data
, file
);
1623 ret
= cmd_ops
->reg(glob
, trigger_ops
, trigger_data
, file
);
1625 * The above returns on success the # of triggers registered,
1626 * but if it didn't register any it returns zero. Consider no
1627 * triggers registered a failure too.
1630 if (!(attrs
->pause
|| attrs
->cont
|| attrs
->clear
))
1635 /* Just return zero, not the number of registered triggers */
1640 if (cmd_ops
->set_filter
)
1641 cmd_ops
->set_filter(NULL
, trigger_data
, NULL
);
1643 kfree(trigger_data
);
1645 destroy_hist_data(hist_data
);
1649 static struct event_command trigger_hist_cmd
= {
1651 .trigger_type
= ETT_EVENT_HIST
,
1652 .flags
= EVENT_CMD_FL_NEEDS_REC
,
1653 .func
= event_hist_trigger_func
,
1654 .reg
= hist_register_trigger
,
1655 .unreg
= hist_unregister_trigger
,
1656 .unreg_all
= hist_unreg_all
,
1657 .get_trigger_ops
= event_hist_get_trigger_ops
,
1658 .set_filter
= set_trigger_filter
,
1661 __init
int register_trigger_hist_cmd(void)
1665 ret
= register_event_command(&trigger_hist_cmd
);
1672 hist_enable_trigger(struct event_trigger_data
*data
, void *rec
)
1674 struct enable_trigger_data
*enable_data
= data
->private_data
;
1675 struct event_trigger_data
*test
;
1677 list_for_each_entry_rcu(test
, &enable_data
->file
->triggers
, list
) {
1678 if (test
->cmd_ops
->trigger_type
== ETT_EVENT_HIST
) {
1679 if (enable_data
->enable
)
1680 test
->paused
= false;
1682 test
->paused
= true;
1688 hist_enable_count_trigger(struct event_trigger_data
*data
, void *rec
)
1693 if (data
->count
!= -1)
1696 hist_enable_trigger(data
, rec
);
1699 static struct event_trigger_ops hist_enable_trigger_ops
= {
1700 .func
= hist_enable_trigger
,
1701 .print
= event_enable_trigger_print
,
1702 .init
= event_trigger_init
,
1703 .free
= event_enable_trigger_free
,
1706 static struct event_trigger_ops hist_enable_count_trigger_ops
= {
1707 .func
= hist_enable_count_trigger
,
1708 .print
= event_enable_trigger_print
,
1709 .init
= event_trigger_init
,
1710 .free
= event_enable_trigger_free
,
1713 static struct event_trigger_ops hist_disable_trigger_ops
= {
1714 .func
= hist_enable_trigger
,
1715 .print
= event_enable_trigger_print
,
1716 .init
= event_trigger_init
,
1717 .free
= event_enable_trigger_free
,
1720 static struct event_trigger_ops hist_disable_count_trigger_ops
= {
1721 .func
= hist_enable_count_trigger
,
1722 .print
= event_enable_trigger_print
,
1723 .init
= event_trigger_init
,
1724 .free
= event_enable_trigger_free
,
1727 static struct event_trigger_ops
*
1728 hist_enable_get_trigger_ops(char *cmd
, char *param
)
1730 struct event_trigger_ops
*ops
;
1733 enable
= (strcmp(cmd
, ENABLE_HIST_STR
) == 0);
1736 ops
= param
? &hist_enable_count_trigger_ops
:
1737 &hist_enable_trigger_ops
;
1739 ops
= param
? &hist_disable_count_trigger_ops
:
1740 &hist_disable_trigger_ops
;
1745 static void hist_enable_unreg_all(struct trace_event_file
*file
)
1747 struct event_trigger_data
*test
, *n
;
1749 list_for_each_entry_safe(test
, n
, &file
->triggers
, list
) {
1750 if (test
->cmd_ops
->trigger_type
== ETT_HIST_ENABLE
) {
1751 list_del_rcu(&test
->list
);
1752 update_cond_flag(file
);
1753 trace_event_trigger_enable_disable(file
, 0);
1754 if (test
->ops
->free
)
1755 test
->ops
->free(test
->ops
, test
);
1760 static struct event_command trigger_hist_enable_cmd
= {
1761 .name
= ENABLE_HIST_STR
,
1762 .trigger_type
= ETT_HIST_ENABLE
,
1763 .func
= event_enable_trigger_func
,
1764 .reg
= event_enable_register_trigger
,
1765 .unreg
= event_enable_unregister_trigger
,
1766 .unreg_all
= hist_enable_unreg_all
,
1767 .get_trigger_ops
= hist_enable_get_trigger_ops
,
1768 .set_filter
= set_trigger_filter
,
1771 static struct event_command trigger_hist_disable_cmd
= {
1772 .name
= DISABLE_HIST_STR
,
1773 .trigger_type
= ETT_HIST_ENABLE
,
1774 .func
= event_enable_trigger_func
,
1775 .reg
= event_enable_register_trigger
,
1776 .unreg
= event_enable_unregister_trigger
,
1777 .unreg_all
= hist_enable_unreg_all
,
1778 .get_trigger_ops
= hist_enable_get_trigger_ops
,
1779 .set_filter
= set_trigger_filter
,
1782 static __init
void unregister_trigger_hist_enable_disable_cmds(void)
1784 unregister_event_command(&trigger_hist_enable_cmd
);
1785 unregister_event_command(&trigger_hist_disable_cmd
);
1788 __init
int register_trigger_hist_enable_disable_cmds(void)
1792 ret
= register_event_command(&trigger_hist_enable_cmd
);
1793 if (WARN_ON(ret
< 0))
1795 ret
= register_event_command(&trigger_hist_disable_cmd
);
1796 if (WARN_ON(ret
< 0))
1797 unregister_trigger_hist_enable_disable_cmds();