From 42226acb04df64eee9f9bc4fc1dc567d30ed2091 Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Wed, 13 Apr 2016 10:40:00 +0000 Subject: [PATCH] Add (admitedly redundant) clarification of kernel tasks --- examples/plugins/http-requests/http-requests.c | 2 +- examples/plugins/http-requests/http-requests.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/examples/plugins/http-requests/http-requests.c b/examples/plugins/http-requests/http-requests.c index 76bc2c7bae..3e849fe74c 100644 --- a/examples/plugins/http-requests/http-requests.c +++ b/examples/plugins/http-requests/http-requests.c @@ -1,7 +1,7 @@ #include #include -/* Table from (Process id|Task id) to (Number of received http requests) */ +/* Table from (Task group id|Task id) to (Number of received http requests) */ BPF_HASH(received_http_requests, u64, u64); diff --git a/examples/plugins/http-requests/http-requests.py b/examples/plugins/http-requests/http-requests.py index a2cb43a06b..866cb1fa96 100755 --- a/examples/plugins/http-requests/http-requests.py +++ b/examples/plugins/http-requests/http-requests.py @@ -27,10 +27,14 @@ def __init__(self): self.lock = threading.Lock() def update_http_rate_per_pid(self, last_req_count_snapshot): - # Aggregate per-task http request counts into per-process counts + # Aggregate the kernel's per-task http request counts into userland's + # per-process counts req_count_table = self.bpf.get_table(EBPF_TABLE_NAME) new_req_count_snapshot = collections.defaultdict(int) for pid_tgid, req_count in req_count_table.iteritems(): + # Note that the kernel's tgid maps into userland's pid + # (not to be confused by the kernel's pid, which is + # the unique identifier of a kernel task) pid = pid_tgid.value >> 32 new_req_count_snapshot[pid] += req_count.value