Skip to content

Commit 2bc629a

Browse files
Frederic Weisbeckerrafaeljw
authored andcommitted
nohz: Gather tick_sched booleans under a common flag field
Optimize the space and leave plenty of room for further flags. Signed-off-by: Frederic Weisbecker <frederic@kernel.org> [ rjw: Do not use __this_cpu_read() to access tick_stopped and add got_idle_tick to avoid overloading inidle ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 87c9fe6 commit 2bc629a

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

‎kernel/time/tick-sched.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,9 @@ __setup("nohz=", setup_tick_nohz);
465465

466466
bool tick_nohz_tick_stopped(void)
467467
{
468-
return __this_cpu_read(tick_cpu_sched.tick_stopped);
468+
struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);
469+
470+
return ts->tick_stopped;
469471
}
470472

471473
bool tick_nohz_tick_stopped_cpu(int cpu)
@@ -1014,8 +1016,8 @@ bool tick_nohz_idle_got_tick(void)
10141016
{
10151017
struct tick_sched *ts = this_cpu_ptr(&tick_cpu_sched);
10161018

1017-
if (ts->inidle > 1) {
1018-
ts->inidle = 1;
1019+
if (ts->got_idle_tick) {
1020+
ts->got_idle_tick = 0;
10191021
return true;
10201022
}
10211023
return false;
@@ -1161,7 +1163,7 @@ static void tick_nohz_handler(struct clock_event_device *dev)
11611163
ktime_t now = ktime_get();
11621164

11631165
if (ts->inidle)
1164-
ts->inidle = 2;
1166+
ts->got_idle_tick = 1;
11651167

11661168
dev->next_event = KTIME_MAX;
11671169

@@ -1261,7 +1263,7 @@ static enum hrtimer_restart tick_sched_timer(struct hrtimer *timer)
12611263
ktime_t now = ktime_get();
12621264

12631265
if (ts->inidle)
1264-
ts->inidle = 2;
1266+
ts->got_idle_tick = 1;
12651267

12661268
tick_sched_do_timer(now);
12671269

‎kernel/time/tick-sched.h‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,24 @@ enum tick_nohz_mode {
4141
* @timer_expires: Anticipated timer expiration time (in case sched tick is stopped)
4242
* @timer_expires_base: Base time clock monotonic for @timer_expires
4343
* @do_timer_lst: CPU was the last one doing do_timer before going idle
44+
* @got_idle_tick: Tick timer function has run with @inidle set
4445
*/
4546
struct tick_sched {
4647
struct hrtimer sched_timer;
4748
unsigned long check_clocks;
4849
enum tick_nohz_mode nohz_mode;
50+
51+
unsigned int inidle : 1;
52+
unsigned int tick_stopped : 1;
53+
unsigned int idle_active : 1;
54+
unsigned int do_timer_last : 1;
55+
unsigned int got_idle_tick : 1;
56+
4957
ktime_t last_tick;
5058
ktime_t next_tick;
51-
int inidle;
52-
int tick_stopped;
5359
unsigned long idle_jiffies;
5460
unsigned long idle_calls;
5561
unsigned long idle_sleeps;
56-
int idle_active;
5762
ktime_t idle_entrytime;
5863
ktime_t idle_waketime;
5964
ktime_t idle_exittime;
@@ -64,7 +69,6 @@ struct tick_sched {
6469
u64 timer_expires_base;
6570
u64 next_timer;
6671
ktime_t idle_expires;
67-
int do_timer_last;
6872
atomic_t tick_dep_mask;
6973
};
7074

0 commit comments

Comments
 (0)