Re: [PATCH] take 2 of the tr-based current

Manfred Spraul (manfred@colorfullife.com)
Fri, 09 Nov 2001 15:54:03 +0100


Jakub Jelinek wrote:
>
> On Thu, Nov 08, 2001 at 09:11:43PM -0500, Benjamin LaHaise wrote:
> > -static unsigned get_TR(void) __attribute__ ((pure))
> > +static unsigned get_TR(void) __attribute__ ((pure));
> > +static unsigned get_TR(void)
> > {
> > unsigned tr;
> > __asm__("str %w0" : "=g" (tr));
>
> Why not
> static inline unsigned __attribute__ ((const)) get_TR(void)
> {
> }
> ?
> If TR register only ever changes during cpu_init, I don't see why you
> cannot use const.

The task register is only pure, not const. It's true that it's only
initialized during cpu_init(), but different cpus in the system have
different task register values.
get_TR();
schedule();
get_TR();
must reload the task register.

But the value of "current" can be considered as const: It never changes
for a running thread. The exception are fork() and clone(), but both
functions directly call asm code and run on a fresh stack after forking.

> Using pure would mean if you do get_TR, then store
> something into global memory and do get_TR again, it will be done twice.
> Also, I wonder why you don't inline it.
>

ben?
I think get_current should be inline, const. get_TR() and
smp_processor_id would be inline, pure.

--
	Manfred
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/