Hi, Le Wed, 24 Oct 2007 20:09:51 +0900, NAHieu <nahieu@xxxxxxxxx> a écrit : > Hi, > > I noticed that the value of "current" macro has changed in the newer > kernel version (from 2.6.20?). It seems that now the task_struct > structure that points to the current process is now put in the FS > segment. That means from address range 0 upwards, we have the > "current" structure. Could anybody confirm this? > > I remember in the past, we have FS segment register point the the same > base 0 address, as other segment registers. But now FS is used to > access to "current", its base is no longer 0? We have #define current get_current() On 2.6.19, get_current() is: 008 static __always_inline struct task_struct * get_current(void) 009 { 010 return current_thread_info()->task; 011 } and current_thread_info() is: 091 static inline struct thread_info *current_thread_info(void) 092 { 093 return (struct thread_info *)(current_stack_pointer & ~(THREAD_SIZE - 1)); 094 } So the thread_info structure is at the bottom of the stack. After 2.6.20, get_current() changed: 009 static __always_inline struct task_struct *get_current(void) 010 { 011 return read_pda(pcurrent); 012 } read_pda() is implemented in include/asm-i386/pda.h, and PDA stands for Per-processor Data Areas. It seems that there's a per-processor data area, which can be accessed using the 'gs' segment register (whose value is different on each processor). In 2.6.22, read_pda() was renamed x86_read_percpu(), but the principle remains the same, except that the 'fs' segment register is used instead of 'gs', and that the implementation is different on SMP (where 'fs' is used) and non-SMP system (where a direct access is possible). So, yes, on 2.6.22 SMP systems, the segment pointed by the 'fs' register has a base address != 0. Does that answer your question ? Thomas -- Thomas Petazzoni - thomas.petazzoni@xxxxxxxx http://{thomas,sos,kos}.enix.org - http://www.toulibre.org http://www.{livret,agenda}dulibre.org -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