Page MenuHomeFreeBSD

allocate inpcb aligned to cachelines
ClosedPublic

Authored by gallatin on Dec 13 2022, 8:30 PM.
Tags
None
Referenced Files
F102646497: D37687.diff
Fri, Nov 15, 7:21 AM
Unknown Object (File)
Sun, Nov 3, 4:15 PM
Unknown Object (File)
Sep 30 2024, 7:27 AM
Unknown Object (File)
Sep 8 2024, 12:15 PM
Unknown Object (File)
Sep 8 2024, 6:43 AM
Unknown Object (File)
Sep 7 2024, 7:47 AM
Unknown Object (File)
Sep 3 2024, 11:43 AM
Unknown Object (File)
Aug 21 2024, 2:28 AM
Subscribers

Details

Summary

The inpcb struct is one of the most heavily utilized in the kernel on a busy network server. By aligning it to a cacheline boundary, we can ensure that closely related fields in the inpcb (and tcpcb) can be predictable located on the same cacheline. rrs has already done a lot of this work to put related fields on the same line for the tcbcb.

In combination with a forthcoming patch to align the start of the tcpcb, we see a roughly 3% reduction in CPU use on a busy web server serving traffic over roughly 50,000 TCP connections.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

This revision is now accepted and ready to land.Dec 13 2022, 10:18 PM

Seems reasonable to me. The tcp_inpcb and udp_inpcb zones have an item size of 424 bytes, that yields 9 items per slab. With the new alignment I believe we'll get the same number so this change is effectively free. I wonder if UMA should automatically increase alignment to CACHE_LINE_SIZE if doing so doesn't hurt slab efficiency. Do you see any downsides to doing that?

Seems reasonable to me. The tcp_inpcb and udp_inpcb zones have an item size of 424 bytes, that yields 9 items per slab. With the new alignment I believe we'll get the same number so this change is effectively free. I wonder if UMA should automatically increase alignment to CACHE_LINE_SIZE if doing so doesn't hurt slab efficiency. Do you see any downsides to doing that?

I think that's a good idea!

This revision was automatically updated to reflect the committed changes.