[PATCH v2 11/37] hrtimer: Change boolean struct members into bitfield

Anna-Maria Gleixner
2017-10-22T21:43:13Z

[-- Attachment #1: hrtimer--Change-bool-into-bitfield.patch --]
[-- Type: text/plain, Size: 1908 bytes --]

The struct member migration_enabled and nohz_active of struct
hrtimer_cpu_base are boolean. Thus, they cannot easily be packed with the
subsequent bitfield when CONFIG_HIGH_RES_TIMERS is enabled.

Change the type of boolean struct members into bitfield. Adapt the function
timers_update_migration() which updates those members.

No functional change.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Anna-Maria Gleixner <anna-maria@linutronix.de>
---
include/linux/hrtimer.h | 4 ++--
kernel/time/timer.c | 6 ++++--
2 files changed, 6 insertions(+), 4 deletions(-)

--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -184,8 +184,8 @@ struct hrtimer_cpu_base {
unsigned int cpu;
unsigned int active_bases;
unsigned int clock_was_set_seq;
- bool migration_enabled;
- bool nohz_active;
+ unsigned int migration_enabled : 1,
+ nohz_active : 1;
#ifdef CONFIG_HIGH_RES_TIMERS
unsigned int in_hrtirq : 1,
hres_active : 1,
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -216,6 +216,7 @@ unsigned int sysctl_timer_migration = 1;
void timers_update_migration(bool update_nohz)
{
bool on = sysctl_timer_migration && tick_nohz_active;
+ struct hrtimer_cpu_base *base;
unsigned int cpu;

/* Avoid the loop, if nothing to update */
@@ -225,12 +226,13 @@ void timers_update_migration(bool update
for_each_possible_cpu(cpu) {
per_cpu(timer_bases[BASE_STD].migration_enabled, cpu) = on;
per_cpu(timer_bases[BASE_DEF].migration_enabled, cpu) = on;
- per_cpu(hrtimer_bases.migration_enabled, cpu) = on;
+ base = per_cpu_ptr(&hrtimer_bases, cpu);
+ base->migration_enabled = on;
if (!update_nohz)
continue;
per_cpu(timer_bases[BASE_STD].nohz_active, cpu) = true;
per_cpu(timer_bases[BASE_DEF].nohz_active, cpu) = true;
- per_cpu(hrtimer_bases.nohz_active, cpu) = true;
+ base->nohz_active = true;
}
}