Skip to content

Commit 719254f

Browse files
KAGA-KOKOThomas Gleixner
authored andcommitted
NOHZ: unify the nohz function calls in irq_enter()
We have two separate nohz function calls in irq_enter() for no good reason. Just call a single NOHZ function from irq_enter() and call the bits in the tick code. Signed-off-by: Thomas Gleixner <[email protected]>
1 parent 2e532d6 commit 719254f

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

include/linux/tick.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,36 +96,35 @@ extern cpumask_t *tick_get_broadcast_oneshot_mask(void);
9696
extern void tick_clock_notify(void);
9797
extern int tick_check_oneshot_change(int allow_nohz);
9898
extern struct tick_sched *tick_get_tick_sched(int cpu);
99+
extern void tick_check_idle(int cpu);
99100
# else
100101
static inline void tick_clock_notify(void) { }
101102
static inline int tick_check_oneshot_change(int allow_nohz) { return 0; }
103+
static inline void tick_check_idle(int cpu) { }
102104
# endif
103105

104106
#else /* CONFIG_GENERIC_CLOCKEVENTS */
105107
static inline void tick_init(void) { }
106108
static inline void tick_cancel_sched_timer(int cpu) { }
107109
static inline void tick_clock_notify(void) { }
108110
static inline int tick_check_oneshot_change(int allow_nohz) { return 0; }
111+
static inline void tick_check_idle(int cpu) { }
109112
#endif /* !CONFIG_GENERIC_CLOCKEVENTS */
110113

111114
# ifdef CONFIG_NO_HZ
112115
extern void tick_nohz_stop_sched_tick(int inidle);
113116
extern void tick_nohz_restart_sched_tick(void);
114-
extern void tick_nohz_update_jiffies(void);
115117
extern ktime_t tick_nohz_get_sleep_length(void);
116-
extern void tick_nohz_stop_idle(int cpu);
117118
extern u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time);
118119
# else
119120
static inline void tick_nohz_stop_sched_tick(int inidle) { }
120121
static inline void tick_nohz_restart_sched_tick(void) { }
121-
static inline void tick_nohz_update_jiffies(void) { }
122122
static inline ktime_t tick_nohz_get_sleep_length(void)
123123
{
124124
ktime_t len = { .tv64 = NSEC_PER_SEC/HZ };
125125

126126
return len;
127127
}
128-
static inline void tick_nohz_stop_idle(int cpu) { }
129128
static inline u64 get_cpu_idle_time_us(int cpu, u64 *unused) { return -1; }
130129
# endif /* !NO_HZ */
131130

kernel/softirq.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -265,16 +265,12 @@ asmlinkage void do_softirq(void)
265265
*/
266266
void irq_enter(void)
267267
{
268-
#ifdef CONFIG_NO_HZ
269268
int cpu = smp_processor_id();
269+
270270
if (idle_cpu(cpu) && !in_interrupt())
271-
tick_nohz_stop_idle(cpu);
272-
#endif
271+
tick_check_idle(cpu);
272+
273273
__irq_enter();
274-
#ifdef CONFIG_NO_HZ
275-
if (idle_cpu(cpu))
276-
tick_nohz_update_jiffies();
277-
#endif
278274
}
279275

280276
#ifdef __ARCH_IRQ_EXIT_IRQS_DISABLED

kernel/time/tick-sched.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void tick_nohz_update_jiffies(void)
155155
touch_softlockup_watchdog();
156156
}
157157

158-
void tick_nohz_stop_idle(int cpu)
158+
static void tick_nohz_stop_idle(int cpu)
159159
{
160160
struct tick_sched *ts = &per_cpu(tick_cpu_sched, cpu);
161161

@@ -558,6 +558,17 @@ static inline void tick_nohz_switch_to_nohz(void) { }
558558

559559
#endif /* NO_HZ */
560560

561+
/*
562+
* Called from irq_enter to notify about the possible interruption of idle()
563+
*/
564+
void tick_check_idle(int cpu)
565+
{
566+
#ifdef CONFIG_NO_HZ
567+
tick_nohz_stop_idle(cpu);
568+
tick_nohz_update_jiffies();
569+
#endif
570+
}
571+
561572
/*
562573
* High resolution timer specific code
563574
*/

0 commit comments

Comments
 (0)