netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemb@google.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, Willem de Bruijn <willemb@google.com>
Subject: [PATCH net-next 3/7] packet: rollover prepare: single return in packet_rcv_has_room
Date: Wed,  6 May 2015 14:27:13 -0400	[thread overview]
Message-ID: <1430936837-22655-4-git-send-email-willemb@google.com> (raw)
In-Reply-To: <1430936837-22655-1-git-send-email-willemb@google.com>

From: Willem de Bruijn <willemb@google.com>

Convert

  if (x) {
    A;
    return y;
  }
  B;
  return y;

Into

  if (x) {
    A;
  } else {
    B;
  }

  return y;

No other changes.

Signed-off-by: Willem de Bruijn <willemb@google.com>
---
 net/packet/af_packet.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index f8ec909..8275056 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1239,20 +1239,21 @@ static bool packet_rcv_has_room(struct packet_sock *po, struct sk_buff *skb)
 	struct sock *sk = &po->sk;
 	bool has_room;
 
-	if (po->prot_hook.func != tpacket_rcv)
-		return (atomic_read(&sk->sk_rmem_alloc) + skb->truesize)
-			<= sk->sk_rcvbuf;
-
-	spin_lock(&sk->sk_receive_queue.lock);
-	if (po->tp_version == TPACKET_V3)
-		has_room = prb_lookup_block(po, &po->rx_ring,
-					    po->rx_ring.prb_bdqc.kactive_blk_num,
-					    TP_STATUS_KERNEL);
-	else
-		has_room = packet_lookup_frame(po, &po->rx_ring,
-					       po->rx_ring.head,
-					       TP_STATUS_KERNEL);
-	spin_unlock(&sk->sk_receive_queue.lock);
+	if (po->prot_hook.func != tpacket_rcv) {
+		has_room = (atomic_read(&sk->sk_rmem_alloc) + skb->truesize)
+			   <= sk->sk_rcvbuf;
+	} else {
+		spin_lock(&sk->sk_receive_queue.lock);
+		if (po->tp_version == TPACKET_V3)
+			has_room = prb_lookup_block(po, &po->rx_ring,
+						    po->rx_ring.prb_bdqc.kactive_blk_num,
+						    TP_STATUS_KERNEL);
+		else
+			has_room = packet_lookup_frame(po, &po->rx_ring,
+						       po->rx_ring.head,
+						       TP_STATUS_KERNEL);
+		spin_unlock(&sk->sk_receive_queue.lock);
+	}
 
 	return has_room;
 }
-- 
2.2.0.rc0.207.ga3a616c

  parent reply	other threads:[~2015-05-06 18:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-06 18:27 [PATCH net-next 0/7] packet: refine rollover Willem de Bruijn
2015-05-06 18:27 ` [PATCH net-next 1/7] packet: rollover prepare: move code out of callsites Willem de Bruijn
2015-05-06 18:27 ` [PATCH net-next 2/7] packet: rollover prepare: per-socket state Willem de Bruijn
2015-05-06 18:27 ` Willem de Bruijn [this message]
2015-05-07 13:49   ` [PATCH net-next 3/7] packet: rollover prepare: single return in packet_rcv_has_room David Laight
2015-05-07 16:05     ` Willem de Bruijn
2015-05-06 18:27 ` [PATCH net-next 4/7] packet: rollover lock contention avoidance Willem de Bruijn
2015-05-06 19:44   ` Eric Dumazet
2015-05-06 21:05     ` Willem de Bruijn
2015-05-06 18:27 ` [PATCH net-next 5/7] packet: rollover only to socket with headroom Willem de Bruijn
2015-05-06 18:27 ` [PATCH net-next 6/7] packet: rollover huge flows before small flows Willem de Bruijn
2015-05-06 19:34   ` Eric Dumazet
2015-05-06 20:06     ` Willem de Bruijn
2015-05-06 20:16       ` Eric Dumazet
2015-05-06 20:19         ` Willem de Bruijn
2015-05-06 18:27 ` [PATCH net-next 7/7] packet: rollover statistics Willem de Bruijn

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=1430936837-22655-4-git-send-email-willemb@google.com \
    --to=willemb@google.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /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 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).