From: Soheil Hassas Yeganeh <soheil@google.com>
To: Eric Dumazet <edumazet@google.com>
Cc: "David S . Miller" <davem@davemloft.net>,
netdev <netdev@vger.kernel.org>, Alexei Starovoitov <ast@fb.com>,
Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
Eric Dumazet <eric.dumazet@gmail.com>
Subject: Re: [PATCH v2 net-next 2/7] tcp: do not block bh during prequeue processing
Date: Fri, 29 Apr 2016 09:20:19 -0400 [thread overview]
Message-ID: <CACSApvY_StBa121b8o+QDR7F+aPVT2Xj+AFxdWZ-HvEzcKie7w@mail.gmail.com> (raw)
In-Reply-To: <1461899449-8096-3-git-send-email-edumazet@google.com>
On Thu, Apr 28, 2016 at 11:10 PM, Eric Dumazet <edumazet@google.com> wrote:
> AFAIK, nothing in current TCP stack absolutely wants BH
> being disabled once socket is owned by a thread running in
> process context.
>
> As mentioned in my prior patch ("tcp: give prequeue mode some care"),
> processing a batch of packets might take time, better not block BH
> at all.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
> ---
> net/ipv4/tcp.c | 4 ----
> net/ipv4/tcp_input.c | 30 ++----------------------------
> 2 files changed, 2 insertions(+), 32 deletions(-)
>
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index b24c6ed4a04f..4787f86ae64c 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -1449,12 +1449,8 @@ static void tcp_prequeue_process(struct sock *sk)
>
> NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPPREQUEUED);
>
> - /* RX process wants to run with disabled BHs, though it is not
> - * necessary */
> - local_bh_disable();
> while ((skb = __skb_dequeue(&tp->ucopy.prequeue)) != NULL)
> sk_backlog_rcv(sk, skb);
> - local_bh_enable();
>
> /* Clear memory counter. */
> tp->ucopy.memory = 0;
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index ac85fb42a5a2..6171f92be090 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -4611,14 +4611,12 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)
>
> __set_current_state(TASK_RUNNING);
>
> - local_bh_enable();
> if (!skb_copy_datagram_msg(skb, 0, tp->ucopy.msg, chunk)) {
> tp->ucopy.len -= chunk;
> tp->copied_seq += chunk;
> eaten = (chunk == skb->len);
> tcp_rcv_space_adjust(sk);
> }
> - local_bh_disable();
> }
>
> if (eaten <= 0) {
> @@ -5134,7 +5132,6 @@ static int tcp_copy_to_iovec(struct sock *sk, struct sk_buff *skb, int hlen)
> int chunk = skb->len - hlen;
> int err;
>
> - local_bh_enable();
> if (skb_csum_unnecessary(skb))
> err = skb_copy_datagram_msg(skb, hlen, tp->ucopy.msg, chunk);
> else
> @@ -5146,32 +5143,9 @@ static int tcp_copy_to_iovec(struct sock *sk, struct sk_buff *skb, int hlen)
> tcp_rcv_space_adjust(sk);
> }
>
> - local_bh_disable();
> return err;
> }
>
> -static __sum16 __tcp_checksum_complete_user(struct sock *sk,
> - struct sk_buff *skb)
> -{
> - __sum16 result;
> -
> - if (sock_owned_by_user(sk)) {
> - local_bh_enable();
> - result = __tcp_checksum_complete(skb);
> - local_bh_disable();
> - } else {
> - result = __tcp_checksum_complete(skb);
> - }
> - return result;
> -}
> -
> -static inline bool tcp_checksum_complete_user(struct sock *sk,
> - struct sk_buff *skb)
> -{
> - return !skb_csum_unnecessary(skb) &&
> - __tcp_checksum_complete_user(sk, skb);
> -}
> -
> /* Does PAWS and seqno based validation of an incoming segment, flags will
> * play significant role here.
> */
> @@ -5386,7 +5360,7 @@ void tcp_rcv_established(struct sock *sk, struct sk_buff *skb,
> }
> }
> if (!eaten) {
> - if (tcp_checksum_complete_user(sk, skb))
> + if (tcp_checksum_complete(skb))
> goto csum_error;
>
> if ((int)skb->truesize > sk->sk_forward_alloc)
> @@ -5430,7 +5404,7 @@ no_ack:
> }
>
> slow_path:
> - if (len < (th->doff << 2) || tcp_checksum_complete_user(sk, skb))
> + if (len < (th->doff << 2) || tcp_checksum_complete(skb))
> goto csum_error;
>
> if (!th->ack && !th->rst && !th->syn)
> --
> 2.8.0.rc3.226.g39d4020
>
Very nice!
next prev parent reply other threads:[~2016-04-29 13:21 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-29 3:10 [PATCH v2 net-next 0/7] net: make TCP preemptible Eric Dumazet
2016-04-29 3:10 ` [PATCH v2 net-next 1/7] tcp: do not assume TCP code is non preemptible Eric Dumazet
2016-04-29 13:18 ` Soheil Hassas Yeganeh
2016-04-29 14:37 ` Eric Dumazet
2016-04-29 14:41 ` Soheil Hassas Yeganeh
2016-04-29 3:10 ` [PATCH v2 net-next 2/7] tcp: do not block bh during prequeue processing Eric Dumazet
2016-04-29 13:20 ` Soheil Hassas Yeganeh [this message]
2016-04-29 3:10 ` [PATCH v2 net-next 3/7] dccp: do not assume DCCP code is non preemptible Eric Dumazet
2016-04-29 13:21 ` Soheil Hassas Yeganeh
2016-04-29 3:10 ` [PATCH v2 net-next 4/7] udp: prepare for non BH masking at backlog processing Eric Dumazet
2016-04-29 13:23 ` Soheil Hassas Yeganeh
2016-04-29 3:10 ` [PATCH v2 net-next 5/7] sctp: prepare for socket backlog behavior change Eric Dumazet
2016-04-29 3:10 ` [PATCH v2 net-next 6/7] net: do not block BH while processing socket backlog Eric Dumazet
2016-04-29 13:37 ` Soheil Hassas Yeganeh
2016-04-29 3:10 ` [PATCH v2 net-next 7/7] tcp: make tcp_sendmsg() aware of " Eric Dumazet
2016-04-29 4:43 ` Alexei Starovoitov
2016-04-29 5:05 ` Eric Dumazet
2016-04-29 5:19 ` Alexei Starovoitov
2016-04-29 13:13 ` Soheil Hassas Yeganeh
2016-04-29 20:39 ` [PATCH v2 net-next 0/7] net: make TCP preemptible David Miller
2016-04-29 20:53 ` Eric Dumazet
2016-04-30 9:57 ` Julian Anastasov
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=CACSApvY_StBa121b8o+QDR7F+aPVT2Xj+AFxdWZ-HvEzcKie7w@mail.gmail.com \
--to=soheil@google.com \
--cc=ast@fb.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=marcelo.leitner@gmail.com \
--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).