lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 09 Dec 2020 10:14:26 +0800
From:   "刘邵华BTD" <liush@...winnertech.com>
To:     "Michael S. Tsirkin" <mst@...hat.com>
Cc:     "jasowang" <jasowang@...hat.com>,
        "virtualization" <virtualization@...ts.linux-foundation.org>,
        "linux-kernel" <linux-kernel@...r.kernel.org>
Subject: 回复:[PATCH] virtio: replace constant parameter '1' with num

Hi Michael,
>> 'num' can represent the value of out_sgs(in_sags), no need to pass 
>> in constant parameters in 'virtqueue_add'.
>> 
>> Signed-off-by: liush <liush@...winnertech.com>

>Point being?
>A constant is likely easier for the compiler to optimize ...

Thanks.
I was unaware that a constant was for compiler optimization. 
It seems that 'num' is more readable compared to a constant. And 'virtqueue_add_*' 
does not specify that only one buf is added, but ‘1’ is passed in ‘virtqueue_add’, 
which limits the function of 'virtqueue_add_*'. Besides compilation optimization, 
are there any other considerations.

>> ---
>>  drivers/virtio/virtio_ring.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
>> index becc776..7583f8b 100644
>> --- a/drivers/virtio/virtio_ring.c
>> +++ b/drivers/virtio/virtio_ring.c
>> @@ -1760,7 +1760,7 @@ int virtqueue_add_outbuf(struct virtqueue *vq,
>>      void *data,
>>      gfp_t gfp)
>>  {
>> - return virtqueue_add(vq, &sg, num, 1, 0, data, NULL, gfp);
>> + return virtqueue_add(vq, &sg, num, num, 0, data, NULL, gfp);
>>  }
>>  EXPORT_SYMBOL_GPL(virtqueue_add_outbuf);
>>  
>> @@ -1782,7 +1782,7 @@ int virtqueue_add_inbuf(struct virtqueue *vq,
>>     void *data,
>>     gfp_t gfp)
>>  {
>> - return virtqueue_add(vq, &sg, num, 0, 1, data, NULL, gfp);
>> + return virtqueue_add(vq, &sg, num, 0, num, data, NULL, gfp);
>>  }
>>  EXPORT_SYMBOL_GPL(virtqueue_add_inbuf);
>>  
>> --

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