Skip to contentSkip to conversation

virtio-mem: virtio_mem_init: Access bb_size just in BBM mode

RFC In review Hui Zhu 3 participants 3 messages Jun 15, 2021

Subsystems (2)
lore
Share & tools
lore

Hui Zhu

author
#0 lore raw

RFC 1/1 virtio-mem: virtio_mem_init: Access bb_size just in BBM mode

From: Hui Zhu <[email protected]>

/* In BBM, we also want at least two big blocks. */ vm->offline_threshold = max_t(uint64_t, 2 * vm->bbm.bb_size,

			      vm->offline_threshold);

This line does not modify vm->offline_threshold depending on the data in vm->sbm that shares this address is 0 in SBM mode.
I think it might be difficult to make sure when we change this in the future.

This commit adds an if to make sure that this line just be executed in BBM mode.

---
 drivers/virtio/virtio_mem.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/virtio/virtio_mem.c +3 -2
index 10ec60d..8185916 100644
@@ -2472,8 +2472,9 @@ static int virtio_mem_init(struct virtio_mem *vm)
 	vm->offline_threshold = max_t(uint64_t, 2 * memory_block_size_bytes(),
 				      VIRTIO_MEM_DEFAULT_OFFLINE_THRESHOLD);
 	/* In BBM, we also want at least two big blocks. */
-	vm->offline_threshold = max_t(uint64_t, 2 * vm->bbm.bb_size,
-				      vm->offline_threshold);
+	if (!vm->in_sbm)
+		vm->offline_threshold = max_t(uint64_t, 2 * vm->bbm.bb_size,
+					      vm->offline_threshold);
 
 	dev_info(&vm->vdev->dev, "start address: 0x%llx", vm->addr);
 	dev_info(&vm->vdev->dev, "region size: 0x%llx", vm->region_size);
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 25 lines · Hui Zhu

From: Hui Zhu <[email protected]>

/* In BBM, we also want at least two big blocks. */ vm->offline_threshold = max_t(uint64_t, 2 * vm->bbm.bb_size,

			      vm->offline_threshold);

This line does not modify vm->offline_threshold depending on the data in vm->sbm that shares this address is 0 in SBM mode.
I think it might be difficult to make sure when we change this in the future.

This commit adds an if to make sure that this line just be executed in BBM mode.

---
  drivers/virtio/virtio_mem.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/virtio/virtio_mem.c +0 -0
index 10ec60d..8185916 100644
@@ -2472,8 +2472,9 @@ static int virtio_mem_init(struct virtio_mem *vm)
  	vm->offline_threshold = max_t(uint64_t, 2 * memory_block_size_bytes(),

drivers/virtio/virtio_mem.c static int virtio_mem_init(struct virtio_mem *vm) · line 2480

Quoted 10 lines
drivers/virtio/virtio_mem.c +3 -2
  				      VIRTIO_MEM_DEFAULT_OFFLINE_THRESHOLD);
  	/* In BBM, we also want at least two big blocks. */
-	vm->offline_threshold = max_t(uint64_t, 2 * vm->bbm.bb_size,
-				      vm->offline_threshold);
+	if (!vm->in_sbm)
+		vm->offline_threshold = max_t(uint64_t, 2 * vm->bbm.bb_size,
+					      vm->offline_threshold);
 
  	dev_info(&vm->vdev->dev, "start address: 0x%llx", vm->addr);
  	dev_info(&vm->vdev->dev, "region size: 0x%llx", vm->region_size);

Good that you also spotted it, I already have a fix pending for that :)

https://lkml.kernel.org/r/[email protected]

Signature · 8 lines
Thanks,

David / dhildenb

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
#2 lore raw
Quoted 37 lines

2021年6月15日 15:43,David Hildenbrand <[email protected]> 写道:

Quoted 19 lines · Hui Zhu

From: Hui Zhu <[email protected]>
/* In BBM, we also want at least two big blocks. */ vm->offline_threshold = max_t(uint64_t, 2 * vm->bbm.bb_size,

			      vm->offline_threshold);

This line does not modify vm->offline_threshold depending on the data in vm->sbm that shares this address is 0 in SBM mode.
I think it might be difficult to make sure when we change this in the future.
This commit adds an if to make sure that this line just be executed in BBM mode.

---
 drivers/virtio/virtio_mem.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/virtio/virtio_mem.c +0 -0
index 10ec60d..8185916 100644

drivers/virtio/virtio_mem.c static int virtio_mem_init(struct virtio_mem *vm) · line 2479

Quoted 10 lines
drivers/virtio/virtio_mem.c +3 -2
@@ -2472,8 +2472,9 @@ static int virtio_mem_init(struct virtio_mem *vm)
 	vm->offline_threshold = max_t(uint64_t, 2 * memory_block_size_bytes(),
 				      VIRTIO_MEM_DEFAULT_OFFLINE_THRESHOLD);
 	/* In BBM, we also want at least two big blocks. */
-	vm->offline_threshold = max_t(uint64_t, 2 * vm->bbm.bb_size,
-				      vm->offline_threshold);
+	if (!vm->in_sbm)
+		vm->offline_threshold = max_t(uint64_t, 2 * vm->bbm.bb_size,
+					      vm->offline_threshold);
   	dev_info(&vm->vdev->dev, "start address: 0x%llx", vm->addr);
 	dev_info(&vm->vdev->dev, "region size: 0x%llx", vm->region_size);

Good that you also spotted it, I already have a fix pending for that :)

Quoted 1 line

https://lkml.kernel.org/r/[email protected]

Oops! Please ignore this RFC.

Best,
Hui

Quoted 5 lines
Signature · 4 lines
-- 
Thanks,

David / dhildenb