Re: [PATCH 04/10] dm: reduce stack footprint dealing with block device names

From
Mike Snitzer <hidden>
Date
2021-06-23 20:20:56
Also in
linux-fsdevel, lkml
Reply to
Anton Suvorov, 2021-06-02
On Wed, Jun 02 2021 at 11:28P -0400,
Anton Suvorov [off-list ref] wrote:
Stack usage reduced (measured with allyesconfig):

./drivers/md/dm-cache-target.c	cache_ctr	392	328	-64
./drivers/md/dm-cache-target.c	cache_io_hints	208	72	-136
./drivers/md/dm-clone-target.c	clone_ctr	416	352	-64
./drivers/md/dm-clone-target.c	clone_io_hints	216	80	-136
./drivers/md/dm-crypt.c	crypt_convert_block_aead	408	272	-136
./drivers/md/dm-crypt.c	kcryptd_async_done	192	56	-136
./drivers/md/dm-integrity.c	integrity_metadata	872	808	-64
./drivers/md/dm-mpath.c	parse_priority_group	368	304	-64
./drivers/md/dm-table.c	device_area_is_invalid	216	80	-136
./drivers/md/dm-table.c	dm_set_device_limits	200	72	-128
./drivers/md/dm-thin.c	pool_io_hints	216	80	-136

Signed-off-by: Anton Suvorov <redacted>
---
 drivers/md/dm-cache-target.c | 10 ++++------
 drivers/md/dm-clone-target.c | 10 ++++------
 drivers/md/dm-crypt.c        |  6 ++----
 drivers/md/dm-integrity.c    |  4 ++--
 drivers/md/dm-mpath.c        |  6 ++----
 drivers/md/dm-table.c        | 34 ++++++++++++++++------------------
 drivers/md/dm-thin.c         |  8 +++-----
 7 files changed, 33 insertions(+), 45 deletions(-)
<snip>
quoted hunk ↗ jump to hunk
diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
index 20f2510db1f6..d2fec41635ff 100644
--- a/drivers/md/dm-integrity.c
+++ b/drivers/md/dm-integrity.c
@@ -1781,8 +1781,8 @@ static void integrity_metadata(struct work_struct *w)
 						checksums_ptr - checksums, dio->op == REQ_OP_READ ? TAG_CMP : TAG_WRITE);
 			if (unlikely(r)) {
 				if (r > 0) {
-					char b[BDEVNAME_SIZE];
-					DMERR_LIMIT("%s: Checksum failed at sector 0x%llx", bio_devname(bio, b),
+					DMERR_LIMIT("%pg: Checksum failed at sector 0x%llx",
+						    bio->bi_bdev,
 						    (sector - ((r + ic->tag_size - 1) / ic->tag_size)));
 					r = -EILSEQ;
 					atomic64_inc(&ic->number_of_mismatches);
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index bced42f082b0..678e5bb0fa5a 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -900,10 +900,8 @@ static int setup_scsi_dh(struct block_device *bdev, struct multipath *m,
 	if (m->hw_handler_name) {
 		r = scsi_dh_attach(q, m->hw_handler_name);
 		if (r == -EBUSY) {
-			char b[BDEVNAME_SIZE];
-
-			printk(KERN_INFO "dm-mpath: retaining handler on device %s\n",
-			       bdevname(bdev, b));
+			pr_info("dm-mpath: retaining handler on device %pg\n",
+				bdev);
 			goto retain;
 		}
 		if (r < 0) {
Would appreciate it if you just left the arguments on the same line,
for this dm-mpath.c change and the dm-integrity.c change, don't worry
about 80 column.

Also, would prefer you use DMINFO() instead of pr_info().  DMINFO()
achieves the same but will add "device-mapper: multipath: " prefix for
you, also you then don't need to add the newline. So use:

     DMINFO("retaining handler on device %pg", bdev);

quoted hunk ↗ jump to hunk
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 7e88e5e06922..175b9c7b1c48 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -282,20 +281,20 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
 		return 0;
 
 	if (start & (logical_block_size_sectors - 1)) {
-		DMWARN("%s: start=%llu not aligned to h/w "
-		       "logical block size %u of %s",
+		DMWARN("%s: start=%llu not aligned to h/w logical block size %u of %pg",
 		       dm_device_name(ti->table->md),
 		       (unsigned long long)start,
-		       limits->logical_block_size, bdevname(bdev, b));
+		       limits->logical_block_size,
+		       bdev);
 		return 1;
 	}
 
 	if (len & (logical_block_size_sectors - 1)) {
-		DMWARN("%s: len=%llu not aligned to h/w "
-		       "logical block size %u of %s",
+		DMWARN("%s: len=%llu not aligned to h/w logical block size %u of %pg",
 		       dm_device_name(ti->table->md),
 		       (unsigned long long)len,
-		       limits->logical_block_size, bdevname(bdev, b));
+		       limits->logical_block_size,
+		       bdev);
 		return 1;
 	}
 
Again, please just leave 'bdev' on the previous lines.

If you make those few tweaks, please add:

Acked-by: Mike Snitzer <redacted>
Thread (26 messages) 26 messages, 5 authors, last reply 2021-06-23
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help