s390/time: Use jiffies instead of jiffies_64
Heiko Carstens
maintainerPATCH 1/1 s390/time: Use jiffies instead of jiffies_64
Christoph Schlameuss and Alexander Egorenkov reported a data-race reported by KCSAN when jiffies_64 is read:
==================================================================
BUG: KCSAN: data-race in do_account_vtime / tick_do_update_jiffies64
write to 0x0000016599ea8600 of 8 bytes by interrupt on cpu 6:
tick_do_update_jiffies64+0x140/0x250
=============================================================>
BUG: KCSAN: data-race in do_account_vtime / tick_do_update_ji>
write to 0x0000016599ea8600 of 8 bytes by interrupt on cpu 6:
tick_do_update_jiffies64+0x140/0x250 tick_nohz_handler+0x2e6/0x300 __run_hrtimer+0x156/0x4d0 __hrtimer_run_queues+0xd2/0x150
...
system_call+0x72/0x90
read to 0x0000016599ea8600 of 8 bytes by interrupt on cpu 12:
do_account_vtime+0x7d6/0x860 vtime_flush+0x26/0xe0 update_process_times+0x32/0x160 tick_nohz_handler+0x12a/0x300
...
system_call+0x72/0x90
value changed: 0x00000000ffffaa6c -> 0x00000000ffffaa6d
...
=============================================================>
Problem is that jiffies_64 instead of jiffies is used. Both are at the same address, but only jiffies is of volatile type, which prevents this warning.
Change the vtime code so jiffies instead of jiffies_64 is used everywhere. This addresses also the inconsistency that both jiffies and jiffies_64 were used in the original patch which introduced this.
--- arch/s390/kernel/vtime.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/s390/kernel/vtime.c +3 -3
@@ -32,7 +32,7 @@ static atomic64_t virt_timer_elapsed;DEFINE_PER_CPU (u64, mt_cycles[8 ]); static DEFINE_PER_CPU(u64, mt_scaling_mult) = { 1 }; static DEFINE_PER_CPU(u64, mt_scaling_div) = { 1 }; -static DEFINE_PER_CPU(u64, mt_scaling_jiffies); +static DEFINE_PER_CPU(unsigned long, mt_scaling_jiffies);static inline void set_vtimer (u64 expires) {
@@ -81,7 +81,7 @@ static void update_mt_scaling(void)memcpy (cycles_old, cycles_new,sizeof (u64) * (smp_cpu_mtid +1 )); } -__this_cpu_write (mt_scaling_jiffies, jiffies_64); +__this_cpu_write (mt_scaling_jiffies, jiffies); }static inline u64 update_tsk_timer (unsigned long *tsk_vtime,u64 new)
@@ -144,7 +144,7 @@ static int do_account_vtime(struct task_struct *tsk) lc->system_timer += timer;/* Update MT utilization calculation */ -if (smp_cpu_mtid &&time_after64 (jiffies_64,__this_cpu_read (mt_scaling_jiffies))) +if (smp_cpu_mtid &&time_after (jiffies,__this_cpu_read (mt_scaling_jiffies)))update_mt_scaling ();/* Calculate cputime delta */
Signature · 1 line
2.53.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 15 lines
Christoph Schlameuss and Alexander Egorenkov reported a data-race reported by KCSAN when
jiffies_64is read:==================================================================
BUG: KCSAN: data-race in do_account_vtime / tick_do_update_jiffies64write to
0x0000016599ea8600of 8 bytes by interrupt on cpu 6:
tick_do_update_jiffies64+0x140/0x250
=============================================================>BUG: KCSAN: data-race in do_account_vtime / tick_do_update_ji>write to
0x0000016599ea8600of 8 bytes by interrupt on cpu 6:tick_do_update_jiffies64+0x140/0x250 tick_nohz_handler+0x2e6/0x300 __run_hrtimer+0x156/0x4d0
Quoted 6 lines
[ ... ]
Fixes f341b8dff982 ("s390/vtime: limit MT scaling value updates")Reported-by Christoph Schlameuss <[email protected]>Reported-by Alexander Egorenkov <[email protected]>Signed-off-by Heiko Carstens <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 35 lines · Heiko Carstens
Christoph Schlameuss and Alexander Egorenkov reported a data-race reported by KCSAN when
jiffies_64is read:==================================================================
BUG: KCSAN: data-race in do_account_vtime / tick_do_update_jiffies64write to
0x0000016599ea8600of 8 bytes by interrupt on cpu 6:
tick_do_update_jiffies64+0x140/0x250
=============================================================>BUG: KCSAN: data-race in do_account_vtime / tick_do_update_ji>write to
0x0000016599ea8600of 8 bytes by interrupt on cpu 6:tick_do_update_jiffies64+0x140/0x250 tick_nohz_handler+0x2e6/0x300 __run_hrtimer+0x156/0x4d0 __hrtimer_run_queues+0xd2/0x150...
system_call+0x72/0x90read to
0x0000016599ea8600of 8 bytes by interrupt on cpu 12:do_account_vtime+0x7d6/0x860 vtime_flush+0x26/0xe0 update_process_times+0x32/0x160 tick_nohz_handler+0x12a/0x300...
system_call+0x72/0x90value changed:
0x00000000ffffaa6c->0x00000000ffffaa6d
...
=============================================================>Problem is that
jiffies_64instead of jiffies is used. Both are at the same address, but only jiffies is of volatile type, which prevents this warning.
Quoted 8 lines
Change the vtime code so jiffies instead of
jiffies_64is used everywhere. This addresses also the inconsistency that both jiffies andjiffies_64were used in the original patch which introduced this.Fixes f341b8dff982 ("s390/vtime: limit MT scaling value updates")Reported-by Christoph Schlameuss <[email protected]>Reported-by Alexander Egorenkov <[email protected]>Signed-off-by Heiko Carstens <[email protected]>
Quoted 39 lines · Heiko Carstens
Christoph Schlameuss and Alexander Egorenkov reported a data-race reported by KCSAN when
jiffies_64is read:==================================================================
BUG: KCSAN: data-race in do_account_vtime / tick_do_update_jiffies64write to
0x0000016599ea8600of 8 bytes by interrupt on cpu 6:
tick_do_update_jiffies64+0x140/0x250
=============================================================>BUG: KCSAN: data-race in do_account_vtime / tick_do_update_ji>write to
0x0000016599ea8600of 8 bytes by interrupt on cpu 6:tick_do_update_jiffies64+0x140/0x250 tick_nohz_handler+0x2e6/0x300 __run_hrtimer+0x156/0x4d0 __hrtimer_run_queues+0xd2/0x150...
system_call+0x72/0x90read to
0x0000016599ea8600of 8 bytes by interrupt on cpu 12:do_account_vtime+0x7d6/0x860 vtime_flush+0x26/0xe0 update_process_times+0x32/0x160 tick_nohz_handler+0x12a/0x300...
system_call+0x72/0x90value changed:
0x00000000ffffaa6c->0x00000000ffffaa6d
...
=============================================================>Problem is that
jiffies_64instead of jiffies is used. Both are at the same address, but only jiffies is of volatile type, which prevents this warning.Change the vtime code so jiffies instead of
jiffies_64is used everywhere. This addresses also the inconsistency that both jiffies andjiffies_64were used in the original patch which introduced this.
Quoted 7 lines
Fixes f341b8dff982 ("s390/vtime: limit MT scaling value updates")Reported-by Christoph Schlameuss <[email protected]>Reported-by Alexander Egorenkov <[email protected]>Signed-off-by Heiko Carstens <[email protected]>--- arch/s390/kernel/vtime.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Applied, thank you!