Page MenuHomeFreeBSD

uma: allow uma_zfree_pcu(..., NULL)
ClosedPublic

Authored by kp on Mar 10 2021, 3:40 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Mar 19, 8:58 PM
Unknown Object (File)
Tue, Mar 19, 8:58 PM
Unknown Object (File)
Tue, Mar 19, 8:58 PM
Unknown Object (File)
Tue, Mar 19, 8:45 PM
Unknown Object (File)
Feb 18 2024, 2:16 PM
Unknown Object (File)
Dec 25 2023, 4:51 AM
Unknown Object (File)
Dec 14 2023, 10:42 PM
Unknown Object (File)
Nov 27 2023, 3:34 AM
Subscribers

Details

Summary

We already allow free(NULL) and uma_zfree(..., NULL). Make
uma_zfree_pcpu(..., NULL) work as well.
This also means that counter_u64_free(NULL) will work.

These make cleanup code simpler.

MFC after: 1 week
Sponsored-by: Rubicon Communications, LLC ("Netgate")

Diff Detail

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

Event Timeline

kp requested review of this revision.Mar 10 2021, 3:40 PM

So the weird thing about pcpu pointers is that they're not pointers in the usual sense. We add some per-CPU offset to the value to get a real pointer. In fact, on amd64, zpcpu_get(NULL) will give a pointer with value &curthread. OTOH, uma_zalloc_pcpu() returns NULL to indicate failure, so I guess it should be ok to treat that value specially here too.

This revision is now accepted and ready to land.Mar 10 2021, 3:57 PM
This revision was automatically updated to reflect the committed changes.

They originally were pointers and counter_u64_free(NULL) worked. That was regressed with fb886947d97375ea9906fa1396f83573b6d0674b I think

They originally were pointers and counter_u64_free(NULL) worked. That was regressed with fb886947d97375ea9906fa1396f83573b6d0674b I think

We used to use plain uma_zalloc()/_zfree() with PCPU zones, so counter_u64_free(NULL) worked. There was a change to add dedicated KPIs for PCPU zones to reduce branching in the fast path, I believe this is where the behaviour changed. 4e180881ae4a325cfaeef336aa1a16b0d5bbae67