Skip to contentSkip to conversation

__initdata strings

RFC Andi Kleen 3 participants 3 messages Oct 10, 2004 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Andi Kleen

author
#1 lore raw
Quoted 8 lines · Oleg Nesterov

Hello.

This patch is not intended for inclusion, just for illustration.

__init functions leaves strings (mainly printk's arguments) in .data section. It make sense to move them in .init.data.

Is there anyone else who would consider this useful?

There is a more generic way to do this with gcc extensions. Something like (uncompiled/untested)

#define __i(x) ({ static char __str[] __initdata = x; __str; })

But I'm not sure the few bytes saved are worth the code uglification. Probably not. likely/unlikely is already bad enough.

-Andi

#2 lore raw
Quoted 4 lines · Andi Kleen

There is a more generic way to do this with gcc extensions. Something like

#define __i(x) ({ static char __str[] __initdata = x; __str; })

I can't see any difference with:

#define I_STRING(str) \

({                                             \
       static char data[] __initdata = (str);  \
       data;                                   \

})

Quoted 1 line

But I'm not sure the few bytes saved are worth the code uglification.

Probably you are right, but i think it would be few kilobytes, there are so many __init functions.

Oleg.

#3 lore raw
Quoted 3 lines · Oleg Nesterov
Quoted 1 line · Andi Kleen

There is a more generic way to do this with gcc extensions. Something like

Or with a pre-processor, using a sparse based tool such as this one I've written a long time ago:

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

That uses what Andi described, but does this automatically if initstr is made part of the building process.

Quoted 2 lines
Quoted 2 lines

#define __i(x) ({ static char __str[] __initdata = x; __str; })

Regards,

- Arnaldo