Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hrtimer: Align the hrtimer clock bases as well

We don't use cacheline_align here because that might waste lot of
space on 32bit machine with 64 bytes cachelines and on 64bit machines
with 128 bytes cachelines.

The size of struct hrtimer_clock_base is 64byte on 64bit and 32byte on
32bit machines. So we utilize the cache lines proper.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Cc: Preeti U Murthy <preeti@linux.vnet.ibm.com>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/r/20150414203501.498165771@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

+9 -1
+9 -1
include/linux/hrtimer.h
··· 130 130 struct task_struct *task; 131 131 }; 132 132 133 + #ifdef CONFIG_64BIT 134 + # define HRTIMER_CLOCK_BASE_ALIGN 64 135 + #else 136 + # define HRTIMER_CLOCK_BASE_ALIGN 32 137 + #endif 138 + 133 139 /** 134 140 * struct hrtimer_clock_base - the timer base for a specific clock 135 141 * @cpu_base: per cpu clock base ··· 153 147 struct timerqueue_head active; 154 148 ktime_t (*get_time)(void); 155 149 ktime_t offset; 156 - }; 150 + } __attribute__((__aligned__(HRTIMER_CLOCK_BASE_ALIGN))); 157 151 158 152 enum hrtimer_base_type { 159 153 HRTIMER_BASE_MONOTONIC, ··· 201 195 202 196 static inline void hrtimer_set_expires(struct hrtimer *timer, ktime_t time) 203 197 { 198 + BUILD_BUG_ON(sizeof(struct hrtimer_clock_base) > HRTIMER_CLOCK_BASE_ALIGN); 199 + 204 200 timer->node.expires = time; 205 201 timer->_softexpires = time; 206 202 }