block: reduce stack usage in diskstats_show
authorAbd-Alrhman Masalkhi <abd.masalkhi@gmail.com>
Tue, 27 Jul 2021 06:25:13 +0000 (08:25 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 2 Aug 2021 19:37:28 +0000 (13:37 -0600)
I have compiled the kernel with a cross compiler "hppa-linux-gnu-" v9.3.0
on x86-64 host machine. I got the following warning:

block/genhd.c: In function ‘diskstats_show’:
block/genhd.c:1227:1: warning: the frame size of 1688 bytes is larger
than 1280 bytes [-Wframe-larger-than=]
 1227  |  }

By Reduced the stack footprint by using the %pg printk specifier instead
of disk_name to remove the need for the on-stack buffer.

Signed-off-by: Abd-Alrhman Masalkhi <abd.masalkhi@gmail.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20210727062518.122108-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/genhd.c

index 5dbb99b..cf705cf 100644 (file)
@@ -1111,7 +1111,6 @@ static int diskstats_show(struct seq_file *seqf, void *v)
 {
        struct gendisk *gp = v;
        struct block_device *hd;
-       char buf[BDEVNAME_SIZE];
        unsigned int inflight;
        struct disk_stats stat;
        unsigned long idx;
@@ -1134,15 +1133,14 @@ static int diskstats_show(struct seq_file *seqf, void *v)
                else
                        inflight = part_in_flight(hd);
 
-               seq_printf(seqf, "%4d %7d %s "
+               seq_printf(seqf, "%4d %7d %pg "
                           "%lu %lu %lu %u "
                           "%lu %lu %lu %u "
                           "%u %u %u "
                           "%lu %lu %lu %u "
                           "%lu %u"
                           "\n",
-                          MAJOR(hd->bd_dev), MINOR(hd->bd_dev),
-                          disk_name(gp, hd->bd_partno, buf),
+                          MAJOR(hd->bd_dev), MINOR(hd->bd_dev), hd,
                           stat.ios[STAT_READ],
                           stat.merges[STAT_READ],
                           stat.sectors[STAT_READ],