public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Juan Quintela <quintela@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>,
	kvm@vger.kernel.org, virtualization@lists.osdl.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	David Miller <davem@davemloft.net>,
	markmc@redhat.com, gleb@redhat.com, herbert.xu@redhat.com,
	dlaor@redhat.com, avi@redhat.com
Subject: Re: [PATCH 1/3] vhost: logging math fix
Date: Tue, 23 Feb 2010 20:26:21 +0100	[thread overview]
Message-ID: <m3bpffwy76.fsf@trasno.mitica> (raw)
In-Reply-To: <51e0f786b06c198ab355abab19f0bd11ac6a167b.1266943453.git.mst@redhat.com> (Michael S. Tsirkin's message of "Tue, 23 Feb 2010 18:57:43 +0200")

"Michael S. Tsirkin" <mst@redhat.com> wrote:
> vhost was dong some complex math to get
> offset to log at, and got it wrong by a couple of bytes,
> while in fact it's simple: get address where we write,
> subtract start of buffer, add log base.
>
> Do it this way.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>

> ---
>  drivers/vhost/vhost.c |   10 ++++++----
>  1 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index 6eb1525..c767279 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -1004,10 +1004,12 @@ int vhost_add_used(struct vhost_virtqueue *vq, unsigned int head, int len)
>  	if (unlikely(vq->log_used)) {
>  		/* Make sure data is seen before log. */

We explain what smp_wmb() does.

>  		smp_wmb();
> -		log_write(vq->log_base, vq->log_addr + sizeof *vq->used->ring *
> -			  (vq->last_used_idx % vq->num),
> -			  sizeof *vq->used->ring);
> -		log_write(vq->log_base, vq->log_addr, sizeof *vq->used->ring);
> +		log_write(vq->log_base,
> +			  vq->log_addr + ((void *)used - (void *)vq->used),
> +			  sizeof *used);
> +		log_write(vq->log_base,
> +			  vq->log_addr + offsetof(struct vring_used, idx),
> +			  sizeof vq->used->idx);

Once here, can we add a comment explaining _what_ are we trying to write
to the log?  michael explains that t is the used element and the index,
but nothing states that.

>  		if (vq->log_ctx)
>  			eventfd_signal(vq->log_ctx, 1);
>  	}

  reply	other threads:[~2010-02-23 19:26 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-23 16:57 [PATCH 0/3] vhost: logging fixes Michael S. Tsirkin
2010-02-23 16:57 ` [PATCH 1/3] vhost: logging math fix Michael S. Tsirkin
2010-02-23 19:26   ` Juan Quintela [this message]
2010-02-23 16:57 ` [PATCH 2/3] vhost: initialize log eventfd context pointer Michael S. Tsirkin
2010-02-23 19:31   ` Juan Quintela
2010-02-23 16:57 ` [PATCH 3/3] vhost: fix get_user_pages_fast error handling Michael S. Tsirkin
2010-02-23 17:34   ` Gleb Natapov
2010-02-23 17:32     ` Michael S. Tsirkin
2010-02-23 17:39       ` Gleb Natapov
2010-02-23 17:39         ` Michael S. Tsirkin
2010-02-23 17:43           ` Gleb Natapov
2010-02-23 22:42         ` David Miller
2010-02-24  5:37           ` Michael S. Tsirkin
2010-02-24  7:04             ` David Miller
2010-02-24  7:34               ` Michael S. Tsirkin
2010-02-24  7:41                 ` David Miller
2010-02-23 19:56   ` Juan Quintela

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=m3bpffwy76.fsf@trasno.mitica \
    --to=quintela@redhat.com \
    --cc=avi@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dlaor@redhat.com \
    --cc=gleb@redhat.com \
    --cc=herbert.xu@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markmc@redhat.com \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    --cc=virtualization@lists.osdl.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