public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: <pazke@orbita1.ru>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] small addition to <linux/init.h>
Date: Mon, 14 May 2001 16:21:18 +0400	[thread overview]
Message-ID: <20010514162118.C2912@orbita1.ru> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 779 bytes --]

Hi all,

please take a quick look at attached patch (IMHO it can be usefull :)

The code below is a common code pattern in Linux kernel: 

static int __init foo(void)
{
	. . .
	printk("%s: blah blah blah\n", bar);
	. . .
}

this is bad because "blah blah blah\n" goes to .rodata section and plagues 
the memory. With this small patch it's possibe to rewrite this fragment as:

static int __init foo(void)
{
	. . .
	printk(__init_msg("%s: blah blah blah\n"), bar);
	. . .
}

and thus "blah blah blah\n" goes to .data.init and then to bitbucket.
IMHO it can save some extra memory for us.

Best regadrs.

-- 
Andrey Panin            | Embedded systems software engineer
pazke@orbita1.ru        | PGP key: http://www.orbita1.ru/~pazke/AndreyPanin.asc

[-- Attachment #1.2: patch-__init_msg --]
[-- Type: text/plain, Size: 590 bytes --]

diff -ur linux.vanilla/include/linux/init.h linux/include/linux/init.h
--- linux.vanilla/include/linux/init.h	Mon May 14 15:51:20 2001
+++ linux/include/linux/init.h	Mon May 14 15:54:05 2001
@@ -155,4 +155,9 @@
 #define __devexitdata __exitdata
 #endif
 
+#define __init_msg(x) ({ static char msg[] __initdata = (x); msg; })
+#define __exit_msg(x) ({ static char msg[] __exitdata = (x); msg; })
+#define __devinit_msg(x) ({ static char msg[] __devinitdata = (x); msg; })
+#define __devexit_msg(x) ({ static char msg[] __devexitdata = (x); msg; })
+
 #endif /* _LINUX_INIT_H */

[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]

                 reply	other threads:[~2001-05-14 12:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20010514162118.C2912@orbita1.ru \
    --to=pazke@orbita1.ru \
    --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