• Frederic Weisbecker's avatar
    posix-timers: Remove dead thread posix cpu timers caching · 724a3713
    Frederic Weisbecker authored
    When a task is exiting or has exited, its posix cpu timers
    don't tick anymore and won't elapse further. It's too late
    for them to expire.
    
    So any further call to timer_gettime() on these timers will
    return the same remaining expiry time.
    
    The current code optimize this by caching the remaining delta
    and storing it where we use to save the absolute expiration time.
    This way, the future calls to timer_gettime() won't need to
    compute the difference between the absolute expiration time and
    the current time anymore.
    
    Now this optimization doesn't seem to bring much value. Computing
    the timer remaining delta is not very costly. Fetching the timer
    value OTOH can be costly in two ways:
    
    * CPUCLOCK_SCHED read requires to lock the target's rq. But some
    optimizations are on the way to make task_sched_runtime() not holding
    the rq lock of a non-running target.
    
    * CPUCLOCK_VIRT/CPUCLOCK_PROF read simply consist in fetching
    current->utime/current->stime except when the system uses full
    dynticks cputime accounting. The latter requires a per task lock
    in order to correctly compute user and system time. But once the
    target is dead, this lock shouldn't be contended anyway.
    
    All in one this caching doesn't seem to be justified.
    Given that it complicates the code significantly for
    few wins, let's remove it on single thread timers.
    Signed-off-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Ingo Molnar <mingo@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Oleg Nesterov <oleg@redhat.com>
    Cc: Kosaki Motohiro <kosaki.motohiro@jp.fujitsu.com>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    724a3713
posix-cpu-timers.c 39.5 KB