Thread (6 messages) flat view 6 messages, 2 authors, 2020-01-22

Re: [PATCH v2 bpf-next 3/3] bpf: tcp: Add bpf_cubic example

From: Martin Lau <hidden>
Date: 2020-01-22 22:17:48
Also in: bpf

On Wed, Jan 22, 2020 at 01:53:45PM -0800, Andrii Nakryiko wrote:
On Tue, Jan 21, 2020 at 10:42 PM Martin KaFai Lau [off-list ref] wrote:
quoted
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...

[...]
quoted
+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
It is in my TODO list.  I am happy to be beaten though ;)
quoted
+       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);
+}
+
[...]
quoted
+
+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
Thanks for pointing it out.  Will do.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help