Skip to content

Commit

Permalink
cgroup-rstat-flushing: New contended counter per level
Browse files Browse the repository at this point in the history
 # HELP ebpf_exporter_cgroup_rstat_lock_contended Lock contention counters per cgroup level
 # TYPE ebpf_exporter_cgroup_rstat_lock_contended counter
 ebpf_exporter_cgroup_rstat_lock_contended{level="0"} 36
 ebpf_exporter_cgroup_rstat_lock_contended{level="1"} 847
 ebpf_exporter_cgroup_rstat_lock_contended{level="2"} 415
 ebpf_exporter_cgroup_rstat_lock_contended{level="3"} 0
 ebpf_exporter_cgroup_rstat_lock_contended{level="4"} 0
 ebpf_exporter_cgroup_rstat_lock_contended{level="5"} 0

Signed-off-by: Jesper Dangaard Brouer <[email protected]>
  • Loading branch information
netoptimizer committed Aug 1, 2024
1 parent 727a241 commit 72b7a2f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
21 changes: 21 additions & 0 deletions examples/cgroup-rstat-flushing.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ struct {
__type(value, u64);
} cgroup_rstat_locked_yield SEC(".maps");

/* Per cgroup level lock contended counter */
struct {
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
__uint(max_entries, MAX_CGRP_LEVELS + 1);
__type(key, u32);
__type(value, u64);
} cgroup_rstat_lock_contended SEC(".maps");

/** Measurement#1: lock rates
* =========================
Expand Down Expand Up @@ -76,6 +83,20 @@ int BPF_PROG(rstat_locked, struct cgroup *cgrp, int cpu, bool contended)
(*cnt)++;
}

/* What cgrp level is interesting, but I didn't manage to encode it in
* above counters. As contended case is the most interesting, have
* level counter for contended.
*/
if (contended) {
u32 level = cgrp->level;

if (level > MAX_CGRP_LEVELS)
level = MAX_CGRP_LEVELS;

read_array_ptr(&cgroup_rstat_lock_contended, &level, cnt);
(*cnt)++;
}

return 0;
}

Expand Down
7 changes: 7 additions & 0 deletions examples/cgroup-rstat-flushing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,11 @@ metrics:
size: 4
decoders: # contended boolean converted to 0 and 1
- name: uint
- name: cgroup_rstat_lock_contended
help: Lock contention counters per cgroup level
labels:
- name: level
size: 4
decoders:
- name: uint

0 comments on commit 72b7a2f

Please sign in to comment.