lkml.org 
[lkml]   [2015]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 6/7] posix-cpu-timers: Migrate to use new tick dependency mask model
    Date
    Instead of providing asynchronous checks for the nohz subsystem to verify
    posix cpu timers tick dependency, migrate the latter to the new mask.

    In order to keep track of the running timers and expose the tick
    dependency accordingly, we must probe the timers queuing and dequeuing
    on threads and process lists.

    Unfortunately it implies both task and signal level dependencies. We
    should be able to further optimize this and merge all that on the task
    level dependency, at the cost of a bit of complexity and may be overhead.

    Cc: Christoph Lameter <cl@linux.com>
    Cc: Chris Metcalf <cmetcalf@ezchip.com>
    Cc: Ingo Molnar <mingo@kernel.org>
    Cc: Luiz Capitulino <lcapitulino@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Rik van Riel <riel@redhat.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Viresh Kumar <viresh.kumar@linaro.org>
    Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
    ---
    include/linux/posix-timers.h | 3 ---
    kernel/time/posix-cpu-timers.c | 52 +++++++++---------------------------------
    kernel/time/tick-sched.c | 5 ----
    3 files changed, 11 insertions(+), 49 deletions(-)

    diff --git a/include/linux/posix-timers.h b/include/linux/posix-timers.h
    index 907f3fd..62d44c1 100644
    --- a/include/linux/posix-timers.h
    +++ b/include/linux/posix-timers.h
    @@ -128,9 +128,6 @@ void posix_cpu_timer_schedule(struct k_itimer *timer);
    void run_posix_cpu_timers(struct task_struct *task);
    void posix_cpu_timers_exit(struct task_struct *task);
    void posix_cpu_timers_exit_group(struct task_struct *task);
    -
    -bool posix_cpu_timers_can_stop_tick(struct task_struct *tsk);
    -
    void set_process_cpu_timer(struct task_struct *task, unsigned int clock_idx,
    cputime_t *newval, cputime_t *oldval);

    diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c
    index f5e86d2..3751330 100644
    --- a/kernel/time/posix-cpu-timers.c
    +++ b/kernel/time/posix-cpu-timers.c
    @@ -333,7 +333,6 @@ static int posix_cpu_clock_get(const clockid_t which_clock, struct timespec *tp)
    return err;
    }

    -
    /*
    * Validate the clockid_t for a new CPU-clock timer, and initialize the timer.
    * This is called from sys_timer_create() and do_cpu_nanosleep() with the
    @@ -474,13 +473,16 @@ static void arm_timer(struct k_itimer *timer)
    struct task_cputime *cputime_expires;
    struct cpu_timer_list *const nt = &timer->it.cpu;
    struct cpu_timer_list *next;
    + unsigned long *tick_dep;

    if (CPUCLOCK_PERTHREAD(timer->it_clock)) {
    head = p->cpu_timers;
    cputime_expires = &p->cputime_expires;
    + tick_dep = &p->tick_dependency;
    } else {
    head = p->signal->cpu_timers;
    cputime_expires = &p->signal->cputime_expires;
    + tick_dep = &p->signal->tick_dependency;
    }
    head += CPUCLOCK_WHICH(timer->it_clock);

    @@ -517,6 +519,7 @@ static void arm_timer(struct k_itimer *timer)
    cputime_expires->sched_exp = exp;
    break;
    }
    + __tick_nohz_set_dep_delayed(TICK_POSIX_TIMER_BIT, tick_dep);
    }
    }

    @@ -582,39 +585,6 @@ static int cpu_timer_sample_group(const clockid_t which_clock,
    return 0;
    }

    -#ifdef CONFIG_NO_HZ_FULL
    -static void nohz_kick_work_fn(struct work_struct *work)
    -{
    - tick_nohz_full_kick_all();
    -}
    -
    -static DECLARE_WORK(nohz_kick_work, nohz_kick_work_fn);
    -
    -/*
    - * We need the IPIs to be sent from sane process context.
    - * The posix cpu timers are always set with irqs disabled.
    - */
    -static void posix_cpu_timer_kick_nohz(void)
    -{
    - if (context_tracking_is_enabled())
    - schedule_work(&nohz_kick_work);
    -}
    -
    -bool posix_cpu_timers_can_stop_tick(struct task_struct *tsk)
    -{
    - if (!task_cputime_zero(&tsk->cputime_expires))
    - return false;
    -
    - /* Check if cputimer is running. This is accessed without locking. */
    - if (READ_ONCE(tsk->signal->cputimer.running))
    - return false;
    -
    - return true;
    -}
    -#else
    -static inline void posix_cpu_timer_kick_nohz(void) { }
    -#endif
    -
    /*
    * Guts of sys_timer_settime for CPU timers.
    * This is called with the timer locked and interrupts disabled.
    @@ -761,8 +731,7 @@ static int posix_cpu_timer_set(struct k_itimer *timer, int timer_flags,
    sample_to_timespec(timer->it_clock,
    old_incr, &old->it_interval);
    }
    - if (!ret)
    - posix_cpu_timer_kick_nohz();
    +
    return ret;
    }

    @@ -911,6 +880,8 @@ static void check_thread_timers(struct task_struct *tsk,
    __group_send_sig_info(SIGXCPU, SEND_SIG_PRIV, tsk);
    }
    }
    + if (task_cputime_zero(tsk_expires))
    + __tick_nohz_clear_dep(TICK_POSIX_TIMER_BIT, &tsk->tick_dependency);
    }

    static inline void stop_process_timers(struct signal_struct *sig)
    @@ -919,6 +890,7 @@ static inline void stop_process_timers(struct signal_struct *sig)

    /* Turn off cputimer->running. This is done without locking. */
    WRITE_ONCE(cputimer->running, false);
    + __tick_nohz_clear_dep(TICK_POSIX_TIMER_BIT, &sig->tick_dependency);
    }

    static u32 onecputick;
    @@ -1095,8 +1067,6 @@ void posix_cpu_timer_schedule(struct k_itimer *timer)
    arm_timer(timer);
    unlock_task_sighand(p, &flags);

    - /* Kick full dynticks CPUs in case they need to tick on the new timer */
    - posix_cpu_timer_kick_nohz();
    out:
    timer->it_overrun_last = timer->it_overrun;
    timer->it_overrun = -1;
    @@ -1270,7 +1240,7 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clock_idx,
    }

    if (!*newval)
    - goto out;
    + return;
    *newval += now;
    }

    @@ -1288,8 +1258,8 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clock_idx,
    tsk->signal->cputime_expires.virt_exp = *newval;
    break;
    }
    -out:
    - posix_cpu_timer_kick_nohz();
    +
    + __tick_nohz_set_dep_delayed(TICK_POSIX_TIMER_BIT, &tsk->signal->tick_dependency);
    }

    static int do_cpu_nanosleep(const clockid_t which_clock, int flags,
    diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
    index d670729..2a1ce82 100644
    --- a/kernel/time/tick-sched.c
    +++ b/kernel/time/tick-sched.c
    @@ -202,11 +202,6 @@ static bool can_stop_full_tick(struct tick_sched *ts)
    return false;
    }

    - if (!posix_cpu_timers_can_stop_tick(current)) {
    - trace_tick_stop(0, "posix timers running\n");
    - return false;
    - }
    -
    #ifdef CONFIG_HAVE_UNSTABLE_SCHED_CLOCK
    /*
    * sched_clock_tick() needs us?
    --
    2.5.3


    \
     
     \ /
      Last update: 2015-11-13 15:41    [W:4.292 / U:0.152 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site