Commit 329c8d84 authored by Eric Dumazet's avatar Eric Dumazet Committed by Linus Torvalds

time: SMP friendly alignment of struct clocksource

struct clocksource is a critical data structure.

Most of its fields are read only, some of them are heavily modified at each
timer interrupt.

It makes sense to separate those fields and make sure they all share one
cache line, or at least the minimum for machines with small cache lines.

[akpm@linux-foundation.org: build fix]
Signed-off-by: default avatarEric Dumazet <dada1@cosmosbay.com>
Acked-by: default avatarJohn Stultz <johnstul@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f75d222b
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <linux/timex.h> #include <linux/timex.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/cache.h>
#include <linux/timer.h> #include <linux/timer.h>
#include <asm/div64.h> #include <asm/div64.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -52,6 +53,9 @@ struct clocksource; ...@@ -52,6 +53,9 @@ struct clocksource;
* @xtime_interval: Used internally by timekeeping core, please ignore. * @xtime_interval: Used internally by timekeeping core, please ignore.
*/ */
struct clocksource { struct clocksource {
/*
* First part of structure is read mostly
*/
char *name; char *name;
struct list_head list; struct list_head list;
int rating; int rating;
...@@ -63,8 +67,15 @@ struct clocksource { ...@@ -63,8 +67,15 @@ struct clocksource {
cycle_t (*vread)(void); cycle_t (*vread)(void);
/* timekeeping specific data, ignore */ /* timekeeping specific data, ignore */
cycle_t cycle_last, cycle_interval; cycle_t cycle_interval;
u64 xtime_nsec, xtime_interval; u64 xtime_interval;
/*
* Second part is written at each timer interrupt
* Keep it in a different cache line to dirty no
* more than one cache line.
*/
cycle_t cycle_last ____cacheline_aligned_in_smp;
u64 xtime_nsec;
s64 error; s64 error;
#ifdef CONFIG_CLOCKSOURCE_WATCHDOG #ifdef CONFIG_CLOCKSOURCE_WATCHDOG
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment