linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sgi-gru: simplify procfs code some more
@ 2019-10-07 18:30 Joe Perches
  2019-10-08  1:59 ` Dimitri Sivanich
  0 siblings, 1 reply; 2+ messages in thread
From: Joe Perches @ 2019-10-07 18:30 UTC (permalink / raw)
  To: Dimitri Sivanich
  Cc: Christoph Hellwig, Arnd Bergmann, Greg Kroah-Hartman, linux-kernel

Use seq_puts and simple string output and not seq_printf with formats
and individual strings to reduce overall object size.

$ size drivers/misc/sgi-gru/gruprocfs.o* (x86-64 defconfig with gru)
   text	   data	    bss	    dec	    hex	filename
   7006	      8	      0	   7014	   1b66	drivers/misc/sgi-gru/gruprocfs.o.new
   7472	      8	      0	   7480	   1d38	drivers/misc/sgi-gru/gruprocfs.o.old

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/misc/sgi-gru/gruprocfs.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
index 3a8d76d1ccae..2817f4751306 100644
--- a/drivers/misc/sgi-gru/gruprocfs.c
+++ b/drivers/misc/sgi-gru/gruprocfs.c
@@ -119,7 +119,7 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
 		"cch_interrupt_sync", "cch_deallocate", "tfh_write_only",
 		"tfh_write_restart", "tgh_invalidate"};
 
-	seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
+	seq_puts(s, "#id                        count   aver-clks    max-clks\n");
 	for (op = 0; op < mcsop_last; op++) {
 		count = atomic_long_read(&mcs_op_statistics[op].count);
 		total = atomic_long_read(&mcs_op_statistics[op].total);
@@ -165,8 +165,7 @@ static int cch_seq_show(struct seq_file *file, void *data)
 	const char *mode[] = { "??", "UPM", "INTR", "OS_POLL" };
 
 	if (gid == 0)
-		seq_printf(file, "#%5s%5s%6s%7s%9s%6s%8s%8s\n", "gid", "bid",
-			   "ctx#", "asid", "pid", "cbrs", "dsbytes", "mode");
+		seq_puts(file, "#  gid  bid  ctx#   asid      pid  cbrs dsbytes    mode\n");
 	if (gru)
 		for (i = 0; i < GRU_NUM_CCH; i++) {
 			ts = gru->gs_gts[i];
@@ -191,10 +190,8 @@ static int gru_seq_show(struct seq_file *file, void *data)
 	struct gru_state *gru = GID_TO_GRU(gid);
 
 	if (gid == 0) {
-		seq_printf(file, "#%5s%5s%7s%6s%6s%8s%6s%6s\n", "gid", "nid",
-			   "ctx", "cbr", "dsr", "ctx", "cbr", "dsr");
-		seq_printf(file, "#%5s%5s%7s%6s%6s%8s%6s%6s\n", "", "", "busy",
-			   "busy", "busy", "free", "free", "free");
+		seq_puts(file, "#  gid  nid    ctx   cbr   dsr     ctx   cbr   dsr\n");
+		seq_puts(file, "#             busy  busy  busy    free  free  free\n");
 	}
 	if (gru) {
 		ctxfree = GRU_NUM_CCH - gru->gs_active_contexts;



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] sgi-gru: simplify procfs code some more
  2019-10-07 18:30 [PATCH] sgi-gru: simplify procfs code some more Joe Perches
@ 2019-10-08  1:59 ` Dimitri Sivanich
  0 siblings, 0 replies; 2+ messages in thread
From: Dimitri Sivanich @ 2019-10-08  1:59 UTC (permalink / raw)
  To: Joe Perches
  Cc: Christoph Hellwig, Arnd Bergmann, Greg Kroah-Hartman,
	linux-kernel, Dimitri Sivanich

While a reduction in object size is welcome, in this case it does come at the
expense of some clarity, as field sizes are no longer as clear.
Nevertheless, will add my ack.

Acked-by: Dimitri Sivanich <sivanich@hpe.com>

On Mon, Oct 07, 2019 at 11:30:46AM -0700, Joe Perches wrote:
> Use seq_puts and simple string output and not seq_printf with formats
> and individual strings to reduce overall object size.
> 
> $ size drivers/misc/sgi-gru/gruprocfs.o* (x86-64 defconfig with gru)
>    text	   data	    bss	    dec	    hex	filename
>    7006	      8	      0	   7014	   1b66	drivers/misc/sgi-gru/gruprocfs.o.new
>    7472	      8	      0	   7480	   1d38	drivers/misc/sgi-gru/gruprocfs.o.old
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  drivers/misc/sgi-gru/gruprocfs.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
> index 3a8d76d1ccae..2817f4751306 100644
> --- a/drivers/misc/sgi-gru/gruprocfs.c
> +++ b/drivers/misc/sgi-gru/gruprocfs.c
> @@ -119,7 +119,7 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
>  		"cch_interrupt_sync", "cch_deallocate", "tfh_write_only",
>  		"tfh_write_restart", "tgh_invalidate"};
>  
> -	seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
> +	seq_puts(s, "#id                        count   aver-clks    max-clks\n");
>  	for (op = 0; op < mcsop_last; op++) {
>  		count = atomic_long_read(&mcs_op_statistics[op].count);
>  		total = atomic_long_read(&mcs_op_statistics[op].total);
> @@ -165,8 +165,7 @@ static int cch_seq_show(struct seq_file *file, void *data)
>  	const char *mode[] = { "??", "UPM", "INTR", "OS_POLL" };
>  
>  	if (gid == 0)
> -		seq_printf(file, "#%5s%5s%6s%7s%9s%6s%8s%8s\n", "gid", "bid",
> -			   "ctx#", "asid", "pid", "cbrs", "dsbytes", "mode");
> +		seq_puts(file, "#  gid  bid  ctx#   asid      pid  cbrs dsbytes    mode\n");
>  	if (gru)
>  		for (i = 0; i < GRU_NUM_CCH; i++) {
>  			ts = gru->gs_gts[i];
> @@ -191,10 +190,8 @@ static int gru_seq_show(struct seq_file *file, void *data)
>  	struct gru_state *gru = GID_TO_GRU(gid);
>  
>  	if (gid == 0) {
> -		seq_printf(file, "#%5s%5s%7s%6s%6s%8s%6s%6s\n", "gid", "nid",
> -			   "ctx", "cbr", "dsr", "ctx", "cbr", "dsr");
> -		seq_printf(file, "#%5s%5s%7s%6s%6s%8s%6s%6s\n", "", "", "busy",
> -			   "busy", "busy", "free", "free", "free");
> +		seq_puts(file, "#  gid  nid    ctx   cbr   dsr     ctx   cbr   dsr\n");
> +		seq_puts(file, "#             busy  busy  busy    free  free  free\n");
>  	}
>  	if (gru) {
>  		ctxfree = GRU_NUM_CCH - gru->gs_active_contexts;
> 
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-10-08  1:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-07 18:30 [PATCH] sgi-gru: simplify procfs code some more Joe Perches
2019-10-08  1:59 ` Dimitri Sivanich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).