Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

samples/trace_event: Add '__rel_loc' using sample event

Add '__rel_loc' using sample event for testing.
User can use this for testing purpose. There is
no reason to use this macro from the kernel.

Link: https://lkml.kernel.org/r/163757343050.510314.2876529802471645178.stgit@devnote2

Cc: Beau Belgrave <beaub@linux.microsoft.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

authored by

Masami Hiramatsu and committed by
Steven Rostedt (VMware)
b466b133 55de2c0b

+36
+3
samples/trace_events/trace-events-sample.c
··· 21 21 22 22 static void simple_thread_func(int cnt) 23 23 { 24 + unsigned long bitmask[1] = {0xdeadbeefUL}; 24 25 int array[6]; 25 26 int len = cnt % 5; 26 27 int i; ··· 44 43 trace_foo_with_template_cond("prints other times", cnt); 45 44 46 45 trace_foo_with_template_print("I have to be different", cnt); 46 + 47 + trace_foo_rel_loc("Hello __rel_loc", cnt, bitmask); 47 48 } 48 49 49 50 static int simple_thread(void *arg)
+33
samples/trace_events/trace-events-sample.h
··· 506 506 TP_ARGS(foo, bar), 507 507 TP_printk("bar %s %d", __get_str(foo), __entry->bar)); 508 508 509 + /* 510 + * There are yet another __rel_loc dynamic data attribute. If you 511 + * use __rel_dynamic_array() and __rel_string() etc. macros, you 512 + * can use this attribute. There is no difference from the viewpoint 513 + * of functionality with/without 'rel' but the encoding is a bit 514 + * different. This is expected to be used with user-space event, 515 + * there is no reason that the kernel event use this, but only for 516 + * testing. 517 + */ 518 + 519 + TRACE_EVENT(foo_rel_loc, 520 + 521 + TP_PROTO(const char *foo, int bar, unsigned long *mask), 522 + 523 + TP_ARGS(foo, bar, mask), 524 + 525 + TP_STRUCT__entry( 526 + __rel_string( foo, foo ) 527 + __field( int, bar ) 528 + __rel_bitmask( bitmask, 529 + BITS_PER_BYTE * sizeof(unsigned long) ) 530 + ), 531 + 532 + TP_fast_assign( 533 + __assign_rel_str(foo, foo); 534 + __entry->bar = bar; 535 + __assign_rel_bitmask(bitmask, mask, 536 + BITS_PER_BYTE * sizeof(unsigned long)); 537 + ), 538 + 539 + TP_printk("foo_rel_loc %s, %d, %s", __get_rel_str(foo), __entry->bar, 540 + __get_rel_bitmask(bitmask)) 541 + ); 509 542 #endif 510 543 511 544 /***** NOTICE! The #if protection ends here. *****/