Re: [PATCH v4 4/4] selftests: net: add a virtio_net deadlock selftest

Bui Quang Minh
2025-04-24T10:33:58Z

On 4/24/25 05:23, Jakub Kicinski wrote:
> On Wed, 23 Apr 2025 22:20:41 +0700 Bui Quang Minh wrote:
>> I've tried to make the setup_xsk into each test. However, I've an issue
>> that the XDP socket destruct waits for an RCU grace period as I see this
>> sock's flag SOCK_RCU_FREE is set. So if we start the next test right
>> away, we can have the error when setting up XDP socket again because
>> previous XDP socket has not unbound the network interface's queue yet. I
>> can resolve the issue by putting the sleep(1) after closing the socket
>> in xdp_helper:
>>
>> diff --git a/tools/testing/selftests/net/lib/xdp_helper.c
>> b/tools/testing/selftests/net/lib/xdp_helper.c
>> index f21536ab95ba..e882bb22877f 100644
>> --- a/tools/testing/selftests/net/lib/xdp_helper.c
>> +++ b/tools/testing/selftests/net/lib/xdp_helper.c
>> @@ -162,5 +162,6 @@ int main(int argc, char **argv)
>>          */
>>
>>         close(sock_fd);
>> +       sleep(1);
>>         return 0;
>>  }
>>
>> Do you think it's enough or do you have a better suggestion here?
> Interesting :S What errno does the kernel return? EBUSY?
> Perhaps we could loop for a second retrying the bind()
> if kernel returns EBUSY in case it's just a socket waiting
> to be cleaned up?

Yes, the kernel returns EBUSY. Loop and retry sounds good to me but it's
not easy to get the return code when using bkg(). So for simplicity,
I'll retry with sleep(1) 3 times when the xdp_helper fails.

Thanks,
Quang Minh.