Skip to contentSkip to conversation

virtio-blk: remove unneeded "likely" statements

PATCH In review Max Gurtovoy 3 participants 3 messages Sep 5, 2021 – Sep 6, 2021

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

PATCH v2 1/1 virtio-blk: remove unneeded "likely" statements

Usually we use "likely/unlikely" to optimize the fast path. Remove redundant "likely/unlikely" statements in the control path to simplify the code and make it easier to read.

---

changes from v1:
- added "Reviewed-by" (Stefan)
- commit description update (Stefan)

---
 drivers/block/virtio_blk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/virtio_blk.c +2 -2
index afb37aac09e8..e574fbf5e6df 100644
@@ -765,7 +765,7 @@ static int virtblk_probe(struct virtio_device *vdev)
 		goto out_free_vblk;
 
 	/* Default queue sizing is to fill the ring. */
-	if (likely(!virtblk_queue_depth)) {
+	if (!virtblk_queue_depth) {
 		queue_depth = vblk->vqs[0].vq->num_free;
 		/* ... but without indirect descs, we use 2 descs per req */
 		if (!virtio_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC))
@@ -839,7 +839,7 @@ static int virtblk_probe(struct virtio_device *vdev)
 	else
 		blk_size = queue_logical_block_size(q);
 
-	if (unlikely(blk_size < SECTOR_SIZE || blk_size > PAGE_SIZE)) {
+	if (blk_size < SECTOR_SIZE || blk_size > PAGE_SIZE) {
 		dev_err(&vdev->dev,
 			"block size is changed unexpectedly, now is %u\n",
 			blk_size);
Signature · 1 line
2.18.1
Reviewed-by on v2 1/1
#2 lore raw
In reply to Max Gurtovoy
Quoted 30 lines

Usually we use "likely/unlikely" to optimize the fast path. Remove redundant "likely/unlikely" statements in the control path to simplify the code and make it easier to read.

---

changes from v1:
- added "Reviewed-by" (Stefan)
- commit description update (Stefan)

---
 drivers/block/virtio_blk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/virtio_blk.c +1 -1
index afb37aac09e8..e574fbf5e6df 100644
@@ -765,7 +765,7 @@ static int virtblk_probe(struct virtio_device *vdev)
                goto out_free_vblk;
 
        /* Default queue sizing is to fill the ring. */
-       if (likely(!virtblk_queue_depth)) {
+       if (!virtblk_queue_depth) {
                queue_depth = vblk->vqs[0].vq->num_free;
                /* ... but without indirect descs, we use 2 descs per req */
                if (!virtio_has_feature(vdev, VIRTIO_RING_F_INDIRECT_DESC))

drivers/block/virtio_blk.c static int virtblk_probe(struct virtio_device *vdev)

Quoted 9 lines
drivers/block/virtio_blk.c +1 -2
@@ -839,7 +839,7 @@ static int virtblk_probe(struct virtio_device *vdev)
        else
                blk_size = queue_logical_block_size(q);
 
-       if (unlikely(blk_size < SECTOR_SIZE || blk_size > PAGE_SIZE)) {
+       if (blk_size < SECTOR_SIZE || blk_size > PAGE_SIZE) {
                dev_err(&vdev->dev,
                        "block size is changed unexpectedly, now is %u\n",
                        blk_size);
--