Page MenuHomeFreeBSD

tcp: Make hostcache.cache_count MPSAFE by using a counter_u64_t
ClosedPublic

Authored by rscheff on Mar 31 2021, 10:53 AM.
Tags
None
Referenced Files
F106643911: D29510.diff
Fri, Jan 3, 6:35 AM
Unknown Object (File)
Tue, Dec 17, 10:10 AM
Unknown Object (File)
Tue, Dec 17, 3:22 AM
Unknown Object (File)
Dec 4 2024, 6:09 AM
Unknown Object (File)
Nov 16 2024, 8:26 AM
Unknown Object (File)
Nov 12 2024, 2:31 AM
Unknown Object (File)
Nov 11 2024, 7:00 PM
Unknown Object (File)
Nov 11 2024, 6:43 PM
Subscribers

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 38209
Build 35098: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Mar 31 2021, 1:59 PM

FWIW, I disagree with this change. I think we should instead use atomic operations here.

Counters have the property that they are cheap to update, but expensive to read. Moreover, if you are doing a lot of reads, you will be pulling in cachelines from the per-CPU space into other CPUs (which is fine, but uses cache space).

For something which will be written often, but only read occasionally, counters are a big performance win. (Statistics, for example, are a great example of things for which counters are ideal.) For things which are read with any regularity (and, especially, from critical paths), atomics should perform better.

I suggest reverting this change and replacing it with atomic operations.

In D29510#661680, @jtl wrote:

FWIW, I disagree with this change. I think we should instead use atomic operations here.

Counters have the property that they are cheap to update, but expensive to read. Moreover, if you are doing a lot of reads, you will be pulling in cachelines from the per-CPU space into other CPUs (which is fine, but uses cache space).

For something which will be written often, but only read occasionally, counters are a big performance win. (Statistics, for example, are a great example of things for which counters are ideal.) For things which are read with any regularity (and, especially, from critical paths), atomics should perform better.

I suggest reverting this change and replacing it with atomic operations.

Thanks for the explanation. I actually suggested to Richard to use the counter API instead of atomic operations. So it is my mistake...