Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp904348lqp; Thu, 23 May 2024 03:44:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXGefm+8n5o+tAaU+OsP2bC1ddPQagOe8afgjeBG3Eqy7Sq99bgCEi5NXgYesBW8anFlFlH+8ggEhUZNBG4XoYLzPnwWvyww5rd1t3sHQ== X-Google-Smtp-Source: AGHT+IEITYuepPQxCkK0orNTWphHewM1hRI2PDBTO1OG3THITXA1ddSatvJN6jTCkOvh9JBQtAmo X-Received: by 2002:a0d:d8c8:0:b0:61b:3364:32db with SMTP id 00721157ae682-627e4846bd4mr49046407b3.36.1716461092429; Thu, 23 May 2024 03:44:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716461092; cv=pass; d=google.com; s=arc-20160816; b=CixDHA3lGGni5Kxkr67ddqge4Uewb2Ag2saHC0h9619YtuxhiCRJbeIYplnLffotui zOnlE7c8oPvOW+uodvpRIg/o2EgFx/wScHyAoVgRxM/8Ul6scQLH3xNgAv2eeHMGwnUc 1qd3ihlRPgjW6VnuKQ1v/q9XaEvloPGFSZvZ8MhDA9IoWJ1EHitM/+EkdXutJH9OnDGd Otbr+599UWcXM5NRJcrrmbof+2Lc1rwV/RzCmJYVNMbPGBu0OO5olTP3OGqGZj4Epd/R XqC0zJaBneV56GwqcacdPYXZGTLO5gSNKxBAHnHGTi+GNnkbs44HVvAo5JvrMQ+gBogS gTKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=+b8FaGjpy1m/+RszNBOW0Osd/3HyG6oUQQPlglChFwA=; fh=LMD++Neen/uL2bmCB54jnFOk8H4aKpkjQiz1i4fjgWI=; b=pAkAfbM37kCJ5FtNxJxEFoD9p/BSPnkfqaumQJQuZby4SvXI121nDtjp9YIi2ixKRQ S4unSzZ0wja0kaTdL8yve+qO+1dFjF6DgbrHjr62rdPJaHrLdRxNYok8ge/DQOXyu2JL TTfE6t1ZckPYms9P8JmMwfGaG1BirPoOY6HRqr58kwe6DdB9pYtlIMByRFq3vvyofYjS d7yoF5vb4Mhq8jL/YlsHGBJ0K+oIMVIz8itq5hHFyVzZeVEnooe/PIUhaB1rx/nJNtfY tt+iaytorNrWNaQXzsv4holqUB6XAnJJXehItJFUUqbLgrYUndP3JhFF+cBpbfrpgQWc rYQQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZrlmGANq; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-187354-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187354-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6aa605c0d98si101585016d6.12.2024.05.23.03.44.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 03:44:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187354-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZrlmGANq; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-187354-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187354-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1EDF01C22335 for ; Thu, 23 May 2024 10:44:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6483B14532E; Thu, 23 May 2024 10:44:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZrlmGANq" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ECF051442FC for ; Thu, 23 May 2024 10:44:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716461069; cv=none; b=hn4GCekuO1zI+Nn5h6AEkvJQKG2R8wJXtDmjYXLYZ4VAJb4u+qQYdIf9FC4ea7ow0Ss9aUl3a9Up8SJv2iO7nKAJmspkIgagq64Lb1KuttkAKYiIiIWJLPdeWEqe6vPoV0JEKlT1Da5OpojIFSdIZuML64ijFJ+yubR5wgMZMd8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716461069; c=relaxed/simple; bh=5hx2fSiT2DY4uOpmEnaz0dH8rVhtHW/XCwPNtgDvYrg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Pf9UvQ5Q9kRGTWtbia73bLqBtiBoVvRotkDvNvgIfcRI3zv68xp4rOHZlAOf2yoo5jiF668aV2Qd0C5SyX2aczz7jvU7Y36JCHIH4E0Jw8M1rGecEn1H14DBtO6+1JhwPQPP5LP1gPvYfv1hOM1L7xC1it3sIQ6r1MNqGwzjIro= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZrlmGANq; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716461067; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+b8FaGjpy1m/+RszNBOW0Osd/3HyG6oUQQPlglChFwA=; b=ZrlmGANqUk02/p2DlxIAjjQkjsGLceI4MwBiV0opvzx00xQDl91hbefSiHd+edY92SBzLO hOt7Wm420QH6zOvVSu+ImmhZ4pu4/eiAP5Uwb2MUDVFmU0fkH3GA2DAvWpBd+KSYHBBuw2 NO2GK+4mMxwPm3O/LSBqWjKz5gIvwv0= Received: from mail-vs1-f71.google.com (mail-vs1-f71.google.com [209.85.217.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-641-m-2AOZRMO-6jWfkLy5GUSg-1; Thu, 23 May 2024 06:44:25 -0400 X-MC-Unique: m-2AOZRMO-6jWfkLy5GUSg-1 Received: by mail-vs1-f71.google.com with SMTP id ada2fe7eead31-47f449f0217so4011271137.2 for ; Thu, 23 May 2024 03:44:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716461065; x=1717065865; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+b8FaGjpy1m/+RszNBOW0Osd/3HyG6oUQQPlglChFwA=; b=KwqkKWCWGsdgekm0dR1tlQ74tQPynkM1lZ2woFmbWz1exDl9Rt1vHUVr6eiN5luIfo /zoW8YNXNsjSS5WYTfsdoJkO008UtGoTZioOHjfJJcul36zHxXb/EczSX1RaI7SSUZ8J XVkhdSwnxjk5PzMaf6D8JXk+lwWPQY0vw93/8RLCjTx9mPhceeU9PeZbpKYXYQYwbwZU yKs6zC2WrN4VmQsK9F/azUm94hqyqg00Bm4qYzL/Nal8aXOHXn+jzYk93A2A7/ywLKT0 asWuAlj8lRy2b+0WYeymX0C/ij/wxhOclNI/SHV1B3+RPym1SEoBKIWIobm6+LJihFho pgXA== X-Forwarded-Encrypted: i=1; AJvYcCX8GppgLbEWbRGgJhOEzyyy8PZl6NbFG+LgLJTUjgTzffH31DKiMvK7sxkK+wikqUYsN4eGK65yYhT/YKNHobdzJ2qczWmgmgCbId7F X-Gm-Message-State: AOJu0Yy0mSDOHdYciXscgiGHOQMXsAV0jw3D9XR70z7SwkhVFWyjYza/ DZ76pQmczKphd6HQdt6fxd8cJGfAV/u2N8fAwDPVm1b7sYcmDoDf3sH4vSEeB5jVdr4SLfyLVYv f6SPn/W1oJ3jXmR/4rFybcvC382FKVNwp8yYQi1jPj68uwK7SsbGEcX1QEQ/Cow== X-Received: by 2002:a05:6102:6ce:b0:47e:ee4d:8431 with SMTP id ada2fe7eead31-48900956d84mr4979032137.3.1716461065114; Thu, 23 May 2024 03:44:25 -0700 (PDT) X-Received: by 2002:a05:6102:6ce:b0:47e:ee4d:8431 with SMTP id ada2fe7eead31-48900956d84mr4979019137.3.1716461064769; Thu, 23 May 2024 03:44:24 -0700 (PDT) Received: from sgarzare-redhat (host-79-53-30-109.retail.telecomitalia.it. [79.53.30.109]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-43f991bb19dsm25568231cf.63.2024.05.23.03.44.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 03:44:24 -0700 (PDT) Date: Thu, 23 May 2024 12:44:20 +0200 From: Stefano Garzarella To: Xuewei Niu Cc: stefanha@redhat.com, mst@redhat.com, davem@davemloft.net, kvm@vger.kernel.org, virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Xuewei Niu Subject: Re: [RFC PATCH 3/5] vsock/virtio: can_msgzerocopy adapts to multi-devices Message-ID: References: <20240517144607.2595798-1-niuxuewei.nxw@antgroup.com> <20240517144607.2595798-4-niuxuewei.nxw@antgroup.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20240517144607.2595798-4-niuxuewei.nxw@antgroup.com> On Fri, May 17, 2024 at 10:46:05PM GMT, Xuewei Niu wrote: >Adds a new argument, named "cid", to let them know which `virtio_vsock` to >be selected. > >Signed-off-by: Xuewei Niu >--- > include/linux/virtio_vsock.h | 2 +- > net/vmw_vsock/virtio_transport.c | 5 ++--- > net/vmw_vsock/virtio_transport_common.c | 6 +++--- > 3 files changed, 6 insertions(+), 7 deletions(-) Every commit in linux must be working to support bisection. So these changes should be made before adding multi-device support. > >diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h >index c82089dee0c8..21bfd5e0c2e7 100644 >--- a/include/linux/virtio_vsock.h >+++ b/include/linux/virtio_vsock.h >@@ -168,7 +168,7 @@ struct virtio_transport { > * extra checks and can perform zerocopy transmission by > * default. > */ >- bool (*can_msgzerocopy)(int bufs_num); >+ bool (*can_msgzerocopy)(u32 cid, int bufs_num); > }; > > ssize_t >diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c >index 93d25aeafb83..998b22e5ce36 100644 >--- a/net/vmw_vsock/virtio_transport.c >+++ b/net/vmw_vsock/virtio_transport.c >@@ -521,14 +521,13 @@ static void virtio_vsock_rx_done(struct virtqueue *vq) > queue_work(virtio_vsock_workqueue, &vsock->rx_work); > } > >-static bool virtio_transport_can_msgzerocopy(int bufs_num) >+static bool virtio_transport_can_msgzerocopy(u32 cid, int bufs_num) > { > struct virtio_vsock *vsock; > bool res = false; > > rcu_read_lock(); >- >- vsock = rcu_dereference(the_virtio_vsock); >+ vsock = virtio_transport_get_virtio_vsock(cid); > if (vsock) { > struct virtqueue *vq = vsock->vqs[VSOCK_VQ_TX]; > >diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c >index bed75a41419e..e7315d7b9af1 100644 >--- a/net/vmw_vsock/virtio_transport_common.c >+++ b/net/vmw_vsock/virtio_transport_common.c >@@ -39,7 +39,7 @@ virtio_transport_get_ops(struct vsock_sock *vsk) > > static bool virtio_transport_can_zcopy(const struct virtio_transport *t_ops, > struct virtio_vsock_pkt_info *info, >- size_t pkt_len) >+ size_t pkt_len, unsigned int cid) > { > struct iov_iter *iov_iter; > >@@ -62,7 +62,7 @@ static bool virtio_transport_can_zcopy(const struct virtio_transport *t_ops, > int pages_to_send = iov_iter_npages(iov_iter, MAX_SKB_FRAGS); > > /* +1 is for packet header. */ >- return t_ops->can_msgzerocopy(pages_to_send + 1); >+ return t_ops->can_msgzerocopy(cid, pages_to_send + 1); > } > > return true; >@@ -375,7 +375,7 @@ static int virtio_transport_send_pkt_info(struct vsock_sock *vsk, > info->msg->msg_flags &= ~MSG_ZEROCOPY; > > if (info->msg->msg_flags & MSG_ZEROCOPY) >- can_zcopy = virtio_transport_can_zcopy(t_ops, info, pkt_len); >+ can_zcopy = virtio_transport_can_zcopy(t_ops, info, pkt_len, src_cid); > > if (can_zcopy) > max_skb_len = min_t(u32, VIRTIO_VSOCK_MAX_PKT_BUF_SIZE, >-- >2.34.1 >