virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH net-next v9 4/4] vsock/virtio: MSG_ZEROCOPY flag support
       [not found] ` <20230916130918.4105122-5-avkrasnov@salutedevices.com>
@ 2023-09-18 14:50   ` Stefano Garzarella
  0 siblings, 0 replies; 7+ messages in thread
From: Stefano Garzarella @ 2023-09-18 14:50 UTC (permalink / raw)
  To: Arseniy Krasnov
  Cc: Bobby Eshleman, kvm, Michael S. Tsirkin, netdev, linux-kernel,
	virtualization, oxffffaa, Eric Dumazet, Stefan Hajnoczi, kernel,
	Jakub Kicinski, Paolo Abeni, David S. Miller

On Sat, Sep 16, 2023 at 04:09:18PM +0300, Arseniy Krasnov wrote:
>This adds handling of MSG_ZEROCOPY flag on transmission path:
>
>1) If this flag is set and zerocopy transmission is possible (enabled
>   in socket options and transport allows zerocopy), then non-linear
>   skb will be created and filled with the pages of user's buffer.
>   Pages of user's buffer are locked in memory by 'get_user_pages()'.
>2) Replaces way of skb owning: instead of 'skb_set_owner_sk_safe()' it
>   calls 'skb_set_owner_w()'. Reason of this change is that
>   '__zerocopy_sg_from_iter()' increments 'sk_wmem_alloc' of socket, so
>   to decrease this field correctly, proper skb destructor is needed:
>   'sock_wfree()'. This destructor is set by 'skb_set_owner_w()'.
>3) Adds new callback to 'struct virtio_transport': 'can_msgzerocopy'.
>   If this callback is set, then transport needs extra check to be able
>   to send provided number of buffers in zerocopy mode. Currently, the
>   only transport that needs this callback set is virtio, because this
>   transport adds new buffers to the virtio queue and we need to check,
>   that number of these buffers is less than size of the queue (it is
>   required by virtio spec). vhost and loopback transports don't need
>   this check.
>
>Signed-off-by: Arseniy Krasnov <avkrasnov@salutedevices.com>
>---
> Changelog:
> v5(big patchset) -> v1:
>  * Refactorings of 'if' conditions.
>  * Remove extra blank line.
>  * Remove 'frag_off' field unneeded init.
>  * Add function 'virtio_transport_fill_skb()' which fills both linear
>    and non-linear skb with provided data.
> v1 -> v2:
>  * Use original order of last four arguments in 'virtio_transport_alloc_skb()'.
> v2 -> v3:
>  * Add new transport callback: 'msgzerocopy_check_iov'. It checks that
>    provided 'iov_iter' with data could be sent in a zerocopy mode.
>    If this callback is not set in transport - transport allows to send
>    any 'iov_iter' in zerocopy mode. Otherwise - if callback returns 'true'
>    then zerocopy is allowed. Reason of this callback is that in case of
>    G2H transmission we insert whole skb to the tx virtio queue and such
>    skb must fit to the size of the virtio queue to be sent in a single
>    iteration (may be tx logic in 'virtio_transport.c' could be reworked
>    as in vhost to support partial send of current skb). This callback
>    will be enabled only for G2H path. For details pls see comment
>    'Check that tx queue...' below.
> v3 -> v4:
>  * 'msgzerocopy_check_iov' moved from 'struct vsock_transport' to
>    'struct virtio_transport' as it is virtio specific callback and
>    never needed in other transports.
> v4 -> v5:
>  * 'msgzerocopy_check_iov' renamed to 'can_msgzerocopy' and now it
>    uses number of buffers to send as input argument. I think there is
>    no need to pass iov to this callback (at least today, it is used only
>    by guest side of virtio transport), because the only thing that this
>    callback does is comparison of number of buffers to be inserted to
>    the tx queue and size of this queue.
>  * Remove any checks for type of current 'iov_iter' with payload (is it
>    'iovec' or 'ubuf'). These checks left from the earlier versions where I
>    didn't use already implemented kernel API which handles every type of
>    'iov_iter'.
> v5 -> v6:
>  * Refactor 'virtio_transport_fill_skb()'.
>  * Add 'WARN_ON_ONCE()' and comment on invalid combination of destination
>    socket and payload in 'virtio_transport_alloc_skb()'.
> v7 -> v8:
>  * Move '+1' addition from 'can_msgzerocopy' callback body to the caller.
>    This addition means packet header.
>  * In 'virtio_transport_can_zcopy()' rename 'max_to_send' argument to
>    'pkt_len'.
>  * Update commit message by adding details about new 'can_msgzerocopy'
>    callback.
>  * In 'virtio_transport_init_hdr()' move 'len' argument directly after
>    'info'.
>  * Add comment about processing last skb in tx loop.
>  * Update comment for 'can_msgzerocopy' callback for more details.
> v8 -> v9:
>  * Return and update comment for 'virtio_transport_alloc_skb()'.
>  * Pass pointer to transport ops to 'virtio_transport_can_zcopy()',
>    this allows to use it directly without calling virtio_transport_get_ops()'.
>  * Remove redundant call for 'msg_data_left()' in 'virtio_transport_fill_skb()'.
>  * Do not pass 'struct vsock_sock*' to 'virtio_transport_alloc_skb()',
>    use same pointer from already passed 'struct virtio_vsock_pkt_info*'.
>  * Fix setting 'end of message' bit for SOCK_SEQPACKET (add call for
>    'msg_data_left()' == 0).
>  * Add 'zcopy' parameter to packet allocation trace event.

Thanks for addressing the comments!
>
> include/linux/virtio_vsock.h                  |   9 +
> .../events/vsock_virtio_transport_common.h    |  12 +-
> net/vmw_vsock/virtio_transport.c              |  32 +++
> net/vmw_vsock/virtio_transport_common.c       | 250 ++++++++++++++----
> 4 files changed, 241 insertions(+), 62 deletions(-)

LGTM!

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next v9 0/4] vsock/virtio/vhost: MSG_ZEROCOPY preparations
       [not found] <20230916130918.4105122-1-avkrasnov@salutedevices.com>
       [not found] ` <20230916130918.4105122-5-avkrasnov@salutedevices.com>
@ 2023-09-18 17:27 ` Michael S. Tsirkin
       [not found] ` <b5873e36-fe8c-85e8-e11b-4ccec386c015@salutedevices.com>
  2 siblings, 0 replies; 7+ messages in thread
From: Michael S. Tsirkin @ 2023-09-18 17:27 UTC (permalink / raw)
  To: Arseniy Krasnov
  Cc: Bobby Eshleman, kvm, netdev, linux-kernel, virtualization,
	oxffffaa, Eric Dumazet, Stefan Hajnoczi, kernel, Jakub Kicinski,
	Paolo Abeni, David S. Miller

On Sat, Sep 16, 2023 at 04:09:14PM +0300, Arseniy Krasnov wrote:
> Hello,
> 
> this patchset is first of three parts of another big patchset for
> MSG_ZEROCOPY flag support:
> https://lore.kernel.org/netdev/20230701063947.3422088-1-AVKrasnov@sberdevices.ru/
> 
> During review of this series, Stefano Garzarella <sgarzare@redhat.com>
> suggested to split it for three parts to simplify review and merging:
> 
> 1) virtio and vhost updates (for fragged skbs) <--- this patchset
> 2) AF_VSOCK updates (allows to enable MSG_ZEROCOPY mode and read
>    tx completions) and update for Documentation/.
> 3) Updates for tests and utils.
> 
> This series enables handling of fragged skbs in virtio and vhost parts.
> Newly logic won't be triggered, because SO_ZEROCOPY options is still
> impossible to enable at this moment (next bunch of patches from big
> set above will enable it).

Acked-by: Michael S. Tsirkin <mst@redhat.com>
> 
> I've included changelog to some patches anyway, because there were some
> comments during review of last big patchset from the link above.
> 
> Head for this patchset is:
> https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=f2fa1c812c91e99d0317d1fc7d845e1e05f39716
> 
> Link to v1:
> https://lore.kernel.org/netdev/20230717210051.856388-1-AVKrasnov@sberdevices.ru/
> Link to v2:
> https://lore.kernel.org/netdev/20230718180237.3248179-1-AVKrasnov@sberdevices.ru/
> Link to v3:
> https://lore.kernel.org/netdev/20230720214245.457298-1-AVKrasnov@sberdevices.ru/
> Link to v4:
> https://lore.kernel.org/netdev/20230727222627.1895355-1-AVKrasnov@sberdevices.ru/
> Link to v5:
> https://lore.kernel.org/netdev/20230730085905.3420811-1-AVKrasnov@sberdevices.ru/
> Link to v6:
> https://lore.kernel.org/netdev/20230814212720.3679058-1-AVKrasnov@sberdevices.ru/
> Link to v7:
> https://lore.kernel.org/netdev/20230827085436.941183-1-avkrasnov@salutedevices.com/
> Link to v8:
> https://lore.kernel.org/netdev/20230911202234.1932024-1-avkrasnov@salutedevices.com/


> Changelog:
>  v3 -> v4:
>  * Patchset rebased and tested on new HEAD of net-next (see hash above).
>  v4 -> v5:
>  * See per-patch changelog after ---.
>  v5 -> v6:
>  * Patchset rebased and tested on new HEAD of net-next (see hash above).
>  * See per-patch changelog after ---.
>  v6 -> v7:
>  * Patchset rebased and tested on new HEAD of net-next (see hash above).
>  * See per-patch changelog after ---.
>  v7 -> v8:
>  * Patchset rebased and tested on new HEAD of net-next (see hash above).
>  * See per-patch changelog after ---.
>  v8 -> v9:
>  * Patchset rebased and tested on new HEAD of net-next (see hash above).
>  * See per-patch changelog after ---.
> 
> Arseniy Krasnov (4):
>   vsock/virtio/vhost: read data from non-linear skb
>   vsock/virtio: support to send non-linear skb
>   vsock/virtio: non-linear skb handling for tap
>   vsock/virtio: MSG_ZEROCOPY flag support
> 
>  drivers/vhost/vsock.c                         |  14 +-
>  include/linux/virtio_vsock.h                  |  10 +
>  .../events/vsock_virtio_transport_common.h    |  12 +-
>  net/vmw_vsock/virtio_transport.c              |  92 +++++-
>  net/vmw_vsock/virtio_transport_common.c       | 307 ++++++++++++++----
>  5 files changed, 348 insertions(+), 87 deletions(-)
> 
> -- 
> 2.25.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next v9 0/4] vsock/virtio/vhost: MSG_ZEROCOPY preparations
       [not found] ` <b5873e36-fe8c-85e8-e11b-4ccec386c015@salutedevices.com>
