Skip to content

Commit 1370c45

Browse files
idoschkuba-moo
authored andcommitted
vxlan: Read jiffies once when updating FDB 'used' time
Avoid two volatile reads in the data path. Instead, read jiffies once and only if an FDB entry was found. Reviewed-by: Petr Machata <[email protected]> Signed-off-by: Ido Schimmel <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Reviewed-by: Nikolay Aleksandrov <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f6205f8 commit 1370c45

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/net/vxlan/vxlan_core.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,12 @@ static struct vxlan_fdb *vxlan_find_mac(struct vxlan_dev *vxlan,
434434
struct vxlan_fdb *f;
435435

436436
f = __vxlan_find_mac(vxlan, mac, vni);
437-
if (f && READ_ONCE(f->used) != jiffies)
438-
WRITE_ONCE(f->used, jiffies);
437+
if (f) {
438+
unsigned long now = jiffies;
439+
440+
if (READ_ONCE(f->used) != now)
441+
WRITE_ONCE(f->used, now);
442+
}
439443

440444
return f;
441445
}

0 commit comments

Comments
 (0)