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
F103096058: D29522.id86659.diff
Wed, Nov 20, 10:22 PM
F103095990: D29522.id86663.diff
Wed, Nov 20, 10:21 PM
F103095985: D29522.id86647.diff
Wed, Nov 20, 10:21 PM
F103095930: D29522.id.diff
Wed, Nov 20, 10:20 PM
F103095929: D29522.id86657.diff
Wed, Nov 20, 10:20 PM
F103094855: D29522.diff
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
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