@ 2023-09-19  7:54   ` Stefano Garzarella
  2023-09-19 13:19     ` Paolo Abeni
  0 siblings, 1 reply; 7+ messages in thread
From: Stefano Garzarella @ 2023-09-19  7:54 UTC (permalink / raw)
  To: Arseniy Krasnov
  Cc: Bobby Eshleman, kvm, Michael S. Tsirkin, netdev, linux-kernel,
	virtualization, oxffffaa, Eric Dumazet, Stefan Hajnoczi, kernel,
	Jakub Kicinski, Paolo Abeni, David S. Miller

On Mon, Sep 18, 2023 at 07:56:00PM +0300, Arseniy Krasnov wrote:
>Hi Stefano,
>
>thanks for review! So when this patchset will be merged to net-next,
>I'll start sending next part of MSG_ZEROCOPY patchset, e.g. AF_VSOCK +
>Documentation/ patches.

Ack, if it is not a very big series, maybe better to include also the
tests so we can run them before merge the feature.

WDYT?

Stefano

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next v9 0/4] vsock/virtio/vhost: MSG_ZEROCOPY preparations
  2023-09-19  7:54   ` Stefano Garzarella
@ 2023-09-19 13:19     ` Paolo Abeni
  2023-09-19 13:35       ` Stefano Garzarella
  0 siblings, 1 reply; 7+ messages in thread
From: Paolo Abeni @ 2023-09-19 13:19 UTC (permalink / raw)
  To: Stefano Garzarella, Arseniy Krasnov, Michael S. Tsirkin
  Cc: Bobby Eshleman, kvm, netdev, linux-kernel, virtualization,
	oxffffaa, Eric Dumazet, Stefan Hajnoczi, kernel, Jakub Kicinski,
	David S. Miller

On Tue, 2023-09-19 at 09:54 +0200, Stefano Garzarella wrote:
> On Mon, Sep 18, 2023 at 07:56:00PM +0300, Arseniy Krasnov wrote:
> > Hi Stefano,
> > 
> > thanks for review! So when this patchset will be merged to net-next,
> > I'll start sending next part of MSG_ZEROCOPY patchset, e.g. AF_VSOCK +
> > Documentation/ patches.
> 
> Ack, if it is not a very big series, maybe better to include also the
> tests so we can run them before merge the feature.

I understand that at least 2 follow-up series are waiting for this, one
of them targeting net-next and the bigger one targeting the virtio
tree. Am I correct?

DaveM suggests this should go via the virtio tree, too. Any different
opinion?

Thanks!

Paolo

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next v9 0/4] vsock/virtio/vhost: MSG_ZEROCOPY preparations
  2023-09-19 13:19     ` Paolo Abeni
