From: Stephen Hemminger <stephen@networkplumber.org>
To: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Cc: netdev@vger.kernel.org, roopa@cumulusnetworks.com,
bridge@lists.linux-foundation.org, davem@davemloft.net
Subject: [Bridge] [PATCH net-next] bridge: avoid unnecessary read of jiffies
Date: Tue, 7 Feb 2017 08:46:46 -0800 [thread overview]
Message-ID: <20170207084646.70dc888a@xeon-e3> (raw)
In-Reply-To: <1486227909-18319-5-git-send-email-nikolay@cumulusnetworks.com>
Jiffies is volatile so read it once.
Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
net/bridge/br_fdb.c | 6 ++++--
net/bridge/br_input.c | 6 ++++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 5028691fa68a..5693168e88b6 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -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))
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 220943f920d2..4615a9b3e26c 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -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)
--
2.11.0
WARNING: multiple messages have this Message-ID (diff)
From: Stephen Hemminger <stephen@networkplumber.org>
To: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Cc: netdev@vger.kernel.org, roopa@cumulusnetworks.com,
bridge@lists.linux-foundation.org, davem@davemloft.net
Subject: [PATCH net-next] bridge: avoid unnecessary read of jiffies
Date: Tue, 7 Feb 2017 08:46:46 -0800 [thread overview]
Message-ID: <20170207084646.70dc888a@xeon-e3> (raw)
In-Reply-To: <1486227909-18319-5-git-send-email-nikolay@cumulusnetworks.com>
Jiffies is volatile so read it once.
Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
---
net/bridge/br_fdb.c | 6 ++++--
net/bridge/br_input.c | 6 ++++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index 5028691fa68a..5693168e88b6 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -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))
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 220943f920d2..4615a9b3e26c 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -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)
--
2.11.0
next prev parent reply other threads:[~2017-02-07 16:46 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-04 17:05 [Bridge] [PATCH net-next 0/4] bridge: improve cache utilization Nikolay Aleksandrov
2017-02-04 17:05 ` Nikolay Aleksandrov via Bridge
2017-02-04 17:05 ` [Bridge] [PATCH net-next 1/4] bridge: modify bridge and port to have often accessed fields in one cache line Nikolay Aleksandrov
2017-02-04 17:05 ` Nikolay Aleksandrov
2017-02-04 17:05 ` [Bridge] [PATCH net-next 2/4] bridge: move to workqueue gc Nikolay Aleksandrov
2017-02-04 17:05 ` Nikolay Aleksandrov
2017-02-04 17:05 ` [Bridge] [PATCH net-next 3/4] bridge: move write-heavy fdb members in their own cache line Nikolay Aleksandrov
2017-02-04 17:05 ` Nikolay Aleksandrov
2017-02-04 17:05 ` [Bridge] [PATCH net-next 4/4] bridge: fdb: write to used and updated at most once per jiffy Nikolay Aleksandrov
2017-02-04 17:05 ` Nikolay Aleksandrov
2017-02-07 16:46 ` Stephen Hemminger [this message]
2017-02-07 16:46 ` [PATCH net-next] bridge: avoid unnecessary read of jiffies Stephen Hemminger
2017-02-07 16:56 ` [Bridge] " Nikolay Aleksandrov
2017-02-07 16:56 ` Nikolay Aleksandrov via Bridge
2017-02-07 19:16 ` [Bridge] " David Miller
2017-02-07 19:16 ` David Miller
2017-02-04 21:46 ` [Bridge] [PATCH net-next 0/4] bridge: improve cache utilization Stephen Hemminger
2017-02-04 21:46 ` Stephen Hemminger
2017-02-04 21:58 ` [Bridge] " Nikolay Aleksandrov
2017-02-04 21:58 ` Nikolay Aleksandrov
2017-02-07 3:53 ` [Bridge] " David Miller
2017-02-07 3:53 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170207084646.70dc888a@xeon-e3 \
--to=stephen@networkplumber.org \
--cc=bridge@lists.linux-foundation.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=nikolay@cumulusnetworks.com \
--cc=roopa@cumulusnetworks.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.