summaryrefslogtreecommitdiff
path: root/scripts/basic
diff options
context:
space:
mode:
authorKameron Carr <kameroncarr@linux.microsoft.com>2026-10-19 16:09:48 -0700
committerWei Liu <wei.liu@kernel.org>2026-10-21 00:00:29 -0700
commita8e60890cb86a181d8216ac7e60873ba9d7d2ff9 (patch)
tree80ed5622a9829cfe91df363e97b33be7905d2676 /scripts/basic
parent10e2eba7ccb507af62bfff72687c8c559fa4d689 (diff)
downloadlinux-a8e60890cb86a181d8216ac7e60873ba9d7d2ff9.tar.gz
linux-a8e60890cb86a181d8216ac7e60873ba9d7d2ff9.zip
Drivers: hv: vmbus: Compute ring byte counts from a caller-held snapshot
hv_get_ringbuffer_availbytes() reads the indices directly, so a caller that also wants the index values has to read them a second time. The host can change them in between, resulting in the byte counts and the indices reflecting two different states of the ring. Replace it with hv_ringbuffer_avail_write() and hv_ringbuffer_avail_read(), which take the indices as arguments and return a single count. They are separate because most callers want only one of the two values. Use them in hv_ringbuffer_write() in place of the open-coded equivalent. hv_get_bytes_to_read(), hv_get_bytes_to_write() and hv_pkt_iter_avail() duplicated the same arithmetic, so put the helpers in include/linux/hyperv.h and use them there too. Add a hv_ringbuffer_indices_invalid() helper that bounds checks a pair of read and write indices, and use it for the check in hv_ringbuffer_write(). Convert the remaining callers to use a single snapshot: - hv_ringbuffer_get_debuginfo() now reports the indices and the computed byte counts from the same snapshot. - hv_pkt_iter_close() computes the free space from priv_read_index instead of re-reading the shared read index. The two agree unless a misbehaving host has rewritten the value. No functional change intended for a well-behaved host. Signed-off-by: Kameron Carr <kameroncarr@linux.microsoft.com> Reviewed-by: Michael Kelley <mhklinux@outlook.com> Signed-off-by: Wei Liu <wei.liu@kernel.org>
Diffstat (limited to 'scripts/basic')
0 files changed, 0 insertions, 0 deletions