On 14.07.2018 12:52, Maxime Villard wrote: > Le 14/07/2018 à 10:29, Martin Husemann a écrit : >> On Fri, Jul 13, 2018 at 11:49:33PM +0200, Kamil Rytarowski wrote: >>> #ifdefing it out in a non-benchmarking application (I was checking ones >>> that do something with syscalls) is more negligible than 0,3% of >>> overhead in the kernel in a loop. >> >> My vote is on #ifdef by a default-off kernel option as well. >> Next step: optimize the switch, but that is no priority then. Can't we >> use pcu(9) for that? > > I've written this [1], from memory I think it's enough. Kamil, please test > it, because I intend to commit it soon. Same for i386. > > We don't update DR6/DR7 on each return to userland, and rather do it during > context switches, only when one of the two LWPs is using dbregs. When none > is (which always is the case), we don't touch. > > [1] http://m00nbsd.net/garbage/dbregs/amd64.diff Thank you for this! I kept it originally as a performance improvement on my TODO list after finishing correctness of the features. This patch needs a switch for XEN, as it uses a dedicated API for this. I had this approach in my old draft patches: +#ifndef XEN [...] +#else + movq DBREG_DBREGS_0(%rsi), %rdi + call _C_LABEL(ldr0) + movq DBREG_DBREGS_1(%rsi), %rdi + call _C_LABEL(ldr1) + movq DBREG_DBREGS_2(%rsi), %rdi + call _C_LABEL(ldr2) + movq DBREG_DBREGS_3(%rsi), %rdi + call _C_LABEL(ldr3) + movq DBREG_DBREGS_6(%rsi), %rdi + call _C_LABEL(ldr6) + movq DBREG_DBREGS_6(%rsi), %rdi + call _C_LABEL(ldr6) +#endif I will test it under pressure of multiple threads and CPUs and return to you today.
Attachment:
signature.asc
Description: OpenPGP digital signature