linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Colin Ian King <colin.king@canonical.com>,
	Andrzej Hajda <a.hajda@samsung.com>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Robert Foss <robert.foss@linaro.org>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
	dri-devel@lists.freedesktop.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/bridge/tc358767: make the array ext_div static const, makes object smaller
Date: Thu, 19 Aug 2021 07:40:41 -0700	[thread overview]
Message-ID: <3da667b1b415b19325c034dcb389a201fa46cfd3.camel@perches.com> (raw)
In-Reply-To: <913b96bc-f5c4-1a26-c5f7-70a9d0ab3f53@canonical.com>

On Thu, 2021-08-19 at 14:54 +0100, Colin Ian King wrote:
> On 19/08/2021 14:51, Joe Perches wrote:
> > On Thu, 2021-08-19 at 14:38 +0100, Colin King wrote:
> > > From: Colin Ian King <colin.king@canonical.com>
> > > 
> > > Don't populate the array ext_div on the stack but instead it
> > > static const. Makes the object code smaller by 118 bytes:
> > > 
> > > Before:
> > >    text    data    bss     dec    hex filename
> > >   39449   17500    128   57077   def5 ./drivers/gpu/drm/bridge/tc358767.o
> > > 
> > > After:
> > >    text    data    bss     dec    hex filename
> > >   39235   17596    128   56959   de7f ./drivers/gpu/drm/bridge/tc358767.o
> > 
> > Why is text smaller and data larger with this change?
> 
> There are less instructions being used with the change since it's not
> shoving the array data onto the stack at run time. Instead the array is
> being stored in the data section and there is less object code required
> to access the data.

Ah.  It's really because it's not a minimal compilation ala defconfig.

I think you should really stop making these size comparisons with
.config uses that are not based on a defconfig as a whole lot of other
things are going on.

Please notice that the object sizes are significantly smaller below:

So with an x86-64 defconfig and this compilation unit enabled with
CONFIG_OF enabled and CONFIG_DRM_TOSHIBA_TC358767=y, with gcc 10.3
and this change the object size actually increases a bit.

$ size drivers/gpu/drm/bridge/tc358767.o*
   text	   data	    bss	    dec	    hex	filename
  13554	    268	      1	  13823	   35ff	drivers/gpu/drm/bridge/tc358767.o.new
  13548	    268	      1	  13817	   35f9	drivers/gpu/drm/bridge/tc358767.o.old

objdump -h shows these differences:

.old:
  0 .text         00001e1f  0000000000000000  0000000000000000  00000040  2**4
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
[...]
 14 .rodata       000005ae  0000000000000000  0000000000000000  000046e0  2**5
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA

.new:
  0 .text         00001e05  0000000000000000  0000000000000000  00000040  2**4
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
[...]
 11 .rodata       000005ce  0000000000000000  0000000000000000  00004600  2**5
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA

cheers, Joe


  reply	other threads:[~2021-08-19 14:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-19 13:38 [PATCH] drm/bridge/tc358767: make the array ext_div static const, makes object smaller Colin King
2021-08-19 13:51 ` Joe Perches
2021-08-19 13:54   ` Colin Ian King
2021-08-19 14:40     ` Joe Perches [this message]
2021-08-19 14:51       ` Colin Ian King
2021-08-19 15:10         ` Joe Perches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3da667b1b415b19325c034dcb389a201fa46cfd3.camel@perches.com \
    --to=joe@perches.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=a.hajda@samsung.com \
    --cc=airlied@linux.ie \
    --cc=colin.king@canonical.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=narmstrong@baylibre.com \
    --cc=robert.foss@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).