mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-26 00:37:24 +00:00
Add (admitedly redundant) clarification on kernel tasks
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
#include <linux/skbuff.h>
|
||||
#include <net/sock.h>
|
||||
|
||||
/* 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).
|
||||
We need to gather requests per task and not only per task group (i.e. userspace pid)
|
||||
so that entries can be cleared up independently when a task exists.
|
||||
This implies that userspace needs to do the per-process aggregation.
|
||||
*/
|
||||
BPF_HASH(received_http_requests, u64, u64);
|
||||
|
||||
|
||||
|
||||
@@ -27,10 +27,14 @@ class KernelInspector(threading.Thread):
|
||||
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user