Skip to content

Commit 3c4fbe5

Browse files
Miao XieIngo Molnar
authored andcommitted
nohz: fix wrong event handler after online an offlined cpu
On the tickless system(CONFIG_NO_HZ=y and CONFIG_HIGH_RES_TIMERS=n), after I made an offlined cpu online, I found this cpu's event handler was tick_handle_periodic, not tick_nohz_handler. After debuging, I found this bug was caused by the wrong tick mode. the tick mode is not changed to NOHZ_MODE_INACTIVE when the cpu is offline. This patch fixes this bug. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 6a55617 commit 3c4fbe5

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎include/linux/tick.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,13 @@ extern struct tick_device *tick_get_device(int cpu);
7474
extern int tick_init_highres(void);
7575
extern int tick_program_event(ktime_t expires, int force);
7676
extern void tick_setup_sched_timer(void);
77+
# endif
78+
79+
# if defined CONFIG_NO_HZ || defined CONFIG_HIGH_RES_TIMERS
7780
extern void tick_cancel_sched_timer(int cpu);
7881
# else
7982
static inline void tick_cancel_sched_timer(int cpu) { }
80-
# endif /* HIGHRES */
83+
# endif
8184

8285
# ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
8386
extern struct tick_device *tick_get_broadcast_device(void);

‎kernel/time/tick-sched.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,17 +643,21 @@ void tick_setup_sched_timer(void)
643643
ts->nohz_mode = NOHZ_MODE_HIGHRES;
644644
#endif
645645
}
646+
#endif /* HIGH_RES_TIMERS */
646647

648+
#if defined CONFIG_NO_HZ || defined CONFIG_HIGH_RES_TIMERS
647649
void tick_cancel_sched_timer(int cpu)
648650
{
649651
struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
650652

653+
# ifdef CONFIG_HIGH_RES_TIMERS
651654
if (ts->sched_timer.base)
652655
hrtimer_cancel(&ts->sched_timer);
656+
# endif
653657

654658
ts->nohz_mode = NOHZ_MODE_INACTIVE;
655659
}
656-
#endif /* HIGH_RES_TIMERS */
660+
#endif
657661

658662
/**
659663
* Async notification about clocksource changes

0 commit comments

Comments
 (0)