Skip to content

Commit af2350b

Browse files
committed
vtime: Always debug check snapshot source _before_ updating it
The vtime delta update performed by get_vtime_delta() always check that the source of the snapshot is valid. Meanhile the snapshot updaters that rely on get_vtime_delta() also set the new snapshot origin. But some of them do this right before the call to get_vtime_delta(), making its debug check useless. This is easily fixable by moving the snapshot origin update after the call to get_vtime_delta(). The order doesn't matter there. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Li Zhong <zhong@linux.vnet.ibm.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Kevin Hilman <khilman@linaro.org>
1 parent b854faf commit af2350b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎kernel/sched/cputime.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,9 +660,9 @@ void vtime_account_system(struct task_struct *tsk)
660660
void vtime_gen_account_irq_exit(struct task_struct *tsk)
661661
{
662662
write_seqlock(&tsk->vtime_seqlock);
663+
__vtime_account_system(tsk);
663664
if (context_tracking_in_user())
664665
tsk->vtime_snap_whence = VTIME_USER;
665-
__vtime_account_system(tsk);
666666
write_sequnlock(&tsk->vtime_seqlock);
667667
}
668668

@@ -680,8 +680,8 @@ void vtime_account_user(struct task_struct *tsk)
680680
void vtime_user_enter(struct task_struct *tsk)
681681
{
682682
write_seqlock(&tsk->vtime_seqlock);
683-
tsk->vtime_snap_whence = VTIME_USER;
684683
__vtime_account_system(tsk);
684+
tsk->vtime_snap_whence = VTIME_USER;
685685
write_sequnlock(&tsk->vtime_seqlock);
686686
}
687687

0 commit comments

Comments
 (0)