Why is get_current() not const function?
Hi!
E.g. on x86-64,
NEW_AUX_ENT(AT_UID, (elf_addr_t) current->uid);
NEW_AUX_ENT(AT_EUID, (elf_addr_t) current->euid);
NEW_AUX_ENT(AT_GID, (elf_addr_t) current->gid);
NEW_AUX_ENT(AT_EGID, (elf_addr_t) current->egid);results in 4 movq %gs:0,%rax instructions while one is completely enough.
Anyone remembers why get_current function (on arches which define current to get_current()) is not const and why on x86-64
the movq %%gs:0, %0 inline asm is volatile with "memory" clobber? AFAIK current ought to be constant in any function with the exception of schedule.
If the reason is kernel/sched.c, then IMHO it is certainly worth making get_current const everywhere but in kernel/sched.c (e.g. through special define in sched.c before any includes).
Jakub
In article <[email protected]>,
Quoted 3 lines · Jakub Jelinek
Anyone remembers why
get_currentfunction (on arches which define current toget_current()) is not const
Because it makes no difference at all on x86, since gcc will ignore "const" for inline functions. At least that used to be true.
Quoted 2 lines
and why on x86-64the movq %%gs:0, %0 inline asm is volatile with "memory" clobber?
Can't help you on that one, but it looks like it uses various helper functions for doing the x86-64 per-processor data structures, and I bet those helper functions are shared by _other_ users who definitely want to have their data properly re-read. Ie "current()" may be constant in process context, but that sure isn't true about a lot of other things in the per-processor data structures.
Linus