[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.0611132015240.28562@twinlark.arctic.org>
Date: Mon, 13 Nov 2006 20:22:25 -0800 (PST)
From: dean gaudet <dean@...tic.org>
To: Andi Kleen <ak@...e.de>
cc: Suleiman Souhlal <ssouhlal@...ebsd.org>,
Linux Kernel ML <linux-kernel@...r.kernel.org>,
vojtech@...e.cz, Jiri Bohac <jbohac@...e.cz>
Subject: Re: [PATCH 1/2] Make the TSC safe to be used by gettimeofday().
On Mon, 13 Nov 2006, dean gaudet wrote:
> next an implementation which relies on the kernel restarting the computation when
> necessary. this would be achieved by testing to see when the task to be restarted
> is on the vsyscall page and backtracking the task to the vsyscall entry point.
>
> this is challenging when the vsyscall is implemented in C -- because of potential
> stack usage. there are ways to get this to work though, even without resorting to
> assembly. i'm presenting this only as a best case scenario should such an effort
> be undertaken. (i have a crazy idea involving the direction flag which i need to
> mock up.)
nevermind the crazy idea using DF... i was hoping to use DF as a generic
"restart a vsyscall" indicator -- switch_to() would note the task is on
the vsyscall page and unilaterally clear DF before restoring eflags.
then a vsyscall critical section could be surrounded like so:
unsigned long tmp;
do {
asm volatile("std");
critical section
asm volatile(
"\n pushf"
"\n pop %0"
"\n cld"
: "=r" (tmp));
} while ((tmp & 0x400) == 0);
it works great on k8 ... but DF manipulation hurts way too much on core2 and p4.
i even tried reading DF using a string instruction:
long tmp;
do {
asm volatile("std");
critical section
asm volatile(
"\n mov %%rsp,%%rsi"
"\n lodsl"
"\n sub %%rsp,%%rsi"
"\n cld"
: "=S" (tmp));
} while (tmp > 0);
it's no better.
i've also tried similar tricks setting the EFLAGS.ID bit... but the popf
hurts in that case.
i think a general vsyscall restart mechanism would be useful (for more
than just the time functions), but still haven't found one which is
cheap enough.
-dean
-
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