From: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
To: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
linux-kernel@vger.kernel.org,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Olivier Langlois <olivier@trillion01.com>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
Steven Rostedt <rostedt@goodmis.org>,
David Miller <davem@davemloft.net>,
Thomas Gleixner <tglx@linutronix.de>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH 2/2] posix-cpu-timers: fix wrong timer initialization
Date: Mon, 29 Apr 2013 14:53:07 -0400 [thread overview]
Message-ID: <517EC193.1060306@gmail.com> (raw)
In-Reply-To: <517EB3B4.6040702@gmail.com>
>>> @@ -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.
next prev parent reply other threads:[~2013-04-29 18:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-29 6:26 [PATCH 1/2] posix-cpu-timers: fix acounting delta_exec twice kosaki.motohiro
2013-04-29 6:26 ` [PATCH 2/2] posix-cpu-timers: fix wrong timer initialization kosaki.motohiro
2013-04-29 10:36 ` Peter Zijlstra
2013-04-29 17:53 ` KOSAKI Motohiro
2013-04-29 18:53 ` KOSAKI Motohiro [this message]
2013-04-29 19:17 ` [BUGFIX PATCH 3/2] posix-cpu-timers: check_thread_timers() uses task_sched_runtime() KOSAKI Motohiro
2013-04-29 19:18 ` [PATCH 4/2] sched: task_sched_runtime introduce micro optimization KOSAKI Motohiro
2013-04-29 19:19 ` [PATCH 5/2] posix-cpu-timers: cleanup cpu_{clock,timer}_sample{,_group} KOSAKI Motohiro
2013-04-29 19:20 ` [PATCH 6/2] posix-cpu-timers: timer functions must use timer time instead of clock time KOSAKI Motohiro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=517EC193.1060306@gmail.com \
--to=kosaki.motohiro@gmail.com \
--cc=davem@davemloft.net \
--cc=fweisbec@gmail.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=olivier@trillion01.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=schwidefsky@de.ibm.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox