File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -915,6 +915,20 @@ config EVENT_TRACE_TEST_SYSCALLS
915
915
TBD - enable a way to actually call the syscalls as we test their
916
916
events
917
917
918
+ config FTRACE_SORT_STARTUP_TEST
919
+ bool "Verify compile time sorting of ftrace functions"
920
+ depends on DYNAMIC_FTRACE
921
+ depends on BUILDTIME_TABLE_SORT
922
+ help
923
+ Sorting of the mcount_loc sections that is used to find the
924
+ where the ftrace knows where to patch functions for tracing
925
+ and other callbacks is done at compile time. But if the sort
926
+ is not done correctly, it will cause non-deterministic failures.
927
+ When this is set, the sorted sections will be verified that they
928
+ are in deed sorted and will warn if they are not.
929
+
930
+ If unsure, say N
931
+
918
932
config RING_BUFFER_STARTUP_TEST
919
933
bool "Ring buffer startup self test"
920
934
depends on RING_BUFFER
Original file line number Diff line number Diff line change @@ -6388,6 +6388,27 @@ static int ftrace_cmp_ips(const void *a, const void *b)
6388
6388
return 0 ;
6389
6389
}
6390
6390
6391
+ #ifdef CONFIG_FTRACE_SORT_STARTUP_TEST
6392
+ static void test_is_sorted (unsigned long * start , unsigned long count )
6393
+ {
6394
+ int i ;
6395
+
6396
+ for (i = 1 ; i < count ; i ++ ) {
6397
+ if (WARN (start [i - 1 ] > start [i ],
6398
+ "[%d] %pS at %lx is not sorted with %pS at %lx\n" , i ,
6399
+ (void * )start [i - 1 ], start [i - 1 ],
6400
+ (void * )start [i ], start [i ]))
6401
+ break ;
6402
+ }
6403
+ if (i == count )
6404
+ pr_info ("ftrace section at %px sorted properly\n" , start );
6405
+ }
6406
+ #else
6407
+ static void test_is_sorted (unsigned long * start , unsigned long count )
6408
+ {
6409
+ }
6410
+ #endif
6411
+
6391
6412
static int ftrace_process_locs (struct module * mod ,
6392
6413
unsigned long * start ,
6393
6414
unsigned long * end )
@@ -6414,6 +6435,8 @@ static int ftrace_process_locs(struct module *mod,
6414
6435
if (!IS_ENABLED (CONFIG_BUILDTIME_TABLE_SORT ) || mod ) {
6415
6436
sort (start , count , sizeof (* start ),
6416
6437
ftrace_cmp_ips , NULL );
6438
+ } else {
6439
+ test_is_sorted (start , count );
6417
6440
}
6418
6441
6419
6442
start_pg = ftrace_allocate_pages (count );
You can’t perform that action at this time.
0 commit comments