From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Martin KaFai Lau <kafai@fb.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
David Miller <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Kernel Team <kernel-team@fb.com>,
Networking <netdev@vger.kernel.org>
Subject: Re: [PATCH v2 bpf-next 3/3] bpf: tcp: Add bpf_cubic example
Date: Wed, 22 Jan 2020 13:53:45 -0800 [thread overview]
Message-ID: <CAEf4BzYU2xZkUvK-JP53jrKXnWryACHsaX4JO_trEn=1N9-k1A@mail.gmail.com> (raw)
In-Reply-To: <20200122064210.1834848-1-kafai@fb.com>
On Tue, Jan 21, 2020 at 10:42 PM Martin KaFai Lau <kafai@fb.com> 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 <kafai@fb.com>
> ---
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)
> +
[...]
next prev parent reply other threads:[~2020-01-22 21:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-22 6:41 [PATCH v2 bpf-next 0/3] bpf: tcp: Add bpf_cubic example Martin KaFai Lau
2020-01-22 6:41 ` [PATCH v2 bpf-next 1/3] bpf: Add BPF_FUNC_jiffies64 Martin KaFai Lau
2020-01-22 6:42 ` [PATCH v2 bpf-next 2/3] bpf: Sync uapi bpf.h to tools/ Martin KaFai Lau
2020-01-22 6:42 ` [PATCH v2 bpf-next 3/3] bpf: tcp: Add bpf_cubic example Martin KaFai Lau
2020-01-22 21:53 ` Andrii Nakryiko [this message]
2020-01-22 22:17 ` Martin Lau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAEf4BzYU2xZkUvK-JP53jrKXnWryACHsaX4JO_trEn=1N9-k1A@mail.gmail.com' \
--to=andrii.nakryiko@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kafai@fb.com \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).