linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* some char * optimizations in kernel
@ 2001-02-22 11:32 Ph. Marek
  2001-02-23 21:21 ` Pavel Machek
  2001-02-26  7:00 ` Ph. Marek
  0 siblings, 2 replies; 3+ messages in thread
From: Ph. Marek @ 2001-02-22 11:32 UTC (permalink / raw)
  To: linux-kernel

Hello everybody,

looking through the sources I found several pieces like
lib/vsprintf.c, line 111:
	const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";

As tested with egcs-2.91.60 even with -O3 there is a difference
between 
	const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
and
	const char digits[]="0123456789abcdefghijklmnopqrstuvwxyz";

in the resulting assembler code.


Usage of this pointer results in it being loaded in a register, and then
pushed on the stack (for subrouting using); if it's an array, the address
is pushed directly.

Furthermore, in the "char *"-case the pointer is stored in memory.



As I'm not at home I can't give a complete reference of all these cases.
(But it's trivial [at least for me :-)] using perl).

So if this changes are approved and I have the time I can post a diff in
the next few days.


BTW: For which size of patch is it possible to get included in the "Hall of
fame" (has helped with linux kernel)?
And, btw too, where can I find a maintainer of a specific file? eg., one of
these cases is in init/version.c which has "Copyright (C) 1992  Theodore
Ts'o" - but I have to guess it's tytso@valinux.com.
Is there something like Documentation/maintainers?



Regards,

Phil


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: some char * optimizations in kernel
  2001-02-22 11:32 some char * optimizations in kernel Ph. Marek
@ 2001-02-23 21:21 ` Pavel Machek
  2001-02-26  7:00 ` Ph. Marek
  1 sibling, 0 replies; 3+ messages in thread
From: Pavel Machek @ 2001-02-23 21:21 UTC (permalink / raw)
  To: Ph. Marek, linux-kernel

Hi!

> Hello everybody,
> 
> looking through the sources I found several pieces like
> lib/vsprintf.c, line 111:
> 	const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
> 
> As tested with egcs-2.91.60 even with -O3 there is a difference
> between 
> 	const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
> and
> 	const char digits[]="0123456789abcdefghijklmnopqrstuvwxyz";
> 
> in the resulting assembler code.
> 
> 
> Usage of this pointer results in it being loaded in a register, and then
> pushed on the stack (for subrouting using); if it's an array, the address
> is pushed directly.
> 
> Furthermore, in the "char *"-case the pointer is stored in memory.

It has to be, no matter of optimalization level. Some other module
might access that variable. You _could_ do static const char *..., but
it would probably not help.

> As I'm not at home I can't give a complete reference of all these cases.
> (But it's trivial [at least for me :-)] using perl).
> 
> So if this changes are approved and I have the time I can post a diff in
> the next few days.
> 
> 
> BTW: For which size of patch is it possible to get included in the "Hall of
> fame" (has helped with linux kernel)?

Try something bigger than this :-).

> And, btw too, where can I find a maintainer of a specific file? eg., one of
> these cases is in init/version.c which has "Copyright (C) 1992  Theodore
> Ts'o" - but I have to guess it's tytso@valinux.com.
> Is there something like Documentation/maintainers?

It is something like MAINTAINERS in root.

-- 
I'm pavel@ucw.cz. "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents at discuss@linmodems.org

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: some char * optimizations in kernel
  2001-02-22 11:32 some char * optimizations in kernel Ph. Marek
  2001-02-23 21:21 ` Pavel Machek
@ 2001-02-26  7:00 ` Ph. Marek
  1 sibling, 0 replies; 3+ messages in thread
From: Ph. Marek @ 2001-02-26  7:00 UTC (permalink / raw)
  To: Pavel Machek, linux-kernel

>> Furthermore, in the "char *"-case the pointer is stored in memory.
>
>It has to be, no matter of optimalization level. Some other module
>might access that variable. You _could_ do static const char *..., but
>it would probably not help.
I know that the pointer is NEEDED (from the compilers pov); what I don't
know is whether it has any ill side-effects to change it to a char [].
Most of this stuff is a version-string outputted at initialization time and
is not needed any more (afaik) but, as you noted, sometimes it could be
used by modules.

IIRC it doesn't matter if a symbol points to a pointer or an array - the
symbol is resolved either way.
BUT, if there is something that absolutly EXPECTS this as a pointer - is
this replaced in memory by insmod/modprobe on every occasion?


Well, just as well, I'll make a patch and post it.


>> And, btw too, where can I find a maintainer of a specific file? eg., one of
>> these cases is in init/version.c which has "Copyright (C) 1992  Theodore
>> Ts'o" - but I have to guess it's tytso@valinux.com.
>> Is there something like Documentation/maintainers?
>
>It is something like MAINTAINERS in root.
Thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2001-02-26  7:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-22 11:32 some char * optimizations in kernel Ph. Marek
2001-02-23 21:21 ` Pavel Machek
2001-02-26  7:00 ` Ph. Marek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).