On 05/03/2024 17:39, Dmitry Antipov wrote:
On 3/4/24 13:51, Wen Gu wrote:
IMHO, if we want to address the problem of fasync_struct entries being
incorrectly inserted to old socket, we may have to change the general
code.
BTW what about using shared wait queue? Just to illustrate an idea:
I'm sorry but could we please clean up the e-mail threads?
This one here is a question if we are still alive: Yes, we are.
The other one i currently treat as an RFC and gracefully ignore the
PATCH tag. If you want to post it as an patch please come up with a
solution, clean it up and re-post it.
See patchwork errors for example:
https://patchwork.kernel.org/project/netdevbpf/patch/20240221051608.43241-1-dmantipov@xxxxxxxxx/
For the general RFC discussion we are going to comment on it as soon as
we have something to say about it.
Feel free to re-post your idea regarding a shared wait queue there.
Thank you for your interest in smc and the ideas!
- Jan
diff --git a/include/linux/net.h b/include/linux/net.h
index c9b4a63791a4..02df64747db7 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -126,6 +126,7 @@ struct socket {
const struct proto_ops *ops; /* Might change with IPV6_ADDRFORM
or MPTCP. */
struct socket_wq wq;
+ struct socket_wq *shared_wq;
};
/*
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 0f53a5c6fd9d..f04d61e316b2 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -3360,6 +3360,9 @@ static int __smc_create(struct net *net, struct
socket *sock, int protocol,
smc->clcsock = clcsock;
}
+ sock->shared_wq = &smc->shared_wq;
+ smc->clcsock->shared_wq = &smc->shared_wq;
+
out:
return rc;
}
diff --git a/net/smc/smc.h b/net/smc/smc.h
index df64efd2dee8..26e66c289d4f 100644
--- a/net/smc/smc.h
+++ b/net/smc/smc.h
@@ -287,6 +287,7 @@ struct smc_sock { /* smc sock
container */
/* protects clcsock of a listen
* socket
* */
+ struct socket_wq shared_wq;
};
#define smc_sk(ptr) container_of_const(ptr, struct smc_sock, sk)
diff --git a/net/socket.c b/net/socket.c
index ed3df2f749bf..9b9e6932906f 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1437,7 +1437,8 @@ static int sock_fasync(int fd, struct file *filp,
int on)
{
struct socket *sock = filp->private_data;
struct sock *sk = sock->sk;
- struct socket_wq *wq = &sock->wq;
+ struct socket_wq *wq = (unlikely(sock->shared_wq) ?
+ sock->shared_wq : &sock->wq);
if (sk == NULL)
return -EINVAL;
Dmitry