From: Xin Long <lucien.xin@gmail.com>
To: Eric Dumazet <edumazet@google.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, eric.dumazet@gmail.com,
Jacob Moroni <jmoroni@google.com>,
Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Subject: Re: [PATCH net-next] sctp: fix busy polling
Date: Fri, 22 Dec 2023 11:08:03 -0500 [thread overview]
Message-ID: <CADvbK_e+J2nut4Q5NE3oAdUqEDXAFZrecs4zY+CrLE9ob8AtZg@mail.gmail.com> (raw)
In-Reply-To: <20231219170017.73902-1-edumazet@google.com>
On Tue, Dec 19, 2023 at 12:00 PM Eric Dumazet <edumazet@google.com> wrote:
>
> Busy polling while holding the socket lock makes litle sense,
> because incoming packets wont reach our receive queue.
>
> Fixes: 8465a5fcd1ce ("sctp: add support for busy polling to sctp protocol")
> Reported-by: Jacob Moroni <jmoroni@google.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
> Cc: Xin Long <lucien.xin@gmail.com>
> ---
> net/sctp/socket.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 5fb02bbb4b349ef9ab9c2790cccb30fb4c4e897c..6b9fcdb0952a0fe599ae5d1d1cc6fa9557a3a3bc 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -2102,6 +2102,10 @@ static int sctp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
> if (unlikely(flags & MSG_ERRQUEUE))
> return inet_recv_error(sk, msg, len, addr_len);
>
> + if (sk_can_busy_loop(sk) &&
> + skb_queue_empty_lockless(&sk->sk_receive_queue))
> + sk_busy_loop(sk, flags & MSG_DONTWAIT);
> +
Here is no any sk_state check, if the SCTP socket(TCP type) has been
already closed by peer, will sctp_recvmsg() block here?
Maybe here it needs a `!(sk->sk_shutdown & RCV_SHUTDOWN)` check,
which is set when it's closed by the peer.
Thanks
> lock_sock(sk);
>
> if (sctp_style(sk, TCP) && !sctp_sstate(sk, ESTABLISHED) &&
> @@ -9046,12 +9050,6 @@ struct sk_buff *sctp_skb_recv_datagram(struct sock *sk, int flags, int *err)
> if (sk->sk_shutdown & RCV_SHUTDOWN)
> break;
>
> - if (sk_can_busy_loop(sk)) {
> - sk_busy_loop(sk, flags & MSG_DONTWAIT);
> -
> - if (!skb_queue_empty_lockless(&sk->sk_receive_queue))
> - continue;
> - }
>
> /* User doesn't want to wait. */
> error = -EAGAIN;
> --
> 2.43.0.472.g3155946c3a-goog
>
next prev parent reply other threads:[~2023-12-22 16:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-19 17:00 [PATCH net-next] sctp: fix busy polling Eric Dumazet
2023-12-22 16:08 ` Xin Long [this message]
2023-12-22 17:05 ` Eric Dumazet
2023-12-22 18:34 ` Xin Long
2024-01-03 10:51 ` Eric Dumazet
2024-01-03 15:14 ` Xin Long
2024-01-03 16:06 ` Eric Dumazet
2024-01-04 10:30 ` patchwork-bot+netdevbpf
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=CADvbK_e+J2nut4Q5NE3oAdUqEDXAFZrecs4zY+CrLE9ob8AtZg@mail.gmail.com \
--to=lucien.xin@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=jmoroni@google.com \
--cc=kuba@kernel.org \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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 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).