* [PATCH] Drivers: hv: balloon: account for vmbus packet header in max_pkt_size
@ 2022-01-19 20:20 Yanming Liu
2022-01-19 22:02 ` Michael Kelley (LINUX)
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Yanming Liu @ 2022-01-19 20:20 UTC (permalink / raw)
To: linux-hyperv
Cc: linux-kernel, Andrea Parri (Microsoft),
Andres Beltran, Dexuan Cui, Wei Liu, Stephen Hemminger,
Haiyang Zhang, K. Y. Srinivasan, Yanming Liu, Michael Kelley
Commit adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V
out of the ring buffer") introduced a notion of maximum packet size in
vmbus channel and used that size to initialize a buffer holding all
incoming packet along with their vmbus packet header. hv_balloon uses
the default maximum packet size VMBUS_DEFAULT_MAX_PKT_SIZE which matches
its maximum message size, however vmbus_open expects this size to also
include vmbus packet header. This leads to 4096 bytes
dm_unballoon_request messages being truncated to 4080 bytes. When the
driver tries to read next packet it starts from a wrong read_index,
receives garbage and prints a lot of "Unhandled message: type:
<garbage>" in dmesg.
Allocate the buffer with HV_HYP_PAGE_SIZE more bytes to make room for
the header.
Fixes: adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out of the ring buffer")
Suggested-by: Michael Kelley (LINUX) <mikelley@microsoft.com>
Suggested-by: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
Signed-off-by: Yanming Liu <yanminglr@gmail.com>
---
The patch was "[PATCH v2] hv: account for packet descriptor in maximum
packet size". As pointed out by Michael Kelley [1], other hv drivers
already overallocate a lot, and hv_balloon is hopefully the only
remaining affected driver. It's better to just fix hv_balloon. Patch
summary is changed to reflect this new (much smaller) scope.
[1] https://lore.kernel.org/linux-hyperv/CY4PR21MB1586D30C6CEC81EFC37A9848D7599@CY4PR21MB1586.namprd21.prod.outlook.com/
drivers/hv/hv_balloon.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
index ca873a3b98db..f2d05bff4245 100644
--- a/drivers/hv/hv_balloon.c
+++ b/drivers/hv/hv_balloon.c
@@ -1660,6 +1660,13 @@ static int balloon_connect_vsp(struct hv_device *dev)
unsigned long t;
int ret;
+ /*
+ * max_pkt_size should be large enough for one vmbus packet header plus
+ * our receive buffer size. Hyper-V sends messages up to
+ * HV_HYP_PAGE_SIZE bytes long on balloon channel.
+ */
+ dev->channel->max_pkt_size = HV_HYP_PAGE_SIZE * 2;
+
ret = vmbus_open(dev->channel, dm_ring_size, dm_ring_size, NULL, 0,
balloon_onchannelcallback, dev);
if (ret)
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH] Drivers: hv: balloon: account for vmbus packet header in max_pkt_size
2022-01-19 20:20 [PATCH] Drivers: hv: balloon: account for vmbus packet header in max_pkt_size Yanming Liu
@ 2022-01-19 22:02 ` Michael Kelley (LINUX)
2022-01-19 22:32 ` Andrea Parri
2022-01-23 21:55 ` Wei Liu
2 siblings, 0 replies; 4+ messages in thread
From: Michael Kelley (LINUX) @ 2022-01-19 22:02 UTC (permalink / raw)
To: Yanming Liu, linux-hyperv
Cc: linux-kernel, Andrea Parri (Microsoft),
Andres Beltran, Dexuan Cui, Wei Liu, Stephen Hemminger,
Haiyang Zhang, KY Srinivasan
From: Yanming Liu <yanminglr@gmail.com> Sent: Wednesday, January 19, 2022 12:21 PM
>
> Commit adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V
> out of the ring buffer") introduced a notion of maximum packet size in
> vmbus channel and used that size to initialize a buffer holding all
> incoming packet along with their vmbus packet header. hv_balloon uses
> the default maximum packet size VMBUS_DEFAULT_MAX_PKT_SIZE which matches
> its maximum message size, however vmbus_open expects this size to also
> include vmbus packet header. This leads to 4096 bytes
> dm_unballoon_request messages being truncated to 4080 bytes. When the
> driver tries to read next packet it starts from a wrong read_index,
> receives garbage and prints a lot of "Unhandled message: type:
> <garbage>" in dmesg.
>
> Allocate the buffer with HV_HYP_PAGE_SIZE more bytes to make room for
> the header.
>
> Fixes: adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out of the
> ring buffer")
> Suggested-by: Michael Kelley (LINUX) <mikelley@microsoft.com>
> Suggested-by: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
> Signed-off-by: Yanming Liu <yanminglr@gmail.com>
> ---
> The patch was "[PATCH v2] hv: account for packet descriptor in maximum
> packet size". As pointed out by Michael Kelley [1], other hv drivers
> already overallocate a lot, and hv_balloon is hopefully the only
> remaining affected driver. It's better to just fix hv_balloon. Patch
> summary is changed to reflect this new (much smaller) scope.
>
> [1]
> https://lore.kernel.org/linux-hyperv/CY4PR21MB1586D30C6CEC81EFC37A9848D7599@CY4PR21MB1586.namprd21.prod.outlook.com/
>
> drivers/hv/hv_balloon.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
> index ca873a3b98db..f2d05bff4245 100644
> --- a/drivers/hv/hv_balloon.c
> +++ b/drivers/hv/hv_balloon.c
> @@ -1660,6 +1660,13 @@ static int balloon_connect_vsp(struct hv_device *dev)
> unsigned long t;
> int ret;
>
> + /*
> + * max_pkt_size should be large enough for one vmbus packet header plus
> + * our receive buffer size. Hyper-V sends messages up to
> + * HV_HYP_PAGE_SIZE bytes long on balloon channel.
> + */
> + dev->channel->max_pkt_size = HV_HYP_PAGE_SIZE * 2;
> +
> ret = vmbus_open(dev->channel, dm_ring_size, dm_ring_size, NULL, 0,
> balloon_onchannelcallback, dev);
> if (ret)
> --
> 2.34.1
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Drivers: hv: balloon: account for vmbus packet header in max_pkt_size
2022-01-19 20:20 [PATCH] Drivers: hv: balloon: account for vmbus packet header in max_pkt_size Yanming Liu
2022-01-19 22:02 ` Michael Kelley (LINUX)
@ 2022-01-19 22:32 ` Andrea Parri
2022-01-23 21:55 ` Wei Liu
2 siblings, 0 replies; 4+ messages in thread
From: Andrea Parri @ 2022-01-19 22:32 UTC (permalink / raw)
To: Yanming Liu
Cc: linux-hyperv, linux-kernel, Andres Beltran, Dexuan Cui, Wei Liu,
Stephen Hemminger, Haiyang Zhang, K. Y. Srinivasan,
Michael Kelley
On Thu, Jan 20, 2022 at 04:20:52AM +0800, Yanming Liu wrote:
> Commit adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V
> out of the ring buffer") introduced a notion of maximum packet size in
> vmbus channel and used that size to initialize a buffer holding all
> incoming packet along with their vmbus packet header. hv_balloon uses
> the default maximum packet size VMBUS_DEFAULT_MAX_PKT_SIZE which matches
> its maximum message size, however vmbus_open expects this size to also
> include vmbus packet header. This leads to 4096 bytes
> dm_unballoon_request messages being truncated to 4080 bytes. When the
> driver tries to read next packet it starts from a wrong read_index,
> receives garbage and prints a lot of "Unhandled message: type:
> <garbage>" in dmesg.
>
> Allocate the buffer with HV_HYP_PAGE_SIZE more bytes to make room for
> the header.
>
> Fixes: adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out of the ring buffer")
> Suggested-by: Michael Kelley (LINUX) <mikelley@microsoft.com>
> Suggested-by: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
> Signed-off-by: Yanming Liu <yanminglr@gmail.com>
> ---
> The patch was "[PATCH v2] hv: account for packet descriptor in maximum
> packet size". As pointed out by Michael Kelley [1], other hv drivers
> already overallocate a lot, and hv_balloon is hopefully the only
> remaining affected driver. It's better to just fix hv_balloon. Patch
> summary is changed to reflect this new (much smaller) scope.
hopefully - adeguately describing what/how we "know" (here), it remarks
us that our estimates are empirical (and that people may have different
opinions about "safe" estimates ;-))
Reviewed-by: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
Thanks,
Andrea
> [1] https://lore.kernel.org/linux-hyperv/CY4PR21MB1586D30C6CEC81EFC37A9848D7599@CY4PR21MB1586.namprd21.prod.outlook.com/
>
> drivers/hv/hv_balloon.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
> index ca873a3b98db..f2d05bff4245 100644
> --- a/drivers/hv/hv_balloon.c
> +++ b/drivers/hv/hv_balloon.c
> @@ -1660,6 +1660,13 @@ static int balloon_connect_vsp(struct hv_device *dev)
> unsigned long t;
> int ret;
>
> + /*
> + * max_pkt_size should be large enough for one vmbus packet header plus
> + * our receive buffer size. Hyper-V sends messages up to
> + * HV_HYP_PAGE_SIZE bytes long on balloon channel.
> + */
> + dev->channel->max_pkt_size = HV_HYP_PAGE_SIZE * 2;
> +
> ret = vmbus_open(dev->channel, dm_ring_size, dm_ring_size, NULL, 0,
> balloon_onchannelcallback, dev);
> if (ret)
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Drivers: hv: balloon: account for vmbus packet header in max_pkt_size
2022-01-19 20:20 [PATCH] Drivers: hv: balloon: account for vmbus packet header in max_pkt_size Yanming Liu
2022-01-19 22:02 ` Michael Kelley (LINUX)
2022-01-19 22:32 ` Andrea Parri
@ 2022-01-23 21:55 ` Wei Liu
2 siblings, 0 replies; 4+ messages in thread
From: Wei Liu @ 2022-01-23 21:55 UTC (permalink / raw)
To: Yanming Liu
Cc: linux-hyperv, linux-kernel, Andrea Parri (Microsoft),
Andres Beltran, Dexuan Cui, Wei Liu, Stephen Hemminger,
Haiyang Zhang, K. Y. Srinivasan, Michael Kelley
On Thu, Jan 20, 2022 at 04:20:52AM +0800, Yanming Liu wrote:
> Commit adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V
> out of the ring buffer") introduced a notion of maximum packet size in
> vmbus channel and used that size to initialize a buffer holding all
> incoming packet along with their vmbus packet header. hv_balloon uses
> the default maximum packet size VMBUS_DEFAULT_MAX_PKT_SIZE which matches
> its maximum message size, however vmbus_open expects this size to also
> include vmbus packet header. This leads to 4096 bytes
> dm_unballoon_request messages being truncated to 4080 bytes. When the
> driver tries to read next packet it starts from a wrong read_index,
> receives garbage and prints a lot of "Unhandled message: type:
> <garbage>" in dmesg.
>
> Allocate the buffer with HV_HYP_PAGE_SIZE more bytes to make room for
> the header.
>
> Fixes: adae1e931acd ("Drivers: hv: vmbus: Copy packets sent by Hyper-V out of the ring buffer")
> Suggested-by: Michael Kelley (LINUX) <mikelley@microsoft.com>
> Suggested-by: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
> Signed-off-by: Yanming Liu <yanminglr@gmail.com>
Applied to hyperv-fixes. Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-01-23 21:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-19 20:20 [PATCH] Drivers: hv: balloon: account for vmbus packet header in max_pkt_size Yanming Liu
2022-01-19 22:02 ` Michael Kelley (LINUX)
2022-01-19 22:32 ` Andrea Parri
2022-01-23 21:55 ` Wei Liu
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.