diff mbox series

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

Message ID 20230605212717.2570570-4-kent.overstreet@linux.dev (mailing list archive)
State New, archived
Headers show
Series [v2,1/5] block: Rework bio_for_each_segment_all() | expand

Commit Message

Kent Overstreet June 5, 2023, 9:27 p.m. UTC
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@linux.dev>
---
 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(-)

Comments

kernel test robot June 6, 2023, 7:31 a.m. UTC | #1
Hi Kent,

kernel test robot noticed the following build errors:

[auto build test ERROR on axboe-block/for-next]
[cannot apply to kdave/for-next device-mapper-dm/for-next gfs2/for-next tytso-ext4/dev linus/master v6.4-rc5 next-20230606]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Kent-Overstreet/block-Rework-bio_for_each_folio_all/20230606-052850
base:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
patch link:    https://lore.kernel.org/r/20230605212717.2570570-4-kent.overstreet%40linux.dev
patch subject: [PATCH v2 4/5] block: Change memcpy_(to|from)_bvec to pass bvec by value
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20230606/202306061511.LwAxWAce-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 12.3.0
reproduce (this is a W=1 build):
        mkdir -p ~/bin
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git remote add axboe-block https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git
        git fetch axboe-block for-next
        git checkout axboe-block/for-next
        b4 shazam https://lore.kernel.org/r/20230605212717.2570570-4-kent.overstreet@linux.dev
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=alpha olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=alpha SHELL=/bin/bash drivers/scsi/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202306061511.LwAxWAce-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/scsi/aha1542.c: In function 'aha1542_free_cmd':
>> drivers/scsi/aha1542.c:270:40: error: incompatible type for argument 1 of 'memcpy_to_bvec'
     270 |                         memcpy_to_bvec(&bv, buf);
         |                                        ^~~
         |                                        |
         |                                        struct bio_vec *
   In file included from include/linux/blk_types.h:10,
                    from include/linux/blkdev.h:9,
                    from include/scsi/scsi_cmnd.h:6,
                    from drivers/scsi/aha1542.c:23:
   include/linux/bvec.h:271:50: note: expected 'struct bio_vec' but argument is of type 'struct bio_vec *'
     271 | static inline void memcpy_to_bvec(struct bio_vec bvec, const char *from)
         |                                   ~~~~~~~~~~~~~~~^~~~


vim +/memcpy_to_bvec +270 drivers/scsi/aha1542.c

^1da177e4c3f41 Linus Torvalds    2005-04-16  258  
1794ef2b150dd5 Christoph Hellwig 2018-11-10  259  static void aha1542_free_cmd(struct scsi_cmnd *cmd)
1794ef2b150dd5 Christoph Hellwig 2018-11-10  260  {
1794ef2b150dd5 Christoph Hellwig 2018-11-10  261  	struct aha1542_cmd *acmd = scsi_cmd_priv(cmd);
1794ef2b150dd5 Christoph Hellwig 2018-11-10  262  
2f2fef022c3e7a Christoph Hellwig 2021-03-31  263  	if (cmd->sc_data_direction == DMA_FROM_DEVICE) {
11bf4ec580737c Bart Van Assche   2021-08-09  264  		struct request *rq = scsi_cmd_to_rq(cmd);
2f2fef022c3e7a Christoph Hellwig 2021-03-31  265  		void *buf = acmd->data_buffer;
2f2fef022c3e7a Christoph Hellwig 2021-03-31  266  		struct req_iterator iter;
2f2fef022c3e7a Christoph Hellwig 2021-03-31  267  		struct bio_vec bv;
2f2fef022c3e7a Christoph Hellwig 2021-03-31  268  
11bf4ec580737c Bart Van Assche   2021-08-09  269  		rq_for_each_segment(bv, rq, iter) {
e6ab6113526aa4 Christoph Hellwig 2021-10-18 @270  			memcpy_to_bvec(&bv, buf);
2f2fef022c3e7a Christoph Hellwig 2021-03-31  271  			buf += bv.bv_len;
2f2fef022c3e7a Christoph Hellwig 2021-03-31  272  		}
1794ef2b150dd5 Christoph Hellwig 2018-11-10  273  	}
1794ef2b150dd5 Christoph Hellwig 2018-11-10  274  
1794ef2b150dd5 Christoph Hellwig 2018-11-10  275  	scsi_dma_unmap(cmd);
1794ef2b150dd5 Christoph Hellwig 2018-11-10  276  }
1794ef2b150dd5 Christoph Hellwig 2018-11-10  277
diff mbox series

Patch

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);
 }
 
 /**