Skip to content

Commit aafd9d6

Browse files
committed
Merge branch 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull timer/dynticks updates from Ingo Molnar: "This tree contains misc dynticks updates: a fix and three cleanups" * 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: sched/nohz: Fix overflow error in scheduler_tick_max_deferment() nohz_full: fix code style issue of tick_nohz_full_stop_tick nohz: Get timekeeping max deferment outside jiffies_lock tick: Rename tick_check_idle() to tick_irq_enter()
2 parents 595bf99 + a2b4c60 commit aafd9d6

File tree

5 files changed

+25
-18
lines changed

5 files changed

+25
-18
lines changed

include/linux/jiffies.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,12 @@ extern unsigned long preset_lpj;
294294
*/
295295
extern unsigned int jiffies_to_msecs(const unsigned long j);
296296
extern unsigned int jiffies_to_usecs(const unsigned long j);
297+
298+
static inline u64 jiffies_to_nsecs(const unsigned long j)
299+
{
300+
return (u64)jiffies_to_usecs(j) * NSEC_PER_USEC;
301+
}
302+
297303
extern unsigned long msecs_to_jiffies(const unsigned int m);
298304
extern unsigned long usecs_to_jiffies(const unsigned int u);
299305
extern unsigned long timespec_to_jiffies(const struct timespec *value);

include/linux/tick.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ extern struct cpumask *tick_get_broadcast_oneshot_mask(void);
104104
extern void tick_clock_notify(void);
105105
extern int tick_check_oneshot_change(int allow_nohz);
106106
extern struct tick_sched *tick_get_tick_sched(int cpu);
107-
extern void tick_check_idle(void);
107+
extern void tick_irq_enter(void);
108108
extern int tick_oneshot_mode_active(void);
109109
# ifndef arch_needs_cpu
110110
# define arch_needs_cpu(cpu) (0)
111111
# endif
112112
# else
113113
static inline void tick_clock_notify(void) { }
114114
static inline int tick_check_oneshot_change(int allow_nohz) { return 0; }
115-
static inline void tick_check_idle(void) { }
115+
static inline void tick_irq_enter(void) { }
116116
static inline int tick_oneshot_mode_active(void) { return 0; }
117117
# endif
118118

@@ -121,7 +121,7 @@ static inline void tick_init(void) { }
121121
static inline void tick_cancel_sched_timer(int cpu) { }
122122
static inline void tick_clock_notify(void) { }
123123
static inline int tick_check_oneshot_change(int allow_nohz) { return 0; }
124-
static inline void tick_check_idle(void) { }
124+
static inline void tick_irq_enter(void) { }
125125
static inline int tick_oneshot_mode_active(void) { return 0; }
126126
#endif /* !CONFIG_GENERIC_CLOCKEVENTS */
127127

kernel/sched/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2476,7 +2476,7 @@ u64 scheduler_tick_max_deferment(void)
24762476
if (time_before_eq(next, now))
24772477
return 0;
24782478

2479-
return jiffies_to_usecs(next - now) * NSEC_PER_USEC;
2479+
return jiffies_to_nsecs(next - now);
24802480
}
24812481
#endif
24822482

kernel/softirq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ void irq_enter(void)
328328
* here, as softirq will be serviced on return from interrupt.
329329
*/
330330
local_bh_disable();
331-
tick_check_idle();
331+
tick_irq_enter();
332332
_local_bh_enable();
333333
}
334334

kernel/time/tick-sched.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -533,12 +533,13 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts,
533533
struct clock_event_device *dev = __get_cpu_var(tick_cpu_device).evtdev;
534534
u64 time_delta;
535535

536+
time_delta = timekeeping_max_deferment();
537+
536538
/* Read jiffies and the time when jiffies were updated last */
537539
do {
538540
seq = read_seqbegin(&jiffies_lock);
539541
last_update = last_jiffies_update;
540542
last_jiffies = jiffies;
541-
time_delta = timekeeping_max_deferment();
542543
} while (read_seqretry(&jiffies_lock, seq));
543544

544545
if (rcu_needs_cpu(cpu, &rcu_delta_jiffies) ||
@@ -678,18 +679,18 @@ static ktime_t tick_nohz_stop_sched_tick(struct tick_sched *ts,
678679
static void tick_nohz_full_stop_tick(struct tick_sched *ts)
679680
{
680681
#ifdef CONFIG_NO_HZ_FULL
681-
int cpu = smp_processor_id();
682+
int cpu = smp_processor_id();
682683

683-
if (!tick_nohz_full_cpu(cpu) || is_idle_task(current))
684-
return;
684+
if (!tick_nohz_full_cpu(cpu) || is_idle_task(current))
685+
return;
685686

686-
if (!ts->tick_stopped && ts->nohz_mode == NOHZ_MODE_INACTIVE)
687-
return;
687+
if (!ts->tick_stopped && ts->nohz_mode == NOHZ_MODE_INACTIVE)
688+
return;
688689

689-
if (!can_stop_full_tick())
690-
return;
690+
if (!can_stop_full_tick())
691+
return;
691692

692-
tick_nohz_stop_sched_tick(ts, ktime_get(), cpu);
693+
tick_nohz_stop_sched_tick(ts, ktime_get(), cpu);
693694
#endif
694695
}
695696

@@ -1023,7 +1024,7 @@ static void tick_nohz_kick_tick(struct tick_sched *ts, ktime_t now)
10231024
#endif
10241025
}
10251026

1026-
static inline void tick_check_nohz_this_cpu(void)
1027+
static inline void tick_nohz_irq_enter(void)
10271028
{
10281029
struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
10291030
ktime_t now;
@@ -1042,17 +1043,17 @@ static inline void tick_check_nohz_this_cpu(void)
10421043
#else
10431044

10441045
static inline void tick_nohz_switch_to_nohz(void) { }
1045-
static inline void tick_check_nohz_this_cpu(void) { }
1046+
static inline void tick_nohz_irq_enter(void) { }
10461047

10471048
#endif /* CONFIG_NO_HZ_COMMON */
10481049

10491050
/*
10501051
* Called from irq_enter to notify about the possible interruption of idle()
10511052
*/
1052-
void tick_check_idle(void)
1053+
void tick_irq_enter(void)
10531054
{
10541055
tick_check_oneshot_broadcast_this_cpu();
1055-
tick_check_nohz_this_cpu();
1056+
tick_nohz_irq_enter();
10561057
}
10571058

10581059
/*

0 commit comments

Comments
 (0)