@ 2023-09-19 13:35       ` Stefano Garzarella
  2023-09-20  2:38         ` Michael S. Tsirkin
  0 siblings, 1 reply; 7+ messages in thread
From: Stefano Garzarella @ 2023-09-19 13:35 UTC (permalink / raw)
  To: Paolo Abeni, Michael S. Tsirkin
  Cc: Bobby Eshleman, kvm, netdev, Arseniy Krasnov, linux-kernel,
	virtualization, oxffffaa, Eric Dumazet, Stefan Hajnoczi, kernel,
	Jakub Kicinski, David S. Miller

On Tue, Sep 19, 2023 at 03:19:54PM +0200, Paolo Abeni wrote:
>On Tue, 2023-09-19 at 09:54 +0200, Stefano Garzarella wrote:
>> On Mon, Sep 18, 2023 at 07:56:00PM +0300, Arseniy Krasnov wrote:
>> > Hi Stefano,
>> >
>> > thanks for review! So when this patchset will be merged to net-next,
>> > I'll start sending next part of MSG_ZEROCOPY patchset, e.g. AF_VSOCK +
>> > Documentation/ patches.
>>
>> Ack, if it is not a very big series, maybe better to include also the
>> tests so we can run them before merge the feature.
>
>I understand that at least 2 follow-up series are waiting for this, one
>of them targeting net-next and the bigger one targeting the virtio
>tree. Am I correct?

IIUC the next series will touch only the vsock core
(net/vmw_vsock/af_vsock.c), tests, and documentation.

The virtio part should be fully covered by this series.

@Arseniy feel free to correct me!

>
>DaveM suggests this should go via the virtio tree, too. Any different
>opinion?

For this series should be fine, I'm not sure about the next series.
Merging this with the virtio tree, then it forces us to do it for
followup as well right?

In theory followup is more on the core, so better with net-next, but
it's also true that for now only virtio transports support it, so it
might be okay to continue with virtio.

@Michael WDYT?

