[PATCH v2 4/5] block: Change memcpy_(to|from)_bvec to pass bvec by value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a small code size decrease; memcpy_from_bvec() is inlined so
there's no benefit to passing the bvec by referene, but taking a pointer
to it may inhibit optimization in the caller.

Signed-off-by: Kent Overstreet <kent.overstreet@xxxxxxxxx>
---
 block/blk-map.c               | 2 +-
 block/bounce.c                | 4 ++--
 drivers/block/floppy.c        | 4 ++--
 drivers/block/ps3disk.c       | 2 +-
 drivers/block/zram/zram_drv.c | 4 ++--
 drivers/md/dm-log-writes.c    | 2 +-
 drivers/scsi/aha1542.c        | 2 +-
 include/linux/bvec.h          | 8 ++++----
 8 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/block/blk-map.c b/block/blk-map.c
index 524d84011f..50540d0a22 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -447,7 +447,7 @@ static void bio_copy_kern_endio_read(struct bio *bio)
 	struct bio_vec bvec;
 
 	bio_for_each_segment_all(bvec, bio, iter) {
-		memcpy_from_bvec(p, &bvec);
+		memcpy_from_bvec(p, bvec);
 		p += bvec.bv_len;
 	}
 
diff --git a/block/bounce.c b/block/bounce.c
index e701832d76..1dc6716084 100644
--- a/block/bounce.c
+++ b/block/bounce.c
@@ -92,7 +92,7 @@ static void copy_to_high_bio_irq(struct bio *to, struct bio *from)
 			 * been modified by the block layer, so use the original
 			 * copy, bounce_copy_vec already uses tovec->bv_len
 			 */
-			memcpy_to_bvec(&tovec, page_address(fromvec.bv_page) +
+			memcpy_to_bvec(tovec, page_address(fromvec.bv_page) +
 				       tovec.bv_offset);
 		}
 		bio_advance_iter(from, &from_iter, tovec.bv_len);
@@ -249,7 +249,7 @@ struct bio *__blk_queue_bounce(struct bio *bio_orig, struct request_queue *q)
 
 		if (rw == WRITE) {
 			flush_dcache_page(to->bv_page);
-			memcpy_from_bvec(page_address(bounce_page), to);
+			memcpy_from_bvec(page_address(bounce_page), *to);
 		}
 		to->bv_page = bounce_page;
 	}
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index cec2c20f5e..039e4ebfad 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -2483,9 +2483,9 @@ static void copy_buffer(int ssize, int max_sector, int max_sector_2)
 		}
 
 		if (CT(raw_cmd->cmd[COMMAND]) == FD_READ)
-			memcpy_to_bvec(&bv, dma_buffer);
+			memcpy_to_bvec(bv, dma_buffer);
 		else
-			memcpy_from_bvec(dma_buffer, &bv);
+			memcpy_from_bvec(dma_buffer, bv);
 
 		remaining -= size;
 		dma_buffer += size;
diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c
index 36d7b36c60..73db9ca530 100644
--- a/drivers/block/ps3disk.c
+++ b/drivers/block/ps3disk.c
@@ -86,7 +86,7 @@ static void ps3disk_scatter_gather(struct ps3_storage_device *dev,
 
 	rq_for_each_segment(bvec, req, iter) {
 		if (gather)
-			memcpy_from_bvec(dev->bounce_buf + offset, &bvec);
+			memcpy_from_bvec(dev->bounce_buf + offset, bvec);
 		else
 			memcpy_to_bvec(&bvec, dev->bounce_buf + offset);
 	}
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index f6d90f1ba5..b68ae64a99 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1396,7 +1396,7 @@ static int zram_bvec_read_partial(struct zram *zram, struct bio_vec *bvec,
 		return -ENOMEM;
 	ret = zram_read_page(zram, page, index, NULL);
 	if (likely(!ret))
-		memcpy_to_bvec(bvec, page_address(page) + offset);
+		memcpy_to_bvec(*bvec, page_address(page) + offset);
 	__free_page(page);
 	return ret;
 }
@@ -1548,7 +1548,7 @@ static int zram_bvec_write_partial(struct zram *zram, struct bio_vec *bvec,
 
 	ret = zram_read_page(zram, page, index, bio);
 	if (!ret) {
-		memcpy_from_bvec(page_address(page) + offset, bvec);
+		memcpy_from_bvec(page_address(page) + offset, *bvec);
 		ret = zram_write_page(zram, page, index);
 	}
 	__free_page(page);
diff --git a/drivers/md/dm-log-writes.c b/drivers/md/dm-log-writes.c
index f17a6cf228..7772466d0a 100644
--- a/drivers/md/dm-log-writes.c
+++ b/drivers/md/dm-log-writes.c
@@ -744,7 +744,7 @@ static int log_writes_map(struct dm_target *ti, struct bio *bio)
 		}
 
 		dst = kmap_local_page(page);
-		memcpy_from_bvec(dst, &bv);
+		memcpy_from_bvec(dst, bv);
 		kunmap_local(dst);
 		block->vecs[i].bv_page = page;
 		block->vecs[i].bv_len = bv.bv_len;
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index 9503996c63..5db9e31352 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -450,7 +450,7 @@ static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd)
 		struct bio_vec bv;
 
 		rq_for_each_segment(bv, rq, iter) {
-			memcpy_from_bvec(buf, &bv);
+			memcpy_from_bvec(buf, bv);
 			buf += bv.bv_len;
 		}
 	}
diff --git a/include/linux/bvec.h b/include/linux/bvec.h
index ebf8b612ba..ee5965fedf 100644
--- a/include/linux/bvec.h
+++ b/include/linux/bvec.h
@@ -257,9 +257,9 @@ static inline void *bvec_kmap_local(struct bio_vec *bvec)
  *
  * Must be called on single-page bvecs only.
  */
-static inline void memcpy_from_bvec(char *to, struct bio_vec *bvec)
+static inline void memcpy_from_bvec(char *to, struct bio_vec bvec)
 {
-	memcpy_from_page(to, bvec->bv_page, bvec->bv_offset, bvec->bv_len);
+	memcpy_from_page(to, bvec.bv_page, bvec.bv_offset, bvec.bv_len);
 }
 
 /**
@@ -268,9 +268,9 @@ static inline void memcpy_from_bvec(char *to, struct bio_vec *bvec)
  *
  * Must be called on single-page bvecs only.
  */
-static inline void memcpy_to_bvec(struct bio_vec *bvec, const char *from)
+static inline void memcpy_to_bvec(struct bio_vec bvec, const char *from)
 {
-	memcpy_to_page(bvec->bv_page, bvec->bv_offset, from, bvec->bv_len);
+	memcpy_to_page(bvec.bv_page, bvec.bv_offset, from, bvec.bv_len);
 }
 
 /**
-- 
2.40.1




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux