netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/2] bonding: slight optimization and avoid spam for bond xmit path
@ 2014-03-25  9:00 Ding Tianhong
  2014-03-25  9:00 ` [PATCH net-next v2 1/2] bonding: slight optimization " Ding Tianhong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ding Tianhong @ 2014-03-25  9:00 UTC (permalink / raw)
  To: fubar, vfalico, andy, joe, kaber; +Cc: davem, netdev

v1->v2: Add ratelimit for debugging is not a good idea, it will miss some message
	if the user turns the debugging on, so remove the patch 3.
	use net_err_ratelimited instead of pr_err_ratelimited and use __func__ instead of
	bond_xmit_broadcast().

Ding Tianhong (2):
  bonding: slight optimization for bond xmit path
  bonding: ratelimit pr_err() for bond xmit broadcast

 drivers/net/bonding/bond_main.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

-- 
1.8.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net-next v2 1/2] bonding: slight optimization for bond xmit path
  2014-03-25  9:00 [PATCH net-next v2 0/2] bonding: slight optimization and avoid spam for bond xmit path Ding Tianhong
@ 2014-03-25  9:00 ` Ding Tianhong
  2014-03-25  9:00 ` [PATCH net-next v2 2/2] bonding: ratelimit pr_err() for bond xmit broadcast Ding Tianhong
  2014-03-26 20:42 ` [PATCH net-next v2 0/2] bonding: slight optimization and avoid spam for bond xmit path David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Ding Tianhong @ 2014-03-25  9:00 UTC (permalink / raw)
  To: fubar, vfalico, andy, joe, kaber; +Cc: davem, netdev

Add unlikely() micro to the unlikely conditions in the bond
xmit path for slight optimization.

Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
---
 drivers/net/bonding/bond_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index e717db3..ee17c24 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2957,7 +2957,7 @@ static bool bond_flow_dissect(struct bonding *bond, struct sk_buff *skb,
 	fk->ports = 0;
 	noff = skb_network_offset(skb);
 	if (skb->protocol == htons(ETH_P_IP)) {
-		if (!pskb_may_pull(skb, noff + sizeof(*iph)))
+		if (unlikely(!pskb_may_pull(skb, noff + sizeof(*iph))))
 			return false;
 		iph = ip_hdr(skb);
 		fk->src = iph->saddr;
@@ -2966,7 +2966,7 @@ static bool bond_flow_dissect(struct bonding *bond, struct sk_buff *skb,
 		if (!ip_is_fragment(iph))
 			proto = iph->protocol;
 	} else if (skb->protocol == htons(ETH_P_IPV6)) {
-		if (!pskb_may_pull(skb, noff + sizeof(*iph6)))
+		if (unlikely(!pskb_may_pull(skb, noff + sizeof(*iph6))))
 			return false;
 		iph6 = ipv6_hdr(skb);
 		fk->src = (__force __be32)ipv6_addr_hash(&iph6->saddr);
@@ -3768,7 +3768,7 @@ static netdev_tx_t bond_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	 * If we risk deadlock from transmitting this in the
 	 * netpoll path, tell netpoll to queue the frame for later tx
 	 */
-	if (is_netpoll_tx_blocked(dev))
+	if (unlikely(is_netpoll_tx_blocked(dev)))
 		return NETDEV_TX_BUSY;
 
 	rcu_read_lock();
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net-next v2 2/2] bonding: ratelimit pr_err() for bond xmit broadcast
  2014-03-25  9:00 [PATCH net-next v2 0/2] bonding: slight optimization and avoid spam for bond xmit path Ding Tianhong
  2014-03-25  9:00 ` [PATCH net-next v2 1/2] bonding: slight optimization " Ding Tianhong
@ 2014-03-25  9:00 ` Ding Tianhong
  2014-03-26 20:42 ` [PATCH net-next v2 0/2] bonding: slight optimization and avoid spam for bond xmit path David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Ding Tianhong @ 2014-03-25  9:00 UTC (permalink / raw)
  To: fubar, vfalico, andy, joe, kaber; +Cc: davem, netdev

It may spam if the system is out of the memory, add ratelimit for it.

Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
---
 drivers/net/bonding/bond_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index ee17c24..52c4c77 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3656,8 +3656,8 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev)
 			struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
 
 			if (!skb2) {
-				pr_err("%s: Error: bond_xmit_broadcast(): skb_clone() failed\n",
-				       bond_dev->name);
+				net_err_ratelimited("%s: Error: %s: skb_clone() failed\n",
+						    bond_dev->name, __func__);
 				continue;
 			}
 			/* bond_dev_queue_xmit always returns 0 */
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v2 0/2] bonding: slight optimization and avoid spam for bond xmit path
  2014-03-25  9:00 [PATCH net-next v2 0/2] bonding: slight optimization and avoid spam for bond xmit path Ding Tianhong
  2014-03-25  9:00 ` [PATCH net-next v2 1/2] bonding: slight optimization " Ding Tianhong
  2014-03-25  9:00 ` [PATCH net-next v2 2/2] bonding: ratelimit pr_err() for bond xmit broadcast Ding Tianhong
@ 2014-03-26 20:42 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2014-03-26 20:42 UTC (permalink / raw)
  To: dingtianhong; +Cc: fubar, vfalico, andy, joe, kaber, netdev

From: Ding Tianhong <dingtianhong@huawei.com>
Date: Tue, 25 Mar 2014 17:00:08 +0800

> v1->v2: Add ratelimit for debugging is not a good idea, it will miss some message
> 	if the user turns the debugging on, so remove the patch 3.
> 	use net_err_ratelimited instead of pr_err_ratelimited and use __func__ instead of
> 	bond_xmit_broadcast().

Series applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-03-26 20:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-25  9:00 [PATCH net-next v2 0/2] bonding: slight optimization and avoid spam for bond xmit path Ding Tianhong
2014-03-25  9:00 ` [PATCH net-next v2 1/2] bonding: slight optimization " Ding Tianhong
2014-03-25  9:00 ` [PATCH net-next v2 2/2] bonding: ratelimit pr_err() for bond xmit broadcast Ding Tianhong
2014-03-26 20:42 ` [PATCH net-next v2 0/2] bonding: slight optimization and avoid spam for bond xmit path David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).