Re: [PATCH] vhost: replace % with & on data path

2015-11-30 Thread kbuild test robot
Hi Michael,

[auto build test ERROR on: v4.4-rc3]
[also build test ERROR on: next-20151127]

url:
https://github.com/0day-ci/linux/commits/Michael-S-Tsirkin/vhost-replace-with-on-data-path/20151130-163704
config: s390-performance_defconfig (attached as .config)
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=s390 

All errors (new ones prefixed by >>):

   drivers/vhost/vhost.c: In function 'vhost_get_vq_desc':
   drivers/vhost/vhost.c:1345:6: warning: unused variable 'ret' 
[-Wunused-variable]
 int ret;
 ^
   drivers/vhost/vhost.c:1344:13: warning: unused variable 'ring_head' 
[-Wunused-variable]
 __virtio16 ring_head;
^
   drivers/vhost/vhost.c:1341:24: warning: unused variable 'found' 
[-Wunused-variable]
 unsigned int i, head, found = 0;
   ^
   drivers/vhost/vhost.c:1341:18: warning: unused variable 'head' 
[-Wunused-variable]
 unsigned int i, head, found = 0;
 ^
   drivers/vhost/vhost.c:1341:15: warning: unused variable 'i' 
[-Wunused-variable]
 unsigned int i, head, found = 0;
  ^
   drivers/vhost/vhost.c:1340:20: warning: unused variable 'desc' 
