Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 83b1bc12 authored by Li RongQing's avatar Li RongQing Committed by David S. Miller
Browse files

tun: align write-heavy flow entry members to a cache line



tun flow entry 'updated' fields are written when receive
every packet. Thus if a flow is receiving packets from a
particular flow entry, it'll cause false-sharing with
all the other who has looked it up, so move it in its own
cache line

and update 'queue_index' and 'update' field only when
they are changed to reduce the cache false-sharing.

Signed-off-by: default avatarZhang Yu <zhangyu31@baidu.com>
Signed-off-by: default avatarWang Li <wangli39@baidu.com>
Signed-off-by: default avatarLi RongQing <lirongqing@baidu.com>
Acked-by: default avatarJason Wang <jasowang@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7a35a50d
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ struct tun_flow_entry {
	u32 rxhash;
	u32 rps_rxhash;
	int queue_index;
	unsigned long updated;
	unsigned long updated ____cacheline_aligned_in_smp;
};

#define TUN_NUM_FLOW_ENTRIES 1024
@@ -539,7 +539,9 @@ static void tun_flow_update(struct tun_struct *tun, u32 rxhash,
	e = tun_flow_find(head, rxhash);
	if (likely(e)) {
		/* TODO: keep queueing to old queue until it's empty? */
		if (e->queue_index != queue_index)
			e->queue_index = queue_index;
		if (e->updated != jiffies)
			e->updated = jiffies;
		sock_rps_record_flow_hash(e->rps_rxhash);
	} else {