Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added pid & tid filtering feature #1414

Merged
merged 1 commit into from
Sep 8, 2022

Conversation

salsal97
Copy link
Contributor

@salsal97 salsal97 commented Sep 1, 2022

This PR adds the strace filter that let's you filter by thread ID or process ID (upto 10 at a time)
to make your output more relevant

@salsal97 salsal97 changed the title added tid filtering feature added pid & tid filtering feature Sep 2, 2022
@salsal97 salsal97 requested a review from vtikoo September 2, 2022 00:16
tools/myst/host/exec.c Outdated Show resolved Hide resolved
tools/myst/host/strace.c Outdated Show resolved Hide resolved
kernel/syscall.c Outdated Show resolved Hide resolved
tools/myst/host/strace.c Show resolved Hide resolved
tools/myst/host/strace.c Outdated Show resolved Hide resolved
kernel/syscall.c Outdated Show resolved Hide resolved
kernel/syscall.c Outdated Show resolved Hide resolved
tools/myst/host/strace.c Outdated Show resolved Hide resolved
tools/myst/host/strace.c Outdated Show resolved Hide resolved
@salsal97 salsal97 force-pushed the strace_improvements3 branch 3 times, most recently from 92332d7 to 59672a5 Compare September 3, 2022 00:47
kernel/syscall.c Outdated Show resolved Hide resolved
tools/myst/host/strace.c Outdated Show resolved Hide resolved
@vtikoo
Copy link
Collaborator

vtikoo commented Sep 6, 2022

As syscall entry and exit hooks are hot code paths, thinking about performance impact.

Checking whether current thread/process is whitelisted is a linear scan of array of ints. In the worst case this is a scan of 100 integers, which would span atleast 6 cache lines.
The syscall include and exclude filters are single word lookups. Checking whether the syscall number snum is in either list, requires only looking at trace[snum].

An alternative is encoding the tid filter as a bit vector. The max number of threads we support is 1024, so that would be a bit vector atleast 128 bytes long. We could potentially also leverage the fact that our tid/pid generation algorithm starts from 101. So tid 101 could be the 1st bit of the bit vector and so on.

Having said that, if memory is not the bottleneck then this optimization might not be as useful.

@salsal97 salsal97 merged commit 07121ad into deislabs:main Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants