Skip to content

Commit

Permalink
Skip idle swapper threads, closes iovisor#1732 (iovisor#1741)
Browse files Browse the repository at this point in the history
Run queue latency does not make much sense for idle `swapper` threads.

The same happens in `perf sched`:

* https://github.com/torvalds/linux/blob/v4.14/tools/perf/builtin-sched.c

```c
    /*
     * Ignore idle threads:
     */
    if (!strcmp(thread__comm_str(work_list->thread), "swapper"))
        return;
```

```c
static bool is_idle_sample(struct perf_sample *sample,
	       struct perf_evsel *evsel)
{
    /* pid 0 == swapper == idle task */
    if (strcmp(perf_evsel__name(evsel), "sched:sched_switch") == 0)
        return perf_evsel__intval(evsel, sample, "prev_pid") == 0;

    return sample->pid == 0;
}
```
  • Loading branch information
bobrik authored and yonghong-song committed May 9, 2018
1 parent 5c48a3f commit 799f46a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions tools/runqlat.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
// record enqueue timestamp
static int trace_enqueue(u32 tgid, u32 pid)
{
if (FILTER)
if (FILTER || pid == 0)
return 0;
u64 ts = bpf_ktime_get_ns();
start.update(&pid, &ts);
Expand Down Expand Up @@ -119,15 +119,15 @@
if (prev->state == TASK_RUNNING) {
tgid = prev->tgid;
pid = prev->pid;
if (!(FILTER)) {
if (!(FILTER || pid == 0)) {
u64 ts = bpf_ktime_get_ns();
start.update(&pid, &ts);
}
}
tgid = bpf_get_current_pid_tgid() >> 32;
pid = bpf_get_current_pid_tgid();
if (FILTER)
if (FILTER || pid == 0)
return 0;
u64 *tsp, delta;
Expand Down Expand Up @@ -183,15 +183,15 @@
if (state == TASK_RUNNING) {
bpf_probe_read(&tgid, sizeof(prev->tgid), &prev->tgid);
bpf_probe_read(&pid, sizeof(prev->pid), &prev->pid);
if (!(FILTER)) {
if (!(FILTER || pid == 0)) {
u64 ts = bpf_ktime_get_ns();
start.update(&pid, &ts);
}
}
bpf_probe_read(&tgid, sizeof(next->tgid), &next->tgid);
bpf_probe_read(&pid, sizeof(next->pid), &next->pid);
if (FILTER)
if (FILTER || pid == 0)
return 0;
u64 *tsp, delta;
Expand Down
6 changes: 3 additions & 3 deletions tools/runqslower.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
// record enqueue timestamp
static int trace_enqueue(u32 tgid, u32 pid)
{
if (FILTER_PID)
if (FILTER_PID || pid == 0)
return 0;
u64 ts = bpf_ktime_get_ns();
start.update(&pid, &ts);
Expand Down Expand Up @@ -106,7 +106,7 @@
if (prev->state == TASK_RUNNING) {
tgid = prev->tgid;
pid = prev->pid;
if (!(FILTER_PID)) {
if (!(FILTER_PID || pid == 0)) {
u64 ts = bpf_ktime_get_ns();
start.update(&pid, &ts);
}
Expand Down Expand Up @@ -176,7 +176,7 @@
if (state == TASK_RUNNING) {
bpf_probe_read(&tgid, sizeof(prev->tgid), &prev->tgid);
bpf_probe_read(&pid, sizeof(prev->pid), &prev->pid);
if (!(FILTER_PID)) {
if (!(FILTER_PID || pid == 0)) {
u64 ts = bpf_ktime_get_ns();
start.update(&pid, &ts);
}
Expand Down

0 comments on commit 799f46a

Please sign in to comment.