1919 * Statistics counters.
2020 */
2121static atomic_long_t counters [KCSAN_COUNTER_COUNT ];
22+ static const char * const counter_names [] = {
23+ [KCSAN_COUNTER_USED_WATCHPOINTS ] = "used_watchpoints" ,
24+ [KCSAN_COUNTER_SETUP_WATCHPOINTS ] = "setup_watchpoints" ,
25+ [KCSAN_COUNTER_DATA_RACES ] = "data_races" ,
26+ [KCSAN_COUNTER_ASSERT_FAILURES ] = "assert_failures" ,
27+ [KCSAN_COUNTER_NO_CAPACITY ] = "no_capacity" ,
28+ [KCSAN_COUNTER_REPORT_RACES ] = "report_races" ,
29+ [KCSAN_COUNTER_RACES_UNKNOWN_ORIGIN ] = "races_unknown_origin" ,
30+ [KCSAN_COUNTER_UNENCODABLE_ACCESSES ] = "unencodable_accesses" ,
31+ [KCSAN_COUNTER_ENCODING_FALSE_POSITIVES ] = "encoding_false_positives" ,
32+ };
33+ static_assert (ARRAY_SIZE (counter_names ) == KCSAN_COUNTER_COUNT );
2234
2335/*
2436 * Addresses for filtering functions from reporting. This list can be used as a
@@ -39,24 +51,6 @@ static struct {
3951};
4052static DEFINE_SPINLOCK (report_filterlist_lock );
4153
42- static const char * counter_to_name (enum kcsan_counter_id id )
43- {
44- switch (id ) {
45- case KCSAN_COUNTER_USED_WATCHPOINTS : return "used_watchpoints" ;
46- case KCSAN_COUNTER_SETUP_WATCHPOINTS : return "setup_watchpoints" ;
47- case KCSAN_COUNTER_DATA_RACES : return "data_races" ;
48- case KCSAN_COUNTER_ASSERT_FAILURES : return "assert_failures" ;
49- case KCSAN_COUNTER_NO_CAPACITY : return "no_capacity" ;
50- case KCSAN_COUNTER_REPORT_RACES : return "report_races" ;
51- case KCSAN_COUNTER_RACES_UNKNOWN_ORIGIN : return "races_unknown_origin" ;
52- case KCSAN_COUNTER_UNENCODABLE_ACCESSES : return "unencodable_accesses" ;
53- case KCSAN_COUNTER_ENCODING_FALSE_POSITIVES : return "encoding_false_positives" ;
54- case KCSAN_COUNTER_COUNT :
55- BUG ();
56- }
57- return NULL ;
58- }
59-
6054void kcsan_counter_inc (enum kcsan_counter_id id )
6155{
6256 atomic_long_inc (& counters [id ]);
@@ -271,8 +265,7 @@ static int show_info(struct seq_file *file, void *v)
271265 /* show stats */
272266 seq_printf (file , "enabled: %i\n" , READ_ONCE (kcsan_enabled ));
273267 for (i = 0 ; i < KCSAN_COUNTER_COUNT ; ++ i )
274- seq_printf (file , "%s: %ld\n" , counter_to_name (i ),
275- atomic_long_read (& counters [i ]));
268+ seq_printf (file , "%s: %ld\n" , counter_names [i ], atomic_long_read (& counters [i ]));
276269
277270 /* show filter functions, and filter type */
278271 spin_lock_irqsave (& report_filterlist_lock , flags );
0 commit comments