Message ID | 20240405023914.54872-2-kerneljasonxing@gmail.com (mailing list archive) |
---|---|
State | Rejected |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | mptcp: add reset reasons in skb in more cases | expand |
On Fri, 2024-04-05 at 10:39 +0800, Jason Xing wrote: > From: Jason Xing <kernelxing@tencent.com> > > Before this, what mptcp_reset_option() checks is totally the same as > mptcp_get_ext() does, so we could skip it. Note that the somewhat duplicate test is (a possibly not great) optimization to avoid jumping in the mptcp code (possible icache misses) for plain TCP sockets. I guess we want to maintain it. Cheers, Paolo
Hello Paolo, On Fri, Apr 5, 2024 at 3:47 PM Paolo Abeni <pabeni@redhat.com> wrote: > > On Fri, 2024-04-05 at 10:39 +0800, Jason Xing wrote: > > From: Jason Xing <kernelxing@tencent.com> > > > > Before this, what mptcp_reset_option() checks is totally the same as > > mptcp_get_ext() does, so we could skip it. > > Note that the somewhat duplicate test is (a possibly not great) > optimization to avoid jumping in the mptcp code (possible icache > misses) for plain TCP sockets. > > I guess we want to maintain it. Okay, I just read code and found the duplication but may I ask why it has something to do with icache misses? Thanks, Jason > > Cheers, > > Paolo >
On Fri, 2024-04-05 at 15:58 +0800, Jason Xing wrote: > Hello Paolo, > > On Fri, Apr 5, 2024 at 3:47 PM Paolo Abeni <pabeni@redhat.com> wrote: > > > > On Fri, 2024-04-05 at 10:39 +0800, Jason Xing wrote: > > > From: Jason Xing <kernelxing@tencent.com> > > > > > > Before this, what mptcp_reset_option() checks is totally the same as > > > mptcp_get_ext() does, so we could skip it. > > > > Note that the somewhat duplicate test is (a possibly not great) > > optimization to avoid jumping in the mptcp code (possible icache > > misses) for plain TCP sockets. > > > > I guess we want to maintain it. > > Okay, I just read code and found the duplication but may I ask why it > has something to do with icache misses? The first check/mptcp_get_ext() is in mptcp_reset_option() / tcp_v4_send_reset(). For plain TCP socket it will fail and the execution will continue inside the same compilation unit. The code locality should avoid icaches misses around there. Removing such check, even when processing plain TCP packets, the code execution will have to call into mptcp_get_reset_option() in the mptcp code, decreasing the code locality and increasing the chance of icache misses. I don't have actual profile data, so this is an early optimization (and thus root of all evil), but sounds reasonable to me (yep, I'm biased!) Cheers, Paolo
Hello Paolo, On Fri, Apr 5, 2024 at 4:34 PM Paolo Abeni <pabeni@redhat.com> wrote: > > On Fri, 2024-04-05 at 15:58 +0800, Jason Xing wrote: > > Hello Paolo, > > > > On Fri, Apr 5, 2024 at 3:47 PM Paolo Abeni <pabeni@redhat.com> wrote: > > > > > > On Fri, 2024-04-05 at 10:39 +0800, Jason Xing wrote: > > > > From: Jason Xing <kernelxing@tencent.com> > > > > > > > > Before this, what mptcp_reset_option() checks is totally the same as > > > > mptcp_get_ext() does, so we could skip it. > > > > > > Note that the somewhat duplicate test is (a possibly not great) > > > optimization to avoid jumping in the mptcp code (possible icache > > > misses) for plain TCP sockets. > > > > > > I guess we want to maintain it. > > > > Okay, I just read code and found the duplication but may I ask why it > > has something to do with icache misses? > > The first check/mptcp_get_ext() is in mptcp_reset_option() / > tcp_v4_send_reset(). For plain TCP socket it will fail and the > execution will continue inside the same compilation unit. The code > locality should avoid icaches misses around there. > > Removing such check, even when processing plain TCP packets, the code > execution will have to call into mptcp_get_reset_option() in the mptcp > code, decreasing the code locality and increasing the chance of icache > misses. Interesting. Thanks for the explanation:) > > I don't have actual profile data, so this is an early optimization (and > thus root of all evil), but sounds reasonable to me (yep, I'm biased!) I'll drop this patch. Thanks, Jason > > Cheers, > > Paolo >
diff --git a/include/net/mptcp.h b/include/net/mptcp.h index fb996124b3d5..42d13ee26619 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -215,10 +215,7 @@ __be32 mptcp_get_reset_option(const struct sk_buff *skb); static inline __be32 mptcp_reset_option(const struct sk_buff *skb) { - if (skb_ext_exist(skb, SKB_EXT_MPTCP)) - return mptcp_get_reset_option(skb); - - return htonl(0u); + return mptcp_get_reset_option(skb); } #else