[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191216211715.uxzcnj4zc3ba2rly@kafai-mbp.dhcp.thefacebook.com>
Date: Mon, 16 Dec 2019 21:17:19 +0000
From: Martin Lau <kafai@...com>
To: Eric Dumazet <eric.dumazet@...il.com>
CC: "bpf@...r.kernel.org" <bpf@...r.kernel.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
David Miller <davem@...emloft.net>,
Kernel Team <Kernel-team@...com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: [PATCH bpf-next 09/13] bpf: Add BPF_FUNC_jiffies
On Mon, Dec 16, 2019 at 11:33:01AM -0800, Eric Dumazet wrote:
>
>
> On 12/16/19 11:14 AM, Martin Lau wrote:
> > On Fri, Dec 13, 2019 at 05:59:54PM -0800, Eric Dumazet wrote:
> >>
> >>
> >> On 12/13/19 4:47 PM, Martin KaFai Lau wrote:
> >>> This patch adds a helper to handle jiffies. Some of the
> >>> tcp_sock's timing is stored in jiffies. Although things
> >>> could be deduced by CONFIG_HZ, having an easy way to get
> >>> jiffies will make the later bpf-tcp-cc implementation easier.
> >>>
> >>
> >> ...
> >>
> >>> +
> >>> +BPF_CALL_2(bpf_jiffies, u64, in, u64, flags)
> >>> +{
> >>> + if (!flags)
> >>> + return get_jiffies_64();
> >>> +
> >>> + if (flags & BPF_F_NS_TO_JIFFIES) {
> >>> + return nsecs_to_jiffies(in);
> >>> + } else if (flags & BPF_F_JIFFIES_TO_NS) {
> >>> + if (!in)
> >>> + in = get_jiffies_64();
> >>> + return jiffies_to_nsecs(in);
> >>> + }
> >>> +
> >>> + return 0;
> >>> +}
> >>
> >> This looks a bit convoluted :)
> >>
> >> Note that we could possibly change net/ipv4/tcp_cubic.c to no longer use jiffies at all.
> >>
> >> We have in tp->tcp_mstamp an accurate timestamp (in usec) that can be converted to ms.
> > Thanks for the feedbacks!
> >
> > I have a few questions that need some helps.
> >
> > Does it mean tp->tcp_mstamp can be used as the "now" in cubic?
>
> TCP makes sure to update tp->tcp_mstamp at least once when handling
> a particular packet. We did that to avoid calling possibly expensive
> kernel time service (Some platforms do not have fast TSC)
>
> > or tcp_clock_ns() should still be called in cubic, e.g. to replace
> > bictcp_clock() and tcp_jiffies32?
>
> Yeah, there is this lsndtime and tcp_jiffies32 thing, but maybe
> we can find a way to fetch jiffies32 without having to call a bpf helper ?
Loading a kernel global variable is not yet supported.
Thus, helper is needed but it could be inlined like array_map_gen_lookup().
Powered by blists - more mailing lists