lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <45067056.70201@goop.org>
Date:	Tue, 12 Sep 2006 01:31:18 -0700
From:	Jeremy Fitzhardinge <jeremy@...p.org>
To:	Arjan van de Ven <arjan@...radead.org>
CC:	akpm@...l.org, ak@...e.de, mingo@...e.hu,
	linux-kernel@...r.kernel.org
Subject: Re: i386 PDA patches use of %gs

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;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