linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] skx_edac: Move a few hundred bytes to text from data using const
@ 2016-08-22  0:02 Joe Perches
  2016-08-22 16:46 ` Luck, Tony
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2016-08-22  0:02 UTC (permalink / raw)
  To: Tony Luck, Doug Thompson, Borislav Petkov, Mauro Carvalho Chehab
  Cc: linux-edac, linux-kernel

Marking arrays as const makes for smaller data.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/edac/skx_edac.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/edac/skx_edac.c b/drivers/edac/skx_edac.c
index 0ff4878..875e74f 100644
--- a/drivers/edac/skx_edac.c
+++ b/drivers/edac/skx_edac.c
@@ -762,23 +762,23 @@ rir_found:
 	return true;
 }
 
-static u8 skx_close_row[] = {
+static const u8 skx_close_row[] = {
 	15, 16, 17, 18, 20, 21, 22, 28, 10, 11, 12, 13, 29, 30, 31, 32, 33
 };
-static u8 skx_close_column[] = {
+static const u8 skx_close_column[] = {
 	3, 4, 5, 14, 19, 23, 24, 25, 26, 27
 };
-static u8 skx_open_row[] = {
+static const u8 skx_open_row[] = {
 	14, 15, 16, 20, 28, 21, 22, 23, 24, 25, 26, 27, 29, 30, 31, 32, 33
 };
-static u8 skx_open_column[] = {
+static const u8 skx_open_column[] = {
 	3, 4, 5, 6, 7, 8, 9, 10, 11, 12
 };
-static u8 skx_open_fine_column[] = {
+static const u8 skx_open_fine_column[] = {
 	3, 4, 5, 7, 8, 9, 10, 11, 12, 13
 };
 
-static int skx_bits(u64 addr, int nbits, u8 *bits)
+static int skx_bits(u64 addr, int nbits, const u8 *bits)
 {
 	int i, res = 0;
 
@@ -884,7 +884,8 @@ static void skx_mce_output_error(struct mem_ctl_info *mci,
 				 struct decoded_addr *res)
 {
 	enum hw_event_mc_err_type tp_event;
-	char *type, *optype, msg[256];
+	const char *type, *optype;
+	char msg[256];
 	bool ripv = GET_BITFIELD(m->mcgstatus, 0, 0);
 	bool overflow = GET_BITFIELD(m->status, 62, 62);
 	bool uncorrected_error = GET_BITFIELD(m->status, 61, 61);
-- 
2.8.0.rc4.16.g56331f8

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

* Re: [PATCH] skx_edac: Move a few hundred bytes to text from data using const
  2016-08-22  0:02 [PATCH] skx_edac: Move a few hundred bytes to text from data using const Joe Perches
@ 2016-08-22 16:46 ` Luck, Tony
  2016-08-22 16:57   ` Joe Perches
  0 siblings, 1 reply; 3+ messages in thread
From: Luck, Tony @ 2016-08-22 16:46 UTC (permalink / raw)
  To: Joe Perches
  Cc: Doug Thompson, Borislav Petkov, Mauro Carvalho Chehab,
	linux-edac, linux-kernel

On Sun, Aug 21, 2016 at 05:02:41PM -0700, Joe Perches wrote:
> Marking arrays as const makes for smaller data.

Joe,

"a few hundred" seems to be exaggeration.

Before:
$ size drivers/edac/skx_edac.ko
   text	   data	    bss	    dec	    hex	filename
   8435	   1024	     24	   9483	   250b	drivers/edac/skx_edac.ko

After:
$ size drivers/edac/skx_edac.ko
   text    data     bss     dec     hex filename
   8531	    944	     24	   9499	   251b	drivers/edac/skx_edac.ko

so "data" was reduced by 80 bytes, but "text" went up by 96.

Net increase of 16 (perhaps because some padding for alignment???)

Making read-only data const is a good idea in general, but
do we want to do it if it *increases* kernel footprint?

-Tony

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

* Re: [PATCH] skx_edac: Move a few hundred bytes to text from data using const
  2016-08-22 16:46 ` Luck, Tony
@ 2016-08-22 16:57   ` Joe Perches
  0 siblings, 0 replies; 3+ messages in thread
From: Joe Perches @ 2016-08-22 16:57 UTC (permalink / raw)
  To: Luck, Tony
  Cc: Doug Thompson, Borislav Petkov, Mauro Carvalho Chehab,
	linux-edac, linux-kernel

On Mon, 2016-08-22 at 09:46 -0700, Luck, Tony wrote:
> On Sun, Aug 21, 2016 at 05:02:41PM -0700, Joe Perches wrote:
> > Marking arrays as const makes for smaller data.
> Joe,

Hi Tony

> "a few hundred" seems to be exaggeration.
> 
> Before:
> $ size drivers/edac/skx_edac.ko
>    text	   data	    bss	    dec	    hex	filename
>    8435	   1024	     24	   9483	   250b	drivers/edac/skx_edac.ko
> 
> After:
> $ size drivers/edac/skx_edac.ko
>    text    data     bss     dec     hex filename
>    8531	    944	     24	   9499	   251b	drivers/edac/skx_edac.ko
> 
> so "data" was reduced by 80 bytes, but "text" went up by 96.


Yeah, it was a few hundred in an allyesconfig
and I neglected to test the defconfig.

$ size drivers/edac/skx_edac.o* (x86-64)
   text	   data	    bss	    dec	    hex	filename
   6677	     64	     24	   6765	   1a6d	drivers/edac/skx_edac.o.defconfig.new
   6546	    176	     24	   6746	   1a5a	drivers/edac/skx_edac.o.defconfig.old
  20609	   5744	    320	  26673	   6831	drivers/edac/skx_edac.o.new
  20273	   6064	    320	  26657	   6821	drivers/edac/skx_edac.o.old

> Net increase of 16 (perhaps because some padding for alignment???)
> 
> Making read-only data const is a good idea in general, but
> do we want to do it if it *increases* kernel footprint?

Marking all data const that can be const is a good thing.
It reduces exposure and eliminates unintentional overwriting.

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

end of thread, other threads:[~2016-08-22 16:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-22  0:02 [PATCH] skx_edac: Move a few hundred bytes to text from data using const Joe Perches
2016-08-22 16:46 ` Luck, Tony
2016-08-22 16:57   ` Joe Perches

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).