Skip to content

Commit 279eef0

Browse files
Tom Zanussirostedt
authored andcommitted
tracing: Make sure synth_event_trace() example always uses u64
synth_event_trace() is the varargs version of synth_event_trace_array(), which takes an array of u64, as do synth_event_add_val() et al. To not only be consistent with those, but also to address the fact that synth_event_trace() expects every arg to be of the same type since it doesn't also pass in e.g. a format string, the caller needs to make sure all args are of the same type, u64. u64 is used because it needs to accomodate the largest type available in synthetic events, which is u64. This fixes the bug reported by the kernel test robot/Rong Chen. Link: https://lore.kernel.org/lkml/20200212113444.GS12867@shao2-debian/ Link: http://lkml.kernel.org/r/894c4e955558b521210ee0642ba194a9e603354c.1581720155.git.zanussi@kernel.org Fixes: 9fe41ef ("tracing: Add synth event generation test module") Reported-by: kernel test robot <[email protected]> Signed-off-by: Tom Zanussi <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 7276531 commit 279eef0

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

kernel/trace/synth_event_gen_test.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ static int __init test_gen_synth_cmd(void)
111111
/* Create some bogus values just for testing */
112112

113113
vals[0] = 777; /* next_pid_field */
114-
vals[1] = (u64)"hula hoops"; /* next_comm_field */
114+
vals[1] = (u64)(long)"hula hoops"; /* next_comm_field */
115115
vals[2] = 1000000; /* ts_ns */
116116
vals[3] = 1000; /* ts_ms */
117117
vals[4] = smp_processor_id(); /* cpu */
118-
vals[5] = (u64)"thneed"; /* my_string_field */
118+
vals[5] = (u64)(long)"thneed"; /* my_string_field */
119119
vals[6] = 598; /* my_int_field */
120120

121121
/* Now generate a gen_synth_test event */
@@ -218,11 +218,11 @@ static int __init test_empty_synth_event(void)
218218
/* Create some bogus values just for testing */
219219

220220
vals[0] = 777; /* next_pid_field */
221-
vals[1] = (u64)"tiddlywinks"; /* next_comm_field */
221+
vals[1] = (u64)(long)"tiddlywinks"; /* next_comm_field */
222222
vals[2] = 1000000; /* ts_ns */
223223
vals[3] = 1000; /* ts_ms */
224224
vals[4] = smp_processor_id(); /* cpu */
225-
vals[5] = (u64)"thneed_2.0"; /* my_string_field */
225+
vals[5] = (u64)(long)"thneed_2.0"; /* my_string_field */
226226
vals[6] = 399; /* my_int_field */
227227

228228
/* Now trace an empty_synth_test event */
@@ -290,11 +290,11 @@ static int __init test_create_synth_event(void)
290290
/* Create some bogus values just for testing */
291291

292292
vals[0] = 777; /* next_pid_field */
293-
vals[1] = (u64)"tiddlywinks"; /* next_comm_field */
293+
vals[1] = (u64)(long)"tiddlywinks"; /* next_comm_field */
294294
vals[2] = 1000000; /* ts_ns */
295295
vals[3] = 1000; /* ts_ms */
296296
vals[4] = smp_processor_id(); /* cpu */
297-
vals[5] = (u64)"thneed"; /* my_string_field */
297+
vals[5] = (u64)(long)"thneed"; /* my_string_field */
298298
vals[6] = 398; /* my_int_field */
299299

300300
/* Now generate a create_synth_test event */
@@ -330,7 +330,7 @@ static int __init test_add_next_synth_val(void)
330330
goto out;
331331

332332
/* next_comm_field */
333-
ret = synth_event_add_next_val((u64)"slinky", &trace_state);
333+
ret = synth_event_add_next_val((u64)(long)"slinky", &trace_state);
334334
if (ret)
335335
goto out;
336336

@@ -350,7 +350,7 @@ static int __init test_add_next_synth_val(void)
350350
goto out;
351351

352352
/* my_string_field */
353-
ret = synth_event_add_next_val((u64)"thneed_2.01", &trace_state);
353+
ret = synth_event_add_next_val((u64)(long)"thneed_2.01", &trace_state);
354354
if (ret)
355355
goto out;
356356

@@ -396,12 +396,12 @@ static int __init test_add_synth_val(void)
396396
if (ret)
397397
goto out;
398398

399-
ret = synth_event_add_val("next_comm_field", (u64)"silly putty",
399+
ret = synth_event_add_val("next_comm_field", (u64)(long)"silly putty",
400400
&trace_state);
401401
if (ret)
402402
goto out;
403403

404-
ret = synth_event_add_val("my_string_field", (u64)"thneed_9",
404+
ret = synth_event_add_val("my_string_field", (u64)(long)"thneed_9",
405405
&trace_state);
406406
if (ret)
407407
goto out;
@@ -423,13 +423,13 @@ static int __init test_trace_synth_event(void)
423423

424424
/* Trace some bogus values just for testing */
425425
ret = synth_event_trace(create_synth_test, 7, /* number of values */
426-
444, /* next_pid_field */
427-
(u64)"clackers", /* next_comm_field */
428-
1000000, /* ts_ns */
429-
1000, /* ts_ms */
430-
smp_processor_id(), /* cpu */
431-
(u64)"Thneed", /* my_string_field */
432-
999); /* my_int_field */
426+
(u64)444, /* next_pid_field */
427+
(u64)(long)"clackers", /* next_comm_field */
428+
(u64)1000000, /* ts_ns */
429+
(u64)1000, /* ts_ms */
430+
(u64)smp_processor_id(),/* cpu */
431+
(u64)(long)"Thneed", /* my_string_field */
432+
(u64)999); /* my_int_field */
433433
return ret;
434434
}
435435

0 commit comments

Comments
 (0)