Page MenuHomeFreeBSD

tcp: For hostcache performance, use atomics instead of counters
ClosedPublic

Authored by rscheff on Mar 31 2021, 10:29 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 18, 6:24 AM
Unknown Object (File)
Oct 4 2024, 12:32 AM
Unknown Object (File)
Oct 1 2024, 2:10 PM
Unknown Object (File)
Oct 1 2024, 5:45 AM
Unknown Object (File)
Sep 30 2024, 12:12 PM
Unknown Object (File)
Sep 28 2024, 7:36 PM
Unknown Object (File)
Sep 27 2024, 6:46 PM
Unknown Object (File)
Sep 27 2024, 7:53 AM
Subscribers

Details

Summary

As accessing the tcp hostcache happens frequently on some
classes of servers, it was recommended to use atomic_add/subtract
rather than (per-CPU distributed) counters, which have to be
summed up at high cost to cache efficiency.

This eliminates a counter_u64_fetch() from a hot path, introduced
by D29510.

PR: 254333
MFC after: 2 weeks
Sponsored by: NetApp, Inc.

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.Mar 31 2021, 10:50 PM

Thanks for doing this so quickly!

sys/netinet/tcp_hostcache.c
377

I think you need an atomic_load_int() here.

643–644

I think you need an atomic_load_int() here, although I don't think it functionally probably matters too much. In fact, this code already allows races between when the sysctl function is called to get the length, and when the code is called with another buffer. But, it seems like it is probably good to be consistent in using the atomic* functions to access or set atomic variables.

rscheff marked 2 inline comments as done.
  • use atomic access wrapper functions throughout
This revision now requires review to proceed.Apr 1 2021, 7:19 AM
sys/netinet/tcp_hostcache.c
644

Please put the operator at the end of the previous line.

655

Please put the operator at the end of the previous line.

  • move operator to end of line at wrap
This revision is now accepted and ready to land.Apr 1 2021, 7:51 AM