From: "Michael S. Tsirkin" <mst@redhat.com>
To: Paolo Abeni <pabeni@redhat.com>
Cc: linux-kernel@vger.kernel.org, "Andrew Lunn" <andrew@lunn.ch>,
"Jason Wang" <jasowang@redhat.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"Jonathan Corbet" <corbet@lwn.net>,
kvm@vger.kernel.org, virtualization@lists.linux.dev,
netdev@vger.kernel.org, linux-doc@vger.kernel.org,
"Mike Christie" <michael.christie@oracle.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Stefan Hajnoczi" <stefanha@redhat.com>,
"Stefano Garzarella" <sgarzare@redhat.com>
Subject: Re: [PATCH v5 2/2] vhost: switch to arrays of feature bits
Date: Wed, 19 Nov 2025 07:48:53 -0500 [thread overview]
Message-ID: <20251119074746-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <4204ed4b-0da1-407f-84e0-e23e2ce65fc7@redhat.com>
On Wed, Nov 19, 2025 at 12:04:12PM +0100, Paolo Abeni wrote:
> On 11/19/25 7:55 AM, Michael S. Tsirkin wrote:
> > @@ -1720,6 +1720,7 @@ static long vhost_net_set_owner(struct vhost_net *n)
> > static long vhost_net_ioctl(struct file *f, unsigned int ioctl,
> > unsigned long arg)
> > {
> > + const DEFINE_VHOST_FEATURES_ARRAY(features_array, vhost_net_features);
>
> I'm sorry for the late feedback, I was drowning in other stuff.
>
> I have just a couple of non blocking suggestions, feel free to ignore.
Oh this is really nice.
I did exactly this and the diff is smaller while the compiler
was smart enough to figure it out and the generated code is the same.
Thanks!
> I think that if you rename `vhost_net_features` as
> `vhost_net_features_bits` and `features_array` as `vhost_net_features`
> the diffstat could be smaller and possibly clearer.
>
> > u64 all_features[VIRTIO_FEATURES_U64S];
> > struct vhost_net *n = f->private_data;
> > void __user *argp = (void __user *)arg;
> > @@ -1734,14 +1735,14 @@ static long vhost_net_ioctl(struct file *f, unsigned int ioctl,
> > return -EFAULT;
> > return vhost_net_set_backend(n, backend.index, backend.fd);
> > case VHOST_GET_FEATURES:
> > - features = vhost_net_features[0];
> > + features = VHOST_FEATURES_U64(vhost_net_features, 0);
>
> Here and below you could use directly:
>
> features = features_array[0];
>
> if you apply the rename mentioned above, this chunk and the following 3
> should not be needed.
>
> [...]> diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c
> > index 42c955a5b211..af727fccfe40 100644
> > --- a/drivers/vhost/test.c
> > +++ b/drivers/vhost/test.c
> > @@ -308,6 +308,12 @@ static long vhost_test_set_backend(struct vhost_test *n, unsigned index, int fd)
> > return r;
> > }
> >
> > +static const int vhost_test_features[] = {
> > + VHOST_FEATURES
> > +};
> > +
> > +#define VHOST_TEST_FEATURES VHOST_FEATURES_U64(vhost_test_features, 0)
>
> If you rename `VHOST_FEATURES` to `VHOST_FEATURES_BITS` and
> `VHOST_TEST_FEATURES` to `VHOST_FEATURES`, the following two chunks
> should not be needed.
>
> Thanks,
>
> Paolo
prev parent reply other threads:[~2025-11-19 12:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-19 6:55 [PATCH v5 0/2] virtio: feature related cleanups Michael S. Tsirkin
2025-11-19 6:55 ` [PATCH v5 1/2] virtio: clean up features qword/dword terms Michael S. Tsirkin
2025-11-19 6:55 ` [PATCH v5 2/2] vhost: switch to arrays of feature bits Michael S. Tsirkin
2025-11-19 11:04 ` Paolo Abeni
2025-11-19 12:34 ` Michael S. Tsirkin
2025-11-19 12:48 ` Michael S. Tsirkin [this message]
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=20251119074746-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=andrew@lunn.ch \
--cc=corbet@lwn.net \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.christie@oracle.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pbonzini@redhat.com \
--cc=sgarzare@redhat.com \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
/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).