[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP_N_Z-U0_XP69iNLA1Ray9EEVWyXqb2f85bL-sG2oxjM5PaMA@mail.gmail.com>
Date: Mon, 21 Jun 2021 10:27:40 -0700
From: "Jiang Wang ." <jiang.wang@...edance.com>
To: Stefano Garzarella <sgarzare@...hat.com>
Cc: virtualization@...ts.linux-foundation.org,
Stefan Hajnoczi <stefanha@...hat.com>,
"Michael S. Tsirkin" <mst@...hat.com>,
Arseny Krasnov <arseny.krasnov@...persky.com>,
cong.wang@...edance.com,
Xiongchun Duan <duanxiongchun@...edance.com>,
Yongji Xie <xieyongji@...edance.com>,
柴稳 <chaiwen.cc@...edance.com>,
Jason Wang <jasowang@...hat.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Steven Rostedt <rostedt@...dmis.org>,
Ingo Molnar <mingo@...hat.com>,
Colin Ian King <colin.king@...onical.com>,
Norbert Slusarek <nslusarek@....net>,
Andra Paraschiv <andraprs@...zon.com>,
Lu Wei <luwei32@...wei.com>,
Alexander Popov <alex.popov@...ux.com>, kvm@...r.kernel.org,
Networking <netdev@...r.kernel.org>, linux-kernel@...r.kernel.org
Subject: Re: [External] Re: [RFC v1 6/6] virtio/vsock: add sysfs for rx buf
len for dgram
On Fri, Jun 18, 2021 at 3:04 AM Stefano Garzarella <sgarzare@...hat.com> wrote:
>
> On Wed, Jun 09, 2021 at 11:24:58PM +0000, Jiang Wang wrote:
> >Make rx buf len configurable via sysfs
> >
> >Signed-off-by: Jiang Wang <jiang.wang@...edance.com>
> >---
> > net/vmw_vsock/virtio_transport.c | 37 +++++++++++++++++++++++++++++++++++--
> > 1 file changed, 35 insertions(+), 2 deletions(-)
> >
> >diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c
> >index cf47aadb0c34..2e4dd9c48472 100644
> >--- a/net/vmw_vsock/virtio_transport.c
> >+++ b/net/vmw_vsock/virtio_transport.c
> >@@ -29,6 +29,14 @@ static struct virtio_vsock __rcu *the_virtio_vsock;
> > static struct virtio_vsock *the_virtio_vsock_dgram;
> > static DEFINE_MUTEX(the_virtio_vsock_mutex); /* protects the_virtio_vsock */
> >
> >+static int rx_buf_len = VIRTIO_VSOCK_DEFAULT_RX_BUF_SIZE;
> >+static struct kobject *kobj_ref;
> >+static ssize_t sysfs_show(struct kobject *kobj,
> >+ struct kobj_attribute *attr, char *buf);
> >+static ssize_t sysfs_store(struct kobject *kobj,
> >+ struct kobj_attribute *attr, const char *buf, size_t count);
> >+static struct kobj_attribute rxbuf_attr = __ATTR(rx_buf_value, 0660, sysfs_show, sysfs_store);
>
> Maybe better to use a 'dgram' prefix.
Sure.
> >+
> > struct virtio_vsock {
> > struct virtio_device *vdev;
> > struct virtqueue **vqs;
> >@@ -360,7 +368,7 @@ virtio_transport_cancel_pkt(struct vsock_sock *vsk)
> >
> > static void virtio_vsock_rx_fill(struct virtio_vsock *vsock, bool is_dgram)
> > {
> >- int buf_len = VIRTIO_VSOCK_DEFAULT_RX_BUF_SIZE;
> >+ int buf_len = rx_buf_len;
> > struct virtio_vsock_pkt *pkt;
> > struct scatterlist hdr, buf, *sgs[2];
> > struct virtqueue *vq;
> >@@ -1003,6 +1011,22 @@ static struct virtio_driver virtio_vsock_driver = {
> > .remove = virtio_vsock_remove,
> > };
> >
> >+static ssize_t sysfs_show(struct kobject *kobj,
> >+ struct kobj_attribute *attr, char *buf)
> >+{
> >+ return sprintf(buf, "%d", rx_buf_len);
> >+}
> >+
> >+static ssize_t sysfs_store(struct kobject *kobj,
> >+ struct kobj_attribute *attr, const char *buf, size_t count)
> >+{
> >+ if (kstrtou32(buf, 0, &rx_buf_len) < 0)
> >+ return -EINVAL;
> >+ if (rx_buf_len < 1024)
> >+ rx_buf_len = 1024;
> >+ return count;
> >+}
> >+
> > static int __init virtio_vsock_init(void)
> > {
> > int ret;
> >@@ -1020,8 +1044,17 @@ static int __init virtio_vsock_init(void)
> > if (ret)
> > goto out_vci;
> >
> >- return 0;
> >+ kobj_ref = kobject_create_and_add("vsock", kernel_kobj);
>
> So, IIUC, the path will be /sys/vsock/rx_buf_value?
>
> I'm not sure if we need to add a `virtio` subdir (e.g.
> /sys/vsock/virtio/dgram_rx_buf_size)
I agree adding a virtio is better in case vmware or hyperv will
also have some settings.
> Thanks,
> Stefano
>
> >
> >+ /*Creating sysfs file for etx_value*/
> >+ ret = sysfs_create_file(kobj_ref, &rxbuf_attr.attr);
> >+ if (ret)
> >+ goto out_sysfs;
> >+
> >+ return 0;
> >+out_sysfs:
> >+ kobject_put(kobj_ref);
> >+ sysfs_remove_file(kernel_kobj, &rxbuf_attr.attr);
> > out_vci:
> > vsock_core_unregister(&virtio_transport.transport);
> > out_wq:
> >--
> >2.11.0
> >
>
Powered by blists - more mailing lists