Skip to content

Commit

Permalink
threadsnoop: increase PID field width and align to the right
Browse files Browse the repository at this point in the history
for better readability.

Justifications:

https://ux.stackexchange.com/questions/13795/is-there-a-standard-to-left-justify-text-and-right-justify-numeric-values

wc -L /proc/sys/kernel/pid_max
7 /proc/sys/kernel/pid_max
  • Loading branch information
makelinux committed Jan 17, 2024
1 parent 0f4ff11 commit 36d5fd2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ and this project adheres to
- [#2904](https://github.com/iovisor/bpftrace/pull/2904)
- Use `strftime` instead of `elapsed` in `threadsnoop.bt`
- [#2917](https://github.com/iovisor/bpftrace/pull/2917)
- Increase PID field width and align to the right in `threadsnoop.bt`
- [#2927](https://github.com/iovisor/bpftrace/pull/2927)
- Update runqlen.bt to remove `runnable_weight` field from cfs_rq struct.
- [#2790](https://github.com/iovisor/bpftrace/pull/2790)
- Update mdflush.bt to use blkdev.h instead of genhd.h for non-BTF builds.
Expand Down
4 changes: 2 additions & 2 deletions tools/threadsnoop.bt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

BEGIN
{
printf("%-15s %-6s %-16s %s\n", "TIME", "PID", "COMM", "FUNC");
printf("%-15s %7s %-16s %s\n", "TIME", "PID", "COMM", "FUNC");
}

uprobe:libpthread:pthread_create,
uprobe:libc:pthread_create
{
printf("%15s %-6d %-16s %s\n", strftime("%H:%M:%S.%f", nsecs), pid, comm,
printf("%15s %7d %-16s %s\n", strftime("%H:%M:%S.%f", nsecs), pid, comm,
usym(arg2));
}
28 changes: 14 additions & 14 deletions tools/threadsnoop_example.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ Tracing new threads via phtread_create():

# ./threadsnoop.bt
Attaching 2 probes...
TIME PID COMM FUNC
10:20:31.938572 28549 dockerd threadentry
10:20:31.939213 28549 dockerd threadentry
10:20:31.939405 28549 dockerd threadentry
10:20:31.940642 28549 dockerd threadentry
10:20:31.949060 28549 dockerd threadentry
10:20:31.958319 28549 dockerd threadentry
10:20:31.939152 28549 dockerd threadentry
10:20:31.950978 28549 dockerd threadentry
10:20:32.013269 28579 docker-containe 0x562f30f2e710
10:20:32.036764 28549 dockerd threadentry
10:20:32.083780 28579 docker-containe 0x562f30f2e710
10:20:32.116738 629 systemd-journal 0x7fb7114955c0
10:20:32.116844 629 systemd-journal 0x7fb7114955c0
TIME PID COMM FUNC
10:20:31.938572 28549 dockerd threadentry
10:20:31.939213 28549 dockerd threadentry
10:20:31.939405 28549 dockerd threadentry
10:20:31.940642 28549 dockerd threadentry
10:20:31.949060 28549 dockerd threadentry
10:20:31.958319 28549 dockerd threadentry
10:20:31.939152 28549 dockerd threadentry
10:20:31.950978 28549 dockerd threadentry
10:20:32.013269 28579 docker-containe 0x562f30f2e710
10:20:32.036764 28549 dockerd threadentry
10:20:32.083780 28579 docker-containe 0x562f30f2e710
10:20:32.116738 629 systemd-journal 0x7fb7114955c0
10:20:32.116844 629 systemd-journal 0x7fb7114955c0
[...]

The output shows a dockerd process creating several threads with the start
Expand Down

0 comments on commit 36d5fd2

Please sign in to comment.