lkml.org 
[lkml]   [2015]   [May]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch 4/7] timer: Replace timer base by a cpu index
On 26-05-15, 22:50, Thomas Gleixner wrote:
> static struct tvec_base *lock_timer_base(struct timer_list *timer,
> unsigned long *flags)
> __acquires(timer->base->lock)
> {
> - struct tvec_base *base;
> -
> for (;;) {
> - struct tvec_base *prelock_base = timer->base;
> - base = tbase_get_base(prelock_base);
> - if (likely(base != NULL)) {
> + u32 tf = timer->flags;
> + struct tvec_base *base;
> +
> + if (!(tf & TIMER_MIGRATING)) {
> + base = per_cpu_ptr(&tvec_bases, tf & TIMER_CPUMASK);
> spin_lock_irqsave(&base->lock, *flags);
> - if (likely(prelock_base == timer->base))
> + if (timer->flags == tf)
> return base;
> - /* The timer has migrated to another CPU */

Maybe we should retain this comment. Its helpful for people who aren't
very familiar with timer core.

> static void migrate_timer_list(struct tvec_base *new_base, struct hlist_head *head)
> {
> struct timer_list *timer;
> + int cpu = new_base->cpu;
>
> while (!hlist_empty(head)) {
> timer = hlist_entry(head->first, struct timer_list, entry);
> /* We ignore the accounting on the dying cpu */
> detach_timer(timer, false);
> - timer_set_base(timer, new_base);
> + timer->flags = (timer->flags & ~TIMER_BASEMASK) | cpu;

Because 'cpu' is used only once in this routine, maybe we can use
'new_base->cpu' here and the line will still be exactly 80 columns
long.

Not sure, but maybe we can create a inline helper for this operation
as it is repeated at multiple places.

Look good otherwise:

Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>

--
viresh


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