From: Jason Xing <kerneljasonxing@gmail.com>
To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, willemb@google.com,
kuniyu@google.com
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
Jason Xing <kerneljasonxing@gmail.com>
Subject: [PATCH RFC net-next 4/9] net: reuse skb_shared_hwtstamps for BPF Timestamping v2
Date: Sat, 19 Sep 2026 22:37:27 +0800 [thread overview]
Message-ID: <20260919143732.11772-5-kerneljasonxing@gmail.com> (raw)
In-Reply-To: <20260919143732.11772-1-kerneljasonxing@gmail.com>
The ultimate goal is to find a place to store the start time per-packet
basis for different protocols.
It's almost unacceptable to add a new field for latency tracker (BPF
Timestamping V2) for every nornal skb because the space is so precious
nowadays. So what left we can do is to try to find a field to reuse.
The principles are 1) it should be a safe place to store the start
time, 2) it can traverse across netns (candidates like skb->tstamp
are not appropriate due to the clearance by skb_scrub_packet() in
the container scenario), 3) it works in dual directions. Detailed
comparisons and reasons can be found on slides 53-60[1].
As we discussed at Netconf 2026 in Rome, we eventually chose to reuse
hwtstamp with considering the above reasons. Now this reused field has
three meanings.
The two uses between 'hwtstamp' and 'start time' are deliberately ordered:
a real hardware time stamp always wins. The start time is only generated
when the hwtstamp slot is still empty. When hardware timestamping is present,
that means we have a better value from real hardware than the software one,
so choose the hardware timestamp as the start time in the rx path.
[1]: https://netdevconf.info/0x1A/sessions/bof/network-observability-bof.html
Signed-off-by: Jason Xing <kerneljasonxing@gmail.com>
---
include/linux/skbuff.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 55ae1653a1cf..c5347be72ff9 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -447,6 +447,12 @@ static inline bool skb_frag_must_loop(struct page *p)
* struct skb_shared_hwtstamps - hardware time stamps
* @hwtstamp: hardware time stamp transformed into duration
* since arbitrary point in time
+ * @start_time: Start time stamped when SK_BPF_CB_TIMESTAMPING_V2
+ * is enabled; shares storage with @hwtstamp. A real
+ * hardware time stamp always takes precedence: the start
+ * time is only recorded when @hwtstamp is still empty
+ * (no hardware time stamp available), so the two are
+ * never needed at the same time on a given skb.
* @netdev_data: address/cookie of network device driver used as
* reference to actual hardware time stamp
*
@@ -462,6 +468,7 @@ static inline bool skb_frag_must_loop(struct page *p)
struct skb_shared_hwtstamps {
union {
ktime_t hwtstamp;
+ ktime_t start_time;
void *netdev_data;
};
};
--
2.43.7
next prev parent reply other threads:[~2026-09-19 14:39 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 14:37 [PATCH RFC net-next 0/9] net: BPF Timestamping 2.0 for TCP Jason Xing
2026-09-19 14:37 ` [PATCH RFC net-next 1/9] net: add bpf_setsockopt for SK_BPF_CB_TIMESTAMPING_V2 Jason Xing
2026-09-19 14:37 ` [PATCH RFC net-next 2/9] bpf: add bpf_ktime_get_real_ns() kfunc Jason Xing
2026-09-19 14:37 ` [PATCH RFC net-next 3/9] tcp: record a start time in the tx path for SK_BPF_CB_TIMESTAMPING_V2 Jason Xing
2026-09-19 14:37 ` Jason Xing [this message]
2026-09-19 14:37 ` [PATCH RFC net-next 5/9] net-timestamp: use pskb_copy to avoid polluting the orig skb's start time Jason Xing
2026-09-19 14:37 ` [PATCH RFC net-next 6/9] bpf-timestamping: restore skb hwtstamp if it is used by " Jason Xing
2026-09-19 14:37 ` [PATCH RFC net-next 7/9] tcp: propagate the start time onto every skb in the tx path Jason Xing
2026-09-19 14:37 ` [PATCH RFC net-next 8/9] net: generate the start time for every skb in the rx path Jason Xing
2026-09-19 14:37 ` [PATCH RFC net-next 9/9] tcp: handle the start time of each split skb in the tx path Jason Xing
2026-09-19 18:12 ` [PATCH RFC net-next 0/9] net: BPF Timestamping 2.0 for TCP Alexei Starovoitov
2026-09-20 0:41 ` Jason Xing
2026-09-21 18:45 ` Stanislav Fomichev
2026-09-22 1:20 ` Jason Xing
2026-09-22 20:53 ` Stanislav Fomichev
2026-09-23 9:40 ` Jason Xing
2026-09-24 16:11 ` Stanislav Fomichev
2026-09-30 10:21 ` Jason Xing
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=20260919143732.11772-5-kerneljasonxing@gmail.com \
--to=kerneljasonxing@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.com \
/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