2002-07-28 18:37:54

by Oleg Nesterov

[permalink] [raw]
Subject: Re: [announce, patch] Thread-Local Storage (TLS) support for Linux, 2.5.28

Hello.

I thought, that gdt entry consulted only while
loading its index into the segment register.

So load_TLS_desc(next, cpu) must be called before
loading next->fs,next->gs in __switch_to() ?

--- linux-2.5.29/arch/i386/kernel/process.c~ Sun Jul 28 21:44:35 2002
+++ linux-2.5.29/arch/i386/kernel/process.c Sun Jul 28 21:46:07 2002
@@ -675,6 +675,14 @@
tss->esp0 = next->esp0;

/*
+ * Load the per-thread Thread-Local Storage descriptor.
+ *
+ * NOTE: it's faster to do the two stores unconditionally
+ * than to branch away.
+ */
+ load_TLS_desc(next, cpu);
+
+ /*
* Save away %fs and %gs. No need to save %es and %ds, as
* those are always kernel segments while inside the kernel.
*/
@@ -688,14 +696,6 @@
loadsegment(fs, next->fs);
loadsegment(gs, next->gs);
}
-
- /*
- * Load the per-thread Thread-Local Storage descriptor.
- *
- * NOTE: it's faster to do the two stores unconditionally
- * than to branch away.
- */
- load_TLS_desc(next, cpu);

/*
* Now maybe reload the debug registers

Oleg.


2002-07-28 19:59:28

by Ingo Molnar

[permalink] [raw]
Subject: Re: [announce, patch] Thread-Local Storage (TLS) support for Linux, 2.5.28


On Sun, 28 Jul 2002, Oleg Nesterov wrote:

> I thought, that gdt entry consulted only while
> loading its index into the segment register.
>
> So load_TLS_desc(next, cpu) must be called before
> loading next->fs,next->gs in __switch_to() ?

hm, right. I'm wondering, why did the tls_test code still work?

Ingo

2002-07-28 20:06:18

by Ingo Molnar

[permalink] [raw]
Subject: Re: [announce, patch] Thread-Local Storage (TLS) support for Linux, 2.5.28


On Sun, 28 Jul 2002, Oleg Nesterov wrote:

> + * Load the per-thread Thread-Local Storage descriptor.
> + *
> + * NOTE: it's faster to do the two stores unconditionally
> + * than to branch away.
> + */
> + load_TLS_desc(next, cpu);
> +
> + /*
> * Save away %fs and %gs. No need to save %es and %ds, as

actually, shouldnt this be done after saving the current %fs and %gs, and
before loading the next %fs and %gs?

Ingo

2002-07-28 20:12:07

by Ingo Molnar

[permalink] [raw]
Subject: Re: [announce, patch] Thread-Local Storage (TLS) support for Linux, 2.5.28


On Sun, 28 Jul 2002, Ingo Molnar wrote:

> > So load_TLS_desc(next, cpu) must be called before
> > loading next->fs,next->gs in __switch_to() ?
>
> hm, right. I'm wondering, why did the tls_test code still work?

okay, the tls_test.c code worked only because the code didnt
context-switch after installing the TLS.

Ingo