From: Krasnov Arseniy <AVKrasnov@sberdevices.ru>
To: Stefano Garzarella <sgarzare@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Krasnov Arseniy <oxffffaa@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"virtualization@lists.linux-foundation.org"
<virtualization@lists.linux-foundation.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
kernel <kernel@sberdevices.ru>
Subject: Re: [RFC PATCH v1 05/12] vsock/virtio: non-linear skb support
Date: Mon, 20 Feb 2023 09:02:17 +0000 [thread overview]
Message-ID: <dd627cde-e20a-6b0e-b82c-b749dc367db1@sberdevices.ru> (raw)
In-Reply-To: <20230216141856.fnczv3ui6d3lpujy@sgarzare-redhat>
On 16.02.2023 17:18, Stefano Garzarella wrote:
> On Mon, Feb 06, 2023 at 06:58:24AM +0000, Arseniy Krasnov wrote:
>> Use pages of non-linear skb as buffers in virtio tx queue.
>>
>> Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
>> ---
>> net/vmw_vsock/virtio_transport.c | 31 +++++++++++++++++++++++++------
>> 1 file changed, 25 insertions(+), 6 deletions(-)
>>
>> diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c
>> index 28b5a8e8e094..b8a7d6dc9f46 100644
>> --- a/net/vmw_vsock/virtio_transport.c
>> +++ b/net/vmw_vsock/virtio_transport.c
>> @@ -100,7 +100,8 @@ virtio_transport_send_pkt_work(struct work_struct *work)
>> vq = vsock->vqs[VSOCK_VQ_TX];
>>
>> for (;;) {
>> - struct scatterlist hdr, buf, *sgs[2];
>> + struct scatterlist *sgs[MAX_SKB_FRAGS + 1];
>> + struct scatterlist bufs[MAX_SKB_FRAGS + 1];
>
> + 1 is for the header, right?
> I'd add a comment just to be clear ;-)
>
>> int ret, in_sg = 0, out_sg = 0;
>> struct sk_buff *skb;
>> bool reply;
>> @@ -111,12 +112,30 @@ virtio_transport_send_pkt_work(struct work_struct *work)
>>
>> virtio_transport_deliver_tap_pkt(skb);
>> reply = virtio_vsock_skb_reply(skb);
>> + sg_init_one(&bufs[0], virtio_vsock_hdr(skb), sizeof(*virtio_vsock_hdr(skb)));
>> + sgs[out_sg++] = &bufs[0];
>> +
>> + if (skb_is_nonlinear(skb)) {
>> + int i;
>> +
>> + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
>> + struct page *data_page = skb_shinfo(skb)->frags[i].bv_page;
>> +
>> + /* We will use 'page_to_virt()' for userspace page here,
>> + * because virtio layer will call 'virt_to_phys()' later
>> + * to fill buffer descriptor. We don't touch memory at
>> + * "virtual" address of this page.
>> + */
>
> IIUC data_page is a user page, so since we are exposing it to the host,
> I think we should pin it.
>
> Is data_page always a user page, or can it be a kernel page when skb is nonlinear?
By default it is user page, but...may be it is possible to send page of mapped
file with MAP_SHARED flags(i think it this case it will be page from page cache)
>
> Thanks,
> Stefano
>
>> + sg_init_one(&bufs[i + 1],
>> + page_to_virt(data_page), PAGE_SIZE);
>> + sgs[out_sg++] = &bufs[i + 1];
>> + }
>> + } else {
>> + if (skb->len > 0) {
>> + sg_init_one(&bufs[1], skb->data, skb->len);
>> + sgs[out_sg++] = &bufs[1];
>> + }
>>
>> - sg_init_one(&hdr, virtio_vsock_hdr(skb), sizeof(*virtio_vsock_hdr(skb)));
>> - sgs[out_sg++] = &hdr;
>> - if (skb->len > 0) {
>> - sg_init_one(&buf, skb->data, skb->len);
>> - sgs[out_sg++] = &buf;
>> }
>>
>> ret = virtqueue_add_sgs(vq, sgs, out_sg, in_sg, skb, GFP_KERNEL);
>> --
>> 2.25.1
>
next prev parent reply other threads:[~2023-02-20 9:02 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-06 6:51 [RFC PATCH v1 00/12] vsock: MSG_ZEROCOPY flag support Arseniy Krasnov
2023-02-06 6:53 ` [RFC PATCH v1 01/12] vsock: check error queue to set EPOLLERR Arseniy Krasnov
2023-02-16 13:40 ` Stefano Garzarella
2023-02-20 9:00 ` Krasnov Arseniy
2023-02-06 6:54 ` [RFC PATCH v1 02/12] vsock: read from socket's error queue Arseniy Krasnov
2023-02-16 13:55 ` Stefano Garzarella
2023-02-06 6:55 ` [RFC PATCH v1 03/12] vsock: check for MSG_ZEROCOPY support Arseniy Krasnov
2023-02-16 14:02 ` Stefano Garzarella
2023-02-06 6:57 ` [RFC PATCH v1 04/12] vhost/vsock: non-linear skb handling support Arseniy Krasnov
2023-02-16 14:09 ` Stefano Garzarella
2023-02-20 9:01 ` Krasnov Arseniy
2023-02-06 6:58 ` [RFC PATCH v1 05/12] vsock/virtio: non-linear skb support Arseniy Krasnov
2023-02-16 14:18 ` Stefano Garzarella
2023-02-20 9:02 ` Krasnov Arseniy [this message]
2023-02-06 6:59 ` [RFC PATCH v1 06/12] vsock/virtio: non-linear skb handling for TAP dev Arseniy Krasnov
2023-02-16 14:30 ` Stefano Garzarella
2023-02-06 7:00 ` [RFC PATCH v1 07/12] vsock/virtio: MGS_ZEROCOPY flag support Arseniy Krasnov
2023-02-16 15:16 ` Stefano Garzarella
2023-02-20 9:04 ` Krasnov Arseniy
2023-02-28 10:26 ` Stefano Garzarella
2023-02-06 7:01 ` [RFC PATCH v1 08/12] vhost/vsock: support MSG_ZEROCOPY for transport Arseniy Krasnov
2023-02-06 7:02 ` [RFC PATCH v1 09/12] vsock/virtio: " Arseniy Krasnov
2023-02-06 7:03 ` [RFC PATCH v1 10/12] net/sock: enable setting SO_ZEROCOPY for PF_VSOCK Arseniy Krasnov
2023-02-06 7:05 ` [RFC PATCH v1 11/12] test/vsock: MSG_ZEROCOPY flag tests Arseniy Krasnov
2023-02-06 7:06 ` [RFC PATCH v1 12/12] test/vsock: MSG_ZEROCOPY support for vsock_perf Arseniy Krasnov
2023-02-16 15:29 ` Stefano Garzarella
2023-02-20 9:05 ` Krasnov Arseniy
2023-02-28 10:32 ` Stefano Garzarella
2023-02-16 13:33 ` [RFC PATCH v1 00/12] vsock: MSG_ZEROCOPY flag support Stefano Garzarella
2023-02-20 8:59 ` Krasnov Arseniy
2023-02-28 10:23 ` Stefano Garzarella
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=dd627cde-e20a-6b0e-b82c-b749dc367db1@sberdevices.ru \
--to=avkrasnov@sberdevices.ru \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jasowang@redhat.com \
--cc=kernel@sberdevices.ru \
--cc=kuba@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--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
all inboxes | Powered by JetHome®