[PATCH 06/12] vhost: rename confusing 'min' variable in log_write_hva

Weimin Xiong <[email protected]>
Newsgroups dev.linux.lists.virtualization
Message-ID <[email protected]>
From: xiongweimin <[email protected]>

Rename variable 'min' to 'logged_len' for clarity. The original expression
'min(l, min)' where 'min' is both a macro and a variable was confusing.
Also fix the misleading comment about GPAs - this function works with HVAs
and UMEM mappings.

Signed-off-by: Weimin Xiong <[email protected]>
Co-authored-by: Cursor <[email protected]>
---
 drivers/vhost/vhost.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 4c525b3e1..3c080c454 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -2461,14 +2461,14 @@ static int log_write_hva(struct vhost_virtqueue *vq, u64 hva, u64 len)
 {
 	struct vhost_iotlb *umem = vq->umem;
 	struct vhost_iotlb_map *u;
-	u64 start, end, l, min;
+	u64 start, end, l, logged_len;
 	int r;
 	bool hit = false;
 
 	while (len) {
-		min = len;
-		/* More than one GPAs can be mapped into a single HVA. So
-		 * iterate all possible umems here to be safe.
+		logged_len = len;
+		/* Multiple UMEM mappings may cover this HVA range.
+		 * Iterate all mappings to ensure we log all dirty pages.
 		 */
 		list_for_each_entry(u, &umem->list, link) {
 			if (u->addr > hva - 1 + len ||
@@ -2483,14 +2483,14 @@ static int log_write_hva(struct vhost_virtqueue *vq, u64 hva, u64 len)
 			if (r < 0)
 				return r;
 			hit = true;
-			min = min(l, min);
+			logged_len = min(l, logged_len);
 		}
 
 		if (!hit)
 			return -EFAULT;
 
-		len -= min;
-		hva += min;
+		len -= logged_len;
+		hva += logged_len;
 	}
 
 	return 0;
-- 
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.