[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMDZJNVTSLyLoNc=O5zL8+suAd+C_HihCoutULWGiSCb-Fw0Vw@mail.gmail.com>
Date: Thu, 21 Apr 2022 10:37:03 +0800
From: Tonghao Zhang <xiangxia.m.yue@...il.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: Toke Høiland-Jørgensen <toke@...nel.org>,
Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>, Jiri Olsa <jolsa@...nel.org>,
Dave Marchevsky <davemarchevsky@...com>,
Kuniyuki Iwashima <kuniyu@...zon.co.jp>,
Joanne Koong <joannekoong@...com>,
Geliang Tang <geliang.tang@...e.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Eric Dumazet <edumazet@...gle.com>
Subject: Re: [net-next v1] bpf: add bpf_ktime_get_real_ns helper
On Thu, Apr 21, 2022 at 12:17 AM Andrii Nakryiko
<andrii.nakryiko@...il.com> wrote:
>
> On Wed, Apr 20, 2022 at 5:53 AM Toke Høiland-Jørgensen <toke@...nel.org> wrote:
> >
> > xiangxia.m.yue@...il.com writes:
> >
> > > From: Tonghao Zhang <xiangxia.m.yue@...il.com>
> > >
> > > This patch introduce a new bpf_ktime_get_real_ns helper, which may
> > > help us to measure the skb latency in the ingress/forwarding path:
> > >
> > > HW/SW[1] -> ip_rcv/tcp_rcv_established -> tcp_recvmsg_locked/tcp_update_recv_tstamps
> > >
> > > * Insert BPF kprobe into ip_rcv/tcp_rcv_established invoking this helper.
> > > Then we can inspect how long time elapsed since HW/SW.
> > > * If inserting BPF kprobe tcp_update_recv_tstamps invoked by tcp_recvmsg,
> > > we can measure how much latency skb in tcp receive queue. The reason for
> > > this can be application fetch the TCP messages too late.
> >
> > Why not just use one of the existing ktime helpers and also add a BPF
> > probe to set the initial timestamp instead of relying on skb->tstamp?
> >
>
> You don't even need a BPF probe for this. See [0] for how retsnoop is
> converting bpf_ktime_get_ns() into real time.
>
> [0] https://github.com/anakryiko/retsnoop/blob/master/src/retsnoop.c#L649-L668
I try to calculate this offset too. But one case:
If administrator manually or NTP changes the clock, we should
calculate the offset.
How do we know the changes, one solution is that inserting kprobe in
tk_set_wall_to_mono() kernel function,
and using perf_event to notify userspace.
> > -Toke
--
Best regards, Tonghao
Powered by blists - more mailing lists