Re: [PATCH x86/mm 6/6] x86-64 ia32 ptrace get/putreg32 current task

Andi Kleen
2007-11-29T20:11:43Z

> HOWEVER. That is actually not the right (well, "complete") conditional,
> since it's only one sub-case of the thing that matters. The right
> conditional is probably
>
> /*
> * Restore %gs if needed (which is common).
> * We can avoid it if they are identical, and
> * point to the GDT.

How would you catch (common) the case of them having different bases in the
GDT TLS entries? At some point the selector has to be reloaded, otherwise
it won't be picked up by the CPU.

I think the original condition is correct. You could maybe merge it with the
TLS entry rewrite and only do it if something changes there. Not
sure it is worth it though.

-Andi
> */
> if ((prev->gs ^ next->gs) | (next->gs & 4))
> loadsegment(gs, next->gs);
>
> At that point, we would only have to reload stuff if the user actually
> uses a local descriptor table entry (which does happen for threaded apps,
> I guess, but at least we avoid it for all the common traditional UNIX
> processes).
>
> Linus
>