[PATCH 0/13] Turn hrtimers into a range capable timer - Kernel

This is a discussion on [PATCH 0/13] Turn hrtimers into a range capable timer - Kernel ; This series is a follow-on the the nanosecond select/poll series. The goal of this series is to introduce the capability into hrtimers to deal with a "range" rather than a specific point in time. (Several people discussed this recently, but ...

+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 20 of 44

Thread: [PATCH 0/13] Turn hrtimers into a range capable timer

  1. [PATCH 0/13] Turn hrtimers into a range capable timer

    This series is a follow-on the the nanosecond select/poll series.

    The goal of this series is to introduce the capability into hrtimers to
    deal with a "range" rather than a specific point in time.
    (Several people discussed this recently, but we've been toying with the
    concept for a while)

    In addition, in the last patch of the series, the patches make select()
    and poll() use these range timers with a standard "slack" that comes
    from
    1) a per process task_struct value
    2) a "the longer the sleep the more the slack" function that Linus wrote

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  2. [PATCH 3/13] hrtimer: convert timerfd to the new hrtimer apis


    From: Arjan van de Ven
    Subject: [PATCH] hrtimer: convert timerfd to the new hrtimer apis

    In order to be able to do range hrtimers we need to use accessor functions
    to the "expire" member of the hrtimer struct.
    This patch converts timerfd to these accessors.

    Signed-off-by: Arjan van de Ven
    ---
    fs/timerfd.c | 8 +++-----
    1 files changed, 3 insertions(+), 5 deletions(-)

    diff --git a/fs/timerfd.c b/fs/timerfd.c
    index c502c60..0862f0e 100644
    --- a/fs/timerfd.c
    +++ b/fs/timerfd.c
    @@ -52,11 +52,9 @@ static enum hrtimer_restart timerfd_tmrproc(struct hrtimer *htmr)

    static ktime_t timerfd_get_remaining(struct timerfd_ctx *ctx)
    {
    - ktime_t now, remaining;
    -
    - now = ctx->tmr.base->get_time();
    - remaining = ktime_sub(ctx->tmr.expires, now);
    + ktime_t remaining;

    + remaining = hrtimer_expires_remaining(&ctx->tmr);
    return remaining.tv64 < 0 ? ktime_set(0, 0): remaining;
    }

    @@ -74,7 +72,7 @@ static void timerfd_setup(struct timerfd_ctx *ctx, int flags,
    ctx->ticks = 0;
    ctx->tintv = timespec_to_ktime(ktmr->it_interval);
    hrtimer_init(&ctx->tmr, ctx->clockid, htmode);
    - ctx->tmr.expires = texp;
    + hrtimer_set_expires(&ctx->tmr, texp);
    ctx->tmr.function = timerfd_tmrproc;
    if (texp.tv64 != 0)
    hrtimer_start(&ctx->tmr, texp, htmode);
    --
    1.5.5.1

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  3. [PATCH 4/13] hrtimer: convert net::sched_cbq to the new hrtimer apis


    From: Arjan van de Ven
    Subject: [PATCH] hrtimer: convert net::sched_cbq to the new hrtimer apis

    In order to be able to do range hrtimers we need to use accessor functions
    to the "expire" member of the hrtimer struct.
    This patch converts sched_cbq to these accessors.

    Signed-off-by: Arjan van de Ven
    ---
    net/sched/sch_cbq.c | 7 ++++---
    1 files changed, 4 insertions(+), 3 deletions(-)

    diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c
    index 9b720ad..0fa7270 100644
    --- a/net/sched/sch_cbq.c
    +++ b/net/sched/sch_cbq.c
    @@ -545,9 +545,10 @@ static void cbq_ovl_delay(struct cbq_class *cl)
    expires = ktime_set(0, 0);
    expires = ktime_add_ns(expires, PSCHED_US2NS(sched));
    if (hrtimer_try_to_cancel(&q->delay_timer) &&
    - ktime_to_ns(ktime_sub(q->delay_timer.expires,
    - expires)) > 0)
    - q->delay_timer.expires = expires;
    + ktime_to_ns(ktime_sub(
    + hrtimer_get_expires(&q->delay_timer),
    + expires)) > 0)
    + hrtimer_set_expires(&q->delay_timer, expires);
    hrtimer_restart(&q->delay_timer);
    cl->delayed = 1;
    cl->xstats.overactions++;
    --
    1.5.5.1

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  4. [PATCH 6/13] hrtimer: convert powerpc/oprofile to the new hrtimer apis



    From: Arjan van de Ven
    Subject: [PATCH] hrtimer: convert powerpc/oprofile to the new hrtimer apis

    In order to be able to do range hrtimers we need to use accessor functions
    to the "expire" member of the hrtimer struct.
    This patch converts powerpc/oprofile to these accessors.

    Signed-off-by: Arjan van de Ven
    ---
    arch/powerpc/oprofile/cell/spu_profiler.c | 2 +-
    1 files changed, 1 insertions(+), 1 deletions(-)

    diff --git a/arch/powerpc/oprofile/cell/spu_profiler.c b/arch/powerpc/oprofile/cell/spu_profiler.c
    index 380d7e2..02ffe06 100644
    --- a/arch/powerpc/oprofile/cell/spu_profiler.c
    +++ b/arch/powerpc/oprofile/cell/spu_profiler.c
    @@ -196,7 +196,7 @@ int start_spu_profiling(unsigned int cycles_reset)
    pr_debug("timer resolution: %lu\n", TICK_NSEC);
    kt = ktime_set(0, profiling_interval);
    hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
    - timer.expires = kt;
    + hrtimer_set_expires(&timer, kt);
    timer.function = profile_spus;

    /* Allocate arrays for collecting SPU PC samples */
    --
    1.5.5.1

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  5. [PATCH 11/13] hrtimer: turn hrtimers into range timers


    From: Arjan van de Ven
    Subject: [PATCH] hrtimer: turn hrtimers into range timers

    this patch turns hrtimers into range timers; they have 2 expire points
    1) the soft expire point
    2) the hard expire point

    the kernel will do it's regular best effort attempt to get the timer run
    at the hard expire point. However, if some other time fires after the soft
    expire point, the kernel now has the freedom to fire this timer at this point,
    and thus grouping the events and preventing a power-expensive wakeup in the
    future.

    Signed-off-by: Arjan van de Ven
    ---
    include/linux/hrtimer.h | 31 ++++++++++++++++++++++++++++++-
    kernel/hrtimer.c | 43 +++++++++++++++++++++++++++++++++++++++----
    2 files changed, 69 insertions(+), 5 deletions(-)

    diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
    index 485a634..c26b1a5 100644
    --- a/include/linux/hrtimer.h
    +++ b/include/linux/hrtimer.h
    @@ -112,6 +112,7 @@ enum hrtimer_cb_mode {
    struct hrtimer {
    struct rb_node node;
    ktime_t _expires;
    + ktime_t _softexpires;
    enum hrtimer_restart (*function)(struct hrtimer *);
    struct hrtimer_clock_base *base;
    unsigned long state;
    @@ -220,20 +221,37 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer)
    static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time)
    {
    timer->_expires = time;
    + timer->_softexpires = time;
    }
    +
    +static inline void hrtimer_set_expires_range(struct hrtimer *timer, ktime_t time, ktime_t delta)
    +{
    + timer->_softexpires = time;
    + timer->_expires = ktime_add_safe(time, delta);
    +}
    +
    +static inline void hrtimer_set_expires_range_ns(struct hrtimer *timer, ktime_t time, unsigned long delta)
    +{
    + timer->_softexpires = time;
    + timer->_expires = ktime_add_ns(time, delta);
    +}
    +
    static inline void hrtimer_set_expires_tv64(struct hrtimer *timer, s64 tv64)
    {
    timer->_expires.tv64 = tv64;
    + timer->_softexpires.tv64 = tv64;
    }

    static inline void hrtimer_add_expires(struct hrtimer *timer, ktime_t time)
    {
    timer->_expires = ktime_add_safe(timer->_expires, time);
    + timer->_softexpires = ktime_add_safe(timer->_softexpires, time);
    }

    static inline void hrtimer_add_expires_ns(struct hrtimer *timer, unsigned long ns)
    {
    timer->_expires = ktime_add_ns(timer->_expires, ns);
    + timer->_softexpires = ktime_add_ns(timer->_softexpires, ns);
    }

    static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer)
    @@ -241,10 +259,19 @@ static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer)
    return timer->_expires;
    }

    +static inline ktime_t hrtimer_get_softexpires(const struct hrtimer *timer)
    +{
    + return timer->_expires;
    +}
    +
    static inline s64 hrtimer_get_expires_tv64(const struct hrtimer *timer)
    {
    return timer->_expires.tv64;
    }
    +static inline s64 hrtimer_get_softexpires_tv64(const struct hrtimer *timer)
    +{
    + return timer->_softexpires.tv64;
    +}

    static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer)
    {
    @@ -334,7 +361,7 @@ static inline int hrtimer_start_expires(struct hrtimer *timer,

    static inline int hrtimer_restart(struct hrtimer *timer)
    {
    - return hrtimer_start(timer, timer->_expires, HRTIMER_MODE_ABS);
    + return hrtimer_start_expires(timer, HRTIMER_MODE_ABS);
    }

    /* Query timers: */
    @@ -391,6 +418,8 @@ extern long hrtimer_nanosleep_restart(struct restart_block *restart_block);
    extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl,
    struct task_struct *tsk);

    +extern int schedule_hrtimeout_range(ktime_t *expires, unsigned long delta,
    + const enum hrtimer_mode mode);
    extern int schedule_hrtimeout(ktime_t *expires, const enum hrtimer_mode mode);

    /* Soft interrupt function to run the hrtimer queues: */
    diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
    index ae307fe..dc1ded0 100644
    --- a/kernel/hrtimer.c
    +++ b/kernel/hrtimer.c
    @@ -1309,7 +1309,7 @@ void hrtimer_interrupt(struct clock_event_device *dev)

    timer = rb_entry(node, struct hrtimer, node);

    - if (basenow.tv64 < hrtimer_get_expires_tv64(timer)) {
    + if (basenow.tv64 < hrtimer_get_softexpires_tv64(timer)) {
    ktime_t expires;

    expires = ktime_sub(hrtimer_get_expires(timer),
    @@ -1681,14 +1681,20 @@ void __init hrtimers_init(void)
    }

    /**
    - * schedule_hrtimeout - sleep until timeout
    + * schedule_hrtimeout_range - sleep until timeout
    * @expires: timeout value (ktime_t)
    + * @delta: slack in expires timeout (ktime_t)
    * @mode: timer mode, HRTIMER_MODE_ABS or HRTIMER_MODE_REL
    *
    * Make the current task sleep until the given expiry time has
    * elapsed. The routine will return immediately unless
    * the current task state has been set (see set_current_state()).
    *
    + * The @delta argument gives the kernel the freedom to schedule the
    + * actual wakeup to a time that is both power and performance friendly.
    + * The kernel give the normal best effort behavior for "@expires+@delta",
    + * but may decide to fire the timer earlier, but no earlier than @expires.
    + *
    * You can set the task state as follows -
    *
    * %TASK_UNINTERRUPTIBLE - at least @timeout time is guaranteed to
    @@ -1702,7 +1708,7 @@ void __init hrtimers_init(void)
    *
    * Returns 0 when the timer has expired otherwise -EINTR
    */
    -int __sched schedule_hrtimeout(ktime_t *expires,
    +int __sched schedule_hrtimeout_range(ktime_t *expires, unsigned long delta,
    const enum hrtimer_mode mode)
    {
    struct hrtimer_sleeper t;
    @@ -1726,7 +1732,7 @@ int __sched schedule_hrtimeout(ktime_t *expires,
    }

    hrtimer_init_on_stack(&t.timer, CLOCK_MONOTONIC, mode);
    - hrtimer_set_expires(&t.timer, *expires);
    + hrtimer_set_expires_range_ns(&t.timer, *expires, delta);

    hrtimer_init_sleeper(&t, current);

    @@ -1744,4 +1750,33 @@ int __sched schedule_hrtimeout(ktime_t *expires,

    return !t.task ? 0 : -EINTR;
    }
    +EXPORT_SYMBOL_GPL(schedule_hrtimeout_range);
    +
    +/**
    + * schedule_hrtimeout - sleep until timeout
    + * @expires: timeout value (ktime_t)
    + * @mode: timer mode, HRTIMER_MODE_ABS or HRTIMER_MODE_REL
    + *
    + * Make the current task sleep until the given expiry time has
    + * elapsed. The routine will return immediately unless
    + * the current task state has been set (see set_current_state()).
    + *
    + * You can set the task state as follows -
    + *
    + * %TASK_UNINTERRUPTIBLE - at least @timeout time is guaranteed to
    + * pass before the routine returns.
    + *
    + * %TASK_INTERRUPTIBLE - the routine may return early if a signal is
    + * delivered to the current task.
    + *
    + * The current task state is guaranteed to be TASK_RUNNING when this
    + * routine returns.
    + *
    + * Returns 0 when the timer has expired otherwise -EINTR
    + */
    +int __sched schedule_hrtimeout(ktime_t *expires,
    + const enum hrtimer_mode mode)
    +{
    + return schedule_hrtimeout_range(expires, 0, mode);
    +}
    EXPORT_SYMBOL_GPL(schedule_hrtimeout);
    --
    1.5.5.1

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  6. [PATCH 10/13] hrtimer: rename the "expires" struct member to avoid accidental usage


    From: Arjan van de Ven
    Subject: [PATCH] hrtimer: rename the "expires" struct member to avoid accidental usage

    To catch code that still touches the "expires" memory directly, rename it
    to have the compiler complain rather than get nasty, hard to explain,
    runtime behavior

    Signed-off-by: Arjan van de Ven
    ---
    include/linux/hrtimer.h | 20 ++++++++++----------
    1 files changed, 10 insertions(+), 10 deletions(-)

    diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
    index 9900e99..485a634 100644
    --- a/include/linux/hrtimer.h
    +++ b/include/linux/hrtimer.h
    @@ -111,7 +111,7 @@ enum hrtimer_cb_mode {
    */
    struct hrtimer {
    struct rb_node node;
    - ktime_t expires;
    + ktime_t _expires;
    enum hrtimer_restart (*function)(struct hrtimer *);
    struct hrtimer_clock_base *base;
    unsigned long state;
    @@ -219,41 +219,41 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer)

    static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time)
    {
    - timer->expires = time;
    + timer->_expires = time;
    }
    static inline void hrtimer_set_expires_tv64(struct hrtimer *timer, s64 tv64)
    {
    - timer->expires.tv64 = tv64;
    + timer->_expires.tv64 = tv64;
    }

    static inline void hrtimer_add_expires(struct hrtimer *timer, ktime_t time)
    {
    - timer->expires = ktime_add_safe(timer->expires, time);
    + timer->_expires = ktime_add_safe(timer->_expires, time);
    }

    static inline void hrtimer_add_expires_ns(struct hrtimer *timer, unsigned long ns)
    {
    - timer->expires = ktime_add_ns(timer->expires, ns);
    + timer->_expires = ktime_add_ns(timer->_expires, ns);
    }

    static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer)
    {
    - return timer->expires;
    + return timer->_expires;
    }

    static inline s64 hrtimer_get_expires_tv64(const struct hrtimer *timer)
    {
    - return timer->expires.tv64;
    + return timer->_expires.tv64;
    }

    static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer)
    {
    - return ktime_to_ns(timer->expires);
    + return ktime_to_ns(timer->_expires);
    }

    static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer)
    {
    - return ktime_sub(timer->expires, timer->base->get_time());
    + return ktime_sub(timer->_expires, timer->base->get_time());
    }

    /*
    @@ -334,7 +334,7 @@ static inline int hrtimer_start_expires(struct hrtimer *timer,

    static inline int hrtimer_restart(struct hrtimer *timer)
    {
    - return hrtimer_start(timer, timer->expires, HRTIMER_MODE_ABS);
    + return hrtimer_start(timer, timer->_expires, HRTIMER_MODE_ABS);
    }

    /* Query timers: */
    --
    1.5.5.1

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  7. [PATCH 5/13] hrtimer: convert kernel/* to the new hrtimer apis


    From: Arjan van de Ven
    Subject: [PATCH] hrtimer: convert kernel/* to the new hrtimer apis

    In order to be able to do range hrtimers we need to use accessor functions
    to the "expire" member of the hrtimer struct.
    This patch converts kernel/* to these accessors.

    Signed-off-by: Arjan van de Ven
    ---
    kernel/futex.c | 7 +++----
    kernel/hrtimer.c | 44 +++++++++++++++++++++++---------------------
    kernel/posix-timers.c | 10 ++++------
    kernel/rtmutex.c | 3 +--
    kernel/sched.c | 7 +++----
    kernel/time/ntp.c | 3 +--
    kernel/time/tick-sched.c | 21 ++++++++++-----------
    kernel/time/timer_list.c | 4 ++--
    8 files changed, 47 insertions(+), 52 deletions(-)

    diff --git a/kernel/futex.c b/kernel/futex.c
    index 7d1136e..4cd5b43 100644
    --- a/kernel/futex.c
    +++ b/kernel/futex.c
    @@ -1299,10 +1299,9 @@ static int futex_wait(u32 __user *uaddr, struct rw_semaphore *fshared,
    hrtimer_init_on_stack(&t.timer, CLOCK_MONOTONIC,
    HRTIMER_MODE_ABS);
    hrtimer_init_sleeper(&t, current);
    - t.timer.expires = *abs_time;
    + hrtimer_set_expires(&t.timer, *abs_time);

    - hrtimer_start(&t.timer, t.timer.expires,
    - HRTIMER_MODE_ABS);
    + hrtimer_start_expires(&t.timer, HRTIMER_MODE_ABS);
    if (!hrtimer_active(&t.timer))
    t.task = NULL;

    @@ -1404,7 +1403,7 @@ static int futex_lock_pi(u32 __user *uaddr, struct rw_semaphore *fshared,
    hrtimer_init_on_stack(&to->timer, CLOCK_REALTIME,
    HRTIMER_MODE_ABS);
    hrtimer_init_sleeper(to, current);
    - to->timer.expires = *time;
    + hrtimer_set_expires(&to->timer, *time);
    }

    q.pi_state = NULL;
    diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
    index 782137d..ae307fe 100644
    --- a/kernel/hrtimer.c
    +++ b/kernel/hrtimer.c
    @@ -517,7 +517,7 @@ static void hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base)
    if (!base->first)
    continue;
    timer = rb_entry(base->first, struct hrtimer, node);
    - expires = ktime_sub(timer->expires, base->offset);
    + expires = ktime_sub(hrtimer_get_expires(timer), base->offset);
    if (expires.tv64 < cpu_base->expires_next.tv64)
    cpu_base->expires_next = expires;
    }
    @@ -539,10 +539,10 @@ static int hrtimer_reprogram(struct hrtimer *timer,
    struct hrtimer_clock_base *base)
    {
    ktime_t *expires_next = &__get_cpu_var(hrtimer_bases).expires_next;
    - ktime_t expires = ktime_sub(timer->expires, base->offset);
    + ktime_t expires = ktime_sub(hrtimer_get_expires(timer), base->offset);
    int res;

    - WARN_ON_ONCE(timer->expires.tv64 < 0);
    + WARN_ON_ONCE(hrtimer_get_expires_tv64(timer) < 0);

    /*
    * When the callback is running, we do not reprogram the clock event
    @@ -794,7 +794,7 @@ u64 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval)
    u64 orun = 1;
    ktime_t delta;

    - delta = ktime_sub(now, timer->expires);
    + delta = ktime_sub(now, hrtimer_get_expires(timer));

    if (delta.tv64 < 0)
    return 0;
    @@ -806,8 +806,8 @@ u64 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval)
    s64 incr = ktime_to_ns(interval);

    orun = ktime_divns(delta, incr);
    - timer->expires = ktime_add_ns(timer->expires, incr * orun);
    - if (timer->expires.tv64 > now.tv64)
    + hrtimer_add_expires_ns(timer, incr * orun);
    + if (hrtimer_get_expires_tv64(timer) > now.tv64)
    return orun;
    /*
    * This (and the ktime_add() below) is the
    @@ -815,7 +815,7 @@ u64 hrtimer_forward(struct hrtimer *timer, ktime_t now, ktime_t interval)
    */
    orun++;
    }
    - timer->expires = ktime_add_safe(timer->expires, interval);
    + hrtimer_add_expires(timer, interval);

    return orun;
    }
    @@ -847,7 +847,8 @@ static void enqueue_hrtimer(struct hrtimer *timer,
    * We dont care about collisions. Nodes with
    * the same expiry time stay together.
    */
    - if (timer->expires.tv64 < entry->expires.tv64) {
    + if (hrtimer_get_expires_tv64(timer) <
    + hrtimer_get_expires_tv64(entry)) {
    link = &(*link)->rb_left;
    } else {
    link = &(*link)->rb_right;
    @@ -982,7 +983,7 @@ hrtimer_start(struct hrtimer *timer, ktime_t tim, const enum hrtimer_mode mode)
    #endif
    }

    - timer->expires = tim;
    + hrtimer_set_expires(timer, tim);

    timer_stats_hrtimer_set_start_info(timer);

    @@ -1076,7 +1077,7 @@ ktime_t hrtimer_get_remaining(const struct hrtimer *timer)
    ktime_t rem;

    base = lock_hrtimer_base(timer, &flags);
    - rem = ktime_sub(timer->expires, base->get_time());
    + rem = hrtimer_expires_remaining(timer);
    unlock_hrtimer_base(timer, &flags);

    return rem;
    @@ -1108,7 +1109,7 @@ ktime_t hrtimer_get_next_event(void)
    continue;

    timer = rb_entry(base->first, struct hrtimer, node);
    - delta.tv64 = timer->expires.tv64;
    + delta.tv64 = hrtimer_get_expires_tv64(timer);
    delta = ktime_sub(delta, base->get_time());
    if (delta.tv64 < mindelta.tv64)
    mindelta.tv64 = delta.tv64;
    @@ -1308,10 +1309,10 @@ void hrtimer_interrupt(struct clock_event_device *dev)

    timer = rb_entry(node, struct hrtimer, node);

    - if (basenow.tv64 < timer->expires.tv64) {
    + if (basenow.tv64 < hrtimer_get_expires_tv64(timer)) {
    ktime_t expires;

    - expires = ktime_sub(timer->expires,
    + expires = ktime_sub(hrtimer_get_expires(timer),
    base->offset);
    if (expires.tv64 < expires_next.tv64)
    expires_next = expires;
    @@ -1414,7 +1415,8 @@ void hrtimer_run_queues(void)
    struct hrtimer *timer;

    timer = rb_entry(node, struct hrtimer, node);
    - if (base->softirq_time.tv64 <= timer->expires.tv64)
    + if (base->softirq_time.tv64 <=
    + hrtimer_get_expires_tv64(timer))
    break;

    if (timer->cb_mode == HRTIMER_CB_SOFTIRQ) {
    @@ -1462,7 +1464,7 @@ static int __sched do_nanosleep(struct hrtimer_sleeper *t, enum hrtimer_mode mod

    do {
    set_current_state(TASK_INTERRUPTIBLE);
    - hrtimer_start(&t->timer, t->timer.expires, mode);
    + hrtimer_start_expires(&t->timer, mode);
    if (!hrtimer_active(&t->timer))
    t->task = NULL;

    @@ -1484,7 +1486,7 @@ static int update_rmtp(struct hrtimer *timer, struct timespec __user *rmtp)
    struct timespec rmt;
    ktime_t rem;

    - rem = ktime_sub(timer->expires, timer->base->get_time());
    + rem = hrtimer_expires_remaining(timer);
    if (rem.tv64 <= 0)
    return 0;
    rmt = ktime_to_timespec(rem);
    @@ -1503,7 +1505,7 @@ long __sched hrtimer_nanosleep_restart(struct restart_block *restart)

    hrtimer_init_on_stack(&t.timer, restart->nanosleep.index,
    HRTIMER_MODE_ABS);
    - t.timer.expires.tv64 = restart->nanosleep.expires;
    + hrtimer_set_expires_tv64(&t.timer, restart->nanosleep.expires);

    if (do_nanosleep(&t, HRTIMER_MODE_ABS))
    goto out;
    @@ -1530,7 +1532,7 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
    int ret = 0;

    hrtimer_init_on_stack(&t.timer, clockid, mode);
    - t.timer.expires = timespec_to_ktime(*rqtp);
    + hrtimer_set_expires(&t.timer, timespec_to_ktime(*rqtp));
    if (do_nanosleep(&t, mode))
    goto out;

    @@ -1550,7 +1552,7 @@ long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
    restart->fn = hrtimer_nanosleep_restart;
    restart->nanosleep.index = t.timer.base->index;
    restart->nanosleep.rmtp = rmtp;
    - restart->nanosleep.expires = t.timer.expires.tv64;
    + restart->nanosleep.expires = hrtimer_get_expires_tv64(&t.timer);

    ret = -ERESTART_RESTARTBLOCK;
    out:
    @@ -1724,11 +1726,11 @@ int __sched schedule_hrtimeout(ktime_t *expires,
    }

    hrtimer_init_on_stack(&t.timer, CLOCK_MONOTONIC, mode);
    - t.timer.expires = *expires;
    + hrtimer_set_expires(&t.timer, *expires);

    hrtimer_init_sleeper(&t, current);

    - hrtimer_start(&t.timer, t.timer.expires, mode);
    + hrtimer_start_expires(&t.timer, mode);
    if (!hrtimer_active(&t.timer))
    t.task = NULL;

    diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
    index e36d579..f85efcd 100644
    --- a/kernel/posix-timers.c
    +++ b/kernel/posix-timers.c
    @@ -668,7 +668,7 @@ common_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting)
    (timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE))
    timr->it_overrun += (unsigned int) hrtimer_forward(timer, now, iv);

    - remaining = ktime_sub(timer->expires, now);
    + remaining = ktime_sub(hrtimer_get_expires(timer), now);
    /* Return 0 only, when the timer is expired and not pending */
    if (remaining.tv64 <= 0) {
    /*
    @@ -762,7 +762,7 @@ common_timer_set(struct k_itimer *timr, int flags,
    hrtimer_init(&timr->it.real.timer, timr->it_clock, mode);
    timr->it.real.timer.function = posix_timer_fn;

    - timer->expires = timespec_to_ktime(new_setting->it_value);
    + hrtimer_set_expires(timer, timespec_to_ktime(new_setting->it_value));

    /* Convert interval */
    timr->it.real.interval = timespec_to_ktime(new_setting->it_interval);
    @@ -771,14 +771,12 @@ common_timer_set(struct k_itimer *timr, int flags,
    if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE)) {
    /* Setup correct expiry time for relative timers */
    if (mode == HRTIMER_MODE_REL) {
    - timer->expires =
    - ktime_add_safe(timer->expires,
    - timer->base->get_time());
    + hrtimer_add_expires(timer, timer->base->get_time());
    }
    return 0;
    }

    - hrtimer_start(timer, timer->expires, mode);
    + hrtimer_start_expires(timer, mode);
    return 0;
    }

    diff --git a/kernel/rtmutex.c b/kernel/rtmutex.c
    index 6522ae5..69d9cb9 100644
    --- a/kernel/rtmutex.c
    +++ b/kernel/rtmutex.c
    @@ -631,8 +631,7 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state,

    /* Setup the timer, when timeout != NULL */
    if (unlikely(timeout)) {
    - hrtimer_start(&timeout->timer, timeout->timer.expires,
    - HRTIMER_MODE_ABS);
    + hrtimer_start_expires(&timeout->timer, HRTIMER_MODE_ABS);
    if (!hrtimer_active(&timeout->timer))
    timeout->task = NULL;
    }
    diff --git a/kernel/sched.c b/kernel/sched.c
    index 9a1ddb8..b5e2605 100644
    --- a/kernel/sched.c
    +++ b/kernel/sched.c
    @@ -221,9 +221,8 @@ static void start_rt_bandwidth(struct rt_bandwidth *rt_b)

    now = hrtimer_cb_get_time(&rt_b->rt_period_timer);
    hrtimer_forward(&rt_b->rt_period_timer, now, rt_b->rt_period);
    - hrtimer_start(&rt_b->rt_period_timer,
    - rt_b->rt_period_timer.expires,
    - HRTIMER_MODE_ABS);
    + hrtimer_start_expires(&rt_b->rt_period_timer,
    + HRTIMER_MODE_ABS);
    }
    spin_unlock(&rt_b->rt_runtime_lock);
    }
    @@ -1058,7 +1057,7 @@ static void hrtick_start(struct rq *rq, u64 delay)
    struct hrtimer *timer = &rq->hrtick_timer;
    ktime_t time = ktime_add_ns(timer->base->get_time(), delay);

    - timer->expires = time;
    + hrtimer_set_expires(timer, time);

    if (rq == this_rq()) {
    hrtimer_restart(timer);
    diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
    index 5125ddd..4c8d854 100644
    --- a/kernel/time/ntp.c
    +++ b/kernel/time/ntp.c
    @@ -142,8 +142,7 @@ static enum hrtimer_restart ntp_leap_second(struct hrtimer *timer)
    time_state = TIME_OOP;
    printk(KERN_NOTICE "Clock: "
    "inserting leap second 23:59:60 UTC\n");
    - leap_timer.expires = ktime_add_ns(leap_timer.expires,
    - NSEC_PER_SEC);
    + hrtimer_add_expires_ns(&leap_timer, NSEC_PER_SEC);
    res = HRTIMER_RESTART;
    break;
    case TIME_DEL:
    diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
    index 7a46bde..be105fd 100644
    --- a/kernel/time/tick-sched.c
    +++ b/kernel/time/tick-sched.c
    @@ -285,7 +285,7 @@ void tick_nohz_stop_sched_tick(int inidle)
    goto out;
    }

    - ts->idle_tick = ts->sched_timer.expires;
    + ts->idle_tick = hrtimer_get_expires(&ts->sched_timer);
    ts->tick_stopped = 1;
    ts->idle_jiffies = last_jiffies;
    rcu_enter_nohz();
    @@ -416,21 +416,21 @@ void tick_nohz_restart_sched_tick(void)
    ts->tick_stopped = 0;
    ts->idle_exittime = now;
    hrtimer_cancel(&ts->sched_timer);
    - ts->sched_timer.expires = ts->idle_tick;
    + hrtimer_set_expires(&ts->sched_timer, ts->idle_tick);

    while (1) {
    /* Forward the time to expire in the future */
    hrtimer_forward(&ts->sched_timer, now, tick_period);

    if (ts->nohz_mode == NOHZ_MODE_HIGHRES) {
    - hrtimer_start(&ts->sched_timer,
    - ts->sched_timer.expires,
    + hrtimer_start_expires(&ts->sched_timer,
    HRTIMER_MODE_ABS);
    /* Check, if the timer was already in the past */
    if (hrtimer_active(&ts->sched_timer))
    break;
    } else {
    - if (!tick_program_event(ts->sched_timer.expires, 0))
    + if (!tick_program_event(
    + hrtimer_get_expires(&ts->sched_timer), 0))
    break;
    }
    /* Update jiffies and reread time */
    @@ -443,7 +443,7 @@ void tick_nohz_restart_sched_tick(void)
    static int tick_nohz_reprogram(struct tick_sched *ts, ktime_t now)
    {
    hrtimer_forward(&ts->sched_timer, now, tick_period);
    - return tick_program_event(ts->sched_timer.expires, 0);
    + return tick_program_event(hrtimer_get_expires(&ts->sched_timer), 0);
    }

    /*
    @@ -526,7 +526,7 @@ static void tick_nohz_switch_to_nohz(void)
    next = tick_init_jiffy_update();

    for (; {
    - ts->sched_timer.expires = next;
    + hrtimer_set_expires(&ts->sched_timer, next);
    if (!tick_program_event(next, 0))
    break;
    next = ktime_add(next, tick_period);
    @@ -622,16 +622,15 @@ void tick_setup_sched_timer(void)
    ts->sched_timer.cb_mode = HRTIMER_CB_IRQSAFE_NO_SOFTIRQ;

    /* Get the next period (per cpu) */
    - ts->sched_timer.expires = tick_init_jiffy_update();
    + hrtimer_set_expires(&ts->sched_timer, tick_init_jiffy_update());
    offset = ktime_to_ns(tick_period) >> 1;
    do_div(offset, num_possible_cpus());
    offset *= smp_processor_id();
    - ts->sched_timer.expires = ktime_add_ns(ts->sched_timer.expires, offset);
    + hrtimer_add_expires_ns(&ts->sched_timer, offset);

    for (; {
    hrtimer_forward(&ts->sched_timer, now, tick_period);
    - hrtimer_start(&ts->sched_timer, ts->sched_timer.expires,
    - HRTIMER_MODE_ABS);
    + hrtimer_start_expires(&ts->sched_timer, HRTIMER_MODE_ABS);
    /* Check, if the timer was already in the past */
    if (hrtimer_active(&ts->sched_timer))
    break;
    diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
    index a40e20f..5224a32 100644
    --- a/kernel/time/timer_list.c
    +++ b/kernel/time/timer_list.c
    @@ -66,8 +66,8 @@ print_timer(struct seq_file *m, struct hrtimer *timer, int idx, u64 now)
    #endif
    SEQ_printf(m, "\n");
    SEQ_printf(m, " # expires at %Lu nsecs [in %Ld nsecs]\n",
    - (unsigned long long)ktime_to_ns(timer->expires),
    - (long long)(ktime_to_ns(timer->expires) - now));
    + (unsigned long long)ktime_to_ns(hrtimer_get_expires(timer)),
    + (long long)(ktime_to_ns(hrtimer_get_expires(timer)) - now));
    }

    static void
    --
    1.5.5.1

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  8. [PATCH 1/13] hrtimer: add abstraction functions for accessing the "expires" member


    From: Arjan van de Ven
    Subject: [PATCH] hrtimer: add abstraction functions for accessing the "expires" member

    In order to be able to turn hrtimers into range based, we need to provide
    accessor functions for getting to the "expires" ktime_t member of the
    struct hrtimer.

    This patch adds a set of accessors for this purpose:
    * hrtimer_set_expires
    * hrtimer_set_expires_tv64
    * hrtimer_add_expires
    * hrtimer_add_expires_ns
    * hrtimer_get_expires
    * hrtimer_get_expires_tv64
    * hrtimer_get_expires_ns
    * hrtimer_expires_remaining
    * hrtimer_start_expires

    No users of these new accessors are added yet; these follow in later patches.
    Hopefully this patch can even go into 2.6.27-rc so that the conversions will
    not have a bottleneck in -next

    Signed-off-by: Arjan van de Ven
    ---
    include/linux/hrtimer.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
    1 files changed, 45 insertions(+), 0 deletions(-)

    diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
    index becd17d..9900e99 100644
    --- a/include/linux/hrtimer.h
    +++ b/include/linux/hrtimer.h
    @@ -217,6 +217,45 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer)
    return timer->base->cpu_base->hres_active;
    }

    +static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time)
    +{
    + timer->expires = time;
    +}
    +static inline void hrtimer_set_expires_tv64(struct hrtimer *timer, s64 tv64)
    +{
    + timer->expires.tv64 = tv64;
    +}
    +
    +static inline void hrtimer_add_expires(struct hrtimer *timer, ktime_t time)
    +{
    + timer->expires = ktime_add_safe(timer->expires, time);
    +}
    +
    +static inline void hrtimer_add_expires_ns(struct hrtimer *timer, unsigned long ns)
    +{
    + timer->expires = ktime_add_ns(timer->expires, ns);
    +}
    +
    +static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer)
    +{
    + return timer->expires;
    +}
    +
    +static inline s64 hrtimer_get_expires_tv64(const struct hrtimer *timer)
    +{
    + return timer->expires.tv64;
    +}
    +
    +static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer)
    +{
    + return ktime_to_ns(timer->expires);
    +}
    +
    +static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer)
    +{
    + return ktime_sub(timer->expires, timer->base->get_time());
    +}
    +
    /*
    * The resolution of the clocks. The resolution value is returned in
    * the clock_getres() system call to give application programmers an
    @@ -287,6 +326,12 @@ extern int hrtimer_start(struct hrtimer *timer, ktime_t tim,
    extern int hrtimer_cancel(struct hrtimer *timer);
    extern int hrtimer_try_to_cancel(struct hrtimer *timer);

    +static inline int hrtimer_start_expires(struct hrtimer *timer,
    + enum hrtimer_mode mode)
    +{
    + return hrtimer_start(timer, hrtimer_get_expires(timer), mode);
    +}
    +
    static inline int hrtimer_restart(struct hrtimer *timer)
    {
    return hrtimer_start(timer, timer->expires, HRTIMER_MODE_ABS);
    --
    1.5.5.1

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  9. [PATCH 8/13] hrtimer: convert s390 to the new hrtimer apis


    From: Arjan van de Ven
    Subject: [PATCH] hrtimer: convert s390 to the new hrtimer apis

    In order to be able to do range hrtimers we need to use accessor functions
    to the "expire" member of the hrtimer struct.
    This patch converts s390 to these accessors.

    Signed-off-by: Arjan van de Ven
    ---
    drivers/s390/crypto/ap_bus.c | 6 +++---
    1 files changed, 3 insertions(+), 3 deletions(-)

    diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
    index 62b6b55..6f02f1e 100644
    --- a/drivers/s390/crypto/ap_bus.c
    +++ b/drivers/s390/crypto/ap_bus.c
    @@ -659,9 +659,9 @@ static ssize_t poll_timeout_store(struct bus_type *bus, const char *buf,
    hr_time = ktime_set(0, poll_timeout);

    if (!hrtimer_is_queued(&ap_poll_timer) ||
    - !hrtimer_forward(&ap_poll_timer, ap_poll_timer.expires, hr_time)) {
    - ap_poll_timer.expires = hr_time;
    - hrtimer_start(&ap_poll_timer, hr_time, HRTIMER_MODE_ABS);
    + !hrtimer_forward(&ap_poll_timer, hrtimer_get_expires(&ap_poll_timer), hr_time)) {
    + hrtimer_set_expires(&ap_poll_timer, hr_time);
    + hrtimer_start_expires(&ap_poll_timer, HRTIMER_MODE_ABS);
    }
    return count;
    }
    --
    1.5.5.1

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  10. [PATCH 9/13] hrtimer: convert sound/ to the new hrtimer apis


    From: Arjan van de Ven
    Subject: [PATCH] hrtimer: convert sound/ to the new hrtimer apis

    In order to be able to do range hrtimers we need to use accessor functions
    to the "expire" member of the hrtimer struct.
    This patch converts sound/ to these accessors.

    Signed-off-by: Arjan van de Ven
    ---
    sound/drivers/pcsp/pcsp_lib.c | 5 +++--
    1 files changed, 3 insertions(+), 2 deletions(-)

    diff --git a/sound/drivers/pcsp/pcsp_lib.c b/sound/drivers/pcsp/pcsp_lib.c
    index e341f3f..1f42e40 100644
    --- a/sound/drivers/pcsp/pcsp_lib.c
    +++ b/sound/drivers/pcsp/pcsp_lib.c
    @@ -34,7 +34,7 @@ enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle)
    chip->thalf = 0;
    if (!atomic_read(&chip->timer_active))
    return HRTIMER_NORESTART;
    - hrtimer_forward(&chip->timer, chip->timer.expires,
    + hrtimer_forward(&chip->timer, hrtimer_get_expires(&chip->timer),
    ktime_set(0, chip->ns_rem));
    return HRTIMER_RESTART;
    }
    @@ -118,7 +118,8 @@ enum hrtimer_restart pcsp_do_timer(struct hrtimer *handle)
    chip->ns_rem = PCSP_PERIOD_NS();
    ns = (chip->thalf ? PCSP_CALC_NS(timer_cnt) : chip->ns_rem);
    chip->ns_rem -= ns;
    - hrtimer_forward(&chip->timer, chip->timer.expires, ktime_set(0, ns));
    + hrtimer_forward(&chip->timer, hrtimer_get_expires(&chip->timer),
    + ktime_set(0, ns));
    return HRTIMER_RESTART;

    exit_nr_unlock2:
    --
    1.5.5.1

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  11. [PATCH 7/13] hrtimer: convert kvm-ia64 to the new hrtimer apis


    From: Arjan van de Ven
    Subject: [PATCH] hrtimer: convert kvm-ia64 to the new hrtimer apis

    In order to be able to do range hrtimers we need to use accessor functions
    to the "expire" member of the hrtimer struct.
    This patch converts KVM-ia64 to these accessors.

    Signed-off-by: Arjan van de Ven
    ---
    arch/ia64/kvm/kvm-ia64.c | 2 +-
    1 files changed, 1 insertions(+), 1 deletions(-)

    diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
    index 7a37d06..cf8eae1 100644
    --- a/arch/ia64/kvm/kvm-ia64.c
    +++ b/arch/ia64/kvm/kvm-ia64.c
    @@ -1112,7 +1112,7 @@ static void kvm_migrate_hlt_timer(struct kvm_vcpu *vcpu)
    struct hrtimer *p_ht = &vcpu->arch.hlt_timer;

    if (hrtimer_cancel(p_ht))
    - hrtimer_start(p_ht, p_ht->expires, HRTIMER_MODE_ABS);
    + hrtimer_start_expires(p_ht, HRTIMER_MODE_ABS);
    }

    static enum hrtimer_restart hlt_timer_fn(struct hrtimer *data)
    --
    1.5.5.1

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  12. [PATCH 2/13] hrtimer: convert kvm to the new hrtimer apis


    From: Arjan van de Ven
    Subject: [PATCH] hrtimer: convert kvm to the new hrtimer apis

    In order to be able to do range hrtimers we need to use accessor functions
    to the "expire" member of the hrtimer struct.
    This patch converts KVM to these accessors.

    Signed-off-by: Arjan van de Ven
    ---
    arch/x86/kvm/i8254.c | 6 +++---
    arch/x86/kvm/lapic.c | 6 ++----
    2 files changed, 5 insertions(+), 7 deletions(-)

    diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
    index c0f7872..1bf8f57 100644
    --- a/arch/x86/kvm/i8254.c
    +++ b/arch/x86/kvm/i8254.c
    @@ -205,8 +205,8 @@ static int __pit_timer_fn(struct kvm_kpit_state *ps)
    wake_up_interruptible(&vcpu0->wq);
    }

    - pt->timer.expires = ktime_add_ns(pt->timer.expires, pt->period);
    - pt->scheduled = ktime_to_ns(pt->timer.expires);
    + hrtimer_add_expires_ns(&pt->timer, pt->period);
    + pt->scheduled = ktime_to_ns(hrtimer_get_expires(&pt->timer));

    return (pt->period == 0 ? 0 : 1);
    }
    @@ -246,7 +246,7 @@ void __kvm_migrate_pit_timer(struct kvm_vcpu *vcpu)

    timer = &pit->pit_state.pit_timer.timer;
    if (hrtimer_cancel(timer))
    - hrtimer_start(timer, timer->expires, HRTIMER_MODE_ABS);
    + hrtimer_start_expires(timer, HRTIMER_MODE_ABS);
    }

    static void destroy_pit_timer(struct kvm_kpit_timer *pt)
    diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
    index 73f43de..a5b61de 100644
    --- a/arch/x86/kvm/lapic.c
    +++ b/arch/x86/kvm/lapic.c
    @@ -953,9 +953,7 @@ static int __apic_timer_fn(struct kvm_lapic *apic)
    }
    if (apic_lvtt_period(apic)) {
    result = 1;
    - apic->timer.dev.expires = ktime_add_ns(
    - apic->timer.dev.expires,
    - apic->timer.period);
    + hrtimer_add_expires_ns(&apic->timer.dev, apic->timer.period);
    }
    return result;
    }
    @@ -1124,7 +1122,7 @@ void __kvm_migrate_apic_timer(struct kvm_vcpu *vcpu)

    timer = &apic->timer.dev;
    if (hrtimer_cancel(timer))
    - hrtimer_start(timer, timer->expires, HRTIMER_MODE_ABS);
    + hrtimer_start_expires(timer, HRTIMER_MODE_ABS);
    }

    void kvm_lapic_sync_from_vapic(struct kvm_vcpu *vcpu)
    --
    1.5.5.1

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  13. [PATCH 10/13] hrtimer: rename the "expires" struct member to avoid accidental usage


    From: Arjan van de Ven
    Subject: [PATCH] hrtimer: rename the "expires" struct member to avoid accidental usage

    To catch code that still touches the "expires" memory directly, rename it
    to have the compiler complain rather than get nasty, hard to explain,
    runtime behavior

    Signed-off-by: Arjan van de Ven
    ---
    include/linux/hrtimer.h | 20 ++++++++++----------
    1 files changed, 10 insertions(+), 10 deletions(-)

    diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
    index 9900e99..485a634 100644
    --- a/include/linux/hrtimer.h
    +++ b/include/linux/hrtimer.h
    @@ -111,7 +111,7 @@ enum hrtimer_cb_mode {
    */
    struct hrtimer {
    struct rb_node node;
    - ktime_t expires;
    + ktime_t _expires;
    enum hrtimer_restart (*function)(struct hrtimer *);
    struct hrtimer_clock_base *base;
    unsigned long state;
    @@ -219,41 +219,41 @@ static inline int hrtimer_is_hres_active(struct hrtimer *timer)

    static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time)
    {
    - timer->expires = time;
    + timer->_expires = time;
    }
    static inline void hrtimer_set_expires_tv64(struct hrtimer *timer, s64 tv64)
    {
    - timer->expires.tv64 = tv64;
    + timer->_expires.tv64 = tv64;
    }

    static inline void hrtimer_add_expires(struct hrtimer *timer, ktime_t time)
    {
    - timer->expires = ktime_add_safe(timer->expires, time);
    + timer->_expires = ktime_add_safe(timer->_expires, time);
    }

    static inline void hrtimer_add_expires_ns(struct hrtimer *timer, unsigned long ns)
    {
    - timer->expires = ktime_add_ns(timer->expires, ns);
    + timer->_expires = ktime_add_ns(timer->_expires, ns);
    }

    static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer)
    {
    - return timer->expires;
    + return timer->_expires;
    }

    static inline s64 hrtimer_get_expires_tv64(const struct hrtimer *timer)
    {
    - return timer->expires.tv64;
    + return timer->_expires.tv64;
    }

    static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer)
    {
    - return ktime_to_ns(timer->expires);
    + return ktime_to_ns(timer->_expires);
    }

    static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer)
    {
    - return ktime_sub(timer->expires, timer->base->get_time());
    + return ktime_sub(timer->_expires, timer->base->get_time());
    }

    /*
    @@ -334,7 +334,7 @@ static inline int hrtimer_start_expires(struct hrtimer *timer,

    static inline int hrtimer_restart(struct hrtimer *timer)
    {
    - return hrtimer_start(timer, timer->expires, HRTIMER_MODE_ABS);
    + return hrtimer_start(timer, timer->_expires, HRTIMER_MODE_ABS);
    }

    /* Query timers: */
    --
    1.5.5.1

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  14. Re: [PATCH 13/13] hrtimer: make select() and poll() use the hrtimer range feature

    On Mon, 2008-09-01 at 16:14 -0700, Arjan van de Ven wrote:
    > From: Arjan van de Ven
    > Subject: [PATCH] hrtimer: make select() and poll() use the hrtimer range feature
    >
    > This patch makes the select() and poll() hrtimers use the new range
    > feature and settings from the task struct.
    >
    > In addition, this includes the estimate_accuracy() function that Linus
    > posted to lkml (but with a few steps added based on experiments).
    >
    > Signed-off-by: Arjan van de Ven
    > ---
    > fs/select.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++-
    > 1 files changed, 66 insertions(+), 2 deletions(-)
    >
    > diff --git a/fs/select.c b/fs/select.c
    > index f6dceb5..21bf77d 100644
    > --- a/fs/select.c
    > +++ b/fs/select.c
    > @@ -28,6 +28,62 @@
    >
    > #include
    >
    > +
    > +/* Estimate expected accuracy in ns from a timeval */
    > +
    > +static unsigned long __estimate_accuracy(struct timespec *tv)
    > +{
    > + /*
    > + * Tens of ms if we're looking at seconds, even
    > + * more for 10s+ sleeping
    > + */
    > + if (tv->tv_sec) {
    > + /* 100 milliseconds for long sleeps */
    > + if (tv->tv_sec > 10)
    > + return 100 * NSEC_PER_MSEC;
    > +
    > + /*
    > + * Tens of ms for second-granularity sleeps. This,
    > + * btw, is the historical Linux 100Hz timer range.
    > + */
    > + return 10 * NSEC_PER_MSEC;
    > + }
    > +
    > + /* 5 msec if we're looking at 100+ milliseconds */
    > + if (tv->tv_nsec > 100 * NSEC_PER_MSEC)
    > + return 5 * NSEC_PER_MSEC;
    > +
    > + /* A msec if we're looking at 10+ milliseconds */
    > + if (tv->tv_nsec > 10 * NSEC_PER_MSEC)
    > + return NSEC_PER_MSEC;
    > +
    > + /* half a msec if we're looking at milliseconds */
    > + if (tv->tv_nsec > NSEC_PER_MSEC)
    > + return NSEC_PER_MSEC/2;
    > +
    > + /* Single usecs if we're looking at microseconds */
    > + if (tv->tv_nsec > NSEC_PER_USEC)
    > + return NSEC_PER_USEC;
    > +
    > + /* Aim for tenths of nanosecs otherwise */
    > + return 10;
    > +}


    Why not use a simple logarithmic decay to drive this estimate?


    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  15. Re: [PATCH 11/13] hrtimer: turn hrtimers into range timers

    On Mon, 2008-09-01 at 16:08 -0700, Arjan van de Ven wrote:

    > @@ -847,7 +847,8 @@ static void enqueue_hrtimer(struct hrtimer *timer,
    > * We dont care about collisions. Nodes with
    > * the same expiry time stay together.
    > */
    > - if (timer->expires.tv64 < entry->expires.tv64) {
    > + if (hrtimer_get_expires_tv64(timer) <
    > + hrtimer_get_expires_tv64(entry)) {
    > link = &(*link)->rb_left;
    > } else {
    > link = &(*link)->rb_right;


    On Mon, 2008-09-01 at 16:13 -0700, Arjan van de Ven wrote:

    > +static inline void hrtimer_set_expires_range(struct hrtimer *timer, ktime_t time, ktime_t delta)
    > +{
    > + timer->_softexpires = time;
    > + timer->_expires = ktime_add_safe(time, delta);
    > +}


    > @@ -241,10 +259,19 @@ static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer)
    > return timer->_expires;
    > }
    >
    > +static inline ktime_t hrtimer_get_softexpires(const struct hrtimer *timer)
    > +{
    > + return timer->_expires;
    > +}


    Somehow the function is called softexpires, but returns the hard expire
    time...

    > static inline s64 hrtimer_get_expires_tv64(const struct hrtimer *timer)
    > {
    > return timer->_expires.tv64;
    > }
    > +static inline s64 hrtimer_get_softexpires_tv64(const struct hrtimer *timer)
    > +{
    > + return timer->_softexpires.tv64;
    > +}
    >
    > static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer)
    > {


    > @@ -1309,7 +1309,7 @@ void hrtimer_interrupt(struct clock_event_device *dev)
    >
    > timer = rb_entry(node, struct hrtimer, node);
    >
    > - if (basenow.tv64 < hrtimer_get_expires_tv64(timer)) {
    > + if (basenow.tv64 < hrtimer_get_softexpires_tv64(timer)) {
    > ktime_t expires;
    >
    > expires = ktime_sub(hrtimer_get_expires(timer),


    I might be missing something, but this code only looks at the leftmost
    timer, and we're indexed on the hard expire time, which might be rather
    far to the right of here.

    This means that esp for those timers for which we can save most we're
    least likely to do so because we'll plain not see them.



    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  16. Re: [PATCH 11/13] hrtimer: turn hrtimers into range timers

    On Tue, 2008-09-02 at 10:22 +0200, Peter Zijlstra wrote:
    > On Mon, 2008-09-01 at 16:08 -0700, Arjan van de Ven wrote:
    >
    > > @@ -847,7 +847,8 @@ static void enqueue_hrtimer(struct hrtimer *timer,
    > > * We dont care about collisions. Nodes with
    > > * the same expiry time stay together.
    > > */
    > > - if (timer->expires.tv64 < entry->expires.tv64) {
    > > + if (hrtimer_get_expires_tv64(timer) <
    > > + hrtimer_get_expires_tv64(entry)) {
    > > link = &(*link)->rb_left;
    > > } else {
    > > link = &(*link)->rb_right;

    >
    > On Mon, 2008-09-01 at 16:13 -0700, Arjan van de Ven wrote:
    >
    > > +static inline void hrtimer_set_expires_range(struct hrtimer *timer, ktime_t time, ktime_t delta)
    > > +{
    > > + timer->_softexpires = time;
    > > + timer->_expires = ktime_add_safe(time, delta);
    > > +}

    >
    > > @@ -241,10 +259,19 @@ static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer)
    > > return timer->_expires;
    > > }
    > >
    > > +static inline ktime_t hrtimer_get_softexpires(const struct hrtimer *timer)
    > > +{
    > > + return timer->_expires;
    > > +}

    >
    > Somehow the function is called softexpires, but returns the hard expire
    > time...
    >
    > > static inline s64 hrtimer_get_expires_tv64(const struct hrtimer *timer)
    > > {
    > > return timer->_expires.tv64;
    > > }
    > > +static inline s64 hrtimer_get_softexpires_tv64(const struct hrtimer *timer)
    > > +{
    > > + return timer->_softexpires.tv64;
    > > +}
    > >
    > > static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer)
    > > {

    >
    > > @@ -1309,7 +1309,7 @@ void hrtimer_interrupt(struct clock_event_device *dev)
    > >
    > > timer = rb_entry(node, struct hrtimer, node);
    > >
    > > - if (basenow.tv64 < hrtimer_get_expires_tv64(timer)) {
    > > + if (basenow.tv64 < hrtimer_get_softexpires_tv64(timer)) {
    > > ktime_t expires;
    > >
    > > expires = ktime_sub(hrtimer_get_expires(timer),

    >
    > I might be missing something, but this code only looks at the leftmost
    > timer, and we're indexed on the hard expire time, which might be rather
    > far to the right of here.
    >
    > This means that esp for those timers for which we can save most we're
    > least likely to do so because we'll plain not see them.


    What you need is a data structure that supports stabbing queries on
    overlapping intervals, such like a Priority Search Tree.

    If I'm not mistaken, then the augmented Red-Black tree from the EEVDF
    paper is identical to PST[*].

    This data-structure adds a Heap property to each RB-node, allowing one
    to search the tree on a different property.

    So what you can do in this case, is index the RB-tree on the soft
    expire, and index the heap on the hard expire.

    Then you can find the leftmost hard expire by traversing the tree using
    the heap property - and program the clock-event using that time.

    And you can search for soft expired entries using the RB-tree like we do
    now.

    [*] Fabio implemented it on top of the linux RB-tree for their wf2q+
    implementation that they used for their BFQ I/O scheduler:

    http://feanor.sssup.it/~fabio/linux/wfq/

    And I borrowed their implementation for my scheduler work:

    http://programming.kicks-ass.net/ker...hed-eedf.patch



    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  17. Re: [PATCH 12/13] hrtimer: create a "timer_slack" field in the task struct

    Hi!

    > From: Arjan van de Ven
    > Subject: [PATCH] hrtimer: create a "timer_slack" field in the task struct
    >
    > We want to be able to control the default "rounding" that is used by
    > select() and poll() and friends. This is a per process property
    > (so that we can have a "nice" like program to start certain programs with
    > a looser or stricter rounding) that can be set/get via a prctl().
    >
    > For this purpose, a field called "timer_slack_ns" is added to the task
    > struct. In addition, a field called "default_timer_slack"ns" is added
    > so that tasks easily can temporarily to a more/less accurate slack and then
    > back to the default.


    Is this a good idea? IMO it should be per-syscall, not per
    application. Threads would certainly like private values... and this
    makes really ugly interface.

    ....plus it bloats task struct.

    ....where did the sys_indirect proposals go? We created new syscalls,
    right?

    IMO we should create new syscalls here, too.

    Pavel

    > Signed-off-by: Arjan van de Ven
    > ---
    > include/linux/init_task.h | 1 +
    > include/linux/prctl.h | 7 +++++++
    > include/linux/sched.h | 6 ++++++
    > kernel/fork.c | 2 ++
    > kernel/sys.c | 10 ++++++++++
    > 5 files changed, 26 insertions(+), 0 deletions(-)
    >
    > diff --git a/include/linux/init_task.h b/include/linux/init_task.h
    > index 021d8e7..23fd890 100644
    > --- a/include/linux/init_task.h
    > +++ b/include/linux/init_task.h
    > @@ -170,6 +170,7 @@ extern struct group_info init_groups;
    > .cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \
    > .fs_excl = ATOMIC_INIT(0), \
    > .pi_lock = __SPIN_LOCK_UNLOCKED(tsk.pi_lock), \
    > + .timer_slack_ns = 50000, /* 50 usec default slack */ \
    > .pids = { \
    > [PIDTYPE_PID] = INIT_PID_LINK(PIDTYPE_PID), \
    > [PIDTYPE_PGID] = INIT_PID_LINK(PIDTYPE_PGID), \
    > diff --git a/include/linux/prctl.h b/include/linux/prctl.h
    > index 5ad7919..48d887e 100644
    > --- a/include/linux/prctl.h
    > +++ b/include/linux/prctl.h
    > @@ -78,4 +78,11 @@
    > #define PR_GET_SECUREBITS 27
    > #define PR_SET_SECUREBITS 28
    >
    > +/*
    > + * Get/set the timerslack as used by poll/select/nanosleep
    > + * A value of 0 means "use default"
    > + */
    > +#define PR_SET_TIMERSLACK 29
    > +#define PR_GET_TIMERSLACK 30
    > +
    > #endif /* _LINUX_PRCTL_H */
    > diff --git a/include/linux/sched.h b/include/linux/sched.h
    > index cfb0d87..f357780 100644
    > --- a/include/linux/sched.h
    > +++ b/include/linux/sched.h
    > @@ -1301,6 +1301,12 @@ struct task_struct {
    > int latency_record_count;
    > struct latency_record latency_record[LT_SAVECOUNT];
    > #endif
    > + /*
    > + * time slack values; these are used to round up poll() and
    > + * select() etc timeout values. These are in nanoseconds.
    > + */
    > + unsigned long timer_slack_ns;
    > + unsigned long default_timer_slack_ns;
    > };
    >
    > /*
    > diff --git a/kernel/fork.c b/kernel/fork.c
    > index 7ce2ebe..4308d75 100644
    > --- a/kernel/fork.c
    > +++ b/kernel/fork.c
    > @@ -987,6 +987,8 @@ static struct task_struct *copy_process(unsigned long clone_flags,
    > p->prev_utime = cputime_zero;
    > p->prev_stime = cputime_zero;
    >
    > + p->default_timer_slack_ns = current->timer_slack_ns;
    > +
    > #ifdef CONFIG_DETECT_SOFTLOCKUP
    > p->last_switch_count = 0;
    > p->last_switch_timestamp = 0;
    > diff --git a/kernel/sys.c b/kernel/sys.c
    > index 038a7bc..1b96401 100644
    > --- a/kernel/sys.c
    > +++ b/kernel/sys.c
    > @@ -1727,6 +1727,16 @@ asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3,
    > case PR_SET_TSC:
    > error = SET_TSC_CTL(arg2);
    > break;
    > + case PR_GET_TIMERSLACK:
    > + error = current->timer_slack_ns;
    > + break;
    > + case PR_SET_TIMERSLACK:
    > + if (arg2 <= 0)
    > + current->timer_slack_ns =
    > + current->default_timer_slack_ns;
    > + else
    > + current->timer_slack_ns = arg2;
    > + break;
    > default:
    > error = -EINVAL;
    > break;


    --
    (english) http://www.livejournal.com/~pavelmachek
    (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pav...rses/blog.html
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  18. Re: [PATCH 11/13] hrtimer: turn hrtimers into range timers

    On Tue, 2008-09-02 at 13:08 +0200, Peter Zijlstra wrote:
    > On Tue, 2008-09-02 at 10:22 +0200, Peter Zijlstra wrote:
    > > On Mon, 2008-09-01 at 16:08 -0700, Arjan van de Ven wrote:
    > >
    > > > @@ -847,7 +847,8 @@ static void enqueue_hrtimer(struct hrtimer *timer,
    > > > * We dont care about collisions. Nodes with
    > > > * the same expiry time stay together.
    > > > */
    > > > - if (timer->expires.tv64 < entry->expires.tv64) {
    > > > + if (hrtimer_get_expires_tv64(timer) <
    > > > + hrtimer_get_expires_tv64(entry)) {
    > > > link = &(*link)->rb_left;
    > > > } else {
    > > > link = &(*link)->rb_right;

    > >
    > > On Mon, 2008-09-01 at 16:13 -0700, Arjan van de Ven wrote:
    > >
    > > > +static inline void hrtimer_set_expires_range(struct hrtimer *timer, ktime_t time, ktime_t delta)
    > > > +{
    > > > + timer->_softexpires = time;
    > > > + timer->_expires = ktime_add_safe(time, delta);
    > > > +}

    > >
    > > > @@ -241,10 +259,19 @@ static inline ktime_t hrtimer_get_expires(const struct hrtimer *timer)
    > > > return timer->_expires;
    > > > }
    > > >
    > > > +static inline ktime_t hrtimer_get_softexpires(const struct hrtimer *timer)
    > > > +{
    > > > + return timer->_expires;
    > > > +}

    > >
    > > Somehow the function is called softexpires, but returns the hard expire
    > > time...
    > >
    > > > static inline s64 hrtimer_get_expires_tv64(const struct hrtimer *timer)
    > > > {
    > > > return timer->_expires.tv64;
    > > > }
    > > > +static inline s64 hrtimer_get_softexpires_tv64(const struct hrtimer *timer)
    > > > +{
    > > > + return timer->_softexpires.tv64;
    > > > +}
    > > >
    > > > static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer)
    > > > {

    > >
    > > > @@ -1309,7 +1309,7 @@ void hrtimer_interrupt(struct clock_event_device *dev)
    > > >
    > > > timer = rb_entry(node, struct hrtimer, node);
    > > >
    > > > - if (basenow.tv64 < hrtimer_get_expires_tv64(timer)) {
    > > > + if (basenow.tv64 < hrtimer_get_softexpires_tv64(timer)) {
    > > > ktime_t expires;
    > > >
    > > > expires = ktime_sub(hrtimer_get_expires(timer),

    > >
    > > I might be missing something, but this code only looks at the leftmost
    > > timer, and we're indexed on the hard expire time, which might be rather
    > > far to the right of here.
    > >
    > > This means that esp for those timers for which we can save most we're
    > > least likely to do so because we'll plain not see them.

    >
    > What you need is a data structure that supports stabbing queries on
    > overlapping intervals, such like a Priority Search Tree.
    >
    > If I'm not mistaken, then the augmented Red-Black tree from the EEVDF
    > paper is identical to PST[*].
    >
    > This data-structure adds a Heap property to each RB-node, allowing one
    > to search the tree on a different property.
    >
    > So what you can do in this case, is index the RB-tree on the soft
    > expire, and index the heap on the hard expire.
    >
    > Then you can find the leftmost hard expire by traversing the tree using
    > the heap property - and program the clock-event using that time.


    Even better, in the implementations below, the leftmost heap propery can
    be read from the root node, so if, as with the clock event, you don't
    actually need the entry itself, but just the time, you can find it by
    reading the heap propery of the root node.

    Which saves a whole log(n) tree traversal ;-)

    Same goes for reprogramming the clock event on insert and delete, just
    check the root heap property for change.

    > And you can search for soft expired entries using the RB-tree like we do
    > now.
    >
    >
    >[*] Fabio implemented it on top of the linux RB-tree for their wf2q+
    > implementation that they used for their BFQ I/O scheduler:
    >
    > http://feanor.sssup.it/~fabio/linux/wfq/
    >
    > And I borrowed their implementation for my scheduler work:
    >
    > http://programming.kicks-ass.net/ker...hed-eedf.patch
    >
    >
    >
    > --
    > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    > the body of a message to majordomo@vger.kernel.org
    > More majordomo info at http://vger.kernel.org/majordomo-info.html
    > Please read the FAQ at http://www.tux.org/lkml/


    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  19. Re: [PATCH 11/13] hrtimer: turn hrtimers into range timers

    On Tue, 02 Sep 2008 13:08:45 +0200
    >
    > What you need is a data structure that supports stabbing queries on
    > overlapping intervals, such like a Priority Search Tree.
    >



    for perfection we'd need that, for a simple good we don't; timers are
    also performance critical so whatever we do can't be expensive in any
    way... the current method isn't any more expensive.

    --
    If you want to reach me at my work email, use arjan@linux.intel.com
    For development, discussion and tips for power savings,
    visit http://www.lesswatts.org
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  20. Re: [PATCH 12/13] hrtimer: create a "timer_slack" field in the task struct

    On Tue, 2 Sep 2008 12:04:39 +0200
    Pavel Machek wrote:

    > Hi!
    >
    > > From: Arjan van de Ven
    > > Subject: [PATCH] hrtimer: create a "timer_slack" field in the task
    > > struct
    > >
    > > We want to be able to control the default "rounding" that is used by
    > > select() and poll() and friends. This is a per process property
    > > (so that we can have a "nice" like program to start certain
    > > programs with a looser or stricter rounding) that can be set/get
    > > via a prctl().
    > >
    > > For this purpose, a field called "timer_slack_ns" is added to the
    > > task struct. In addition, a field called "default_timer_slack"ns"
    > > is added so that tasks easily can temporarily to a more/less
    > > accurate slack and then back to the default.

    >
    > Is this a good idea? IMO it should be per-syscall, not per
    > application.


    Yes it would be nice to have new syscalls for this
    and no, nobody and nothing would use them.

    THe really big advantag of this default-from-task-struct is that you
    can have a program similar to "nice" that allows you to run an existing
    program at a specified granularity (say, a version of acroread that has
    a really high wakeup count but you still want to save power)

    > Threads would certainly like private values...


    of course these are per thread.. they're in the task struct after all

    > and this makes really ugly interface.


    prctl() is ugly?

    >
    > ...plus it bloats task struct.
    >
    > ...where did the sys_indirect proposals go? We created new syscalls,
    > right?


    .... which nobody uses today.
    It's not just new syscalls, it's a new glibc api as well at that point.


    --
    If you want to reach me at my work email, use arjan@linux.intel.com
    For development, discussion and tips for power savings,
    visit http://www.lesswatts.org
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread
Page 1 of 3 1 2 3 LastLast