about the macro "current" of i386 machines

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi all,
  i found that in kernel 2.6.22 the implementation of "current" macro
of i386 machines is different from previous versions'. and now it became this:

[include/asm-i386/current.h]
...
#define __percpu_seg "%%fs:"
#else  /* !SMP */
#include <asm-generic/percpu.h>
#define __percpu_seg ""
#endif  /* SMP */
...
DECLARE_PER_CPU(struct task_struct *, current_task);
static __always_inline struct task_struct *get_current(void)
{
        return x86_read_percpu(current_task);
}

#define current get_current()
...

[include/asm-i386/percpu.h]
...
#define percpu_from_op(op,var)                                  \
        ({                                                      \
                typeof(var) ret__;                              \
                switch (sizeof(var)) {                          \
                case 1:                                         \
                        asm(op "b "__percpu_seg"%1,%0"          \
                            : "=r" (ret__)                      \
                            : "m" (var));                       \
                        break;                                  \
                case 2:                                         \
                        asm(op "w "__percpu_seg"%1,%0"          \
                            : "=r" (ret__)                      \
                            : "m" (var));                       \
                        break;                                  \
                case 4:                                         \
                        asm(op "l "__percpu_seg"%1,%0"          \
                            : "=r" (ret__)                      \
                            : "m" (var));                       \
                        break;                                  \
                default: __bad_percpu_size();                   \
                }                                               \
                ret__; })

#define x86_read_percpu(var) percpu_from_op("mov", per_cpu__##var)
...

  can anyone tell me how does the code above give me current task_struct
structure? and what about current_thread_info() function? is it useless now?

--
Paul Francisco = pAnk7.yArdbird
http://pank7yardbird.googlepages.com
http://hi.baidu.com/pank7
.' ' ` .           pAnk7.yArdbird    ^_^
: :'   :          pank7yardbird(AT)gmail.com
`. ` '            liyi(AT)net.pku.edu.cn
  `-   Debian GNU/Linux -- The power of reedom

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux