Skip to contentSkip to conversation

tcp/dccp: cache line align inet_hashinfo

PATCH Applied Eric Dumazet 3 participants 4 messages Aug 3, 2023 – Aug 4, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tcp/dccp: cache line align inet_hashinfo

I have seen tcp_hashinfo starting at a non optimal location, forcing input handlers to pull two cache lines instead of one, and sharing a cache line that was dirtied more than necessary:

ffffffff83680600 b tcp_orphan_timer ffffffff83680628 b tcp_orphan_cache ffffffff8368062c b tcp_enable_tx_delay.__tcp_tx_delay_enabled ffffffff83680630 B tcp_hashinfo
ffffffff83680680 b tcp_cong_list_lock

After this patch, ehash, ehash_locks, ehash_mask and ehash_locks_mask are located in a read-only cache line.

---
 include/net/inet_hashtables.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/inet_hashtables.h +1 -1
index 99bd823e97f624e37cf3abb8ac0ec7eef4552b61..74399d20b2184945f2b39bf3dfedb3ae63b500f7 100644
@@ -177,7 +177,7 @@ struct inet_hashinfo {
 	struct inet_listen_hashbucket	*lhash2;
 
 	bool				pernet;
-};
+} ____cacheline_aligned_in_smp;
 
 static inline struct inet_hashinfo *tcp_or_dccp_get_hashinfo(const struct sock *sk)
 {
Signature · 1 line
2.41.0.640.ga95def55d0-goog
#1 lore raw
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Quoted 11 lines · On Thu, 3 Aug 2023 07:53:34 +0000 you wrote:

I have seen tcp_hashinfo starting at a non optimal location, forcing input handlers to pull two cache lines instead of one, and sharing a cache line that was dirtied more than necessary:

ffffffff83680600 b tcp_orphan_timer ffffffff83680628 b tcp_orphan_cache ffffffff8368062c b tcp_enable_tx_delay.__tcp_tx_delay_enabled ffffffff83680630 B tcp_hashinfo
ffffffff83680680 b tcp_cong_list_lock

[...]

Here is the summary with links:
- [net-next] tcp/dccp: cache line align inet_hashinfo

    https://git.kernel.org/netdev/net-next/c/6f5ca184cbef

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
#2 lore raw
Quoted 19 lines · On Fri, Aug 4, 2023 at 10:30 AM <[email protected]> wrote:

Hello:

This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Quoted 11 lines · On Thu, 3 Aug 2023 07:53:34 +0000 you wrote:

I have seen tcp_hashinfo starting at a non optimal location, forcing input handlers to pull two cache lines instead of one, and sharing a cache line that was dirtied more than necessary:

ffffffff83680600 b tcp_orphan_timer ffffffff83680628 b tcp_orphan_cache ffffffff8368062c b tcp_enable_tx_delay.__tcp_tx_delay_enabled ffffffff83680630 B tcp_hashinfo
ffffffff83680680 b tcp_cong_list_lock

[...]

Quoted 10 lines

Here is the summary with links:
- [net-next] tcp/dccp: cache line align inet_hashinfo

    https://git.kernel.org/netdev/net-next/c/6f5ca184cbef

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html

Thanks !

Apparently this misalignment came with

commit cae3873c5b3a4fcd9706fb461ff4e91bdf1f0120

Author: Martin KaFai Lau <[email protected]>
Date:   Wed May 11 17:06:05 2022 -0700

net: inet: Retire port only listening_hash

#3 lore raw
Quoted 33 lines · Eric Dumazet
Quoted 19 lines · On Fri, Aug 4, 2023 at 10:30 AM <[email protected]> wrote:

Hello:

This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Quoted 11 lines · On Thu, 3 Aug 2023 07:53:34 +0000 you wrote:

I have seen tcp_hashinfo starting at a non optimal location, forcing input handlers to pull two cache lines instead of one, and sharing a cache line that was dirtied more than necessary:

ffffffff83680600 b tcp_orphan_timer ffffffff83680628 b tcp_orphan_cache ffffffff8368062c b tcp_enable_tx_delay.__tcp_tx_delay_enabled ffffffff83680630 B tcp_hashinfo
ffffffff83680680 b tcp_cong_list_lock

[...]

Quoted 10 lines

Here is the summary with links:
- [net-next] tcp/dccp: cache line align inet_hashinfo

     https://git.kernel.org/netdev/net-next/c/6f5ca184cbef

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html

Thanks !

Quoted 7 lines

Apparently this misalignment came with

commit cae3873c5b3a4fcd9706fb461ff4e91bdf1f0120

Author: Martin KaFai Lau <[email protected]>
Date:   Wed May 11 17:06:05 2022 -0700

net: inet: Retire port only listening_hash

Ah. Thanks for the fix. TIL.