mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Arnd Bergmann <arnd@arndb.de>,
	"Darren Hart (VMware)" <dvhart@infradead.org>,
	Mattias Jacobsson <2pi@mok.nu>
Cc: Jeff Mahoney <jeffm@suse.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] mod_devicetable.h: reduce sizeof(struct of_device_id) by 80 bytes
Date: Thu, 25 Apr 2019 22:31:01 +0200	[thread overview]
Message-ID: <20190425203101.9403-1-linux@rasmusvillemoes.dk> (raw)

A typical kernel image has hundreds of static struct of_device_id
instances (a lot of which are sentinel all-zeroes), each occupying
~200 bytes. Nobody initializes the .compatible member with strings
anywhere near 128 bytes, so a lot of that memory is simply wasted.

To verify, I first had the 0day bot chew on a patch adding a dummy
extremely long .compatible string, and I did get an email saying that
the patch resulted in lots of new
"warning:initializer-string-for-array-of-chars-is-too-long"
warnings. Then I had it chew on a version of this patch reducing to 46
(because gcc unfortunately does not warn when the literal sans the
terminating nul just fits), and got a SUCCESS mail listing 107
config/arch combinations.

For an arm imx_v6_v7_defconfig kernel, .rodata becomes 70K smaller;
.init.data shrinks by another ~13K, making the whole kernel image
about 83K, or 0.3%, smaller.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/mod_devicetable.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 448621c32e4d..502629bdac2e 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -241,7 +241,7 @@ struct sdw_device_id {
 struct of_device_id {
 	char	name[32];
 	char	type[32];
-	char	compatible[128];
+	char	compatible[48];
 	const void *data;
 };
 
-- 
2.20.1


             reply	other threads:[~2019-04-25 20:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-25 20:31 Rasmus Villemoes [this message]
2019-04-26  9:27 ` Arnd Bergmann
2019-05-02  9:41   ` Rasmus Villemoes
2019-05-02 12:29     ` Jeff Mahoney
2019-05-02 13:07       ` Rasmus Villemoes
2019-04-26 11:05 ` Enrico Weigelt, metux IT consult
2019-04-26 11:33   ` Rasmus Villemoes

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=20190425203101.9403-1-linux@rasmusvillemoes.dk \
    --to=linux@rasmusvillemoes.dk \
    --cc=2pi@mok.nu \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=dvhart@infradead.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jeffm@suse.com \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®