[PATCH 12/17] prmem: linked list: set alignment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As preparation to using write rare on the nodes of various types of
lists, specify that the fields in the basic data structures must be
aligned to sizeof(void *)

It is meant to ensure that any static allocation will not cross a page
boundary, to allow pointers to be updated in one step.

Signed-off-by: Igor Stoppa <igor.stoppa@xxxxxxxxxx>
CC: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
CC: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
CC: Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx>
CC: Alexey Dobriyan <adobriyan@xxxxxxxxx>
CC: Pekka Enberg <penberg@xxxxxxxxxx>
CC: "Paul E. McKenney" <paulmck@xxxxxxxxxxxxxxxxxx>
CC: Lihao Liang <lianglihao@xxxxxxxxxx>
CC: linux-kernel@xxxxxxxxxxxxxxx
---
 include/linux/types.h | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/include/linux/types.h b/include/linux/types.h
index 9834e90aa010..53609bbdcf0f 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -183,17 +183,29 @@ typedef struct {
 } atomic64_t;
 #endif
 
+#ifdef CONFIG_PRMEM
 struct list_head {
-	struct list_head *next, *prev;
-};
+	struct list_head *next __aligned(sizeof(void *));
+	struct list_head *prev __aligned(sizeof(void *));
+} __aligned(sizeof(void *));
 
-struct hlist_head {
-	struct hlist_node *first;
+struct hlist_node {
+	struct hlist_node *next __aligned(sizeof(void *));
+	struct hlist_node **pprev __aligned(sizeof(void *));
+} __aligned(sizeof(void *));
+#else
+struct list_head {
+	struct list_head *next, *prev;
 };
 
 struct hlist_node {
 	struct hlist_node *next, **pprev;
 };
+#endif
+
+struct hlist_head {
+	struct hlist_node *first;
+};
 
 struct ustat {
 	__kernel_daddr_t	f_tfree;
-- 
2.17.1




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux Kernel]     [Linux Kernel Hardening]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux