Re: [RFC] Sectionized printk data

From: Jan Engelhardt
Date: Sat Feb 09 2008 - 19:18:45 EST



On Feb 9 2008 21:54, Arnaldo Carvalho de Melo wrote:
>> 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.
>
>[...]
>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.

There is one corner case to consider:


static char abc[] = "foo";

int __init init_module(void)
{
printk(abc);
}

I am not sure if gcc/ld is smart enough to figure out that abc is
only ever used from within an __init function and that it could hence
be moved to __initdata.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/