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]
Message-ID: <1800171.ETUgnxhFMb@pc-42>
Date:   Mon, 19 Oct 2020 11:43:36 +0200
From:   Jérôme Pouiller <jerome.pouiller@...abs.com>
To:     'Joe Perches' <joe@...ches.com>,
        Colin King <colin.king@...onical.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "devel@...verdev.osuosl.org" <devel@...verdev.osuosl.org>,
        David Laight <David.Laight@...lab.com>
Cc:     "kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] staging: wfx: make a const array static, makes object smaller

On Monday 19 October 2020 10:09:19 CEST David Laight wrote:
> From: Joe Perches
> > Sent: 17 October 2020 01:12
> >
> > On Fri, 2020-10-16 at 23:33 +0100, Colin King wrote:
> > > From: Colin Ian King <colin.king@...onical.com>
> > >
> > > Don't populate const array filter_ies on the stack but instead
> > > make it static. Makes the object code smaller by 261 bytes.
> > >
> > > Before:
> > >    text        data     bss     dec     hex filename
> > >   21674        3166     448   25288    62c8 drivers/staging/wfx/sta.o
> > >
> > > After:
> > >    text        data     bss     dec     hex filename
> > >   21349        3230     448   25027    61c3 drivers/staging/wfx/sta.o
> >
> > Thanks.
> >
> > It's odd to me it's so large a change as it's only
> > 24 bytes of initialization. (3 entries, each 8 bytes)
> 
> Perhaps the 'stack protector' crap?
> 
> Interestingly, loading the data from the 'readonly' section
> is probably a data cache miss.
> Which might end up being slower than the extra code to
> update the on-stack data.
> The extra code might get prefetched...

I had never realized the difference between "const" and "static const" in
this case.

With my gcc fro arm, the output of "objdump -h sta.o" gives:

Before:
  0 .text         000019fc  00000000  00000000  00000034  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  [...]
  7 .rodata       00000015  00000000  00000000  00001e78  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA

After:
  0 .text         00001974  00000000  00000000  00000034  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  [...]
  7 .rodata       0000002d  00000000  00000000  00001dd4  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA

The difference of .rodata is exactly what is expected (24 bytes) and we
save 115 bytes of code.

Reviewed-by: Jérôme Pouiller <jerome.pouiller@...abs.com>


-- 
Jérôme Pouiller


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