Skip to content

Commit

Permalink
Add (admitedly redundant) clarification of kernel tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfonso Acosta committed Apr 13, 2016
1 parent c838350 commit cbc6d33
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/plugins/http-requests/http-requests.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <linux/skbuff.h>
#include <net/sock.h>

/* Table from (Process id|Task id) to (Number of received http requests) */
/* Table from (Task id|Task group id) to (Number of received http requests) */
BPF_HASH(received_http_requests, u64, u64);


Expand Down
6 changes: 5 additions & 1 deletion examples/plugins/http-requests/http-requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit cbc6d33

Please sign in to comment.