On Thu, Nov 06, 2025 at 05:16:29PM +0100, Stefano Garzarella wrote:
On Thu, Oct 23, 2025 at 11:27:40AM -0700, Bobby Eshleman wrote:
From: Bobby Eshleman bobbyeshleman@meta.com
[...]
@@ -65,6 +66,7 @@ struct vsock_sock { u32 peer_shutdown; bool sent_request; bool ignore_connecting_rst;
enum vsock_net_mode net_mode;
/* Protected by lock_sock(sk) */ u64 buffer_size;
@@ -256,4 +258,58 @@ static inline bool vsock_msgzerocopy_allow(const struct vsock_transport *t) { return t->msgzerocopy_allow && t->msgzerocopy_allow(); }
+static inline enum vsock_net_mode vsock_net_mode(struct net *net) +{
- enum vsock_net_mode ret;
- spin_lock_bh(&net->vsock.lock);
- ret = net->vsock.mode;
Do we really need a spin_lock just to set/get a variable? What about WRITE_ONCE/READ_ONCE and/or atomic ?
Not a strong opinion, just to check if we can do something like this:
static inline enum vsock_net_mode vsock_net_mode(struct net *net) { return READ_ONCE(net->vsock.mode); }
static inline bool vsock_net_write_mode(struct net *net, u8 mode) { // Or using test_and_set_bit() if you prefer if (xchg(&net->vsock.mode_locked, true)) return false;
WRITE_ONCE(net->vsock.mode, mode); return true;}
I think that works and seems worth it to avoid the lock on the read side. I'll move this over for the next rev.
[...]
Best, Bobby