diff mbox series

[net-next,1/2] mptcp: don't need to check SKB_EXT_MPTCP in mptcp_reset_option()

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

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1846 this patch: 1846
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 973 this patch: 973
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1882 this patch: 1882
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-04-05--15-00 (tests: 956)

Commit Message

Jason Xing April 5, 2024, 2:39 a.m. UTC
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.

Signed-off-by: Jason Xing <kernelxing@tencent.com>
---
 include/net/mptcp.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Paolo Abeni April 5, 2024, 7:47 a.m. UTC | #1
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
Jason Xing April 5, 2024, 7:58 a.m. UTC | #2
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
>
Paolo Abeni April 5, 2024, 8:34 a.m. UTC | #3
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
Jason Xing April 5, 2024, 9:11 a.m. UTC | #4
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 mbox series

Patch

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