From: Joe Perches <joe@perches.com>
To: Mathias Krause <minipli@googlemail.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Steven Rostedt <rostedt@goodmis.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [RFC PATCH 0/3] Mark literal strings in __init / __exit code
Date: Tue, 24 Jun 2014 12:37:00 -0700 [thread overview]
Message-ID: <1403638620.29061.35.camel@joe-AO725> (raw)
In-Reply-To: <CA+rthh8XwC80hq8z07k+=0J7MDA6tUtLff+J=qMuzYqTNyLKww@mail.gmail.com>
On Tue, 2014-06-24 at 21:13 +0200, Mathias Krause wrote:
> On 24 June 2014 16:31, Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:
[]
> > gcc already seems to contain infrastructure for this kind of thing, so
> > maybe it doesn't even require a plugin, but simply a little coordination
> > with the gcc folks. This snippet from gcc internals seems relevant:
> >
> > -- Target Hook: section * TARGET_ASM_FUNCTION_RODATA_SECTION (tree
> > DECL)
> > Return the readonly data section associated with 'DECL_SECTION_NAME
> > (DECL)'. The default version of this function selects
> > '.gnu.linkonce.r.name' if the function's section is
> > '.gnu.linkonce.t.name', '.rodata.name' if function is in
> > '.text.name', and the normal readonly-data section otherwise.
> >
>
> I don't think it's that easy. You cannot simply put all strings into
> the .init.rodata section when code currently gets emitted to
> .init.text. The reason is because strings used in __init code might be
> referenced later on, too. For example, the name passed to
> class_create() won't be copied. If that one would go into the
> .init.rodata section automatically, we would have dangling pointers
> after the .init.* memory got freed. Therefore a compiler driven
> approach would need to be implemented as a compiler extension, a gcc
> plugin to handle such cases -- know when a string can safely be put
> into the .init.rodata section and when not. But that decision is not
> as easy as Joe might think it would be. How would the plugin know
> which strings to put into the .init.rodata section? Would it only
> handle the ones passed to printk()?
Yes.
> I still strongly believe it's better to do this manually.
Maybe.
It'd work with any version of the compiler that way too.
It's a pretty simple transform.
I believe this will show most all of the __init
uses of printks:
$ grep-2.5.4 -rP --include=*.[ch] -n '\b__init\b[^\n][^\}]+\n}' * | \
grep -P '^[\w\/\.]+:\d+:|\bprintk\b|\bpr_[a-z]+' | \
grep -P -B1 '\bprintk\b|\bpr_[a-z]+'
This shows a little more than a 1000 __init printks
treewide that could be converted.
For example:
arch/ia64/include/asm/cyclone.h:6:extern void __init cyclone_setup(void);
printk(KERN_ERR "Cyclone Counter: System not configured"
--
arch/ia64/kernel/acpi.c:66:static unsigned long __init acpi_find_rsdp(void)
printk(KERN_WARNING PREFIX
--
arch/ia64/kernel/acpi.c:366:static int __init acpi_parse_madt(struct acpi_table
printk(KERN_INFO PREFIX "Local APIC address %p\n", ipi_base_addr);
etc...
There are maybe 200 or so __exit ones.
next prev parent reply other threads:[~2014-06-24 19:37 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-22 22:46 Mathias Krause
2014-06-22 22:46 ` [RFC PATCH 1/3] init.h: Add __init_str / __exit_str macros Mathias Krause
2014-06-24 19:43 ` Joe Perches
2014-06-24 20:13 ` Mathias Krause
2014-06-22 22:46 ` [RFC PATCH 2/3] printk: Provide pi_<level> / pe_<level> macros for __init / __exit code Mathias Krause
2014-06-22 22:46 ` [RFC PATCH 3/3] x86, acpi: Mark __init strings as such Mathias Krause
2014-06-22 22:56 ` [RFC PATCH 0/3] Mark literal strings in __init / __exit code Joe Perches
2014-06-23 6:23 ` Mathias Krause
2014-06-23 6:33 ` Joe Perches
2014-06-24 14:31 ` Rasmus Villemoes
2014-06-24 19:13 ` Mathias Krause
2014-06-24 19:37 ` Joe Perches [this message]
2014-06-24 20:10 ` Mathias Krause
2014-06-24 20:30 ` Joe Perches
2014-06-24 20:41 ` Mathias Krause
2014-06-24 20:57 ` Joe Perches
2014-06-24 21:06 ` Mathias Krause
2014-06-24 21:45 ` Joe Perches
2014-06-25 5:55 ` Mathias Krause
2014-06-25 7:35 ` Rasmus Villemoes
2014-06-25 7:48 ` Joe Perches
2014-06-25 8:34 ` Mathias Krause
2014-06-25 11:22 ` Joe Perches
2014-06-25 8:17 ` Mathias Krause
2014-06-23 1:30 ` Joe Perches
2014-06-23 6:29 ` Mathias Krause
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=1403638620.29061.35.camel@joe-AO725 \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mingo@redhat.com \
--cc=minipli@googlemail.com \
--cc=rjw@rjwysocki.net \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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®