Page MenuHomeFreeBSD

amd64: partially depessimize cpu_fetch_syscall_args and cpu_set_syscall_retval
ClosedPublic

Authored by mjg on Oct 12 2018, 11:45 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Sep 29, 7:03 AM
Unknown Object (File)
Sep 17 2024, 3:17 AM
Unknown Object (File)
Sep 12 2024, 9:26 PM
Unknown Object (File)
Sep 12 2024, 2:35 AM
Unknown Object (File)
Sep 11 2024, 9:21 PM
Unknown Object (File)
Sep 8 2024, 12:48 AM
Unknown Object (File)
Sep 4 2024, 2:37 PM
Unknown Object (File)
Aug 15 2024, 5:40 AM
Subscribers

Details

Summary

cpu_fetch_syscall_args becoms jmp-free for the common case (modulo sv_mask which is going away soon). Bumps getuid rate on Broadwell from 105mln to 107.5mln.

This pessimizes 6 or more arg syscalls, which are a complete minority.

cpu_set_syscall_retval change removes 3 branches in favor of 1 and prevents reloads of ->td_frame.

Note the entire mechanism should be reworked - as it is there is a func call to amd64_syscall, then 3 indirect calls (fetch, syscall itself, set). The initial call can be indirect to a routine which does the fetch/set work and includes inlined amd64_syscall work.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

sys/amd64/amd64/trap.c
973–974

Does it need to be non-static ?

983–984

May be pass frame and sa as the arguments. You already calculated them in non-fallback version.

1002–1003

Change to nitems() ?

1081

Can you replace all three if()s with single or-ed condition and change goto to direct return(fallback()); statement ?

1085

Change to nitems() ?

1092

Again, can you replace this with return () ?

1095

Why 6 and not regcnt ? Or, do you need reg and regcnt in this function at all ?

1101

Then, remove the label.

mjg retitled this revision from amd64: partially depessimize cpu_fetch_syscall_args to amd64: partially depessimize cpu_fetch_syscall_args and cpu_set_syscall_retval.
mjg edited the summary of this revision. (Show Details)
  • also depessimize cpu_set_syscall_retval

Commit _retval() change now, I agree with it.

sys/amd64/amd64/trap.c
985

There regcnt is used as a constant.

I suggest you to add a define to machine/proc.h e.g. NARGREGS 6, and use it consistently instead of the literal '6' or regcnt, in both functions.

1073

This and previous lines, () are excessive.

1087

argp is not needed, inline its initializator there.

I did not commit set retval due to the freeze.

This revision is now accepted and ready to land.Oct 13 2018, 6:39 PM
This revision was automatically updated to reflect the committed changes.