@@ -367,13 +367,13 @@ static noinline void kcsan_found_watchpoint(const volatile void *ptr,
367367 * already removed the watchpoint, or another thread consumed
368368 * the watchpoint before this thread.
369369 */
370- kcsan_counter_inc ( KCSAN_COUNTER_REPORT_RACES );
370+ atomic_long_inc ( & kcsan_counters [ KCSAN_COUNTER_REPORT_RACES ] );
371371 }
372372
373373 if ((type & KCSAN_ACCESS_ASSERT ) != 0 )
374- kcsan_counter_inc ( KCSAN_COUNTER_ASSERT_FAILURES );
374+ atomic_long_inc ( & kcsan_counters [ KCSAN_COUNTER_ASSERT_FAILURES ] );
375375 else
376- kcsan_counter_inc ( KCSAN_COUNTER_DATA_RACES );
376+ atomic_long_inc ( & kcsan_counters [ KCSAN_COUNTER_DATA_RACES ] );
377377
378378 user_access_restore (flags );
379379}
@@ -414,7 +414,7 @@ kcsan_setup_watchpoint(const volatile void *ptr, size_t size, int type)
414414 goto out ;
415415
416416 if (!check_encodable ((unsigned long )ptr , size )) {
417- kcsan_counter_inc ( KCSAN_COUNTER_UNENCODABLE_ACCESSES );
417+ atomic_long_inc ( & kcsan_counters [ KCSAN_COUNTER_UNENCODABLE_ACCESSES ] );
418418 goto out ;
419419 }
420420
@@ -434,12 +434,12 @@ kcsan_setup_watchpoint(const volatile void *ptr, size_t size, int type)
434434 * with which should_watch() returns true should be tweaked so
435435 * that this case happens very rarely.
436436 */
437- kcsan_counter_inc ( KCSAN_COUNTER_NO_CAPACITY );
437+ atomic_long_inc ( & kcsan_counters [ KCSAN_COUNTER_NO_CAPACITY ] );
438438 goto out_unlock ;
439439 }
440440
441- kcsan_counter_inc ( KCSAN_COUNTER_SETUP_WATCHPOINTS );
442- kcsan_counter_inc ( KCSAN_COUNTER_USED_WATCHPOINTS );
441+ atomic_long_inc ( & kcsan_counters [ KCSAN_COUNTER_SETUP_WATCHPOINTS ] );
442+ atomic_long_inc ( & kcsan_counters [ KCSAN_COUNTER_USED_WATCHPOINTS ] );
443443
444444 /*
445445 * Read the current value, to later check and infer a race if the data
@@ -541,16 +541,16 @@ kcsan_setup_watchpoint(const volatile void *ptr, size_t size, int type)
541541 * increment this counter.
542542 */
543543 if (is_assert && value_change == KCSAN_VALUE_CHANGE_TRUE )
544- kcsan_counter_inc ( KCSAN_COUNTER_ASSERT_FAILURES );
544+ atomic_long_inc ( & kcsan_counters [ KCSAN_COUNTER_ASSERT_FAILURES ] );
545545
546546 kcsan_report (ptr , size , type , value_change , KCSAN_REPORT_RACE_SIGNAL ,
547547 watchpoint - watchpoints );
548548 } else if (value_change == KCSAN_VALUE_CHANGE_TRUE ) {
549549 /* Inferring a race, since the value should not have changed. */
550550
551- kcsan_counter_inc ( KCSAN_COUNTER_RACES_UNKNOWN_ORIGIN );
551+ atomic_long_inc ( & kcsan_counters [ KCSAN_COUNTER_RACES_UNKNOWN_ORIGIN ] );
552552 if (is_assert )
553- kcsan_counter_inc ( KCSAN_COUNTER_ASSERT_FAILURES );
553+ atomic_long_inc ( & kcsan_counters [ KCSAN_COUNTER_ASSERT_FAILURES ] );
554554
555555 if (IS_ENABLED (CONFIG_KCSAN_REPORT_RACE_UNKNOWN_ORIGIN ) || is_assert )
556556 kcsan_report (ptr , size , type , KCSAN_VALUE_CHANGE_TRUE ,
@@ -563,7 +563,7 @@ kcsan_setup_watchpoint(const volatile void *ptr, size_t size, int type)
563563 * reused after this point.
564564 */
565565 remove_watchpoint (watchpoint );
566- kcsan_counter_dec ( KCSAN_COUNTER_USED_WATCHPOINTS );
566+ atomic_long_dec ( & kcsan_counters [ KCSAN_COUNTER_USED_WATCHPOINTS ] );
567567out_unlock :
568568 if (!kcsan_interrupt_watcher )
569569 local_irq_restore (irq_flags );
0 commit comments