Page MenuHomeFreeBSD

Rework syscall structure lookups.
ClosedPublic

Authored by jhb on Nov 25 2016, 5:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 20, 2:37 PM
Unknown Object (File)
Sat, Apr 20, 2:37 PM
Unknown Object (File)
Mar 15 2024, 1:48 PM
Unknown Object (File)
Mar 15 2024, 1:47 PM
Unknown Object (File)
Dec 20 2023, 4:37 AM
Unknown Object (File)
Dec 17 2023, 6:34 PM
Unknown Object (File)
Nov 6 2023, 7:27 PM
Unknown Object (File)
Oct 24 2023, 9:50 AM
Subscribers

Details

Summary

Rework syscall structure lookups.

Avoid always using an O(n^2) loop over known syscall structures with
strcmp() on each system call. Instead, use a per-ABI cache indexed by
the system call number. The first 1024 system calls (which should cover
all of the normal system calls in currently-supported ABIs) use a flat array
indexed by the system call number to find system call structure. For other
system calls, a linked list of structures storing an integer to structure
mapping is stored in the ABI. The linked list isn't very smart, but it
should only be used by buggy applications invoking unknown system calls.

The table + linked-list could perhaps be replaced by a hash table, but
I don't quite feel like writing a new hash table from scratch. One
option would be to make truss a C++ program and use unordered_map<>.

We could then turn the procabi thing into a class which might look a bit
nicer (and use constructors to initialize the hash table instead of
the inline STAILQ_HEAD_INITIALIZER).

Test Plan
  • Extended my syscall tester to add some unknown system calls.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 6150
Build 6406: arc lint + arc unit

Event Timeline

jhb retitled this revision from to Rework syscall structure lookups..
jhb updated this object.
jhb edited the test plan for this revision. (Show Details)
jhb added reviewers: bdrewery, kib, mjg.
kib edited edge metadata.
This revision is now accepted and ready to land.Nov 26 2016, 5:44 PM
jhb edited edge metadata.
  • Rebase.
  • Fix build on i386.
This revision now requires review to proceed.Dec 5 2016, 11:52 PM
jhb added a reviewer: jhb.
This revision is now accepted and ready to land.Dec 6 2016, 12:40 AM