* [PATCH] virtio: replace constant parameter '1' with num
@ 2020-12-08 11:57 liush
2020-12-08 13:55 ` Michael S. Tsirkin
0 siblings, 1 reply; 4+ messages in thread
From: liush @ 2020-12-08 11:57 UTC (permalink / raw)
To: mst, jasowang; +Cc: virtualization, linux-kernel, liush
'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@allwinnertech.com>
---
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);
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] virtio: replace constant parameter '1' with num
2020-12-08 11:57 [PATCH] virtio: replace constant parameter '1' with num liush
@ 2020-12-08 13:55 ` Michael S. Tsirkin
0 siblings, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2020-12-08 13:55 UTC (permalink / raw)
To: liush; +Cc: jasowang, virtualization, linux-kernel
On Tue, Dec 08, 2020 at 07:57:51PM +0800, liush wrote:
> '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@allwinnertech.com>
Point being?
A constant is likely easier for the compiler to optimize ...
> ---
> 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);
>
> --
> 2.7.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] virtio: replace constant parameter '1' with num
@ 2020-12-08 13:55 ` Michael S. Tsirkin
0 siblings, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2020-12-08 13:55 UTC (permalink / raw)
To: liush; +Cc: linux-kernel, virtualization
On Tue, Dec 08, 2020 at 07:57:51PM +0800, liush wrote:
> '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@allwinnertech.com>
Point being?
A constant is likely easier for the compiler to optimize ...
> ---
> 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);
>
> --
> 2.7.4
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
^ permalink raw reply [flat|nested] 4+ messages in thread
* 回复:[PATCH] virtio: replace constant parameter '1' with num
2020-12-08 13:55 ` Michael S. Tsirkin
(?)
@ 2020-12-09 2:14 ` 刘邵华BTD
-1 siblings, 0 replies; 4+ messages in thread
From: 刘邵华BTD @ 2020-12-09 2:14 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: jasowang, virtualization, linux-kernel
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@allwinnertech.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);
>>
>> --
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-12-09 2:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08 11:57 [PATCH] virtio: replace constant parameter '1' with num liush
2020-12-08 13:55 ` Michael S. Tsirkin
2020-12-08 13:55 ` Michael S. Tsirkin
2020-12-09 2:14 ` 回复:[PATCH] " 刘邵华BTD
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.