[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <517EC193.1060306@gmail.com>
Date: Mon, 29 Apr 2013 14:53:07 -0400
From: KOSAKI Motohiro <kosaki.motohiro@...il.com>
To: KOSAKI Motohiro <kosaki.motohiro@...il.com>
CC: Peter Zijlstra <peterz@...radead.org>,
linux-kernel@...r.kernel.org,
KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
Olivier Langlois <olivier@...llion01.com>,
Martin Schwidefsky <schwidefsky@...ibm.com>,
Steven Rostedt <rostedt@...dmis.org>,
David Miller <davem@...emloft.net>,
Thomas Gleixner <tglx@...utronix.de>,
Frederic Weisbecker <fweisbec@...il.com>,
Ingo Molnar <mingo@...nel.org>
Subject: Re: [PATCH 2/2] posix-cpu-timers: fix wrong timer initialization
>>> @@ -749,7 +756,13 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int flags,
>>> }
>>>
>>> if (new_expires.sched != 0 && !(flags & TIMER_ABSTIME)) {
>>> - cpu_time_add(timer->it_clock, &new_expires, val);
>>> + union cpu_time_count now;
>>> +
>>> + if (CPUCLOCK_PERTHREAD(timer->it_clock))
>>> + cpu_clock_sample(timer->it_clock, p, &now);
>>> + else
>>> + cpu_clock_sample_group(timer->it_clock, p, &now);
>>
>> This triggered a pattern match against earlier in this function; but they're
>> different now; timer vs clock. So nothing to merge...
>
> Not different, I think.
> Relative timeout need to calculate "now + timeout" by definition.
>
> But which time is "now"?
>
> Example, thread1 has 10ms sum_exec_runtime and 4ms delta and call timer_settime(4ms).
> Old code calculate an expire is 10+4=14. New one calculate 10+4+4=18.
>
> Which expire is correct? When using old one, timer will fire just after syscall. This
> is posix violation.
>
> In the other words,
>
> sighandler(){
> t1 = clock_gettime()
> }
>
> t0 = clock_gettime()
> timer_settime(timeout);
> ... wait to fire
>
> assert (t1 - t0 >= timeout)
>
> This pseudo code must be true. it is snippest what glibc rt/tst-cputimer1 test and failed.
In the other hands, following two calculations need to timer time (aka time without delta).
1) Initialization signal->cputimer for avoiding double delta count.
2) calculating old tiemr because timer firing logic (run_posix_cpu_timers) don't care delta_exec.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists