Skip to contentSkip to conversation

netfilter: flowtable: reorder nf_flowtable struct members

PATCH New Florian Westphal 1 participant 1 message Nov 20, 2023

Subsystems (2)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 netfilter: flowtable: reorder nf_flowtable struct members

Place the read-mostly parts accessed by the datapath first.

In particular, we do access ->flags member (to see if HW offload is enabled) for every single packet, but this is placed in the 5th cacheline.

priority could stay where it is, but move it too to cover a hole.

---
 include/net/netfilter/nf_flow_table.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
include/net/netfilter/nf_flow_table.h +5 -4
index fe1507c1db82..36351e441316 100644
@@ -72,12 +72,13 @@ enum nf_flowtable_flags {
 };
 
 struct nf_flowtable {
-	struct list_head		list;
-	struct rhashtable		rhashtable;
-	int				priority;
+	unsigned int			flags;		/* readonly in datapath */
+	int				priority;	/* control path (padding hole) */
+	struct rhashtable		rhashtable;	/* datapath, read-mostly members come first */
+
+	struct list_head		list;		/* slowpath parts */
 	const struct nf_flowtable_type	*type;
 	struct delayed_work		gc_work;
-	unsigned int			flags;
 	struct flow_block		flow_block;
 	struct rw_semaphore		flow_block_lock; /* Guards flow_block */
 	possible_net_t			net;
Signature · 1 line
2.41.0