* [Patch] vmbus: Simply hv_get_next_write_location() function
@ 2018-01-24 6:21 lantianyu1986
2018-01-24 16:37 ` Stephen Hemminger
0 siblings, 1 reply; 3+ messages in thread
From: lantianyu1986 @ 2018-01-24 6:21 UTC (permalink / raw)
Cc: sthemmin, haiyangz, linux-kernel, devel, Tianyu Lan
From: Tianyu Lan <Tianyu.Lan@microsoft.com>
The "next" variable is redundant in hv_get_next_write_location().
This patch is to remove it and return write_index directly.
Signed-off-by: Tianyu Lan <Tianyu.Lan@microsoft.com>
---
drivers/hv/ring_buffer.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
index 12eb8ca..71558e7 100644
--- a/drivers/hv/ring_buffer.c
+++ b/drivers/hv/ring_buffer.c
@@ -82,9 +82,7 @@ static void hv_signal_on_write(u32 old_write, struct vmbus_channel *channel)
static inline u32
hv_get_next_write_location(struct hv_ring_buffer_info *ring_info)
{
- u32 next = ring_info->ring_buffer->write_index;
-
- return next;
+ return ring_info->ring_buffer->write_index;
}
/* Set the next write location for the specified ring buffer. */
--
2.7.4
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Patch] vmbus: Simply hv_get_next_write_location() function
2018-01-24 6:21 [Patch] vmbus: Simply hv_get_next_write_location() function lantianyu1986
@ 2018-01-24 16:37 ` Stephen Hemminger
2018-01-25 8:33 ` Tianyu Lan
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2018-01-24 16:37 UTC (permalink / raw)
To: lantianyu1986; +Cc: Tianyu Lan, devel, haiyangz, sthemmin, linux-kernel
On Wed, 24 Jan 2018 14:21:30 +0800
lantianyu1986@gmail.com wrote:
> From: Tianyu Lan <Tianyu.Lan@microsoft.com>
>
> The "next" variable is redundant in hv_get_next_write_location().
> This patch is to remove it and return write_index directly.
>
> Signed-off-by: Tianyu Lan <Tianyu.Lan@microsoft.com>
> ---
> drivers/hv/ring_buffer.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
> index 12eb8ca..71558e7 100644
> --- a/drivers/hv/ring_buffer.c
> +++ b/drivers/hv/ring_buffer.c
> @@ -82,9 +82,7 @@ static void hv_signal_on_write(u32 old_write, struct vmbus_channel *channel)
> static inline u32
> hv_get_next_write_location(struct hv_ring_buffer_info *ring_info)
> {
> - u32 next = ring_info->ring_buffer->write_index;
> -
> - return next;
> + return ring_info->ring_buffer->write_index;
> }
>
> /* Set the next write location for the specified ring buffer. */
Looks good.
But let's go farther since function is only used in one location in the file
just eliminate it completely and do simple variable references.
The get/set functions in this file are unnecessary.
Better still it is possible to replace the lock based ring structure
with a compare-exchange solution.
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch] vmbus: Simply hv_get_next_write_location() function
2018-01-24 16:37 ` Stephen Hemminger
@ 2018-01-25 8:33 ` Tianyu Lan
0 siblings, 0 replies; 3+ messages in thread
From: Tianyu Lan @ 2018-01-25 8:33 UTC (permalink / raw)
To: Stephen Hemminger
Cc: Tianyu Lan, devel, haiyangz, sthemmin, linux-kernel@vger kernel org
On Thu, Jan 25, 2018 at 12:37 AM, Stephen Hemminger
<stephen@networkplumber.org> wrote:
> On Wed, 24 Jan 2018 14:21:30 +0800
> lantianyu1986@gmail.com wrote:
>
>> From: Tianyu Lan <Tianyu.Lan@microsoft.com>
>>
>> The "next" variable is redundant in hv_get_next_write_location().
>> This patch is to remove it and return write_index directly.
>>
>> Signed-off-by: Tianyu Lan <Tianyu.Lan@microsoft.com>
>> ---
>> drivers/hv/ring_buffer.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c
>> index 12eb8ca..71558e7 100644
>> --- a/drivers/hv/ring_buffer.c
>> +++ b/drivers/hv/ring_buffer.c
>> @@ -82,9 +82,7 @@ static void hv_signal_on_write(u32 old_write, struct vmbus_channel *channel)
>> static inline u32
>> hv_get_next_write_location(struct hv_ring_buffer_info *ring_info)
>> {
>> - u32 next = ring_info->ring_buffer->write_index;
>> -
>> - return next;
>> + return ring_info->ring_buffer->write_index;
>> }
>>
>> /* Set the next write location for the specified ring buffer. */
>
> Looks good.
> But let's go farther since function is only used in one location in the file
> just eliminate it completely and do simple variable references.
>
> The get/set functions in this file are unnecessary.
Yes, agree and will update patch.
>
> Better still it is possible to replace the lock based ring structure
> with a compare-exchange solution.
There are several read/write operations of ring structure in the
hv_ringbuffer_write()
and these operations should be under protection. Especially for
ring_buffer->write_index,
we need to read it to calculate available write buffer, determine
write position and then update it after
writing buffer. This sequence should be under protection, right?
--
Best regards
Tianyu Lan
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-25 8:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-24 6:21 [Patch] vmbus: Simply hv_get_next_write_location() function lantianyu1986
2018-01-24 16:37 ` Stephen Hemminger
2018-01-25 8:33 ` Tianyu Lan
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).