lkml.org 
[lkml]   [2017]   [Jul]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] sched/cputime: Fix using smp_processor_id() in preemptible
2017-07-07 16:11 GMT+08:00 Peter Zijlstra <peterz@infradead.org>:
> On Thu, Jul 06, 2017 at 08:18:41PM -0700, Wanpeng Li wrote:
>> --- a/kernel/sched/cputime.c
>> +++ b/kernel/sched/cputime.c
>> @@ -683,7 +683,7 @@ static u64 vtime_delta(struct vtime *vtime)
>> {
>> unsigned long long clock;
>>
>> - clock = sched_clock_cpu(smp_processor_id());
>> + clock = sched_clock();
>> if (clock < vtime->starttime)
>> return 0;
>>
>
> This is broken. sched_clock_cpu() and sched_clock() do not have the
> exact same value :-/
>
> So this ends up doing:
>
> vtime->starttime = sched_clock_cpu(cpu);
>
> /* ... */
>
> clock = sched_clock();
>
> delta = clock - vtime->starttime;
>
>
> And you compute a delta using two different clocks.

How about adding preempt_disable/enable() pair around vtime_delta() in
task_cputime()?

Regards,
Wanpeng Li

\
 
 \ /
  Last update: 2017-07-07 10:44    [W:0.038 / U:10.492 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site