From: Jakub Sitnicki <jakub@cloudflare.com>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
duanxiongchun@bytedance.com, wangdongdong.6@bytedance.com,
jiang.wang@bytedance.com, Cong Wang <cong.wang@bytedance.com>,
John Fastabend <john.fastabend@gmail.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Lorenz Bauer <lmb@cloudflare.com>
Subject: Re: [Patch bpf-next v4 02/11] skmsg: introduce a spinlock to protect ingress_msg
Date: Thu, 11 Mar 2021 12:28:01 +0100 [thread overview]
Message-ID: <871rcm3p6m.fsf@cloudflare.com> (raw)
In-Reply-To: <20210310053222.41371-3-xiyou.wangcong@gmail.com>
On Wed, Mar 10, 2021 at 06:32 AM CET, Cong Wang wrote:
> From: Cong Wang <cong.wang@bytedance.com>
>
> Currently we rely on lock_sock to protect ingress_msg,
> it is too big for this, we can actually just use a spinlock
> to protect this list like protecting other skb queues.
>
> __tcp_bpf_recvmsg() is still special because of peeking,
> it still has to use lock_sock.
>
> Cc: John Fastabend <john.fastabend@gmail.com>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
> Cc: Jakub Sitnicki <jakub@cloudflare.com>
> Cc: Lorenz Bauer <lmb@cloudflare.com>
> Signed-off-by: Cong Wang <cong.wang@bytedance.com>
> ---
One nit below.
Acked-by: Jakub Sitnicki <jakub@cloudflare.com>
> include/linux/skmsg.h | 46 +++++++++++++++++++++++++++++++++++++++++++
> net/core/skmsg.c | 3 +++
> net/ipv4/tcp_bpf.c | 18 ++++++-----------
> 3 files changed, 55 insertions(+), 12 deletions(-)
>
> diff --git a/include/linux/skmsg.h b/include/linux/skmsg.h
> index 6c09d94be2e9..7333bf881b81 100644
> --- a/include/linux/skmsg.h
> +++ b/include/linux/skmsg.h
> @@ -89,6 +89,7 @@ struct sk_psock {
> #endif
> struct sk_buff_head ingress_skb;
> struct list_head ingress_msg;
> + spinlock_t ingress_lock;
> unsigned long state;
> struct list_head link;
> spinlock_t link_lock;
> @@ -284,7 +285,45 @@ static inline struct sk_psock *sk_psock(const struct sock *sk)
> static inline void sk_psock_queue_msg(struct sk_psock *psock,
> struct sk_msg *msg)
> {
> + spin_lock_bh(&psock->ingress_lock);
> list_add_tail(&msg->list, &psock->ingress_msg);
> + spin_unlock_bh(&psock->ingress_lock);
> +}
> +
> +static inline struct sk_msg *sk_psock_deque_msg(struct sk_psock *psock)
Should be sk_psock_deque*ue*_msg()?
[...]
next prev parent reply other threads:[~2021-03-11 11:29 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-10 5:32 [Patch bpf-next v4 00/11] sockmap: introduce BPF_SK_SKB_VERDICT and support UDP Cong Wang
2021-03-10 5:32 ` [Patch bpf-next v4 01/11] skmsg: lock ingress_skb when purging Cong Wang
2021-03-11 10:52 ` Jakub Sitnicki
2021-03-10 5:32 ` [Patch bpf-next v4 02/11] skmsg: introduce a spinlock to protect ingress_msg Cong Wang
2021-03-11 11:28 ` Jakub Sitnicki [this message]
2021-03-12 0:45 ` Cong Wang
2021-03-10 5:32 ` [Patch bpf-next v4 03/11] skmsg: introduce skb_send_sock() for sock_map Cong Wang
2021-03-11 11:42 ` Jakub Sitnicki
2021-03-12 0:47 ` Cong Wang
2021-03-10 5:32 ` [Patch bpf-next v4 04/11] skmsg: avoid lock_sock() in sk_psock_backlog() Cong Wang
2021-03-12 12:02 ` Jakub Sitnicki
2021-03-13 17:32 ` Cong Wang
2021-03-15 20:55 ` Jakub Sitnicki
2021-03-10 5:32 ` [Patch bpf-next v4 05/11] sock_map: introduce BPF_SK_SKB_VERDICT Cong Wang
2021-03-10 5:32 ` [Patch bpf-next v4 06/11] sock: introduce sk->sk_prot->psock_update_sk_prot() Cong Wang
2021-03-10 5:32 ` [Patch bpf-next v4 07/11] udp: implement ->read_sock() for sockmap Cong Wang
2021-03-10 5:32 ` [Patch bpf-next v4 08/11] skmsg: extract __tcp_bpf_recvmsg() and tcp_bpf_wait_data() Cong Wang
2021-03-10 5:32 ` [Patch bpf-next v4 09/11] udp: implement udp_bpf_recvmsg() for sockmap Cong Wang
2021-03-10 5:32 ` [Patch bpf-next v4 10/11] sock_map: update sock type checks for UDP Cong Wang
2021-03-10 5:32 ` [Patch bpf-next v4 11/11] selftests/bpf: add a test case for udp sockmap Cong Wang
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=871rcm3p6m.fsf@cloudflare.com \
--to=jakub@cloudflare.com \
--cc=bpf@vger.kernel.org \
--cc=cong.wang@bytedance.com \
--cc=daniel@iogearbox.net \
--cc=duanxiongchun@bytedance.com \
--cc=jiang.wang@bytedance.com \
--cc=john.fastabend@gmail.com \
--cc=lmb@cloudflare.com \
--cc=netdev@vger.kernel.org \
--cc=wangdongdong.6@bytedance.com \
--cc=xiyou.wangcong@gmail.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).