[-Wunused-variable]
 struct vring_desc desc;
   ^
   drivers/vhost/vhost.c: At top level:
   drivers/vhost/vhost.c:1373:2: error: expected identifier or '(' before 'if'
 if (unlikely(__get_user(ring_head,
 ^
   In file included from include/uapi/linux/stddef.h:1:0,
from include/linux/stddef.h:4,
from include/uapi/linux/posix_types.h:4,
from include/uapi/linux/types.h:13,
from include/linux/types.h:5,
from include/uapi/asm-generic/fcntl.h:4,
from arch/s390/include/uapi/asm/fcntl.h:1,
from include/uapi/linux/fcntl.h:4,
from include/linux/fcntl.h:4,
from include/linux/eventfd.h:11,
from drivers/vhost/vhost.c:14:
>> arch/s390/include/asm/uaccess.h:250:2: error: expected identifier or '(' 
>> before ')' token
})
 ^
   include/linux/compiler.h:166:42: note: in definition of macro 'unlikely'
# define unlikely(x) __builtin_expect(!!(x), 0)
 ^
   drivers/vhost/vhost.c:1373:15: note: in expansion of macro '__get_user'
 if (unlikely(__get_user(ring_head,
  ^
   drivers/vhost/vhost.c:1381:2: warning: data definition has no type or 
storage class
 head = vhost16_to_cpu(vq, ring_head);
 ^
   drivers/vhost/vhost.c:1381:2: error: type defaults to 'int' in declaration 
of 'head' [-Werror=implicit-int]
   drivers/vhost/vhost.c:1381:24: error: 'vq' undeclared here (not in a 
function)
 head = vhost16_to_cpu(vq, ring_head);
   ^
   drivers/vhost/vhost.c:1381:28: error: 'ring_head' undeclared here (not in a 
function)
 head = vhost16_to_cpu(vq, ring_head);
   ^
   drivers/vhost/vhost.c:1384:2: error: expected identifier or '(' before 'if'
 if (unlikely(head >= vq->num)) {
 ^
   drivers/vhost/vhost.c:1391:2: warning: data definition has no type or 
storage class
 *out_num = *in_num = 0;
 ^
   drivers/vhost/vhost.c:1391:3: error: type defaults to 'int' in declaration 
of 'out_num' [-Werror=implicit-int]
 *out_num = *in_num = 0;
  ^
   drivers/vhost/vhost.c:1391:14: error: 'in_num' undeclared here (not in a 
function)
 *out_num = *in_num = 0;
 ^
   drivers/vhost/vhost.c:1392:2: error: expected identifier or '(' before 'if'
 if (unlikely(log))
 ^
   drivers/vhost/vhost.c:1395:2: warning: data definition has no type or 
storage class
 i = head;
 ^
   drivers/vhost/vhost.c:1395:2: error: type defaults to 'int' in declaration 
of 'i' [-Werror=implicit-int]
   drivers/vhost/vhost.c:1395:2: error: initializer element is not constant
   drivers/vhost/vhost.c:1396:2: error: expected identifier or '(' before 'do'
 do {
 ^
   drivers/vhost/vhost.c:1454:4: error: expected identifier or '(' before 
'while'
 } while ((i = next_desc(vq, )) != -1);
   ^
   drivers/vhost/vhost.c:1457:4: error: expected '=', ',', ';', 'asm' or 
'__attribute__' before '->' token
 vq->last_avail_idx++;
   ^
   In file included from arch/s390/include/asm/bug.h:69:0,
from include/linux/bug.h:4,
from include/linux/thread_info.h:11,
from include/asm-generic/preempt.h:4,
from arch/s390/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:59,
from include/linux/spinlock.h:50,
from include/linux/wait.h:8,
   

Re: [PATCH] vhost: replace % with & on data path

2015-11-30 Thread kbuild test robot
Hi Michael,

[auto build test ERROR on: v4.4-rc3]
[also build test ERROR on: next-20151127]

url:
https://github.com/0day-ci/linux/commits/Michael-S-Tsirkin/vhost-replace-with-on-data-path/20151130-163704
config: i386-randconfig-s1-201548 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All error/warnings (new ones prefixed by >>):

   drivers/vhost/vhost.c: In function 'vhost_get_vq_desc':
>> drivers/vhost/vhost.c:1345:6: warning: unused variable 'ret' 
>> [-Wunused-variable]
 int ret;
 ^
>> drivers/vhost/vhost.c:1344:13: warning: unused variable 'ring_head' 
>> [-Wunused-variable]
 __virtio16 ring_head;
^
>> drivers/vhost/vhost.c:1341:24: warning: unused variable 'found' 
>> [-Wunused-variable]
 unsigned int i, head, found = 0;
   ^
>> drivers/vhost/vhost.c:1341:18: warning: unused variable 'head' 
>> [-Wunused-variable]
 unsigned int i, head, found = 0;
 ^
>> drivers/vhost/vhost.c:1341:15: warning: unused variable 'i' 
>> [-Wunused-variable]
 unsigned int i, head, found = 0;
  ^
>> drivers/vhost/vhost.c:1340:20: warning: unused variable 'desc' 
>> [-Wunused-variable]
 struct vring_desc desc;
   ^
   drivers/vhost/vhost.c: At top level:
>> drivers/vhost/vhost.c:1373:2: error: expected identifier or '(' before 'if'
 if (unlikely(__get_user(ring_head,
 ^
   In file included from include/uapi/linux/stddef.h:1:0,
from include/linux/stddef.h:4,
from include/uapi/linux/posix_types.h:4,
from include/uapi/linux/types.h:13,
from include/linux/types.h:5,
from include/uapi/asm-generic/fcntl.h:4,
from arch/x86/include/uapi/asm/fcntl.h:1,
from include/uapi/linux/fcntl.h:4,
from include/linux/fcntl.h:4,
from include/linux/eventfd.h:11,
from drivers/vhost/vhost.c:14:
>> arch/x86/include/asm/uaccess.h:414:2: error: expected identifier or '(' 
>> before ')' token
})
 ^
   include/linux/compiler.h:137:45: note: in definition of macro 'unlikely'
#  define unlikely(x) (__builtin_constant_p(x) ? !!(x) : 
__branch_check__(x, 0))
^
   arch/x86/include/asm/uaccess.h:479:2: note: in expansion of macro 
'__get_user_nocheck'
 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
 ^
>> drivers/vhost/vhost.c:1373:15: note: in expansion of macro '__get_user'
 if (unlikely(__get_user(ring_head,
  ^
>> arch/x86/include/asm/uaccess.h:414:2: error: expected identifier or '(' 
>> before ')' token
})
 ^
   include/linux/compiler.h:137:53: note: in definition of macro 'unlikely'
#  define unlikely(x) (__builtin_constant_p(x) ? !!(x) : 
__branch_check__(x, 0))
^
   arch/x86/include/asm/uaccess.h:479:2: note: in expansion of macro 
'__get_user_nocheck'
 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
 ^
>> drivers/vhost/vhost.c:1373:15: note: in expansion of macro '__get_user'
 if (unlikely(__get_user(ring_head,
  ^
>> include/linux/compiler.h:126:4: error: expected identifier or '(' before ')' 
>> token
  })
   ^
   include/linux/compiler.h:137:58: note: in expansion of macro 
'__branch_check__'
#  define unlikely(x) (__builtin_constant_p(x) ? !!(x) : 
__branch_check__(x, 0))
 ^
>> drivers/vhost/vhost.c:1373:6: note: in expansion of macro 'unlikely'
 if (unlikely(__get_user(ring_head,
 ^
>> drivers/vhost/vhost.c:1381:2: warning: data definition has no type or 
>> storage class
 head = vhost16_to_cpu(vq, ring_head);
 ^
>> drivers/vhost/vhost.c:1381:2: error: type defaults to 'int' in declaration 
>> of 'head' [-Werror=implicit-int]
>> drivers/vhost/vhost.c:1381:24: error: 'vq' undeclared here (not in a 
>> function)
 head = vhost16_to_cpu(vq, ring_head);
   ^
>> drivers/vhost/vhost.c:1381:28: error: 'ring_head' undeclared here (not in a 
>> function)
 head = vhost16_to_cpu(vq, ring_head);
   ^
   drivers/vhost/vhost.c:1384:2: error: expected identifier or '(' before 'if'
 if (unlikely(head >= vq->num)) {
 ^
   In file included from include/uapi/linux/stddef.h:1:0,
from include/linux/stddef.h:4,
from include/uapi/linux/posix_types.h:4,
from include/uapi/linux/types.h:13,
from include/linux/types.h:5,
from include/uapi/asm-generic/fcntl.h:4,
from arch/x86/include/uapi/asm/fcntl.h:1,
from include/uapi/linux/fcntl.h:4,
from include/linux/fcntl.h:4,
  

Re: [PATCH] vhost: replace % with & on data path

2015-11-30 Thread Michael S. Tsirkin
On Mon, Nov 30, 2015 at 10:34:07AM +0200, Michael S. Tsirkin wrote:
> We know vring num is a power of 2, so use &
> to mask the high bits.
> 
> Signed-off-by: Michael S. Tsirkin 
> ---
>  drivers/vhost/vhost.c | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index 080422f..85f0f0a 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -1366,10 +1366,12 @@ int vhost_get_vq_desc(struct vhost_virtqueue *vq,
>   /* Only get avail ring entries after they have been exposed by guest. */
>   smp_rmb();
>  
> + }
> +

Oops. This sneaked in from an unrelated patch.
Pls ignore, will repost.

>   /* Grab the next descriptor number they're advertising, and increment
>* the index we've seen. */
>   if (unlikely(__get_user(ring_head,
> - >avail->ring[last_avail_idx % vq->num]))) {
> + >avail->ring[last_avail_idx & (vq->num - 
> 1)]))) {
>   vq_err(vq, "Failed to read head: idx %d address %p\n",
>  last_avail_idx,
>  >avail->ring[last_avail_idx % vq->num]);
> @@ -1489,7 +1491,7 @@ static int __vhost_add_used_n(struct vhost_virtqueue 
> *vq,
>   u16 old, new;
>   int start;
>  
> - start = vq->last_used_idx % vq->num;
> + start = vq->last_used_idx & (vq->num - 1);
>   used = vq->used->ring + start;
>   if (count == 1) {
>   if (__put_user(heads[0].id, >id)) {
> @@ -1531,7 +1533,7 @@ int vhost_add_used_n(struct vhost_virtqueue *vq, struct 
> vring_used_elem *heads,
>  {
>   int start, n, r;
>  
> - start = vq->last_used_idx % vq->num;
> + start = vq->last_used_idx & (vq->num - 1);
>   n = vq->num - start;
>   if (n < count) {
>   r = __vhost_add_used_n(vq, heads, n);
> -- 
> MST
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] vhost: replace % with & on data path

2015-11-30 Thread Michael S. Tsirkin
On Mon, Nov 30, 2015 at 12:42:49AM -0800, Joe Perches wrote:
> On Mon, 2015-11-30 at 10:34 +0200, Michael S. Tsirkin wrote:
> > We know vring num is a power of 2, so use &
> > to mask the high bits.
> []
> > diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> []
> > @@ -1366,10 +1366,12 @@ int vhost_get_vq_desc(struct vhost_virtqueue *vq,
> > /* Only get avail ring entries after they have been exposed by guest. */
> > smp_rmb();
> >  
> > +   }
> 
> ?

Yes, I noticed this - I moved this chunk from the next patch
in my tree by mistake.

Will fix, thanks!

-- 
MST
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] vhost: replace % with & on data path

2015-11-30 Thread David Miller
From: "Michael S. Tsirkin" 
Date: Mon, 30 Nov 2015 10:34:07 +0200

> We know vring num is a power of 2, so use &
> to mask the high bits.
> 
> Signed-off-by: Michael S. Tsirkin 
> ---
>  drivers/vhost/vhost.c | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index 080422f..85f0f0a 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -1366,10 +1366,12 @@ int vhost_get_vq_desc(struct vhost_virtqueue *vq,
>   /* Only get avail ring entries after they have been exposed by guest. */
>   smp_rmb();
>  
> + }
> +

!!!
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] vhost: replace % with & on data path

2015-11-30 Thread Joe Perches
On Mon, 2015-11-30 at 10:34 +0200, Michael S. Tsirkin wrote:
> We know vring num is a power of 2, so use &
> to mask the high bits.
[]
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
[]
> @@ -1366,10 +1366,12 @@ int vhost_get_vq_desc(struct vhost_virtqueue *vq,
>   /* Only get avail ring entries after they have been exposed by guest. */
>   smp_rmb();
>  
> + }

?

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] vhost: replace % with & on data path

2015-11-30 Thread kbuild test robot
Hi Michael,

[auto build test ERROR on: v4.4-rc3]
[also build test ERROR on: next-20151127]

url:
https://github.com/0day-ci/linux/commits/Michael-S-Tsirkin/vhost-replace-with-on-data-path/20151130-163704
config: x86_64-randconfig-s0-11301655 (attached as .config)
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 

All error/warnings (new ones prefixed by >>):

   drivers/vhost/vhost.c: In function 'vhost_get_vq_desc':
   drivers/vhost/vhost.c:1345:6: warning: unused variable 'ret' 
[-Wunused-variable]
 int ret;
 ^
   drivers/vhost/vhost.c:1344:13: warning: unused variable 'ring_head' 
[-Wunused-variable]
 __virtio16 ring_head;
^
   drivers/vhost/vhost.c:1341:24: warning: unused variable 'found' 
[-Wunused-variable]
 unsigned int i, head, found = 0;
   ^
   drivers/vhost/vhost.c:1341:18: warning: unused variable 'head' 
[-Wunused-variable]
 unsigned int i, head, found = 0;
 ^
   drivers/vhost/vhost.c:1341:15: warning: unused variable 'i' 
[-Wunused-variable]
 unsigned int i, head, found = 0;
  ^
   drivers/vhost/vhost.c:1340:20: warning: unused variable 'desc' 
[-Wunused-variable]
 struct vring_desc desc;
   ^
   In file included from include/uapi/linux/stddef.h:1:0,
from include/linux/stddef.h:4,
from include/uapi/linux/posix_types.h:4,
from include/uapi/linux/types.h:13,
from include/linux/types.h:5,
from include/uapi/asm-generic/fcntl.h:4,
from arch/x86/include/uapi/asm/fcntl.h:1,
from include/uapi/linux/fcntl.h:4,
from include/linux/fcntl.h:4,
from include/linux/eventfd.h:11,
from drivers/vhost/vhost.c:14:
   drivers/vhost/vhost.c: At top level:
>> include/linux/compiler.h:147:2: error: expected identifier or '(' before 'if'
 if (__builtin_constant_p((cond)) ? !!(cond) :   \
 ^
   include/linux/compiler.h:145:23: note: in expansion of macro '__trace_if'
#define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
  ^
>> drivers/vhost/vhost.c:1373:2: note: in expansion of macro 'if'
 if (unlikely(__get_user(ring_head,
 ^
   arch/x86/include/asm/uaccess.h:414:2: error: expected identifier or '(' 
before ')' token
})
 ^
   include/linux/compiler.h:147:28: note: in definition of macro '__trace_if'
 if (__builtin_constant_p((cond)) ? !!(cond) :   \
   ^
>> drivers/vhost/vhost.c:1373:2: note: in expansion of macro 'if'
 if (unlikely(__get_user(ring_head,
 ^
   drivers/vhost/vhost.c:1373:6: note: in expansion of macro 'unlikely'
 if (unlikely(__get_user(ring_head,
 ^
   arch/x86/include/asm/uaccess.h:479:2: note: in expansion of macro 
'__get_user_nocheck'
 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
 ^
   drivers/vhost/vhost.c:1373:15: note: in expansion of macro '__get_user'
 if (unlikely(__get_user(ring_head,
  ^
   arch/x86/include/asm/uaccess.h:414:2: error: expected identifier or '(' 
before ')' token
})
 ^
   include/linux/compiler.h:147:28: note: in definition of macro '__trace_if'
 if (__builtin_constant_p((cond)) ? !!(cond) :   \
   ^
>> drivers/vhost/vhost.c:1373:2: note: in expansion of macro 'if'
 if (unlikely(__get_user(ring_head,
 ^
   drivers/vhost/vhost.c:1373:6: note: in expansion of macro 'unlikely'
 if (unlikely(__get_user(ring_head,
 ^
   arch/x86/include/asm/uaccess.h:479:2: note: in expansion of macro 
'__get_user_nocheck'
 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
 ^
   drivers/vhost/vhost.c:1373:15: note: in expansion of macro '__get_user'
 if (unlikely(__get_user(ring_head,
  ^
   include/linux/compiler.h:126:4: error: expected identifier or '(' before ')' 
token
  })
   ^
   include/linux/compiler.h:147:28: note: in definition of macro '__trace_if'
 if (__builtin_constant_p((cond)) ? !!(cond) :   \
   ^
>> drivers/vhost/vhost.c:1373:2: note: in expansion of macro 'if'
 if (unlikely(__get_user(ring_head,
 ^
   include/linux/compiler.h:137:58: note: in expansion of macro 
'__branch_check__'
#  define unlikely(x) (__builtin_constant_p(x) ? !!(x) : 
__branch_check__(x, 0))
 ^
   drivers/vhost/vhost.c:1373:6: note: in expansion of macro 'unlikely'
 if (unlikely(__get_user(ring_head,
 ^
   arch/x86/include/asm/uaccess.h:414:2: error: expected identifier or '(' 
before ')' token
})
 ^
   include/linux/compiler.h:147:40: note: in definition of macro '__trace_if'
 if (__builtin_constant_p((cond)) ? !!(cond) :   \
   ^
>>