All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
To: Alexey Kardashevskiy <aik@ozlabs.ru>, linuxppc-dev@lists.ozlabs.org
Cc: Alexey Kardashevskiy <aik@ozlabs.ru>,
	Thomas Huth <thuth@linux.vnet.ibm.com>
Subject: Re: [PATCH slof v2] virtio: Fix vring allocation
Date: Fri, 13 Mar 2015 15:44:38 +0530	[thread overview]
Message-ID: <8761a5p5kh.fsf@abhimanyu.in.ibm.com> (raw)
In-Reply-To: <1426239723-25789-1-git-send-email-aik@ozlabs.ru>

Alexey Kardashevskiy <aik@ozlabs.ru> writes:

> The value returned by virtio_vring_size() is used to allocate memory
> for vring. The used descriptor list (array of vring_used_elem) is
> counted by the header - vring_used struct - is not.
>
> This fixes virtio_vring_size() to return the correct size.
> At the moment rings are quite small (256) and allocated with
> 4096 alignment, this is why we have not been having issues with
> this so far.
>
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>

> ---
> Changes:
> v2:
> * remove magic numbers
> ---
>  lib/libvirtio/virtio.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/lib/libvirtio/virtio.c b/lib/libvirtio/virtio.c
> index b010796..f9c00a6 100644
> --- a/lib/libvirtio/virtio.c
> +++ b/lib/libvirtio/virtio.c
> @@ -32,8 +32,10 @@
>   */
>  unsigned long virtio_vring_size(unsigned int qsize)
>  {
> -	return VQ_ALIGN(sizeof(struct vring_desc) * qsize + 2 * (2 + qsize))
> -		+ VQ_ALIGN(sizeof(struct vring_used_elem) * qsize);
> +	return VQ_ALIGN(sizeof(struct vring_desc) * qsize +
> +                        sizeof(struct vring_avail) + sizeof(uint16_t) * qsize) +
> +               VQ_ALIGN(sizeof(struct vring_used) +
> +                        sizeof(struct vring_used_elem) * qsize);
>  }
>
>
> -- 
> 2.0.0

  reply	other threads:[~2015-03-13 10:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-13  8:40 [PATCH slof] virtio: Fix vring allocation Alexey Kardashevskiy
2015-03-13  9:19 ` Nikunj A Dadhania
2015-03-13  9:42   ` [PATCH slof v2] " Alexey Kardashevskiy
2015-03-13 10:14     ` Nikunj A Dadhania [this message]
2015-03-13 10:25     ` Thomas Huth

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=8761a5p5kh.fsf@abhimanyu.in.ibm.com \
    --to=nikunj@linux.vnet.ibm.com \
    --cc=aik@ozlabs.ru \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=thuth@linux.vnet.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.