* [PATCH] 9p: make two arrays static const, makes object smaller
@ 2019-09-06 13:38 Colin King
2019-09-06 14:01 ` Dominique Martinet
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2019-09-06 13:38 UTC (permalink / raw)
To: Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet,
v9fs-developer
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Don't populate the arrays on the stack but instead make them
static const. Makes the object code smaller by 386 bytes.
Before:
text data bss dec hex filename
17443 2076 0 19519 4c3f fs/9p/vfs_inode_dotl.o
After:
text data bss dec hex filename
16897 2236 0 19133 4abd fs/9p/vfs_inode_dotl.o
(gcc version 9.2.1, amd64)
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
fs/9p/vfs_inode_dotl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index 60328b21c5fb..961d8d0fa905 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -167,7 +167,7 @@ static int v9fs_mapped_dotl_flags(int flags)
{
int i;
int rflags = 0;
- struct dotl_openflag_map dotl_oflag_map[] = {
+ static const struct dotl_openflag_map dotl_oflag_map[] = {
{ O_CREAT, P9_DOTL_CREATE },
{ O_EXCL, P9_DOTL_EXCL },
{ O_NOCTTY, P9_DOTL_NOCTTY },
@@ -512,7 +512,7 @@ static int v9fs_mapped_iattr_valid(int iattr_valid)
{
int i;
int p9_iattr_valid = 0;
- struct dotl_iattr_map dotl_iattr_map[] = {
+ static const struct dotl_iattr_map dotl_iattr_map[] = {
{ ATTR_MODE, P9_ATTR_MODE },
{ ATTR_UID, P9_ATTR_UID },
{ ATTR_GID, P9_ATTR_GID },
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] 9p: make two arrays static const, makes object smaller
2019-09-06 13:38 [PATCH] 9p: make two arrays static const, makes object smaller Colin King
@ 2019-09-06 14:01 ` Dominique Martinet
0 siblings, 0 replies; 2+ messages in thread
From: Dominique Martinet @ 2019-09-06 14:01 UTC (permalink / raw)
To: Colin King
Cc: Eric Van Hensbergen, Latchesar Ionkov, v9fs-developer,
kernel-janitors, linux-kernel
Colin King wrote on Fri, Sep 06, 2019:
> From: Colin Ian King <colin.king@canonical.com>
>
> Don't populate the arrays on the stack but instead make them
> static const. Makes the object code smaller by 386 bytes.
>
> Before:
> text data bss dec hex filename
> 17443 2076 0 19519 4c3f fs/9p/vfs_inode_dotl.o
>
> After:
> text data bss dec hex filename
> 16897 2236 0 19133 4abd fs/9p/vfs_inode_dotl.o
>
> (gcc version 9.2.1, amd64)
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Fine with me, I'll pick it up for the next cycle.
There are a couple of static structs in net/9p that aren't const (but
could be); I guess the static is all that matters here?
(I'll try to go through and make the rest const when I have time
though, no harm there)
Thanks,
--
Dominique
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-09-06 14:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-06 13:38 [PATCH] 9p: make two arrays static const, makes object smaller Colin King
2019-09-06 14:01 ` Dominique Martinet
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).