Date: Wed, 18 Jul 2001 09:02:48 -0700 From: Terry Lambert <tlambert2@mindspring.com> To: Stefan Hoffmeister <freebsd-ml@econos.de> Cc: "Albert D. Cahalan" <acahalan@cs.uml.edu>, freebsd-hackers@FreeBSD.ORG, Jim.Pirzyk@disney.com Subject: Re: math library difference between linux emulation and native freebsd (and native linux) Message-ID: <3B55B328.777D6FA1@mindspring.com> References: <200107170615.f6H6FU5376195@saturn.cs.uml.edu> <3B546BA9.37E9F437@mindspring.com> <pit8lt8464pe1enjp9jmtkt5s2hjo2v9po@4ax.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Stefan Hoffmeister wrote: > >One obvious reason that the Linux approach is wrong is > >that it ends up requiring the save and restore of FP > >registers on context switches, which is overhead they > >ate anyway, by doing TSS based context switching. The > >amount of state with SSE is up to something like an > >additional 512 bytes -- that's ungodly overhead, since > >most programs don't use this context at all. > > Except that - AFAIK - Linux won't do that. > > Linux install traps, causing the first FPU and SSE instruction to fault > (might as well be only the SSE instructions). Upon the fault, the context > structure size is switched. > > IOW, Linux does not blindly have an FPU context size of 512 bytes. I didn't say that it did; you need to read more carefully. The part you cut off talked about the consequences of FreeBSD jamming a non-default mask on the FPU, in the context of the FreeBSD Linux ABI. I can think of a tricky way (disable traps, set the mask, reenable them, so as to avoid marking the process), but this will not result in the mask being "right" for the initial FPU utilization of the process... you would end up with a need to do a lot of dancing in the trap code to get this right, and still permit FP context switching, since you would need to take the initial fault, fixup everything _including_ setting the default mask -- and then _only_ for the Linux binaries, and then _only_ if the first FPU instruction was not an attempt to set the mask. This is why FreeBSD does _not_ set the mask to a "default": since the FPU context is lazy-bound, the initial mask you would end up with, unless you did a lot of convoluted stuff, would be the mask of the last FPU-using process that was running, and not the mask you expected. Someone else complained "Linux doesn't do this any more" about my statement "...which is overhead they ate anyway, by doing TSS based context switching..." Yes, I _know_ they don't do this _any more_: hence my use of the verb "ate" (past tense) instead of the verb "eat" (present tense). The statement was to indicate _why_ Linux has an abominable default for the mask, from a historical perspective. The bottom line is that the mask value should _not_ be assumed by correct programs, unless they are intended to rely on the historical Linux default, which is an artifact of their prior context switch algorithm, and not some "good idea", unless your idea of a "good idea" is a convoluted trap handler that requires instruction restart in all but the most trivial cases. I will point, once again, to Mathematica as a "correct" program... -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3B55B328.777D6FA1>