* [PATCH] staging: wfx: make a const array static, makes object smaller
@ 2020-10-16 22:33 Colin King
2020-10-17 0:11 ` Joe Perches
0 siblings, 1 reply; 5+ messages in thread
From: Colin King @ 2020-10-16 22:33 UTC (permalink / raw)
To: Jérôme Pouiller, Greg Kroah-Hartman, devel
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.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
(gcc version 10.2.0)
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/staging/wfx/sta.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 2320a81eae0b..196779a1b89a 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -63,7 +63,7 @@ void wfx_suspend_hot_dev(struct wfx_dev *wdev, enum sta_notify_cmd cmd)
static void wfx_filter_beacon(struct wfx_vif *wvif, bool filter_beacon)
{
- const struct hif_ie_table_entry filter_ies[] = {
+ static const struct hif_ie_table_entry filter_ies[] = {
{
.ie_id = WLAN_EID_VENDOR_SPECIFIC,
.has_changed = 1,
--
2.27.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: wfx: make a const array static, makes object smaller
2020-10-16 22:33 [PATCH] staging: wfx: make a const array static, makes object smaller Colin King
@ 2020-10-17 0:11 ` Joe Perches
2020-10-19 8:09 ` David Laight
2020-10-19 17:52 ` Christophe JAILLET
0 siblings, 2 replies; 5+ messages in thread
From: Joe Perches @ 2020-10-17 0:11 UTC (permalink / raw)
To: Colin King, Jérôme Pouiller, Greg Kroah-Hartman, devel
Cc: kernel-janitors, linux-kernel
On Fri, 2020-10-16 at 23:33 +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.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)
This line in the same function:
hif_set_beacon_filter_table(wvif, 3, filter_ies);
might as well use ARRAY_SIZE(filter_ies) instead of 3
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] staging: wfx: make a const array static, makes object smaller
2020-10-17 0:11 ` Joe Perches
@ 2020-10-19 8:09 ` David Laight
2020-10-19 9:43 ` Jérôme Pouiller
2020-10-19 17:52 ` Christophe JAILLET
1 sibling, 1 reply; 5+ messages in thread
From: David Laight @ 2020-10-19 8:09 UTC (permalink / raw)
To: 'Joe Perches',
Colin King, Jérôme Pouiller, Greg Kroah-Hartman, devel
Cc: kernel-janitors, linux-kernel
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@canonical.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...
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: wfx: make a const array static, makes object smaller
2020-10-19 8:09 ` David Laight
@ 2020-10-19 9:43 ` Jérôme Pouiller
0 siblings, 0 replies; 5+ messages in thread
From: Jérôme Pouiller @ 2020-10-19 9:43 UTC (permalink / raw)
To: 'Joe Perches',
Colin King, Greg Kroah-Hartman, devel, David Laight
Cc: kernel-janitors, linux-kernel
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@canonical.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@silabs.com>
--
Jérôme Pouiller
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: wfx: make a const array static, makes object smaller
2020-10-17 0:11 ` Joe Perches
2020-10-19 8:09 ` David Laight
@ 2020-10-19 17:52 ` Christophe JAILLET
1 sibling, 0 replies; 5+ messages in thread
From: Christophe JAILLET @ 2020-10-19 17:52 UTC (permalink / raw)
To: Joe Perches, Colin King, Jérôme Pouiller,
Greg Kroah-Hartman, devel
Cc: kernel-janitors, linux-kernel
Le 17/10/2020 à 02:11, Joe Perches a écrit :
> On Fri, 2020-10-16 at 23:33 +0100, Colin King wrote:
>> From: Colin Ian King <colin.king@canonical.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)
>
The function looks small.
Maybe it is inlined by gcc in each of the 3 callers?
CJ
> This line in the same function:
>
> hif_set_beacon_filter_table(wvif, 3, filter_ies);
>
> might as well use ARRAY_SIZE(filter_ies) instead of 3
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-10-19 17:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-16 22:33 [PATCH] staging: wfx: make a const array static, makes object smaller Colin King
2020-10-17 0:11 ` Joe Perches
2020-10-19 8:09 ` David Laight
2020-10-19 9:43 ` Jérôme Pouiller
2020-10-19 17:52 ` Christophe JAILLET
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).