From mboxrd@z Thu Jan 1 00:00:00 1970 From: "J.A. Magallon" Subject: Re: per-thread global variables Date: Sat, 13 Jul 2002 03:11:14 +0200 Sender: linux-smp-owner@vger.kernel.org Message-ID: <20020713011114.GC1675@werewolf.able.es> References: <20020713001234.GA1675@werewolf.able.es> <1026525032.9956.38.camel@irongate.swansea.linux.org.uk> Mime-Version: 1.0 Content-Transfer-Encoding: 7BIT Return-path: Content-Disposition: inline In-Reply-To: <1026525032.9956.38.camel@irongate.swansea.linux.org.uk>; from alan@lxorguk.ukuu.org.uk on Sat, Jul 13, 2002 at 03:50:32 +0200 List-Id: Content-Type: text/plain; charset="us-ascii" To: Alan Cox Cc: "Robert M. Hyatt" , Lista Linux-SMP On 2002.07.13 Alan Cox wrote: >On Sat, 2002-07-13 at 01:12, J.A. Magallon wrote: >> On IRIX, you have a >> >> // Fixed address space always private for each process/thread >> #define PRDA ((struct prda *)0x00200000L) >> >> struct prda* thrprda; >> int* self; >> > >Which goes to show they weren't planning for clone like performance. A >single unshared page means two seperate mm structs, two sets of page >tables and switches causing TLB flushes. All because > > movl %esp, %eax > andl $ffff8000, %eax > >and casting that is 'hard' > OK, I do not know a word on x86 assembler, but lets see if at least I understand this. stack = reserve 32K+sizeof(my_private_area) (say, 1Kb) clone() lying about stack start: stack + 32K - 1 (private on top and stack grows downwards) |---- stack ----||--- private -----| 0 32K 33k ^ stack passed to clone() void* getpriv() { // get my stack frame pointer, can be anywhere depending on my // movl %esp, %eax |---- stack ----||--- private -----| ^ %eax // Round it to 32k multiple, cause I know the thread stack is 32k aligned // So I have the thread stack end, ie, bottom andl $ffff8000, %eax |---- stack ----||--- private -----| ^ %eax // Move after top of stack addl 32K,%eax |---- stack ----||--- private -----| ^ %eax // and I have the begining of my private area, upwards } Could it even be correct ? TIA -- J.A. Magallon \ Software is like sex: It's better when it's free mailto:jamagallon@able.es \ -- Linus Torvalds, FSF T-shirt Linux werewolf 2.4.19-rc1-jam3, Mandrake Linux 8.3 (Cooker) for i586 gcc (GCC) 3.1.1 (Mandrake Linux 8.3 3.1.1-0.7mdk)