Re: context switch vs. signal delivery [was: Re: Accelerating user mode linux]

Jamie Lokier
2002-08-05T15:35:47Z

Linus Torvalds wrote:
> I agree that it is really sad that we have to save/restore FP on
> signals, but I think it's unavoidable.

Couldn't you mark the FPU as unused for the duration of the
handler, and let the lazy FPU mechanism save the state when it is used
by the signal handler?

> 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 ;( )

I use SEGVs to trap access to read-only pages for garbage collection,
and I know I'm not the only one. That's a lot of SEGVs...

Fwiw, I have timed SIGSEGV handling time on Linux on various Intel CPUs,
on a PA-RISC running HP-UX and on a few Sparcs running Solaris. Linux
came out faster in all cases. Best case: 8 microseconds to trap a page
fault, handle the SEGV and mprotect() one page (600MHz P3). Worst case:
37 microseconds (133MHz Pentium).

That's about 5000 cycles. I'm sure we can do better than that.

For sophisticated user space uses, like the above, I'd like to see
a trap handling mechanism that saves only the _minimum_ state.
Userspace can take care of the rest. Maybe even without a sigreturn in
some cases.

-- Jamie