From: John Fastabend <john.fastabend@gmail.com>
To: Cong Wang <xiyou.wangcong@gmail.com>, netdev@vger.kernel.org
Cc: bpf@vger.kernel.org, Cong Wang <cong.wang@bytedance.com>,
Stanislav Fomichev <sdf@google.com>,
John Fastabend <john.fastabend@gmail.com>,
Jakub Sitnicki <jakub@cloudflare.com>
Subject: RE: [Patch bpf v2] sock_map: move cancel_work_sync() out of sock lock
Date: Wed, 02 Nov 2022 22:41:21 -0700 [thread overview]
Message-ID: <636354819110e_a055820897@john.notmuch> (raw)
In-Reply-To: <20221102043417.279409-1-xiyou.wangcong@gmail.com>
Cong Wang wrote:
> From: Cong Wang <cong.wang@bytedance.com>
>
> Stanislav reported a lockdep warning, which is caused by the
> cancel_work_sync() called inside sock_map_close(), as analyzed
> below by Jakub:
>
> psock->work.func = sk_psock_backlog()
> ACQUIRE psock->work_mutex
> sk_psock_handle_skb()
> skb_send_sock()
> __skb_send_sock()
> sendpage_unlocked()
> kernel_sendpage()
> sock->ops->sendpage = inet_sendpage()
> sk->sk_prot->sendpage = tcp_sendpage()
> ACQUIRE sk->sk_lock
> tcp_sendpage_locked()
> RELEASE sk->sk_lock
> RELEASE psock->work_mutex
>
> sock_map_close()
> ACQUIRE sk->sk_lock
> sk_psock_stop()
> sk_psock_clear_state(psock, SK_PSOCK_TX_ENABLED)
> cancel_work_sync()
> __cancel_work_timer()
> __flush_work()
> // wait for psock->work to finish
> RELEASE sk->sk_lock
>
> We can move the cancel_work_sync() out of the sock lock protection,
> but still before saved_close() was called.
>
> Fixes: 799aa7f98d53 ("skmsg: Avoid lock_sock() in sk_psock_backlog()")
> Reported-by: Stanislav Fomichev <sdf@google.com>
> Cc: John Fastabend <john.fastabend@gmail.com>
> Cc: Jakub Sitnicki <jakub@cloudflare.com>
> Signed-off-by: Cong Wang <cong.wang@bytedance.com>
> ---
LGTM. Thanks.
Acked-by: John Fastabend <john.fastabend@gmail.com>
next prev parent reply other threads:[~2022-11-03 5:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-02 4:34 [Patch bpf v2] sock_map: move cancel_work_sync() out of sock lock Cong Wang
2022-11-03 5:41 ` John Fastabend [this message]
2022-11-03 12:37 ` Jakub Sitnicki
2022-11-03 13:00 ` 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=636354819110e_a055820897@john.notmuch \
--to=john.fastabend@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=cong.wang@bytedance.com \
--cc=jakub@cloudflare.com \
--cc=netdev@vger.kernel.org \
--cc=sdf@google.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).