From: Rusty Russell <rusty@rustcorp.com.au>
To: Leandro Dorileo <l@dorileo.org>, linux-kernel@vger.kernel.org
Cc: virtio-dev@lists.oasis-open.org,
virtualization@lists.linux-foundation.org, mst@redhat.com,
Leandro Dorileo <l@dorileo.org>
Subject: Re: [PATCH] virtio_balloon: don't call virtio_has_feature() twice on init_vqs()
Date: Tue, 28 Jan 2014 10:48:31 +1030 [thread overview]
Message-ID: <87ppndyn54.fsf@rustcorp.com.au> (raw)
In-Reply-To: <1390679972-1406-1-git-send-email-l@dorileo.org>
Leandro Dorileo <l@dorileo.org> writes:
> Cchange init_vqs() to avoid calling twice the virtio_has_feature()
> - attempting to find out if VIRTIO_BALLOON_F_STATS_VQ feature was negotiated -
> consequently we prevent unnecessarily running the drivers' feature_table more
> than needed.
>
> Signed-off-by: Leandro Dorileo <l@dorileo.org>
Hi Leandro,
This seems like a premature optimization. The current code is
fairly clear, and there's no performance issue with init_vqs.
Am I missing something?
Rusty.
> ---
> drivers/virtio/virtio_balloon.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
> index 34bdaba..41771c1 100644
> --- a/drivers/virtio/virtio_balloon.c
> +++ b/drivers/virtio/virtio_balloon.c
> @@ -320,19 +320,21 @@ static int init_vqs(struct virtio_balloon *vb)
> vq_callback_t *callbacks[] = { balloon_ack, balloon_ack, stats_request };
> const char *names[] = { "inflate", "deflate", "stats" };
> int err, nvqs;
> + bool stats;
>
> /*
> * We expect two virtqueues: inflate and deflate, and
> * optionally stat.
> */
> - nvqs = virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ) ? 3 : 2;
> + stats = virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ);
> + nvqs = stats ? 3 : 2;
> err = vb->vdev->config->find_vqs(vb->vdev, nvqs, vqs, callbacks, names);
> if (err)
> return err;
>
> vb->inflate_vq = vqs[0];
> vb->deflate_vq = vqs[1];
> - if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ)) {
> + if (stats) {
> struct scatterlist sg;
> vb->stats_vq = vqs[2];
>
> --
> 1.8.5.3
next prev parent reply other threads:[~2014-01-28 0:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-25 19:59 [PATCH] virtio_balloon: don't call virtio_has_feature() twice on init_vqs() Leandro Dorileo
2014-01-28 0:18 ` Rusty Russell [this message]
2014-01-28 2:06 ` Leandro Dorileo
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=87ppndyn54.fsf@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=l@dorileo.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=virtio-dev@lists.oasis-open.org \
--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