lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 19 Aug 2021 15:51:00 +0100
From:   Colin Ian King <colin.king@...onical.com>
To:     Joe Perches <joe@...ches.com>, Andrzej Hajda <a.hajda@...sung.com>,
        Neil Armstrong <narmstrong@...libre.com>,
        Robert Foss <robert.foss@...aro.org>,
        Laurent Pinchart <Laurent.pinchart@...asonboard.com>,
        Jonas Karlman <jonas@...boo.se>,
        Jernej Skrabec <jernej.skrabec@...il.com>,
        David Airlie <airlied@...ux.ie>,
        Daniel Vetter <daniel@...ll.ch>,
        dri-devel@...ts.freedesktop.org
Cc:     kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drm/bridge/tc358767: make the array ext_div static const,
 makes object smaller

On 19/08/2021 15:40, Joe Perches wrote:
> 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@...onical.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.

I'm using allmodconfig, which I believe is a legitimate configuration,
especially since distros so build kernels with lots of modules.
I'll double check on this though in case I've made a mistake.

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

ACK. Understood.  Even so, it still makes sense for these kind of
janitorial changes as it makes sense to constify arrays when they are
read-only and making them static is sensible for const data.

> 
> cheers, Joe
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