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)
Feb 6 2024, 9:02 PM
Unknown Object (File)
Jan 30 2024, 3:03 AM
Unknown Object (File)
Jan 30 2024, 2:58 AM
Unknown Object (File)
Jan 28 2024, 8:36 AM
Unknown Object (File)
Dec 25 2023, 12:01 PM
Unknown Object (File)
Dec 20 2023, 4:12 AM
Unknown Object (File)
Dec 12 2023, 9:55 AM
Unknown Object (File)
Dec 3 2023, 3:59 PM
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