diff mbox series

[1/2] libtraceevent: Add boiler-plate code for cpumask types

Message ID 20221018151630.1513535-2-vschneid@redhat.com (mailing list archive)
State Superseded
Headers show
Series libtraceevent: Handling cpumask event fields | expand

Commit Message

Valentin Schneider Oct. 18, 2022, 3:16 p.m. UTC
A cpumask event field type was recently added to Linux, which helps
distinguish any odd bitmask from a cpumask. Right now this field type is
not recognized by libtraceevent:

  [ipi:ipi_send_cpumask] function __get_cpumask not defined
  CPU 0 is empty
  CPU 1 is empty
  CPU 3 is empty
  cpus=4
	    echo-173   [002]    11.859745: ipi_send_cpumask:     [FAILED TO PARSE] cpumask=ARRAY[02,
00, 00, 00, 00, 00, 00, 00] callsite=0xffffffff81121013

Since a cpumask is still a bitmask, define the boiler plate code for this
new field type and wire it all to bitmask handling.

Signed-off-by: Valentin Schneider <vschneid@redhat.com>
---
 include/traceevent/event-parse.h |  1 +
 src/event-parse.c                | 24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+)

Comments

Steven Rostedt Nov. 10, 2022, 12:06 a.m. UTC | #1
On Tue, 18 Oct 2022 16:16:29 +0100
Valentin Schneider <vschneid@redhat.com> wrote:

