Skip to contentSkip to conversation

virtio_balloon: pr_dev_info.report initialization cleanup

PATCH In review Dongli Zhang 2 participants 2 messages Dec 20, 2025 – Dec 21, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 virtio_balloon: pr_dev_info.report initialization cleanup

The virtio_balloon vb->pr_dev_info is used as argument for page_reporting_register() only when the VIRTIO_BALLOON_F_REPORTING feature is available. There is no need to initialize vb->pr_dev_info.report if this feature is unavailable.

Similarly, the Hyper-V balloon driver sets dm_device.pr_dev_info.report only when the corresponding feature is present. If page_reporting_register() fails, it even resets pr_dev_info.report back to NULL.

No functional change. Only for cleanup.

---
Changed since v1:
- Add commit message to explain why we would want to do that.

 drivers/virtio/virtio_balloon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/virtio/virtio_balloon.c +2 -1
index 74fe59f5a78c..0c39f2415324 100644
@@ -1034,7 +1034,6 @@ static int virtballoon_probe(struct virtio_device *vdev)
 				 poison_val, &poison_val);
 	}
 
-	vb->pr_dev_info.report = virtballoon_free_page_report;
 	if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_REPORTING)) {
 		unsigned int capacity;
 
@@ -1044,6 +1043,8 @@ static int virtballoon_probe(struct virtio_device *vdev)
 			goto out_unregister_oom;
 		}
 
+		vb->pr_dev_info.report = virtballoon_free_page_report;
+
 		/*
 		 * The default page reporting order is @pageblock_order, which
 		 * corresponds to 512MB in size on ARM64 when 64KB base page
Signature · 1 line
2.39.3
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 33 lines · Dongli Zhang

The virtio_balloon vb->pr_dev_info is used as argument for page_reporting_register() only when the VIRTIO_BALLOON_F_REPORTING feature is available. There is no need to initialize vb->pr_dev_info.report if this feature is unavailable.

Similarly, the Hyper-V balloon driver sets dm_device.pr_dev_info.report only when the corresponding feature is present. If page_reporting_register() fails, it even resets pr_dev_info.report back to NULL.

No functional change. Only for cleanup.

---
Changed since v1:
- Add commit message to explain why we would want to do that.

  drivers/virtio/virtio_balloon.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/virtio/virtio_balloon.c +0 -1
index 74fe59f5a78c..0c39f2415324 100644
@@ -1034,7 +1034,6 @@ static int virtballoon_probe(struct virtio_device *vdev)
  				 poison_val, &poison_val);
  	}
 
-	vb->pr_dev_info.report = virtballoon_free_page_report;
  	if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_REPORTING)) {
  		unsigned int capacity;
 

drivers/virtio/virtio_balloon.c static int virtballoon_probe(struct virtio_device *vdev) · line 1050

Quoted 8 lines
drivers/virtio/virtio_balloon.c +2 -0
@@ -1044,6 +1043,8 @@ static int virtballoon_probe(struct virtio_device *vdev)
  			goto out_unregister_oom;
  		}
 
+		vb->pr_dev_info.report = virtballoon_free_page_report;
+
  		/*
  		 * The default page reporting order is @pageblock_order, which
  		 * corresponds to 512MB in size on ARM64 when 64KB base page
Signature · 3 lines
Cheers

David