diff options
author | Shakeel Butt | 2022-08-26 23:06:42 +0000 |
---|---|---|
committer | Andrew Morton | 2022-09-26 19:46:29 -0700 |
commit | e6ad640bc404eb298dd1880113131768ddf5c6a8 (patch) | |
tree | f72c01caf19e88d74482af862b9378f6f19893b9 /include/linux/cache.h | |
parent | 974f4367dd315acc15ad4a6453f8304aea60dfbd (diff) |
mm: deduplicate cacheline padding code
There are three users (mmzone.h, memcontrol.h, page_counter.h) using
similar code for forcing cacheline padding between fields of different
structures. Dedup that code.
Link: https://lkml.kernel.org/r/20220826230642.566725-1-shakeelb@google.com
Signed-off-by: Shakeel Butt <shakeelb@google.com>
Suggested-by: Feng Tang <feng.tang@intel.com>
Reviewed-by: Feng Tang <feng.tang@intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'include/linux/cache.h')
-rw-r--r-- | include/linux/cache.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/cache.h b/include/linux/cache.h index d742c57eaee5..5da1bbd96154 100644 --- a/include/linux/cache.h +++ b/include/linux/cache.h @@ -85,4 +85,17 @@ #define cache_line_size() L1_CACHE_BYTES #endif +/* + * Helper to add padding within a struct to ensure data fall into separate + * cachelines. + */ +#if defined(CONFIG_SMP) +struct cacheline_padding { + char x[0]; +} ____cacheline_internodealigned_in_smp; +#define CACHELINE_PADDING(name) struct cacheline_padding name +#else +#define CACHELINE_PADDING(name) +#endif + #endif /* __LINUX_CACHE_H */ |