bridge: avoid unnecessary read of jiffies
authorstephen hemminger <stephen@networkplumber.org>
Tue, 7 Feb 2017 16:46:46 +0000 (08:46 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 7 Feb 2017 19:16:05 +0000 (14:16 -0500)
Jiffies is volatile so read it once.

Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
Acked-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br_fdb.c
net/bridge/br_input.c

index 5028691fa68a65a7abb959605c8dd988297c0660..5693168e88b646b698d13386187cfcd2c207ad89 100644 (file)
@@ -592,13 +592,15 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
                                br_warn(br, "received packet on %s with own address as source address (addr:%pM, vlan:%u)\n",
                                        source->dev->name, addr, vid);
                } else {
+                       unsigned long now = jiffies;
+
                        /* fastpath: update of existing entry */
                        if (unlikely(source != fdb->dst)) {
                                fdb->dst = source;
                                fdb_modified = true;
                        }
-                       if (jiffies != fdb->updated)
-                               fdb->updated = jiffies;
+                       if (now != fdb->updated)
+                               fdb->updated = now;
                        if (unlikely(added_by_user))
                                fdb->added_by_user = 1;
                        if (unlikely(fdb_modified))
index 220943f920d272113d2d22392197078ac5b75527..4615a9b3e26ce60c7205492ce3690c92a19c53dd 100644 (file)
@@ -195,11 +195,13 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb
        }
 
        if (dst) {
+               unsigned long now = jiffies;
+
                if (dst->is_local)
                        return br_pass_frame_up(skb);
 
-               if (jiffies != dst->used)
-                       dst->used = jiffies;
+               if (now != dst->used)
+                       dst->used = now;
                br_forward(dst->dst, skb, local_rcv, false);
        } else {
                if (!mcast_hit)