Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 54684
b: refs/heads/master
c: d3ed782
h: refs/heads/master
v: v3
  • Loading branch information
Thomas Gleixner authored and Linus Torvalds committed May 8, 2007
1 parent 045ffdc commit a33b13a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d5d3b736e3264934ec832a657a9a434b65f3d51f
refs/heads/master: d3ed782458f315c30ea679b919a2cc59f2b82565
8 changes: 7 additions & 1 deletion trunk/kernel/time/tick-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ DEFINE_PER_CPU(struct tick_device, tick_cpu_device);
*/
ktime_t tick_next_period;
ktime_t tick_period;
static int tick_do_timer_cpu = -1;
int tick_do_timer_cpu __read_mostly = -1;
DEFINE_SPINLOCK(tick_device_lock);

/*
Expand Down Expand Up @@ -295,6 +295,12 @@ static void tick_shutdown(unsigned int *cpup)
clockevents_exchange_device(dev, NULL);
td->evtdev = NULL;
}
/* Transfer the do_timer job away from this cpu */
if (*cpup == tick_do_timer_cpu) {
int cpu = first_cpu(cpu_online_map);

tick_do_timer_cpu = (cpu != NR_CPUS) ? cpu : -1;
}
spin_unlock_irqrestore(&tick_device_lock, flags);
}

Expand Down
1 change: 1 addition & 0 deletions trunk/kernel/time/tick-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ DECLARE_PER_CPU(struct tick_device, tick_cpu_device);
extern spinlock_t tick_device_lock;
extern ktime_t tick_next_period;
extern ktime_t tick_period;
extern int tick_do_timer_cpu __read_mostly;

extern void tick_setup_periodic(struct clock_event_device *dev, int broadcast);
extern void tick_handle_periodic(struct clock_event_device *dev);
Expand Down
42 changes: 40 additions & 2 deletions trunk/kernel/time/tick-sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,18 @@ void tick_nohz_stop_sched_tick(void)
ts->tick_stopped = 1;
ts->idle_jiffies = last_jiffies;
}

/*
* If this cpu is the one which updates jiffies, then
* give up the assignment and let it be taken by the
* cpu which runs the tick timer next, which might be
* this cpu as well. If we don't drop this here the
* jiffies might be stale and do_timer() never
* invoked.
*/
if (cpu == tick_do_timer_cpu)
tick_do_timer_cpu = -1;

/*
* calculate the expiry time for the next timer wheel
* timer
Expand Down Expand Up @@ -338,12 +350,24 @@ static void tick_nohz_handler(struct clock_event_device *dev)
{
struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
struct pt_regs *regs = get_irq_regs();
int cpu = smp_processor_id();
ktime_t now = ktime_get();

dev->next_event.tv64 = KTIME_MAX;

/*
* Check if the do_timer duty was dropped. We don't care about
* concurrency: This happens only when the cpu in charge went
* into a long sleep. If two cpus happen to assign themself to
* this duty, then the jiffies update is still serialized by
* xtime_lock.
*/
if (unlikely(tick_do_timer_cpu == -1))
tick_do_timer_cpu = cpu;

/* Check, if the jiffies need an update */
tick_do_update_jiffies64(now);
if (tick_do_timer_cpu == cpu)
tick_do_update_jiffies64(now);

/*
* When we are idle and the tick is stopped, we have to touch
Expand Down Expand Up @@ -431,9 +455,23 @@ static enum hrtimer_restart tick_sched_timer(struct hrtimer *timer)
struct hrtimer_cpu_base *base = timer->base->cpu_base;
struct pt_regs *regs = get_irq_regs();
ktime_t now = ktime_get();
int cpu = smp_processor_id();

#ifdef CONFIG_NO_HZ
/*
* Check if the do_timer duty was dropped. We don't care about
* concurrency: This happens only when the cpu in charge went
* into a long sleep. If two cpus happen to assign themself to
* this duty, then the jiffies update is still serialized by
* xtime_lock.
*/
if (unlikely(tick_do_timer_cpu == -1))
tick_do_timer_cpu = cpu;
#endif

/* Check, if the jiffies need an update */
tick_do_update_jiffies64(now);
if (tick_do_timer_cpu == cpu)
tick_do_update_jiffies64(now);

/*
* Do not call, when we are not in irq context and have
Expand Down

0 comments on commit a33b13a

Please sign in to comment.