@@ -54,6 +54,7 @@ struct hist_field {
5454 unsigned int size ;
5555 unsigned int offset ;
5656 unsigned int is_signed ;
57+ const char * type ;
5758 struct hist_field * operands [HIST_FIELD_OPERANDS_MAX ];
5859 struct hist_trigger_data * hist_data ;
5960 struct hist_var var ;
@@ -717,6 +718,7 @@ static void destroy_hist_field(struct hist_field *hist_field,
717718
718719 kfree (hist_field -> var .name );
719720 kfree (hist_field -> name );
721+ kfree (hist_field -> type );
720722
721723 kfree (hist_field );
722724}
@@ -742,6 +744,10 @@ static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data,
742744
743745 if (flags & HIST_FIELD_FL_HITCOUNT ) {
744746 hist_field -> fn = hist_field_counter ;
747+ hist_field -> size = sizeof (u64 );
748+ hist_field -> type = kstrdup ("u64" , GFP_KERNEL );
749+ if (!hist_field -> type )
750+ goto free ;
745751 goto out ;
746752 }
747753
@@ -755,12 +761,18 @@ static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data,
755761 hist_field -> fn = hist_field_log2 ;
756762 hist_field -> operands [0 ] = create_hist_field (hist_data , field , fl , NULL );
757763 hist_field -> size = hist_field -> operands [0 ]-> size ;
764+ hist_field -> type = kstrdup (hist_field -> operands [0 ]-> type , GFP_KERNEL );
765+ if (!hist_field -> type )
766+ goto free ;
758767 goto out ;
759768 }
760769
761770 if (flags & HIST_FIELD_FL_TIMESTAMP ) {
762771 hist_field -> fn = hist_field_timestamp ;
763772 hist_field -> size = sizeof (u64 );
773+ hist_field -> type = kstrdup ("u64" , GFP_KERNEL );
774+ if (!hist_field -> type )
775+ goto free ;
764776 goto out ;
765777 }
766778
@@ -770,13 +782,24 @@ static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data,
770782 if (is_string_field (field )) {
771783 flags |= HIST_FIELD_FL_STRING ;
772784
785+ hist_field -> size = MAX_FILTER_STR_VAL ;
786+ hist_field -> type = kstrdup (field -> type , GFP_KERNEL );
787+ if (!hist_field -> type )
788+ goto free ;
789+
773790 if (field -> filter_type == FILTER_STATIC_STRING )
774791 hist_field -> fn = hist_field_string ;
775792 else if (field -> filter_type == FILTER_DYN_STRING )
776793 hist_field -> fn = hist_field_dynstring ;
777794 else
778795 hist_field -> fn = hist_field_pstring ;
779796 } else {
797+ hist_field -> size = field -> size ;
798+ hist_field -> is_signed = field -> is_signed ;
799+ hist_field -> type = kstrdup (field -> type , GFP_KERNEL );
800+ if (!hist_field -> type )
801+ goto free ;
802+
780803 hist_field -> fn = select_value_fn (field -> size ,
781804 field -> is_signed );
782805 if (!hist_field -> fn ) {
@@ -949,6 +972,11 @@ static struct hist_field *parse_unary(struct hist_trigger_data *hist_data,
949972 expr -> operands [0 ] = operand1 ;
950973 expr -> operator = FIELD_OP_UNARY_MINUS ;
951974 expr -> name = expr_str (expr , 0 );
975+ expr -> type = kstrdup (operand1 -> type , GFP_KERNEL );
976+ if (!expr -> type ) {
977+ ret = - ENOMEM ;
978+ goto free ;
979+ }
952980
953981 return expr ;
954982 free :
@@ -1042,6 +1070,11 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data,
10421070 expr -> operands [1 ] = operand2 ;
10431071 expr -> operator = field_op ;
10441072 expr -> name = expr_str (expr , 0 );
1073+ expr -> type = kstrdup (operand1 -> type , GFP_KERNEL );
1074+ if (!expr -> type ) {
1075+ ret = - ENOMEM ;
1076+ goto free ;
1077+ }
10451078
10461079 switch (field_op ) {
10471080 case FIELD_OP_MINUS :
0 commit comments