Thanks,
Stefano

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next v9 0/4] vsock/virtio/vhost: MSG_ZEROCOPY preparations
  2023-09-19 13:35       ` Stefano Garzarella
@ 2023-09-20  2:38         ` Michael S. Tsirkin
  2023-09-20 11:06           ` Paolo Abeni
  0 siblings, 1 reply; 7+ messages in thread
From: Michael S. Tsirkin @ 2023-09-20  2:38 UTC (permalink / raw)
  To: Stefano Garzarella
  Cc: Bobby Eshleman, kvm, netdev, Arseniy Krasnov, linux-kernel,
	virtualization, oxffffaa, Eric Dumazet, Stefan Hajnoczi, kernel,
	Jakub Kicinski, Paolo Abeni, David S. Miller

On Tue, Sep 19, 2023 at 03:35:51PM +0200, Stefano Garzarella wrote:
> On Tue, Sep 19, 2023 at 03:19:54PM +0200, Paolo Abeni wrote:
> > On Tue, 2023-09-19 at 09:54 +0200, Stefano Garzarella wrote:
> > > On Mon, Sep 18, 2023 at 07:56:00PM +0300, Arseniy Krasnov wrote:
> > > > Hi Stefano,
> > > >
> > > > thanks for review! So when this patchset will be merged to net-next,
> > > > I'll start sending next part of MSG_ZEROCOPY patchset, e.g. AF_VSOCK +
> > > > Documentation/ patches.
> > > 
> > > Ack, if it is not a very big series, maybe better to include also the
> > > tests so we can run them before merge the feature.
> > 
> > I understand that at least 2 follow-up series are waiting for this, one
> > of them targeting net-next and the bigger one targeting the virtio
> > tree. Am I correct?
> 
> IIUC the next series will touch only the vsock core
> (net/vmw_vsock/af_vsock.c), tests, and documentation.
> 
> The virtio part should be fully covered by this series.
> 
> @Arseniy feel free to correct me!
> 
> > 
> > DaveM suggests this should go via the virtio tree, too. Any different
> > opinion?
> 
> For this series should be fine, I'm not sure about the next series.
> Merging this with the virtio tree, then it forces us to do it for
> followup as well right?
> 
> In theory followup is more on the core, so better with net-next, but
> it's also true that for now only virtio transports support it, so it
> might be okay to continue with virtio.
> 
> @Michael WDYT?
> 
> Thanks,
> Stefano

I didn't get DaveM's mail - was this off-list?
I think net-next is easier because the follow up belongs in net-next.
But if not I can take it, sure. Let me know.

-- 
MST

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next v9 0/4] vsock/virtio/vhost: MSG_ZEROCOPY preparations
  2023-09-20  2:38         ` Michael S. Tsirkin
@ 2023-09-20 11:06           ` Paolo Abeni
  0 siblings, 0 replies; 7+ messages in thread
From: Paolo Abeni @ 2023-09-20 11:06 UTC (permalink / raw)
  To: Michael S. Tsirkin, Stefano Garzarella
  Cc: Bobby Eshleman, kvm, netdev, Arseniy Krasnov, linux-kernel,
	virtualization, oxffffaa, Eric Dumazet, Stefan Hajnoczi, kernel,
	Jakub Kicinski, David S. Miller

On Tue, 2023-09-19 at 22:38 -0400, Michael S. Tsirkin wrote:
> On Tue, Sep 19, 2023 at 03:35:51PM +0200, Stefano Garzarella wrote:
> > On Tue, Sep 19, 2023 at 03:19:54PM +0200, Paolo Abeni wrote:
> > 
> > > DaveM suggests this should go via the virtio tree, too. Any different
> > > opinion?
> > 
> > For this series should be fine, I'm not sure about the next series.
> > Merging this with the virtio tree, then it forces us to do it for
> > followup as well right?
> > 
> > In theory followup is more on the core, so better with net-next, but
> > it's also true that for now only virtio transports support it, so it
> > might be okay to continue with virtio.
> > 
> > @Michael WDYT?
> > 
> > Thanks,
> > Stefano
> 
> I didn't get DaveM's mail - was this off-list?

Yes, that was off-list co-ordination.

> I think net-next is easier because the follow up belongs in net-next.
> But if not I can take it, sure. Let me know.

Since there is agreement on that route, we will take it (likely
tomorrow).

Cheers,

Paolo

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-09-20 11:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20230916130918.4105122-1-avkrasnov@salutedevices.com>
     [not found] ` <20230916130918.4105122-5-avkrasnov@salutedevices.com>
2023-09-18 14:50   ` [PATCH net-next v9 4/4] vsock/virtio: MSG_ZEROCOPY flag support Stefano Garzarella
2023-09-18 17:27 ` [PATCH net-next v9 0/4] vsock/virtio/vhost: MSG_ZEROCOPY preparations Michael S. Tsirkin
     [not found] ` <b5873e36-fe8c-85e8-e11b-4ccec386c015@salutedevices.com>
2023-09-19  7:54   ` Stefano Garzarella
2023-09-19 13:19     ` Paolo Abeni
2023-09-19 13:35       ` Stefano Garzarella
2023-09-20  2:38         ` Michael S. Tsirkin
2023-09-20 11:06           ` Paolo Abeni

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).