From: Zachary Amsden <zach@vmware.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Arjan van de Ven <arjan@infradead.org>, Andi Kleen <ak@suse.de>,
Benjamin LaHaise <bcrl@kvack.org>,
Chuck Ebbert <76306.1226@compuserve.com>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [rfc patch] i386: don't save eflags on task switch
Date: Sun, 05 Nov 2006 14:48:10 -0800 [thread overview]
Message-ID: <454E6A2A.5070002@vmware.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0611050944380.25218@g5.osdl.org>
Linus Torvalds wrote:
> On Sun, 5 Nov 2006, Arjan van de Ven wrote:
>
>> actually lockdep is pretty good at finding this type of bug IMMEDIATELY
>> even without the actual race triggering ;)
>>
>
> Ehh. Last time this happened, lockdep didn't find _squat_.
>
> This was when NT and AC leaked across context switches, because the
> context switching had removed the "expensive" save/restore.
>
Owning up to being the one who introduced the thing. Actually, it was a
pretty nice win for native, and a huge win for paravirtualization;
calling out to two helper functions for save / restore flags while
shuffling the stack is just awfully bad during such a critical region.
If you look back all the way to 2.4 kernel series, there was no save /
restore flags, and it didn't look like there ever was. Somewhere during
2.5 development, it migrated in as an unchangelogged fix, and I was able
to dig up an email thread and reason that IOPL was leaking. Course,
instead of thinking it all the way through, I thought the precedent of
having no eflags switching would be good enough with an explicit IOPL
switch. Then nasty AC / NT raised their heads.
ID can be a problem as well; system calls during a code region which is
testing for a Pentium by toggling the ID bit (perhaps from a printf()
libc call) can cause the ID bit to leak onto another process or get
lost. causing CPUID detection to fail.
I like Chuck's new set_eflags() since it fixes all this in a way we
don't have to reason about heavily. Also, moving it to C code instead
of the assembler path is more maintainable. IMHO, the assembler task
switch should switch the stack, which you can't do in C, and that is
it. Everything else can be nicely packaged above it, including the
get_eflags().
Zach
next prev parent reply other threads:[~2006-11-05 22:48 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-04 6:56 [rfc patch] i386: don't save eflags on task switch Chuck Ebbert
2006-11-04 19:09 ` Zachary Amsden
2006-11-04 19:35 ` Linus Torvalds
2006-11-05 3:55 ` Benjamin LaHaise
2006-11-05 4:13 ` Linus Torvalds
2006-11-05 5:41 ` Andi Kleen
2006-11-05 8:01 ` Zachary Amsden
2006-11-05 17:01 ` Andi Kleen
2006-11-05 17:26 ` Linus Torvalds
2006-11-05 17:34 ` Arjan van de Ven
2006-11-05 17:51 ` Linus Torvalds
2006-11-05 22:48 ` Zachary Amsden [this message]
2006-11-05 18:52 ` Andi Kleen
2006-11-05 16:12 ` Linus Torvalds
2006-11-05 16:54 ` Andi Kleen
2006-11-05 17:20 ` Linus Torvalds
2006-11-05 4:17 ` Zachary Amsden
2006-11-05 20:10 ` H. Peter Anvin
-- strict thread matches above, loose matches on Subject: below --
2006-11-04 0:00 Chuck Ebbert
2006-11-04 0:46 ` Linus Torvalds
2006-11-04 1:36 ` Andi Kleen
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=454E6A2A.5070002@vmware.com \
--to=zach@vmware.com \
--cc=76306.1226@compuserve.com \
--cc=ak@suse.de \
--cc=arjan@infradead.org \
--cc=bcrl@kvack.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox