summaryrefslogtreecommitdiffstats
path: root/drivers/net/tun.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2019-10-09 12:20:02 -0400
committerJakub Kicinski <jakub.kicinski@netronome.com>2019-10-10 00:29:33 -0400
commit4ffdd22e49f47db543906d75453a0048a53071ab (patch)
tree3fe252f49f9e7e4997a70c124594f6b459ee709b /drivers/net/tun.c
parente37542ba111f3974dc622ae0a21c1787318de500 (diff)
tun: remove possible false sharing in tun_flow_update()
As mentioned in https://github.com/google/ktsan/wiki/READ_ONCE-and-WRITE_ONCE#it-may-improve-performance a C compiler can legally transform if (e->queue_index != queue_index) e->queue_index = queue_index; to : e->queue_index = queue_index; Note that the code using jiffies has no issue, since jiffies has volatile attribute. if (e->updated != jiffies) e->updated = jiffies; Fixes: 83b1bc122cab ("tun: align write-heavy flow entry members to a cache line") Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Zhang Yu <zhangyu31@baidu.com> Cc: Wang Li <wangli39@baidu.com> Cc: Li RongQing <lirongqing@baidu.com> Acked-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r--drivers/net/tun.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 812dc3a65efb..a8d3141582a5 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -526,8 +526,8 @@ static void tun_flow_update(struct tun_struct *tun, u32 rxhash,
526 e = tun_flow_find(head, rxhash); 526 e = tun_flow_find(head, rxhash);
527 if (likely(e)) { 527 if (likely(e)) {
528 /* TODO: keep queueing to old queue until it's empty? */ 528 /* TODO: keep queueing to old queue until it's empty? */
529 if (e->queue_index != queue_index) 529 if (READ_ONCE(e->queue_index) != queue_index)
530 e->queue_index = queue_index; 530 WRITE_ONCE(e->queue_index, queue_index);
531 if (e->updated != jiffies) 531 if (e->updated != jiffies)
532 e->updated = jiffies; 532 e->updated = jiffies;
533 sock_rps_record_flow_hash(e->rps_rxhash); 533 sock_rps_record_flow_hash(e->rps_rxhash);