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
F103429929: D29522.diff
Sun, Nov 24, 10:26 PM
Unknown Object (File)
Fri, Nov 22, 6:58 AM
Unknown Object (File)
Fri, Nov 22, 6:31 AM
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
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