public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@redhat.com>
To: Jan Engelhardt <jengelh@computergmbh.de>
Cc: Sam Ravnborg <sam@ravnborg.org>,
	Johannes Weiner <hannes@saeurebad.de>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] Sectionized printk data
Date: Sat, 9 Feb 2008 21:54:33 -0200	[thread overview]
Message-ID: <20080209235433.GS4352@ghostprotocols.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0802092307520.6917@fbirervta.pbzchgretzou.qr>

Em Sat, Feb 09, 2008 at 11:08:45PM +0100, Jan Engelhardt escreveu:
> 
> On Feb 4 2008 19:07, Sam Ravnborg wrote:
> >> The attached patch allows something along the lines:
> >> 
> >> int __init some_function(void)
> >> {
> >>         [...]
> >>         pr_init(KERN_WARNING "failure %s in %s\n", ...);
> >>         [...]
> >> }
> >> 
> >> Another idea I had was to make printk a macro that figures out the
> >> section of the surrounding function and then moves the data
> >> automatically when it is a literal, but I couldn't find mechanisms that
> >> allow this.  Anyone of you got an idea?
> >> 
> >> What do you think in general?
> >
> >What is the rationale behind this?
> 
> To drop strings that are only shown once anyway, such as:
> 
> static int __init ebtables_init(void)
> {
>         int ret;
> 
>         mutex_lock(&ebt_mutex);
>         list_add(&ebt_standard_target.list, &ebt_targets);
>         mutex_unlock(&ebt_mutex);
>         if ((ret = nf_register_sockopt(&ebt_sockopts)) < 0)
>                 return ret;
> 
> ->      printk(KERN_INFO "Ebtables v2.0 registered\n");
>         return 0;
> }
> 
> >If you say "saving memory" then please let us know with specific examples
> >in what area these savings will really pay off.

A long time ago I played with this, using a sparse based tool that was
inserted as the compiler and modified the code before passing to gcc,
i.e. a pre-pre-processor:

http://www.kernel.org/pub/linux/kernel/people/acme/sparse/initstr.c

I couldn't find in the archives, but IIRC some extra pages were freed
after boot, i.e. strings moved from .data to .init.data.

With a tool like this the advantage is that no source code has to be
changed, strings in __init functions are automagically moved to
.init.data, the disadvantage is that not all strings can be moved to
.init.data as there were (are?) subsystems that keep pointers to the
string passed and another tool would be involved in the build process.

- Arnaldo

  reply	other threads:[~2008-02-09 23:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-04 15:48 [RFC] Sectionized printk data Johannes Weiner
2008-02-04 18:07 ` Sam Ravnborg
2008-02-04 20:23   ` Johannes Weiner
2008-02-09 22:08   ` Jan Engelhardt
2008-02-09 23:54     ` Arnaldo Carvalho de Melo [this message]
2008-02-10  0:18       ` Jan Engelhardt
2008-02-10  0:27         ` Arnaldo Carvalho de Melo

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=20080209235433.GS4352@ghostprotocols.net \
    --to=acme@redhat.com \
    --cc=hannes@saeurebad.de \
    --cc=jengelh@computergmbh.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sam@ravnborg.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