Skip to content

Commit

Permalink
vxlan: Read jiffies once when updating FDB 'used' time
Browse files Browse the repository at this point in the history
Avoid two volatile reads in the data path. Instead, read jiffies once
and only if an FDB entry was found.

Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://patch.msgid.link/20250204145549.1216254-3-idosch@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Ido Schimmel authored and Jakub Kicinski committed Feb 6, 2025
1 parent f6205f8 commit 1370c45
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/net/vxlan/vxlan_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,12 @@ static struct vxlan_fdb *vxlan_find_mac(struct vxlan_dev *vxlan,
struct vxlan_fdb *f;

f = __vxlan_find_mac(vxlan, mac, vni);
if (f && READ_ONCE(f->used) != jiffies)
WRITE_ONCE(f->used, jiffies);
if (f) {
unsigned long now = jiffies;

if (READ_ONCE(f->used) != now)
WRITE_ONCE(f->used, now);
}

return f;
}
Expand Down

0 comments on commit 1370c45

Please sign in to comment.