From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Vadim Fedorenko <vadim.fedorenko@linux.dev>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
Vadim Fedorenko <vadfed@meta.com>,
Willem de Bruijn <willemb@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
David Ahern <dsahern@kernel.org>,
Jason Xing <kerneljasonxing@gmail.com>,
Simon Horman <horms@kernel.org>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH net-next v3 1/4] net_tstamp: add SCM_TS_OPT_ID to provide OPT_ID in control message
Date: Thu, 05 Sep 2024 09:29:23 -0400 [thread overview]
Message-ID: <66d9b23322f2f_18ac212944a@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <1946af56-9f6f-439d-b954-6bcb82367741@linux.dev>
Vadim Fedorenko wrote:
> On 04/09/2024 21:54, Willem de Bruijn wrote:
> > Vadim Fedorenko wrote:
> >> SOF_TIMESTAMPING_OPT_ID socket option flag gives a way to correlate TX
> >> timestamps and packets sent via socket. Unfortunately, there is no way
> >> to reliably predict socket timestamp ID value in case of error returned
> >> by sendmsg. For UDP sockets it's impossible because of lockless
> >> nature of UDP transmit, several threads may send packets in parallel. In
> >> case of RAW sockets MSG_MORE option makes things complicated. More
> >> details are in the conversation [1].
> >> This patch adds new control message type to give user-space
> >> software an opportunity to control the mapping between packets and
> >> values by providing ID with each sendmsg for UDP sockets.
> >> The documentation is also added in this patch.
> >>
> >> [1] https://lore.kernel.org/netdev/CALCETrU0jB+kg0mhV6A8mrHfTE1D1pr1SD_B9Eaa9aDPfgHdtA@mail.gmail.com/
> >>
> >> Signed-off-by: Vadim Fedorenko <vadfed@meta.com>
> >> @@ -1325,8 +1330,11 @@ static int ip_setup_cork(struct sock *sk, struct inet_cork *cork,
> >> cork->mark = ipc->sockc.mark;
> >> cork->priority = ipc->priority;
> >> cork->transmit_time = ipc->sockc.transmit_time;
> >> + cork->ts_opt_id = ipc->sockc.ts_opt_id;
> >> cork->tx_flags = 0;
> >> sock_tx_timestamp(sk, ipc->sockc.tsflags, &cork->tx_flags);
> >> + if (ipc->sockc.tsflags & SOCKCM_FLAG_TS_OPT_ID)
> >> + cork->flags |= IPCORK_TS_OPT_ID;
> >
> > We can move initialization of ts_opt_id into the branch.
> >
> > Or conversely avoid the branch with some convoluted shift operations
> > to have the rval be either 1 << 1 or 0 << 1. But let's do the simpler
> > thing.
>
> What is the reason to move initialization behind the flag? We are not
> doing this for transmit_time even though it's also used with flag only.
>
> It's not a big deal to change, I just wonder what are the benefits?
Just avoid one assignment in the hot path that does not use this
feature.
cork->ts_opt_id is only valuid if cork->flags & IPCORK_TS_OPT_ID.
next prev parent reply other threads:[~2024-09-05 13:29 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-04 11:31 [PATCH net-next v3 0/4] Add option to provide OPT_ID value via cmsg Vadim Fedorenko
2024-09-04 11:31 ` [PATCH net-next v3 1/4] net_tstamp: add SCM_TS_OPT_ID to provide OPT_ID in control message Vadim Fedorenko
2024-09-04 13:56 ` Jason Xing
2024-09-04 14:01 ` Vadim Fedorenko
2024-09-04 20:54 ` Willem de Bruijn
2024-09-05 10:10 ` Vadim Fedorenko
2024-09-05 13:29 ` Willem de Bruijn [this message]
2024-09-05 8:24 ` Jason Xing
2024-09-05 8:34 ` Vadim Fedorenko
2024-09-05 8:49 ` Jason Xing
2024-09-06 9:22 ` kernel test robot
2024-09-06 12:58 ` kernel test robot
2024-09-04 11:31 ` [PATCH net-next v3 2/4] net_tstamp: add SCM_TS_OPT_ID for TCP sockets Vadim Fedorenko
2024-09-05 14:58 ` Vadim Fedorenko
2024-09-05 15:37 ` Jason Xing
2024-09-05 16:39 ` Willem de Bruijn
2024-09-06 12:20 ` Vadim Fedorenko
2024-09-06 15:25 ` Willem de Bruijn
2024-09-06 16:33 ` Willem de Bruijn
2024-09-06 17:27 ` Vadim Fedorenko
2024-09-06 23:50 ` Willem de Bruijn
2024-09-06 17:27 ` Vadim Fedorenko
2024-09-06 23:48 ` Willem de Bruijn
2024-09-07 21:55 ` Vadim Fedorenko
2024-09-08 19:19 ` Willem de Bruijn
2024-09-08 19:55 ` Vadim Fedorenko
2024-09-04 11:31 ` [PATCH net-next v3 3/4] net_tstamp: add SCM_TS_OPT_ID for RAW sockets Vadim Fedorenko
2024-09-04 11:31 ` [PATCH net-next v3 4/4] selftests: txtimestamp: add SCM_TS_OPT_ID test Vadim Fedorenko
2024-09-04 11:36 ` [PATCH net-next v3 0/4] Add option to provide OPT_ID value via cmsg Vadim Fedorenko
2024-09-04 21:04 ` Willem de Bruijn
2024-09-04 22:50 ` Vadim Fedorenko
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=66d9b23322f2f_18ac212944a@willemb.c.googlers.com.notmuch \
--to=willemdebruijn.kernel@gmail.com \
--cc=dsahern@kernel.org \
--cc=horms@kernel.org \
--cc=kerneljasonxing@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vadfed@meta.com \
--cc=vadim.fedorenko@linux.dev \
--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