• Roland McGrath's avatar
    [PATCH] posix-timers: CPU clock support for POSIX timers · 2c3871a8
    Roland McGrath authored
    POSIX requires that when you claim _POSIX_CPUTIME and _POSIX_THREAD_CPUTIME,
    not only the clock_* calls but also timer_* calls must support the thread and
    process CPU time clocks.  This patch provides that support, building on my
    recent additions to support these clocks in the POSIX clock_* interfaces.
    This patch will not work without those changes, as well as the patch fixing
    the timer lock-siglock deadlock problem.
    
    The apparent pervasive changes to posix-timers.c are simply that some fields
    of struct k_itimer have changed name and moved into a union.  This was
    appropriate since the data structures required for the existing real-time
    timer support and for the new thread/process CPU-time timers are quite
    different.
    
    The glibc patches to support CPU time clocks using the new kernel support is
    in http://people.redhat.com/roland/glibc/kernel-cpuclocks.patch, and that
    includes tests for the timer support (if you build glibc with NPTL).
    From: Christoph Lameter <clameter@sgi.com>
    
      Your patch breaks the mmtimer driver because it used k_itimer values for
      its own purposes.  Here is a fix by defining an additional structure in
      k_itimer (same approach for mmtimer as the cpu timers):
    From: Roland McGrath <roland@redhat.com>
    
    Fix bug identified by Alexander Nyberg <alexn@dsv.su.se>
    
    > The problem arises from code touching the union in alloc_posix_timer()
    > which makes firing go non-zero. When firing is checked in
    > posix_cpu_timer_set() it will be positive causing an infinite loop.
    >
    > So either the below fix or preferably move the INIT_LIST_HEAD(x) from
    > alloc_posix_timer() to somewhere later where it doesn't disturb the other
    > union members.
    
    Thanks for finding this problem.  The latter is what I think is the right
    solution.  This patch does that, and also removes some superfluous rezeroing.
    Signed-off-by: default avatarRoland McGrath <roland@redhat.com>
    Signed-off-by: default avatarChristoph Lameter <clameter@sgi.com>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    2c3871a8
mmtimer.c 18.2 KB