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)
Wed, Nov 20, 10:22 PM
Unknown Object (File)
Wed, Nov 20, 10:21 PM
Unknown Object (File)
Wed, Nov 20, 10:21 PM
Unknown Object (File)
Wed, Nov 20, 10:20 PM
Unknown Object (File)
Wed, Nov 20, 10:20 PM
Unknown Object (File)
Wed, Nov 20, 9:57 PM
Unknown Object (File)
Oct 18 2024, 6:24 AM
Unknown Object (File)
Oct 4 2024, 12:32 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
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 38236
Build 35125: arc lint + arc unit

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