Skip to content

Commit febd9b7

Browse files
committed
netstacklat: disable user_config.groupby_ifindex
Because production have too little traffic on the internal interface that latency stats becomes unusable. Via CONFIG_GROUPBY_IFINDEX also remove this from the hist_key and note that YAML file also needs adjustments. Signed-off-by: Jesper Dangaard Brouer <hawk@kernel.org>
1 parent f5e1baa commit febd9b7

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

examples/netstacklat.bpf.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const struct netstacklat_bpf_config user_config = {
3434
.filter_ifindex = true,
3535
.filter_cgroup = true,
3636
.filter_nonempty_sockqueue = false,
37-
.groupby_ifindex = true,
37+
.groupby_ifindex = false, /* If true also define CONFIG_GROUPBY_IFINDEX */
3838
.groupby_cgroup = true,
3939
};
4040

@@ -74,8 +74,13 @@ struct sk_buff___old {
7474
* and "enabled" hooks.
7575
*/
7676
#define N_CGROUPS 2 /* depend on cgroup_id_map matches in YAML config*/
77+
#ifdef CONFIG_GROUPBY_IFINDEX
7778
#define N_IFACES 6 /* On prod only interested in ext0 and vlan100@ext0 */
79+
#else
80+
#define N_IFACES 1 /* With groupby_ifindex==false */
81+
#endif
7882
#define N_HOOKS 1
83+
7984
#if (CONFIG_HOOKS_EARLY_RCV || CONFIG_HOOKS_ENQUEUE || CONFIG_ENABLE_UDP_HOOKS)
8085
#err "Please update N_HOOKS"
8186
#endif
@@ -344,8 +349,10 @@ static void record_skb_latency(struct sk_buff *skb, struct sock *sk, enum netsta
344349
if (!filter_nth_packet(hook))
345350
return;
346351

352+
#ifdef CONFIG_GROUPBY_IFINDEX
347353
if (user_config.groupby_ifindex)
348354
key.ifindex = ifindex;
355+
#endif
349356

350357
_record_latency_since(skb->tstamp, key);
351358
}
@@ -519,8 +526,10 @@ static void record_socket_latency(struct sock *sk, struct sk_buff *skb,
519526
if (!filter_network_ns(skb, sk))
520527
return;
521528

529+
#ifdef CONFIG_GROUPBY_IFINDEX
522530
if (user_config.groupby_ifindex)
523531
key.ifindex = ifindex;
532+
#endif
524533
if (user_config.groupby_cgroup)
525534
key.cgroup = cgroup_id;
526535

examples/netstacklat.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,24 @@ enum netstacklat_hook {
5959
NETSTACKLAT_N_HOOKS,
6060
};
6161

62+
/* Disabling user_config.groupby_ifindex requires modifying hist_key and YAML
63+
*/
64+
//#define CONFIG_GROUPBY_IFINDEX 1
65+
#undef CONFIG_GROUPBY_IFINDEX
66+
6267
/*
6368
* Key used for the histogram map
6469
* To be compatible with ebpf-exporter, all histograms need a key struct whose final
6570
* member is named "bucket" and is the histogram bucket index.
6671
*/
6772
struct hist_key {
6873
__u64 cgroup;
74+
#ifdef CONFIG_GROUPBY_IFINDEX
6975
__u32 ifindex;
76+
#endif
7077
__u16 hook; // need well defined size for ebpf-exporter to decode
7178
__u16 bucket; // needs to be last to be compatible with ebpf-exporter
72-
};
79+
} __attribute__((packed));
7380

7481
struct netstacklat_bpf_config {
7582
__u32 network_ns;

examples/netstacklat.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@ metrics:
1212
decoders:
1313
- name: uint
1414
- name: cgroup
15-
- name: iface
16-
size: 4
17-
decoders:
18-
# If including output from a different network namespace than ebpf-exporter
19-
# you probably just want to decode as a uint (ifindex) instead
20-
# - name: uint # For the ifname decoder you apparently don't first need a uint decoder like the others
21-
- name: ifname
15+
# See: CONFIG_GROUPBY_IFINDEX
16+
# - name: iface
17+
# size: 4
18+
# decoders:
19+
# # If including output from a different network namespace than ebpf-exporter
20+
# # you probably just want to decode as a uint (ifindex) instead
21+
# # - name: uint # For the ifname decoder you apparently don't first need a uint decoder like the others
22+
# - name: ifname
2223
- name: hook
2324
size: 2
2425
decoders:

0 commit comments

Comments
 (0)