public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Why is get_current() not const function?
@ 2003-03-13 11:19 Jakub Jelinek
  2003-03-17  6:26 ` Linus Torvalds
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2003-03-13 11:19 UTC (permalink / raw)
  To: linux-kernel

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

^ permalink raw reply	[flat|nested] 6+ messages in thread
[parent not found: <20030313061926.S3910@devserv.devel.redhat.com.suse.lists.linux.kernel>]
* Re: Why is get_current() not const function?
@ 2003-03-17 19:11 Manfred Spraul
  0 siblings, 0 replies; 6+ messages in thread
From: Manfred Spraul @ 2003-03-17 19:11 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 319 bytes --]

Is it possible to use __attribute__((const) with inline functions?
I tried that, but it seems that gcc ignores __attribute__((const) and 
looks at the contents of the function instead.

I've tried the attached test app: With gcc-3.2.1 (gcc -O3), and 
"inlconst" was called 10 times, constfnc only once.

--
    Manfred

[-- Attachment #2: consttest.c --]
[-- Type: text/plain, Size: 460 bytes --]

#include <stdio.h>
#include <stdlib.h>

static int constfnc(int x) __attribute__((const));

static inline int inlconst(int x) __attribute__((const));

static void dummy(int i);

static inline int inlconst(int x)
{
	printf("in inlconst.\n");
	return 2;
}

int main(void)
{
	int i;
	for(i=0;i<10;i++) {
		dummy(constfnc(0));
	}
	for (i=0;i<10;i++) {
		dummy(inlconst(0));
	}
}

int constfnc(int x)
{
	printf("in const.\n");
	return 1;
}


void dummy(int i)
{
}


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-03-17 19:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-03-13 11:19 Why is get_current() not const function? Jakub Jelinek
2003-03-17  6:26 ` Linus Torvalds
     [not found] <20030313061926.S3910@devserv.devel.redhat.com.suse.lists.linux.kernel>
2003-03-13 13:31 ` Andi Kleen
     [not found] ` <b53pqi$ud9$1@penguin.transmeta.com.suse.lists.linux.kernel>
2003-03-17 17:26   ` Andi Kleen
2003-03-17 17:39     ` Jakub Jelinek
  -- strict thread matches above, loose matches on Subject: below --
2003-03-17 19:11 Manfred Spraul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox