Page MenuHomeFreeBSD

allocate inpcb aligned to cachelines
ClosedPublic

Authored by gallatin on Dec 13 2022, 8:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 23 2024, 11:33 PM
Unknown Object (File)
Feb 11 2024, 11:38 AM
Unknown Object (File)
Jan 24 2024, 4:59 AM
Unknown Object (File)
Dec 20 2023, 7:41 AM
Unknown Object (File)
Sep 20 2023, 12:55 PM
Unknown Object (File)
Aug 25 2023, 11:10 PM
Unknown Object (File)
Aug 25 2023, 11:09 PM
Unknown Object (File)
Aug 25 2023, 11:07 PM
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 Not Applicable
Unit
Tests Not Applicable

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.