]> git.baikalelectronics.ru Git - kernel.git/commit
skmsg: Avoid lock_sock() in sk_psock_backlog()
authorCong Wang <cong.wang@bytedance.com>
Wed, 31 Mar 2021 02:32:25 +0000 (19:32 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 1 Apr 2021 17:56:13 +0000 (10:56 -0700)
commit5d029dfa8a76f36ca9b7c85e435d415566449ca8
tree38226a66a54ab0b7db060abb3e08cadebaa6500c
parentcf6a1cfaf7b7432e0bf4efc1de469378da704df3
skmsg: Avoid lock_sock() in sk_psock_backlog()

We do not have to lock the sock to avoid losing sk_socket,
instead we can purge all the ingress queues when we close
the socket. Sending or receiving packets after orphaning
socket makes no sense.

We do purge these queues when psock refcnt reaches zero but
here we want to purge them explicitly in sock_map_close().
There are also some nasty race conditions on testing bit
SK_PSOCK_TX_ENABLED and queuing/canceling the psock work,
we can expand psock->ingress_lock a bit to protect them too.

As noticed by John, we still have to lock the psock->work,
because the same work item could be running concurrently on
different CPU's.

Signed-off-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20210331023237.41094-5-xiyou.wangcong@gmail.com
include/linux/skmsg.h
net/core/skmsg.c
net/core/sock_map.c