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

systrace and syscount #786

Open
goldshtn opened this issue Oct 26, 2016 · 18 comments
Open

systrace and syscount #786

goldshtn opened this issue Oct 26, 2016 · 18 comments

Comments

@goldshtn
Copy link
Collaborator

systrace would be an strace-like tool (with limited parsing of arguments). It would provide a general overview of process syscall activity, which can then be examined in more detail with argdist/trace or dedicated tools.

syscount would provide syscall statistics on the whole system or a specific process. Should probably mimic syscount from Brendan Gregg's perf-tools.

@goldshtn
Copy link
Collaborator Author

In terms of implementation, both of these tools would have to use ^[Ss]y[Ss]_* kprobes because the syscall tracepoints don't work at this time. (See #748 for discussion.)

@vitalyvch
Copy link

vitalyvch commented Oct 26, 2016

Just for note: I'm going to release something similar but with accent on performance. It is written in pure C.

@vitalyvch
Copy link

vitalyvch commented Oct 26, 2016

Guys, what do you think about idea of samples/bpf/tracex5_*.c in linux kernel sources? They did something similar, but by kprobing seccomp_phase1(). It allow them to load much much faster @4ast, @brendangregg

@goldshtn
Copy link
Collaborator Author

Can't say I love the idea of installing a dummy seccomp program and then probing an internal seccomp function. This may be quite brittle. What I'd really want is syscall tracepoints. But if this approach works more or less reliably on all kernels from, say, 4.1 -- then maybe ...

@brendangregg
Copy link
Member

@vitalyvch I haven't hacked on this much, but how do we even enable seccomp for the entire system? The tracex5 example seems to only enable seccomp for child processes.

Enabling seccomp just to trace syscalls does seem an odd way to do this.

@vitalyvch
Copy link

Thanks. I'm not very familiar with seccomp so your answers are really useful for me. I already have added preliminary tracepoint support to my tool, and think about adding that seccomp trick.

@goldshtn
Copy link
Collaborator Author

goldshtn commented Nov 9, 2016

@vitalyvch Is your tool something that you plan to release publicly? Is there a likely timeframe? I ask because systrace/syscount can already be immensely useful, and if you think there's a long way to go, we can implement something temporary in the interim.

@goldshtn
Copy link
Collaborator Author

@vitalyvch Have you been able to make progress on releasing your tools? If not, I think we should consider implementing simple versions of those in Python. @brendangregg

@vitalyvch
Copy link

vitalyvch commented Dec 20, 2016

@goldshtn, I'm sorry for delayed reply. So, I do not stop developing. Yes, there is a plan to release, but I should discuss details with team. Currently I'm working on imitating follow-fork option.

@marcinslusarz
Copy link

I'm working with Vitalii on this project. It's basically a BSD-licensed strace replacement written in C using bcc/ebpf with both binary and text output. I can't give you the exact timeline, but the plan is to release it in a few months. Initially it will be a part of pmem/nvml, but since it will not depend on anything in nvml (except maybe on testing framework), we might push it to separate repository.
Personally I'd be happy to include it in bcc tree...

We'll let you know here when the tool will be ready in at least experimental state.

@vitalyvch
Copy link

So, since last commits, tracing sys_* and SyS_* does not produce the desired result: #940

@goldshtn

@goldshtn
Copy link
Collaborator Author

goldshtn commented Feb 5, 2017

@vitalyvch
What do you mean by "since last commits"? Did you bisect this to find the latest commit in which it worked?

@vitalyvch
Copy link

I didn't bisect. I just install night builds every morning, and do manual testing every few days.

On Friday tests failed. Most likely something unexpected was introduced on Wednesday or Thursday.

@goldshtn

@goldshtn
Copy link
Collaborator Author

goldshtn commented Feb 5, 2017

Confirmed, I see this on the latest master. Trying to bisect.

@goldshtn
Copy link
Collaborator Author

goldshtn commented Feb 5, 2017

All right, so it worked here: 199b341
Doesn't work here: 4a57f4d
Only a couple of more to go.

@goldshtn
Copy link
Collaborator Author

goldshtn commented Feb 5, 2017

OK, so looks like it was broken by this merge: b77915d

@goldshtn
Copy link
Collaborator Author

goldshtn commented Feb 5, 2017

Going to file this on #940.

goldshtn added a commit to goldshtn/bcc that referenced this issue Feb 15, 2017
This new tool attaches to the raw_syscalls:sys_enter and sys_exit
tracepoints, and collects frequency counts and optionally latencies
of syscalls (aggregated by syscall or by process). It is a fairly
natural and efficient extension of Brendan Gregg's syscount from
perf-tools. Options include latency tracing, interval printouts,
process filtering, summarizing only failed syscalls, and more.

NOTE:
The translation of syscall numbers to names is performed using a
static list, borrowed from strace sources. It is accurate up to
syscall 313, and does not include the bpf() syscall, for example.
Also, it is only relevant for x86_64.

Basic example:

```
$ syscount -P
Tracing syscalls, printing top 10... Ctrl+C to quit.
[10:13:21]
PID    COMM               COUNT
30216  sshd                 533
31391  vi                   494
25188  screen               134
25776  mysqld                24
31394  python                10
494    systemd-journal        5
^C

$ syscount -L
Tracing syscalls, printing top 10... Ctrl+C to quit.
[10:13:34]
SYSCALL                   COUNT        TIME (us)
select                      132      1902458.009
nanosleep                   166        11136.305
write                        89           41.308
ftruncate                     1           33.217
stat                          1           22.117
fstat                         1            6.134
[unknown: 321]               28            4.553
ioctl                         7            4.544
wait4                       166            3.962
timerfd_settime               1            3.786
^C
```

Related: iovisor#786
goldshtn added a commit to goldshtn/bcc that referenced this issue Feb 16, 2017
This new tool attaches to the raw_syscalls:sys_enter and sys_exit
tracepoints, and collects frequency counts and optionally latencies
of syscalls (aggregated by syscall or by process). It is a fairly
natural and efficient extension of Brendan Gregg's syscount from
perf-tools. Options include latency tracing, interval printouts,
process filtering, summarizing only failed syscalls, and more.

NOTE:
The translation of syscall numbers to names is performed using a
static list, borrowed from strace sources. It is accurate up to
syscall 313, and does not include the bpf() syscall, for example.
Also, it is only relevant for x86_64.

Basic example:

```
$ syscount -P
Tracing syscalls, printing top 10... Ctrl+C to quit.
[10:13:21]
PID    COMM               COUNT
30216  sshd                 533
31391  vi                   494
25188  screen               134
25776  mysqld                24
31394  python                10
494    systemd-journal        5
^C

$ syscount -L
Tracing syscalls, printing top 10... Ctrl+C to quit.
[10:13:34]
SYSCALL                   COUNT        TIME (us)
select                      132      1902458.009
nanosleep                   166        11136.305
write                        89           41.308
ftruncate                     1           33.217
stat                          1           22.117
fstat                         1            6.134
[unknown: 321]               28            4.553
ioctl                         7            4.544
wait4                       166            3.962
timerfd_settime               1            3.786
^C
```

Related: iovisor#786
@vitalyvch
Copy link

Some update:

Our current code is available here: https://github.com/vitalyvch/strace.ebpf

Tools is not released, but could be interesting for you.

@goldshtn , @brendangregg

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

No branches or pull requests

4 participants