Kevin D. Kissell wrote:
Brian Foster wrote:
I haven't reviewed David's code in detail, but from his description, I
thought that there was a vdso page per task/thread. If there's only one
per processor, then, yes, that poses a challenge to porting the FPU
emulation code to use it, since, as you observe, the instruction
sequence to be executed may differ for each delay slot emulation. It
should still be possible, though. FP emulation is in itself expensive,
and FP branches with live delay slots are a smallish subset of the
overall FP instructions to be emulated, so a dynamic scheme to
allocate/free slots in a vdso page wouldn't have that dramatic a
performance impact, overall. As the instructions aren't constant, the
I-caches would need to be flushed after each dsemul setup, even using a
vdso page, but that shouldn't break the fact that one could avoid it for
signals, so long as a different cache line within the vdso page is used
for signal versus dsemul trampolines.
On Wednesday 22 April 2009 20:01:44 David Daney wrote:
Kevin D. Kissell wrote:
David Daney wrote:
This is a preliminary patch to add a vdso to all user processes.
Still missing are ELF headers and .eh_frame information. But it is
enough to allow us to move signal trampolines off of the stack.
We allocate a single page (the vdso) and write all possible signal
trampolines into it. The stack is moved down by one page and the vdso
is mapped into this space.
Signed-off-by: David Daney <firstname.lastname@example.org>
Note that for FPU-less CPUs, the kernel FP emulator also uses a user
stack trampoline to execute instructions in the delay slots of emulated
FP branches. I didn't see any of the math-emu modules being tweaked in
either part of your patch. Presumably, one would want to move that
operation into the vdso as well.
As David says, this is a Very Ugly Problem. Each FP trampoline
is effectively per-(runtime-)instance per-thread, i.e., there is
a unique FP trampoline for every dynamic instance of (non-trivial
non-FP) instruction in an FP delay slot. This is essentially the
complete opposite of the signal-return trampoline, which is fixed
(constant text) for all instances in all threads.
As such, David's vdso (assuming it's similar to those on other
architectures (I've not looked at it closely yet)) may not have
any obvious role to play in moving the FP trampoline('s code?)
off the user's stack.
Kevin is right, this is ugly.
My current plan is to map an anonymous page with execute permission for
each vma (process) and place all FP trampolines there. Each thread that
needs a trampoline will allocate a piece of this page and write the
trampoline. We can arrange it so that the only way a thread can exit
the trampoline is by taking some sort of fault (currently this is true
for the normal case), or exiting. Then we free the trampoline for other
threads to use. If all the slots in the trampoline page are in use, a
thread would block until there is a free one, rarely, if ever would this
Doing the memory management for the trampoline area and the blocking
would add quite a bit of complexity. I am not really concerned about
performance because people that want good FP performance should use a
CPU with FP hardware (like my R5000 O2).