All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Arjan van de Ven <arjan@infradead.org>
Cc: akpm@osdl.org, ak@suse.de, mingo@elte.hu, linux-kernel@vger.kernel.org
Subject: Re: i386 PDA patches use of %gs
Date: Tue, 12 Sep 2006 01:31:18 -0700	[thread overview]
Message-ID: <45067056.70201@goop.org> (raw)
In-Reply-To: <1158047806.2992.7.camel@laptopd505.fenrus.org>

Arjan van de Ven wrote:
> gcc can be fixed if needed. I don't see the kernel switching to use that
> any time soon though...

I have a preliminary patch to implement per_cpu() in terms of __thread.

Hm, my initial tests comparing reloading a NULL selector vs a real 
selector shows absolutely no measurable difference, on either a modern 
Core Duo, or an old P4...  Admittedly this is with an artificial 
usermode test program, but I'd expect to see *some* difference if 
there's a difference.

    J


--

/* gcc -o time-segops time-segops.c -O2 -Wall -lrt -fomit-frame-pointer -funroll-loops */
#include <stdio.h>
#include <time.h>

#define COUNT 10000000

static inline void sync(void)
{
	int a,b,c,d;

	asm volatile("cpuid"
		     : "=a" (a), "=b" (b), "=c" (c), "=d" (d)
		     : "0" (0), "2" (0)
		     : "memory");
}

static void test_none(void)
{
	int i;

	for(i = 0; i < COUNT; i++) {
		sync();
	}
}

static void test_fs(void)
{
	int i, ds;
	asm volatile("mov %%ds,%0" : "=r" (ds));

	for(i = 0; i < COUNT; i++) {
		asm volatile("push %%fs; mov %0, %%fs; popl %%fs"
			     : : "r" (ds));
		sync();
	}
}

static void test_gs(void)
{
	int i, ds;
	asm volatile("mov %%ds,%0" : "=r" (ds));

	for(i = 0; i < COUNT; i++) {
		asm volatile("push %%gs; mov %0, %%gs; popl %%gs"
			     : : "r" (ds));
		sync();
	}
}

typedef void (*test_t)(void);

static test_t tests[] = {
	test_none,
	test_fs,
	test_gs,
	NULL,
};

int main()
{
	int i;
	int ds, fs, gs;

	asm volatile("mov %%ds, %0; "
		     "mov %%fs, %1; "
		     "mov %%gs, %2"
		     : "=r" (ds), "=r" (fs), "=r" (gs) : : "memory");

	printf("fs=%x gs=%x\n", fs, gs);
	for(i = 0; tests[i]; i++) {
		struct timespec start, end;
		unsigned long long delta;

		clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start);
		(*tests[i])();
		clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end);

		delta = (end.tv_sec * 1000000000ull + end.tv_nsec) - 
			(start.tv_sec * 1000000000ull + start.tv_nsec);
		delta /= COUNT;

		printf("%lluns/iteration\n", delta);
	}

	return 0;
}


  reply	other threads:[~2006-09-12  8:31 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-12  7:35 i386 PDA patches use of %gs Arjan van de Ven
2006-09-12  7:48 ` Jeremy Fitzhardinge
2006-09-12  7:56   ` Arjan van de Ven
2006-09-12  8:31     ` Jeremy Fitzhardinge [this message]
2006-11-15 11:27     ` [PATCH] i386-pda UP optimization Eric Dumazet
2006-11-15 11:32       ` Andi Kleen
2006-11-15 17:20         ` Ingo Molnar
2006-11-15 17:24           ` Andi Kleen
2006-11-15 17:46             ` Eric Dumazet
2006-11-15 17:49               ` Ingo Molnar
2006-11-15 17:58                 ` Eric Dumazet
2006-11-15 18:01                   ` Ingo Molnar
2006-11-21 11:38               ` Eric Dumazet
2006-11-21 21:42                 ` Jeremy Fitzhardinge
2006-11-21 21:52                   ` Andi Kleen
2006-11-21 22:10                     ` Jeremy Fitzhardinge
2006-11-21 21:58                   ` Eric Dumazet
2006-11-21 23:12                     ` Jeremy Fitzhardinge
2006-11-15 17:28           ` Jeremy Fitzhardinge
2006-11-15 17:32             ` Ingo Molnar
2006-11-15 17:59               ` Jeremy Fitzhardinge
2006-11-15 18:05                 ` Eric Dumazet
2006-11-15 18:28                   ` Jeremy Fitzhardinge
2006-11-15 18:31                     ` Ingo Molnar
2006-11-15 18:01             ` Arjan van de Ven
2006-11-15 18:24               ` Jeremy Fitzhardinge
2006-11-15 19:06                 ` Ingo Molnar
2006-11-17  0:24                   ` Jeremy Fitzhardinge
2006-11-15 17:52       ` Jeremy Fitzhardinge
2006-11-28 23:12       ` Jeremy Fitzhardinge
2006-11-29  9:30         ` Eric Dumazet
2006-11-29  9:56           ` Jeremy Fitzhardinge
2006-09-13  1:00 ` i386 PDA patches use of %gs Jeremy Fitzhardinge
2006-09-13  9:59   ` Ingo Molnar
2006-09-13 16:17     ` Jeremy Fitzhardinge
2006-11-15 18:26       ` Ingo Molnar
2006-11-15 18:29         ` Ingo Molnar
2006-11-15 18:43           ` Jeremy Fitzhardinge
2006-11-15 18:44             ` Ingo Molnar
2006-11-15 18:39         ` Jeremy Fitzhardinge
2006-11-15 18:43           ` Ingo Molnar
2006-11-15 18:49             ` Jeremy Fitzhardinge
2006-11-15 18:49               ` Ingo Molnar
2006-11-15 19:00                 ` Jeremy Fitzhardinge
2006-11-15 19:03                   ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45067056.70201@goop.org \
    --to=jeremy@goop.org \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=arjan@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.