From: Eric Dumazet <eric.dumazet@gmail.com>
To: Martin KaFai Lau <kafai@fb.com>, bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
David Miller <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
kernel-team@fb.com, netdev@vger.kernel.org
Subject: Re: [PATCH bpf-next 3/3] bpf: tcp: Add bpf_cubic example
Date: Tue, 21 Jan 2020 12:26:07 -0800 [thread overview]
Message-ID: <7b8770e1-6cac-2e67-fb79-2feb2a35a0e5@gmail.com> (raw)
In-Reply-To: <20200121195427.3758504-1-kafai@fb.com>
On 1/21/20 11:54 AM, Martin KaFai Lau wrote:
> This patch adds a bpf_cubic example. Some highlights:
> 1. CONFIG_HZ kconfig is used. For example, CONFIG_HZ is used in the usecs
> to jiffies conversion in usecs_to_jiffies().
> 2. In bitctcp_update() [under tcp_friendliness], the original
> "while (ca->ack_cnt > delta)" loop is changed to the equivalent
> "ca->ack_cnt / delta" operation
...
> + /* cubic function - calc*/
> + /* calculate c * time^3 / rtt,
> + * while considering overflow in calculation of time^3
> + * (so time^3 is done by using 64 bit)
> + * and without the support of division of 64bit numbers
> + * (so all divisions are done by using 32 bit)
> + * also NOTE the unit of those veriables
> + * time = (t - K) / 2^bictcp_HZ
> + * c = bic_scale >> 10
> + * rtt = (srtt >> 3) / HZ
> + * !!! The following code does not have overflow problems,
> + * if the cwnd < 1 million packets !!!
> + */
> +
> + t = (__s32)(tcp_jiffies32 - ca->epoch_start);
> + t += usecs_to_jiffies(ca->delay_min);
> + /* change the unit from HZ to bictcp_HZ */
> + t <<= BICTCP_HZ;
> + t /= HZ;
>
Note that this part could use usec resolution instead of jiffies
to avoid all these inlines for {u|n}secs_to_jiffies()
t = (__s32)(tcp_jiffies32 - ca->epoch_start) * (USEC_PER_JIFFY);
t += ca->delay_min;
/* change the unit from usec to bictcp_HZ */
t <<= BICTCP_HZ;
t /= USEC_PER_SEC;
ie :
diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c
index 8f8eefd3a3ce116aa8fa2b7ef85c7eb503fa8da7..9ba58e95dbe6b15098bcfd045e1d0bb8874d713f 100644
--- a/net/ipv4/tcp_cubic.c
+++ b/net/ipv4/tcp_cubic.c
@@ -271,11 +271,11 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd, u32 acked)
* if the cwnd < 1 million packets !!!
*/
- t = (s32)(tcp_jiffies32 - ca->epoch_start);
- t += usecs_to_jiffies(ca->delay_min);
- /* change the unit from HZ to bictcp_HZ */
+ t = (s32)(tcp_jiffies32 - ca->epoch_start) * (USEC_PER_SEC / HZ);
+ t += ca->delay_min;
+ /* change the unit from usec to bictcp_HZ */
t <<= BICTCP_HZ;
- do_div(t, HZ);
+ do_div(t, USEC_PER_SEC);
if (t < ca->bic_K) /* t - K */
offs = ca->bic_K - t;
But this is a minor detail.
next prev parent reply other threads:[~2020-01-21 20:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-21 19:54 [PATCH bpf-next 0/3] bpf: tcp: Add bpf_cubic example Martin KaFai Lau
2020-01-21 19:54 ` [PATCH bpf-next 1/3] bpf: Add BPF_FUNC_jiffies64 Martin KaFai Lau
2020-01-21 22:41 ` Daniel Borkmann
2020-01-21 22:47 ` Martin Lau
2020-01-21 19:54 ` [PATCH bpf-next 2/3] bpf: Sync uapi bpf.h to tools/ Martin KaFai Lau
2020-01-21 19:54 ` [PATCH bpf-next 3/3] bpf: tcp: Add bpf_cubic example Martin KaFai Lau
2020-01-21 20:26 ` Eric Dumazet [this message]
2020-01-21 22:00 ` 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=7b8770e1-6cac-2e67-fb79-2feb2a35a0e5@gmail.com \
--to=eric.dumazet@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