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 04:05:44 +0200 Sender: linux-smp-owner@vger.kernel.org Message-ID: <20020713020544.GE1675@werewolf.able.es> References: <20020713001234.GA1675@werewolf.able.es> <1026525032.9956.38.camel@irongate.swansea.linux.org.uk> <20020713011114.GC1675@werewolf.able.es> Mime-Version: 1.0 Content-Transfer-Encoding: 7BIT Return-path: Content-Disposition: inline In-Reply-To: <20020713011114.GC1675@werewolf.able.es>; from jamagallon@able.es on Sat, Jul 13, 2002 at 03:11:14 +0200 List-Id: Content-Type: text/plain; charset="us-ascii" To: "J.A. Magallon" Cc: Alan Cox , "Robert M. Hyatt" , Lista Linux-SMP On 2002.07.13 J.A. Magallon wrote: > >> >>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' >> It can be done even arch-independent (__builtin_frame_address is at least since 2.96): #include #include #include #include #include #include #include #define MAXT 4 // User definable #define STACK_PAGES 8 #define PRIV_PAGES 1 // #define STACK_SIZE (STACK_PAGES*PAGE_SIZE) #define PRIV_SIZE (PRIV_PAGES*PAGE_SIZE) #define TOTAL_PAGES (STACK_PAGES+PRIV_PAGES) #define TOTAL_SIZE (TOTAL_PAGES*PAGE_SIZE) #define TOTAL_MASK (~(TOTAL_SIZE-1)) void* getpriv(); #define self() (*(int*)getpriv()) #define setself(k) do { *(int*)getpriv() = k; } while(0) int slave(void *arg); void f(); int main(int argc,char** argv) { void* stack[MAXT]; int i; for (i=0; i