cpu-timers: Return correct previous timer reload value
commitae1a78eecc45fe41215d9dbfd7079999455772d6
authorStanislaw Gruszka <sgruszka@redhat.com>
Thu, 11 Mar 2010 22:04:39 +0000 (11 14:04 -0800)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 12 Mar 2010 21:40:40 +0000 (12 22:40 +0100)
tree6aa1fb1b053aa8f9464a6ce83a2b62cac12bab55
parent5eb9aa6414bdab6d075a8763bc3b647181ef3aab
cpu-timers: Return correct previous timer reload value

According POSIX we need to correctly set old timer it_interval value when
user request that in timer_settime().  Tested using below program.

 #include <sys/time.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
 #include <unistd.h>
 #include <assert.h>

 int main(void)
 {
struct sigaction act;
struct sigevent evt = { };
timer_t tid;
struct itimerspec spec, u_spec, k_spec;

evt.sigev_notify = SIGEV_SIGNAL;
evt.sigev_signo = SIGPROF;
assert(timer_create(CLOCK_PROCESS_CPUTIME_ID, &evt,  &tid) == 0);

spec.it_value.tv_sec = 1;
spec.it_value.tv_nsec = 2;
spec.it_interval.tv_sec = 3;
spec.it_interval.tv_nsec = 4;
u_spec = spec;
assert(timer_settime(tid, 0, &spec,  NULL) == 0);

spec.it_value.tv_sec = 5;
spec.it_value.tv_nsec = 6;
spec.it_interval.tv_sec = 7;
spec.it_interval.tv_nsec = 8;
assert(timer_settime(tid, 0, &spec,  &k_spec) == 0);

 #define PRT(val) printf(#val ":\t%d/%d\n", (int) u_spec.val, (int) k_spec.val)
PRT(it_value.tv_sec);
PRT(it_value.tv_nsec);
PRT(it_interval.tv_sec);
PRT(it_interval.tv_nsec);

return 0;
 }

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
kernel/posix-cpu-timers.c