Re: [PATCH v2 bpf-next 3/3] bpf: tcp: Add bpf_cubic example
From: Andrii Nakryiko <hidden>
Date: 2020-01-22 21:53:58
Also in:
bpf
On Tue, Jan 21, 2020 at 10:42 PM Martin KaFai Lau [off-list ref] wrote:
This patch adds a bpf_cubic example. Some highlights: 1. CONFIG_HZ .kconfig map is used. 2. In bictcp_update(), calculation is changed to use usec resolution (i.e. USEC_PER_JIFFY) instead of using jiffies. Thus, usecs_to_jiffies() is not used in the bpf_cubic.c. 3. In bitctcp_update() [under tcp_friendliness], the original "while (ca->ack_cnt > delta)" loop is changed to the equivalent "ca->ack_cnt / delta" operation. Signed-off-by: Martin KaFai Lau <redacted> ---
just my few cents below... [...]
+static void test_cubic(void)
+{
+ struct bpf_cubic *cubic_skel;
+ struct bpf_link *link;
+
+ cubic_skel = bpf_cubic__open_and_load();
+ if (CHECK(!cubic_skel, "bpf_cubic__open_and_load", "failed\n"))
+ return;
+
+ link = bpf_map__attach_struct_ops(cubic_skel->maps.cubic);we should probably teach bpftool and libbpf to generate a link for struct_ops map and also auto-attach it as part of skeleton's attach... I'll add it if noone gets to it sooner
+ if (CHECK(IS_ERR(link), "bpf_map__attach_struct_ops", "err:%ld\n",
+ PTR_ERR(link))) {
+ bpf_cubic__destroy(cubic_skel);
+ return;
+ }
+
+ do_test("bpf_cubic");
+
+ bpf_link__destroy(link);
+ bpf_cubic__destroy(cubic_skel);
+}
+[...]
+ +extern unsigned long CONFIG_HZ __kconfig __weak;
you probably don't want __weak, if CONFIG_HZ is not defined in Kconfig, then something wrong is going on, probably, so it's better to error out early
+#define HZ CONFIG_HZ +#define USEC_PER_MSEC 1000UL +#define USEC_PER_SEC 1000000UL +#define USEC_PER_JIFFY (USEC_PER_SEC / HZ) +
[...]