> @@ -3484,6 +3498,11 @@ process_function(struct tep_event *event, struct tep_print_arg *arg,
>  		free_token(token);
>  		return process_bitmask(event, arg, tok);
>  	}
> +	if (strcmp(token, "__get_cpumask") == 0 ||
> +	    strcmp(token, "__get_cpumask") == 0) {

Hmm, not sure what the difference between the above two are.

-- Steve

> +		free_token(token);
> +		return process_cpumask(event, arg, tok);
> +	}
>  	if (strcmp(token, "__get_dynamic_array") == 0 ||
>  	    strcmp(token, "__get_rel_dynamic_array") == 0 ||
>  	    strcmp(token, "__get_sockaddr") == 0 ||
Valentin Schneider Nov. 11, 2022, 4:32 p.m. UTC | #2
On 09/11/22 19:06, Steven Rostedt wrote:
> On Tue, 18 Oct 2022 16:16:29 +0100
> Valentin Schneider <vschneid@redhat.com> wrote:
>
>> @@ -3484,6 +3498,11 @@ process_function(struct tep_event *event, struct tep_print_arg *arg,
>>              free_token(token);
>>              return process_bitmask(event, arg, tok);
>>      }
>> +	if (strcmp(token, "__get_cpumask") == 0 ||
>> +	    strcmp(token, "__get_cpumask") == 0) {
>
> Hmm, not sure what the difference between the above two are.
>

One makes sense, the other doesn't :-)

That's a copy/paste fail, the second one wants to be "__get_rel_cpumask"

> -- Steve
>
>> +		free_token(token);
>> +		return process_cpumask(event, arg, tok);
>> +	}
>>      if (strcmp(token, "__get_dynamic_array") == 0 ||
>>          strcmp(token, "__get_rel_dynamic_array") == 0 ||
>>          strcmp(token, "__get_sockaddr") == 0 ||
Steven Rostedt Nov. 15, 2022, 9:10 p.m. UTC | #3
On Fri, 11 Nov 2022 16:32:03 +0000
Valentin Schneider <vschneid@redhat.com> wrote:

> On 09/11/22 19:06, Steven Rostedt wrote:
> > On Tue, 18 Oct 2022 16:16:29 +0100
> > Valentin Schneider <vschneid@redhat.com> wrote:
> >  
> >> @@ -3484,6 +3498,11 @@ process_function(struct tep_event *event, struct tep_print_arg *arg,
> >>              free_token(token);
> >>              return process_bitmask(event, arg, tok);
> >>      }
> >> +	if (strcmp(token, "__get_cpumask") == 0 ||
> >> +	    strcmp(token, "__get_cpumask") == 0) {  
> >
> > Hmm, not sure what the difference between the above two are.
> >  
> 
> One makes sense, the other doesn't :-)
> 
> That's a copy/paste fail, the second one wants to be "__get_rel_cpumask"

I was expecting a v2, should I wait?

-- Steve
Valentin Schneider Nov. 16, 2022, 11:29 a.m. UTC | #4
On 15/11/22 16:10, Steven Rostedt wrote:
> On Fri, 11 Nov 2022 16:32:03 +0000
> Valentin Schneider <vschneid@redhat.com> wrote:
>
>> On 09/11/22 19:06, Steven Rostedt wrote:
>> > On Tue, 18 Oct 2022 16:16:29 +0100
>> > Valentin Schneider <vschneid@redhat.com> wrote:
>> >
>> >> @@ -3484,6 +3498,11 @@ process_function(struct tep_event *event, struct tep_print_arg *arg,
>> >>              free_token(token);
>> >>              return process_bitmask(event, arg, tok);
>> >>      }
>> >> +	if (strcmp(token, "__get_cpumask") == 0 ||
>> >> +	    strcmp(token, "__get_cpumask") == 0) {
>> >
>> > Hmm, not sure what the difference between the above two are.
>> >
>>
>> One makes sense, the other doesn't :-)
>>
>> That's a copy/paste fail, the second one wants to be "__get_rel_cpumask"
>
> I was expecting a v2, should I wait?
>

Yeah it's on its way, I got distracted a bit, sorry!

> -- Steve
diff mbox series

Patch

diff --git a/include/traceevent/event-parse.h b/include/traceevent/event-parse.h
index f749cc2..2bb0f3e 100644
--- a/include/traceevent/event-parse.h
+++ b/include/traceevent/event-parse.h
@@ -242,6 +242,7 @@  enum tep_print_arg_type {
 	TEP_PRINT_OP,
 	TEP_PRINT_FUNC,
 	TEP_PRINT_BITMASK,
+	TEP_PRINT_CPUMASK,
 	TEP_PRINT_DYNAMIC_ARRAY_LEN,
 	TEP_PRINT_HEX_STR,
 };
diff --git a/src/event-parse.c b/src/event-parse.c
index 980e980..362720c 100644
--- a/src/event-parse.c
+++ b/src/event-parse.c
@@ -1083,6 +1083,7 @@  static void free_arg(struct tep_print_arg *arg)
 		free(arg->string.string);
 		break;
 	case TEP_PRINT_BITMASK:
+	case TEP_PRINT_CPUMASK:
 		free(arg->bitmask.bitmask);
 		break;
 	case TEP_PRINT_DYNAMIC_ARRAY:
@@ -2816,6 +2817,7 @@  static int arg_num_eval(struct tep_print_arg *arg, long long *val)
 	case TEP_PRINT_STRING:
 	case TEP_PRINT_BSTRING:
 	case TEP_PRINT_BITMASK:
+	case TEP_PRINT_CPUMASK:
 	default:
 		do_warning("invalid eval type %d", arg->type);
 		ret = 0;
@@ -2845,6 +2847,7 @@  static char *arg_eval (struct tep_print_arg *arg)
 	case TEP_PRINT_STRING:
 	case TEP_PRINT_BSTRING:
 	case TEP_PRINT_BITMASK:
+	case TEP_PRINT_CPUMASK:
 	default:
 		do_warning("invalid eval type %d", arg->type);
 		break;
@@ -3325,6 +3328,17 @@  process_bitmask(struct tep_event *event __maybe_unused, struct tep_print_arg *ar
 	return TEP_EVENT_ERROR;
 }
 
+static enum tep_event_type
+process_cpumask(struct tep_event *event __maybe_unused, struct tep_print_arg *arg,
+		char **tok)
+{
+	enum tep_event_type type = process_bitmask(event, arg, tok);
+	if (type != TEP_EVENT_ERROR)
+		arg->type = TEP_PRINT_CPUMASK;
+
+	return type;
+}
+
 static struct tep_function_handler *
 find_func_handler(struct tep_handle *tep, char *func_name)
 {
@@ -3484,6 +3498,11 @@  process_function(struct tep_event *event, struct tep_print_arg *arg,
 		free_token(token);
 		return process_bitmask(event, arg, tok);
 	}
+	if (strcmp(token, "__get_cpumask") == 0 ||
+	    strcmp(token, "__get_cpumask") == 0) {
+		free_token(token);
+		return process_cpumask(event, arg, tok);
+	}
 	if (strcmp(token, "__get_dynamic_array") == 0 ||
 	    strcmp(token, "__get_rel_dynamic_array") == 0 ||
 	    strcmp(token, "__get_sockaddr") == 0 ||
@@ -4144,6 +4163,7 @@  eval_num_arg(void *data, int size, struct tep_event *event, struct tep_print_arg
 	case TEP_PRINT_STRING:
 	case TEP_PRINT_BSTRING:
 	case TEP_PRINT_BITMASK:
+	case TEP_PRINT_CPUMASK:
 		return 0;
 	case TEP_PRINT_FUNC: {
 		struct trace_seq s;
@@ -4637,6 +4657,7 @@  static void print_str_arg(struct trace_seq *s, void *data, int size,
 	case TEP_PRINT_BSTRING:
 		print_str_to_seq(s, format, len_arg, arg->string.string);
 		break;
+	case TEP_PRINT_CPUMASK:
 	case TEP_PRINT_BITMASK: {
 		if (!arg->bitmask.field) {
 			arg->bitmask.field = tep_find_any_field(event, arg->bitmask.bitmask);
@@ -7158,6 +7179,9 @@  static void print_args(struct tep_print_arg *args)
 	case TEP_PRINT_BITMASK:
 		printf("__get_bitmask(%s)", args->bitmask.bitmask);
 		break;
+	case TEP_PRINT_CPUMASK:
+		printf("__get_cpumask(%s)", args->bitmask.bitmask);
+		break;
 	case TEP_PRINT_TYPE:
 		printf("(%s)", args->typecast.type);
 		print_args(args->typecast.item);