@@ -80,6 +80,7 @@ enum hist_field_flags {
8080 HIST_FIELD_FL_HITCOUNT = 1 ,
8181 HIST_FIELD_FL_KEY = 2 ,
8282 HIST_FIELD_FL_STRING = 4 ,
83+ HIST_FIELD_FL_HEX = 8 ,
8384};
8485
8586struct hist_trigger_attrs {
@@ -303,11 +304,23 @@ static int create_val_field(struct hist_trigger_data *hist_data,
303304{
304305 struct ftrace_event_field * field = NULL ;
305306 unsigned long flags = 0 ;
307+ char * field_name ;
306308 int ret = 0 ;
307309
308310 if (WARN_ON (val_idx >= TRACING_MAP_VALS_MAX ))
309311 return - EINVAL ;
310- field = trace_find_event_field (file -> event_call , field_str );
312+
313+ field_name = strsep (& field_str , "." );
314+ if (field_str ) {
315+ if (strcmp (field_str , "hex" ) == 0 )
316+ flags |= HIST_FIELD_FL_HEX ;
317+ else {
318+ ret = - EINVAL ;
319+ goto out ;
320+ }
321+ }
322+
323+ field = trace_find_event_field (file -> event_call , field_name );
311324 if (!field ) {
312325 ret = - EINVAL ;
313326 goto out ;
@@ -372,14 +385,25 @@ static int create_key_field(struct hist_trigger_data *hist_data,
372385 struct ftrace_event_field * field = NULL ;
373386 unsigned long flags = 0 ;
374387 unsigned int key_size ;
388+ char * field_name ;
375389 int ret = 0 ;
376390
377391 if (WARN_ON (key_idx >= TRACING_MAP_FIELDS_MAX ))
378392 return - EINVAL ;
379393
380394 flags |= HIST_FIELD_FL_KEY ;
381395
382- field = trace_find_event_field (file -> event_call , field_str );
396+ field_name = strsep (& field_str , "." );
397+ if (field_str ) {
398+ if (strcmp (field_str , "hex" ) == 0 )
399+ flags |= HIST_FIELD_FL_HEX ;
400+ else {
401+ ret = - EINVAL ;
402+ goto out ;
403+ }
404+ }
405+
406+ field = trace_find_event_field (file -> event_call , field_name );
383407 if (!field ) {
384408 ret = - EINVAL ;
385409 goto out ;
@@ -713,7 +737,11 @@ hist_trigger_entry_print(struct seq_file *m,
713737 if (i > hist_data -> n_vals )
714738 seq_puts (m , ", " );
715739
716- if (key_field -> flags & HIST_FIELD_FL_STRING ) {
740+ if (key_field -> flags & HIST_FIELD_FL_HEX ) {
741+ uval = * (u64 * )(key + key_field -> offset );
742+ seq_printf (m , "%s: %llx" ,
743+ key_field -> field -> name , uval );
744+ } else if (key_field -> flags & HIST_FIELD_FL_STRING ) {
717745 seq_printf (m , "%s: %-50s" , key_field -> field -> name ,
718746 (char * )(key + key_field -> offset ));
719747 } else {
@@ -729,9 +757,15 @@ hist_trigger_entry_print(struct seq_file *m,
729757 tracing_map_read_sum (elt , HITCOUNT_IDX ));
730758
731759 for (i = 1 ; i < hist_data -> n_vals ; i ++ ) {
732- seq_printf (m , " %s: %10llu" ,
733- hist_data -> fields [i ]-> field -> name ,
734- tracing_map_read_sum (elt , i ));
760+ if (hist_data -> fields [i ]-> flags & HIST_FIELD_FL_HEX ) {
761+ seq_printf (m , " %s: %10llx" ,
762+ hist_data -> fields [i ]-> field -> name ,
763+ tracing_map_read_sum (elt , i ));
764+ } else {
765+ seq_printf (m , " %s: %10llu" ,
766+ hist_data -> fields [i ]-> field -> name ,
767+ tracing_map_read_sum (elt , i ));
768+ }
735769 }
736770
737771 seq_puts (m , "\n" );
@@ -816,9 +850,25 @@ const struct file_operations event_hist_fops = {
816850 .release = single_release ,
817851};
818852
853+ static const char * get_hist_field_flags (struct hist_field * hist_field )
854+ {
855+ const char * flags_str = NULL ;
856+
857+ if (hist_field -> flags & HIST_FIELD_FL_HEX )
858+ flags_str = "hex" ;
859+
860+ return flags_str ;
861+ }
862+
819863static void hist_field_print (struct seq_file * m , struct hist_field * hist_field )
820864{
821865 seq_printf (m , "%s" , hist_field -> field -> name );
866+ if (hist_field -> flags ) {
867+ const char * flags_str = get_hist_field_flags (hist_field );
868+
869+ if (flags_str )
870+ seq_printf (m , ".%s" , flags_str );
871+ }
822872}
823873
824874static int event_hist_trigger_print (struct seq_file * m ,
0 commit comments