linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arseniy Krasnov <avkrasnov@sberdevices.ru>
To: Stefano Garzarella <sgarzare@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Bobby Eshleman <bobby.eshleman@bytedance.com>,
	<kvm@vger.kernel.org>,
	<virtualization@lists.linux-foundation.org>,
	<netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<kernel@sberdevices.ru>, <oxffffaa@gmail.com>
Subject: Re: [RFC PATCH v1 2/3] virtio/vsock: add WARN() for invalid state of socket
Date: Mon, 20 Mar 2023 21:10:34 +0300	[thread overview]
Message-ID: <37bef564-8f3e-aab3-a7d7-24e6c4caa318@sberdevices.ru> (raw)
In-Reply-To: <20230320150715.twapgesp2gj6egua@sgarzare-redhat>



On 20.03.2023 18:07, Stefano Garzarella wrote:
> On Sun, Mar 19, 2023 at 09:52:19PM +0300, Arseniy Krasnov wrote:
>> This prints WARN() and returns from stream dequeue callback when socket's
>> queue is empty, but 'rx_bytes' still non-zero.
>>
>> Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
>> ---
>> net/vmw_vsock/virtio_transport_common.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
>> index 3c75986e16c2..c35b03adad8d 100644
>> --- a/net/vmw_vsock/virtio_transport_common.c
>> +++ b/net/vmw_vsock/virtio_transport_common.c
>> @@ -388,6 +388,13 @@ virtio_transport_stream_do_dequeue(struct vsock_sock *vsk,
>>     u32 free_space;
>>
>>     spin_lock_bh(&vvs->rx_lock);
>> +
>> +    if (skb_queue_empty(&vvs->rx_queue) && vvs->rx_bytes) {
>> +        WARN(1, "No skbuffs with non-zero 'rx_bytes'\n");
> 
> I would use WARN_ONCE, since we can't recover so we will flood the log.
> 
> And you can put the condition in the first argument, I mean something
> like this:
>         if (WARN_ONCE(skb_queue_empty(&vvs->rx_queue) && vvs->rx_bytes,
>                       "rx_queue is empty, but rx_bytes is non-zero\n")) {
I see, ok.
> 
> Thanks,
> Stefano
> 
>> +        spin_unlock_bh(&vvs->rx_lock);
>> +        return err;
>> +    }
>> +
>>     while (total < len && !skb_queue_empty(&vvs->rx_queue)) {
>>         skb = skb_peek(&vvs->rx_queue);
>>
>> -- 
>> 2.25.1
>>
> 

  reply	other threads:[~2023-03-20 19:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-19 18:49 [RFC PATCH v1 0/3] fix header length on skb merging Arseniy Krasnov
2023-03-19 18:51 ` [RFC PATCH v1 1/3] virtio/vsock: " Arseniy Krasnov
2023-03-20 14:57   ` Stefano Garzarella
2023-03-20 18:10     ` Arseniy Krasnov
2023-03-21  8:31       ` Stefano Garzarella
2023-03-19 18:52 ` [RFC PATCH v1 2/3] virtio/vsock: add WARN() for invalid state of socket Arseniy Krasnov
2023-03-20 15:07   ` Stefano Garzarella
2023-03-20 18:10     ` Arseniy Krasnov [this message]
2023-03-19 18:53 ` [RFC PATCH v1 3/3] test/vsock: skbuff merging test Arseniy Krasnov
2023-03-20 15:31   ` Stefano Garzarella
2023-03-20 18:12     ` Arseniy Krasnov

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=37bef564-8f3e-aab3-a7d7-24e6c4caa318@sberdevices.ru \
    --to=avkrasnov@sberdevices.ru \
    --cc=bobby.eshleman@bytedance.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kernel@sberdevices.ru \
    --cc=kuba@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oxffffaa@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /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).