From: 刘邵华BTD <liush@allwinnertech.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: "jasowang" <jasowang@redhat.com>,
"virtualization" <virtualization@lists.linux-foundation.org>,
"linux-kernel" <linux-kernel@vger.kernel.org>
Subject: 回复:[PATCH] virtio: replace constant parameter '1' with num
Date: Wed, 09 Dec 2020 10:14:26 +0800 [thread overview]
Message-ID: <b1dbcd5a-4e25-4af8-bedd-32b1e86200b6.liush@allwinnertech.com> (raw)
In-Reply-To: <20201208085423-mutt-send-email-mst@kernel.org>
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);
>>
>> --
prev parent reply other threads:[~2020-12-09 2:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-08 11:57 [PATCH] " liush
2020-12-08 13:55 ` Michael S. Tsirkin
2020-12-09 2:14 ` 刘邵华BTD [this message]
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=b1dbcd5a-4e25-4af8-bedd-32b1e86200b6.liush@allwinnertech.com \
--to=liush@allwinnertech.com \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--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
all inboxes | Powered by JetHome®