From: Andi Kleen <ak@suse.de>
To: torvalds@transmeta.com (Linus Torvalds)
Cc: linux-kernel@vger.kernel.org
Subject: Re: context switch vs. signal delivery [was: Re: Accelerating user mode linux]
Date: 05 Aug 2002 10:38:16 +0200 [thread overview]
Message-ID: <p73ado1k8ef.fsf@oldwotan.suse.de> (raw)
In-Reply-To: torvalds@transmeta.com's message of "5 Aug 2002 07:36:55 +0200"
torvalds@transmeta.com (Linus Torvalds) writes:
> >This is because the signal save/restore does a lot of unnecessary stuff.
> >One optimization I implemented at one time was adding a SA_NOFP signal
> >bit that told the kernel that the signal handler did not intend
> >to modify floating point state (few signal handlers need FP) It would
> >not save the FPU state then and reached quite some speedup in signal
> >latency.
> >
> >Linux got a lot slower in signal delivery when the SSE2 support was
> >added. That got this speed back.
>
> This will break _horribly_ when (if) glibc starts using SSE2 for things
> like memcpy() etc.
>
> I agree that it is really sad that we have to save/restore FP on
> signals, but I think it's unavoidable. Your hack may work for you, but
> it just gets really dangerous in general. having signals randomly
> subtly corrupt some SSE2 state just because the signal handler uses
> something like memcpy (without even realizing that that could lead to
> trouble) is bad, bad, bad.
I think the possibility at least for memcpy is rather remote. Any sane
SSE memcpy would only kick in for really big arguments (for small
memcpys it doesn't make any sense at all because of the context save/possible
reformatting penalty overhead). So only people doing really
big memcpys could be possibly hurt, and that is rather unlikely.
But your point stands, one definitely needs to be very careful with it.
Also for special things like UML who can ensure their environment is sane it
could be still an useful optimization. I did it originally for async IO
handling in some project. At least offering the choice does not hurt.
If it wcould speed up UML I think it would be certainly worth it.
After all Linux should give you enough rope to shot yourself in the foot ;)
>
> In other words, "not intending to" does not imply "will not". It's just
> potentially too easy to change SSE2 state by mistake.
>
> And yes, this signal handler thing is clearly visible on benchmarks.
> MUCH too clearly visible. I just didn't see any safe alternatives
> (and I still don't ;( )
In theory you could do a superhack: put the FP context into an unmapped
page on the stack and only save with lazy FPU or access to the unmapped
page. Unfortunately the details get too nasty
(where to find the unmapped page? is the tlb manipulation worth it if the
page was mapped? how to store the address of the unmapped page for nested
signal handlers for the page fault handler?) so I discarded this idea.
-Andi
next parent reply other threads:[~2002-08-05 8:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1028294887.18635.71.camel@irongate.swansea.linux.org.uk.suse.lists.linux.kernel>
[not found] ` <Pine.LNX.4.44.0208031332120.7531-100000@localhost.localdomain.suse.lists.linux.kernel>
[not found] ` <m3u1mb5df3.fsf@averell.firstfloor.org.suse.lists.linux.kernel>
[not found] ` <ail2qh$bf0$1@penguin.transmeta.com.suse.lists.linux.kernel>
2002-08-05 8:38 ` Andi Kleen [this message]
2002-08-05 14:24 ` context switch vs. signal delivery [was: Re: Accelerating user mode linux] Jeff Dike
2002-08-05 16:19 ` Linus Torvalds
[not found] <20020805163910.C7130@kushida.apsleyroad.org.suse.lists.linux.kernel>
[not found] ` <Pine.LNX.4.44.0208050922570.1753-100000@home.transmeta.com.suse.lists.linux.kernel>
2002-08-05 16:46 ` Andi Kleen
2002-08-05 21:30 ` Jamie Lokier
2002-08-05 21:35 ` Andi Kleen
2002-08-05 22:09 ` Jamie Lokier
2002-08-05 22:16 ` Andi Kleen
2002-08-02 13:28 Accelerating user mode linux Alan Cox
2002-08-03 11:38 ` context switch vs. signal delivery [was: Re: Accelerating user mode linux] Ingo Molnar
2002-08-04 6:46 ` Andi Kleen
2002-08-05 5:35 ` Linus Torvalds
2002-08-05 5:42 ` Arnaldo Carvalho de Melo
2002-08-05 6:37 ` Lincoln Dale
2002-08-05 15:39 ` Jamie Lokier
2002-08-05 16:38 ` Linus Torvalds
2002-08-06 5:31 ` Mark Mielke
2002-08-05 10:40 ` Ingo Molnar
2002-08-05 14:59 ` Larry McVoy
2002-08-05 15:41 ` Jamie Lokier
2002-08-05 15:44 ` Jamie Lokier
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=p73ado1k8ef.fsf@oldwotan.suse.de \
--to=ak@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/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