1. 12 Mar, 2010 6 commits
    • John Stultz's avatar
      time: Clean up warp_clock() · 64ce4c2f
      John Stultz authored
      warp_clock() currently accesses timekeeping internal state directly, which
      is unnecessary.  Convert it to use the proper timekeeping interfaces.
      Signed-off-by: default avatarJohn Stultz <johnstul@us.ibm.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      64ce4c2f
    • Stanislaw Gruszka's avatar
      cpu-timers: Avoid iterating over all threads in fastpath_timer_check() · c2873937
      Stanislaw Gruszka authored
      Spread p->sighand->siglock locking scope to make sure that
      fastpath_timer_check() never iterates over all threads. Without
      locking there is small possibility that signal->cputimer will stop
      running while we write values to signal->cputime_expires.
      
      Calling thread_group_cputime() from fastpath_timer_check() is not only
      bad because it is slow, also it is racy with __exit_signal() which can
      lead to invalid signal->{s,u}time values.
      Signed-off-by: default avatarStanislaw 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: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      c2873937
    • Stanislaw Gruszka's avatar
      cpu-timers: Change SIGEV_NONE timer implementation · 1f169f84
      Stanislaw Gruszka authored
      When user sets up a timer without associated signal and process does
      not use any other cpu timers and does not exit, tsk->signal->cputimer
      is enabled and running forever.
      
      Avoid running the timer for no reason.
      
      I used below program to check patch does not break current user space
      visible behavior.
      
       #include <sys/time.h>
       #include <signal.h>
       #include <stdio.h>
       #include <stdlib.h>
       #include <string.h>
       #include <time.h>
       #include <unistd.h>
       #include <assert.h>
      
       void consume_cpu(void)
       {
      	int i = 0;
      	int count = 0;
      
      	for(i=0; i<100000000; i++)
      		count++;
       }
      
       int main(void)
       {
      	int i;
      	struct sigaction act;
      	struct sigevent evt = { };
      	timer_t tid;
      	struct itimerspec spec = { };
      
      	evt.sigev_notify = SIGEV_NONE;
      	assert(timer_create(CLOCK_PROCESS_CPUTIME_ID, &evt,  &tid) == 0);
      
      	spec.it_value.tv_sec = 10;
      	assert(timer_settime(tid, 0, &spec,  NULL) == 0);
      
      	for (i = 0; i < 30; i++) {
      		consume_cpu();
      		memset(&spec, 0, sizeof(spec));
      		assert(timer_gettime(tid, &spec) == 0);
      		printf("%lu.%09lu\n",
      			(unsigned long) spec.it_value.tv_sec,
      			(unsigned long) spec.it_value.tv_nsec);
      	}
      
      	assert(timer_delete(tid) == 0);
      	return 0;
       }
      Signed-off-by: default avatarStanislaw 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: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      1f169f84
    • Stanislaw Gruszka's avatar
      cpu-timers: Return correct previous timer reload value · ae1a78ee
      Stanislaw Gruszka authored
      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: default avatarStanislaw 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: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      ae1a78ee
    • Stanislaw Gruszka's avatar
      cpu-timers: Cleanup arm_timer() · 5eb9aa64
      Stanislaw Gruszka authored
      Signed-off-by: default avatarStanislaw 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: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      5eb9aa64
    • Stanislaw Gruszka's avatar
      cpu-timers: Simplify RLIMIT_CPU handling · f55db609
      Stanislaw Gruszka authored
      Let always set signal->cputime_expires expiration cache when setting
      new itimer, POSIX 1.b timer, and RLIMIT_CPU.  Since we are
      initializing prof_exp expiration cache during fork(), this allows to
      remove "RLIMIT_CPU != inf" check from fastpath_timer_check() and do
      some other cleanups.
      
      Checked against regression using test cases from:
      http://marc.info/?l=linux-kernel&m=123749066504641&w=4
      http://marc.info/?l=linux-kernel&m=123811277916642&w=2Signed-off-by: default avatarStanislaw 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: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      f55db609
  2. 09 Mar, 2010 1 commit
  3. 08 Mar, 2010 33 commits