Re: Using %cr2 to reference "current"

Linus Torvalds
2001-11-06T22:42:18Z

In article <E161B0f-0001Io-00@the-village.bc.nu>,
Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
>
>> That should work fairly well, and has the advantage that you can hide more
>> state there if you want (ie it allows us, on demand, to move hot state of
>> "struct task_struct" up there).
>
>Sweet. Now that I'd completely missed. Task private state and task
>public state splitting

Yes. It would be a waste to have to bring in a cache-line into the L1
cache, and then only use 4 bytes of it. So it should make sense to set
this up somewhat like:

struct local_task_struct {
struct task_struct *tsk;
.. other fields ..
};

and then use the _exact_ existing infrastructure to get
"local_task_struct" instead of "task_struct", and let the compiler do
all the rest at a higher level. So we'd just rename "get_current()" to
"get_local_current()", and then do

#define get_current() (get_local_current()->tsk)

and people who want to know about the local task struct can use that.

Linus