PIDs and TIDs in filters and output
- Dominant language
- C
- Stars
- 22.7k
- Forks
- 4.1k
- Avg merge
- 10d 4h
- Merged PRs (30d)
- 3
Description
Lots of the scripts in `tools/` take a PID argument to apply filtering to a particular process. The filtering is usually on `task->pid` (i.e. the lower 32 bits of `bpf_get_current_pid_tgid()`) and consequently only matches a single thread within a process. IME most userspace apps treat PID as TGID, rather than a specific thread within the process (e.g. think `pgrep`, `ps aux`, etc).
Sometime it's handy to filter events by a single task but very often I want to do something for a whole process without filtering by threads within it. E.g., if I wanted to see which stacks in my webserver are doing block IO I'd run `stacksnoop -p $(pgrep webserver) submit_bio` and expect it to match all threads by default. If I was doing this in `perf` its `-p` option would match the process, not a particular thread (there is `-t` to limit to certain threads).
Any objections to changing tools to:
a) make `-p PID` filter on TGID
b) adding a `-t TID` option to limit to a single task (i.e. what `-p` does now)
c) print both TID and PID in output
I realise this is changing existing behavior but I'd argue it'd be a net improvement overall.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by inventorying the scripts in tools/ that accept a PID, with stacksnoop as the example, and inspect how bpf_get_current_pid_tgid() is used for filtering and output. Compare the requested -p TGID and -t TID behavior with perf's process and thread filtering; done means the affected tools consistently support those semantics and print both identifiers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux
- Domain
- operating-systems, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100