linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Liu Yuan <namei.unix@gmail.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>,
	linux-kernel@vger.kernel.org,
	virtualization@lists.linux-foundation.org
Subject: Re: [PATCH] virtio, ring: Use ALIGN macros in virtio_ring.h
Date: Tue, 26 Apr 2011 10:42:30 +0300	[thread overview]
Message-ID: <20110426074230.GA10364@redhat.com> (raw)
In-Reply-To: <1303791070-15196-1-git-send-email-namei.unix@gmail.com>

On Tue, Apr 26, 2011 at 12:11:10PM +0800, Liu Yuan wrote:
> From: Liu Yuan <tailai.ly@taobao.com>
> 
> 
> Signed-off-by: Liu Yuan <tailai.ly@taobao.com>

Issue is, these functions are exported to userspace,
which does not have these macros.

> ---
>  include/linux/virtio_ring.h |    8 +++-----
>  1 files changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
> index e4d144b..6299050 100644
> --- a/include/linux/virtio_ring.h
> +++ b/include/linux/virtio_ring.h
> @@ -99,15 +99,13 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p,
>  	vr->num = num;
>  	vr->desc = p;
>  	vr->avail = p + num*sizeof(struct vring_desc);
> -	vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + align-1)
> -			    & ~(align - 1));
> +	vr->used = (void *)PTR_ALIGN(&vr->avail->ring[num], align);
>  }
>  
>  static inline unsigned vring_size(unsigned int num, unsigned long align)
>  {
> -	return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num)
> -		 + align - 1) & ~(align - 1))
> -		+ sizeof(__u16) * 2 + sizeof(struct vring_used_elem) * num;
> +	return ((sizeof(struct vring_desc) * num + ALIGN(sizeof(__u16) * (2 + num), align))
> +		+ sizeof(__u16) * 2 + sizeof(struct vring_used_elem) * num);
>  }
>  
>  #ifdef __KERNEL__
> -- 
> 1.7.1

  reply	other threads:[~2011-04-26  7:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-26  4:11 [PATCH] virtio, ring: Use ALIGN macros in virtio_ring.h Liu Yuan
2011-04-26  7:42 ` Michael S. Tsirkin [this message]
2011-04-26  7:50   ` Liu Yuan

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=20110426074230.GA10364@redhat.com \
    --to=mst@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namei.unix@gmail.com \
    --cc=rusty@rustcorp.com.au \
    --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;
as well as URLs for NNTP newsgroup(s).