#
cf907074 |
| 15-Jan-2025 |
Andrew Gallatin <gallatin@FreeBSD.org> |
Introduce the UMA_ZONE_NOTRIM uma zone type
The ktls buffer zone allocates 16k contiguous buffers, and often needs to call vm_page_reclaim_contig_domain_ext() to free up contiguous memory, which can
Introduce the UMA_ZONE_NOTRIM uma zone type
The ktls buffer zone allocates 16k contiguous buffers, and often needs to call vm_page_reclaim_contig_domain_ext() to free up contiguous memory, which can be expensive. Web servers which have a daily pattern of peaks and troughs end up having UMA trim the ktls_buffer_zone when they are in their trough, and end up re-building it on the way to their peak.
Rather than calling vm_page_reclaim_contig_domain_ext() multiple times on a daily basis, lets mark the ktls_buffer_zone with a new UMA flag, UMA_ZONE_NOTRIM. This disables UMA_RECLAIM_TRIM on the zone, but allows UMA_RECLAIM_DRAIN* operations, so that if we become extremely short of memory (vm_page_count_severe()), the uma reclaim worker can still free up memory.
Note that UMA_ZONE_UNMANAGED already exists, but can never be drained or trimmed, so it may hold on to memory during times of severe memory pressure. Using UMA_ZONE_NOTRIM rather than UMA_ZONE_UNMANAGED is an attempt to keep this zone more reactive in the face of severe memory pressure.
Sponsored by: Netflix Reviewed by: jhb, kib, markj (via slack) Differential Revision: https://reviews.freebsd.org/D48451
show more ...
|
Revision tags: release/14.2.0, release/13.4.0, release/14.1.0, release/13.3.0, release/14.0.0 |
|
#
733e0abd |
| 13-Oct-2023 |
Olivier Certner <olce.freebsd@certner.fr> |
uma: Permit specifying max of cache line and some custom alignment
To be used for structures for which we want to enforce that pointers to them have some number of lower bits always set to 0, while
uma: Permit specifying max of cache line and some custom alignment
To be used for structures for which we want to enforce that pointers to them have some number of lower bits always set to 0, while still ensuring we benefit from cache line alignment to avoid false sharing between structures and fields within the structures (provided they are properly ordered).
First candidate consumer that comes to mind is 'struct thread', see next commit.
Reviewed by: markj, kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D42265
show more ...
|
#
3d8f548b |
| 13-Oct-2023 |
Olivier Certner <olce.freebsd@certner.fr> |
uma: Make the cache alignment mask unsigned
In uma_set_align_mask(), ensure that the passed value doesn't have its highest bit set, which would lead to problems since keg/zone alignment is internall
uma: Make the cache alignment mask unsigned
In uma_set_align_mask(), ensure that the passed value doesn't have its highest bit set, which would lead to problems since keg/zone alignment is internally stored as signed integers. Such big values do not make sense anyway and indicate some programming error. A future commit will introduce checks for this case and other ones.
Reviewed by: kib, markj MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D42262
show more ...
|
#
e557eafe |
| 13-Oct-2023 |
Olivier Certner <olce.freebsd@certner.fr> |
uma: UMA_ALIGN_CACHE: Resolve the proper value at use point
Having a special value of -1 that is resolved internally to 'uma_align_cache' provides no significant advantages and prevents changing tha
uma: UMA_ALIGN_CACHE: Resolve the proper value at use point
Having a special value of -1 that is resolved internally to 'uma_align_cache' provides no significant advantages and prevents changing that variable to an unsigned type, which is natural for an alignment mask. So suppress it and replace its use with a call to uma_get_align_mask(). The small overhead of the added function call is irrelevant since UMA_ALIGN_CACHE is only used when creating new zones, which is not performance critical.
Reviewed by: markj, kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D42259
show more ...
|
#
dc8f7692 |
| 13-Oct-2023 |
Olivier Certner <olce.freebsd@certner.fr> |
uma: Hide 'uma_align_cache'; Create/rename accessors
Create the uma_get_cache_align_mask() accessor and put it in a separate private header so as to minimize namespace pollution in header/source fil
uma: Hide 'uma_align_cache'; Create/rename accessors
Create the uma_get_cache_align_mask() accessor and put it in a separate private header so as to minimize namespace pollution in header/source files that need only this function and not the whole 'uma.h' header.
Make sure the accessors have '_mask' as a suffix, so that callers are aware that the real alignment is the power of two that is the mask plus one. Rename the stem to something more explicit. Rename uma_set_cache_align_mask()'s single parameter to 'mask'.
Hide 'uma_align_cache' to ensure that it cannot be set in any other way then by a call to uma_set_cache_align_mask(), which will perform sanity checks in a further commit. While here, rename it to 'uma_cache_align_mask'.
This is also in preparation for some further changes, such as improving the sanity checks, eliminating internal resolving of UMA_ALIGN_CACHE and changing the type of the 'uma_cache_align_mask' variable.
Reviewed by: markj, kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D42258
show more ...
|
#
fc9f1d2c |
| 15-Oct-2023 |
Gordon Bergling <gbe@FreeBSD.org> |
uma.h: Fix a typo in a source code comment
- s/setable/settable/
MFC after: 3 days
|
#
95ee2897 |
| 16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
|
#
4d846d26 |
| 10-May-2023 |
Warner Losh <imp@FreeBSD.org> |
spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of
spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause.
Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
show more ...
|
Revision tags: release/13.2.0, release/12.4.0, release/13.1.0 |
|
#
389a3fa6 |
| 15-Feb-2022 |
Mark Johnston <markj@FreeBSD.org> |
uma: Add UMA_ZONE_UNMANAGED
Allow a zone to opt out of cache size management. In particular, uma_reclaim() and uma_reclaim_domain() will not reclaim any memory from the zone, nor will uma_timeout()
uma: Add UMA_ZONE_UNMANAGED
Allow a zone to opt out of cache size management. In particular, uma_reclaim() and uma_reclaim_domain() will not reclaim any memory from the zone, nor will uma_timeout() purge cached items if the zone is idle. This effectively means that the zone consumer has control over when items are reclaimed from the cache. In particular, uma_zone_reclaim() will still reclaim cached items from an unmanaged zone.
Reviewed by: hselasky, kib MFC after: 3 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34142
show more ...
|
Revision tags: release/12.3.0 |
|
#
a9d6f1fe |
| 20-Oct-2021 |
Mark Johnston <markj@FreeBSD.org> |
Remove some remaining references to VM_ALLOC_NOOBJ
Reviewed by: alc, kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32037
|
#
aabe13f1 |
| 14-Apr-2021 |
Mark Johnston <markj@FreeBSD.org> |
uma: Introduce per-domain reclamation functions
Make it possible to reclaim items from a specific NUMA domain.
- Add uma_zone_reclaim_domain() and uma_reclaim_domain(). - Permit parallel reclamatio
uma: Introduce per-domain reclamation functions
Make it possible to reclaim items from a specific NUMA domain.
- Add uma_zone_reclaim_domain() and uma_reclaim_domain(). - Permit parallel reclamations. Use a counter instead of a flag to synchronize with zone_dtor(). - Use the zone lock to protect cache_shrink() now that parallel reclaims can happen. - Add a sysctl that can be used to trigger reclamation from a specific domain.
Currently the new KPIs are unused, so there should be no functional change.
Reviewed by: mav MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29685
show more ...
|
#
09c8cb71 |
| 13-Apr-2021 |
Mark Johnston <markj@FreeBSD.org> |
uma: Add KASAN state transitions
- Add a UMA_ZONE_NOKASAN flag to indicate that items from a particular zone should not be sanitized. This is applied implicitly for NOFREE and cache zones. - Ad
uma: Add KASAN state transitions
- Add a UMA_ZONE_NOKASAN flag to indicate that items from a particular zone should not be sanitized. This is applied implicitly for NOFREE and cache zones. - Add KASAN call backs which get invoked: 1) when a slab is imported into a keg 2) when an item is allocated from a zone 3) when an item is freed to a zone 4) when a slab is freed back to the VM
In state transitions 1 and 3, memory is poisoned so that accesses will trigger a panic. In state transitions 2 and 4, memory is marked valid. - Disable trashing if KASAN is enabled. It just adds extra CPU overhead to catch problems that are detected by KASAN.
MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29456
show more ...
|
Revision tags: release/13.0.0 |
|
#
e574d407 |
| 06-Dec-2020 |
Mark Johnston <markj@FreeBSD.org> |
uma: Make uma_zone_set_maxcache() work better with small limits
The old implementation chose the largest bucket zone such that if the per-CPU caches are fully populated, the total number of items ca
uma: Make uma_zone_set_maxcache() work better with small limits
The old implementation chose the largest bucket zone such that if the per-CPU caches are fully populated, the total number of items cached is no larger than the specified limit. If no such zone existed, UMA would not do any caching.
We can now use uz_bucket_size_max to set a precise limit on the number of items in a zone's bucket, so the total size of per-CPU caches can be bounded more easily. Implement a new policy in uma_zone_set_maxcache(): choose a bucket size such that up to half of the limit can be cached in per-CPU caches, with the rest going to the full bucket cache. This fixes a problem with the kstack_cache zone: the limit of 4 * mp_ncpus items meant that the zone would not do any caching, defeating the whole purpose of the zone. That's because the smallest bucket size holds up to 2 items and we may cache up to 3 full buckets per CPU, and 2 * 3 * mp_ncpus > 4 * mp_ncpus.
Reported by: mjg Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D27168
show more ...
|
#
f8b6c515 |
| 06-Dec-2020 |
Mark Johnston <markj@FreeBSD.org> |
uma: Enforce the use of uz_bucket_size_max in the free path
uz_bucket_size_max is the maximum permitted bucket size. When filling a new bucket to satisfy uma_zalloc(), the bucket is populated with
uma: Enforce the use of uz_bucket_size_max in the free path
uz_bucket_size_max is the maximum permitted bucket size. When filling a new bucket to satisfy uma_zalloc(), the bucket is populated with at most uz_bucket_size_max items. The maximum number of entries in the bucket may be larger. When freeing items, however, we will fill per-CPPU buckets up to their maximum number of entries, potentially exceeding uz_bucket_size_max. This makes it difficult to precisely limit the number of items that may be cached in a zone. For example, if one wants to limit buckets to 1 entry for a particular zone, that's not possible since the smallest bucket holds up to 2 entries.
Try to solve the problem by using uz_bucket_size_max to limit the number of entries in a bucket. Note that the ub_entries field is initialized upon every bucket allocation. Most zones are not affected since they do not impose any specific limit on the maximum bucket size.
While here, remove the UMA_ZONE_MINBUCKET flag. It was unused and we now have uma_zone_set_maxcache() to control the zone's cache size more precisely.
Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D27167
show more ...
|
#
3a440a42 |
| 09-Nov-2020 |
Mateusz Guzik <mjg@FreeBSD.org> |
Add more per-cpu zones.
This covers powers of 2 up to 64.
Example pending user is ZFS.
|
#
2dee296a |
| 05-Nov-2020 |
Mateusz Guzik <mjg@FreeBSD.org> |
Rationalize per-cpu zones.
The 2 provided zones had inconsistent naming between each other ("int" and "64") and other allocator zones (which use bytes).
Follow malloc by naming them "pcpu-" + size
Rationalize per-cpu zones.
The 2 provided zones had inconsistent naming between each other ("int" and "64") and other allocator zones (which use bytes).
Follow malloc by naming them "pcpu-" + size in bytes.
This is a step towards replacing ad-hoc per-cpu zones with general slabs.
show more ...
|
Revision tags: release/12.2.0 |
|
#
c3aa3bf9 |
| 01-Sep-2020 |
Mateusz Guzik <mjg@FreeBSD.org> |
vm: clean up empty lines in .c and .h files
|
#
440cec3f |
| 12-Aug-2020 |
Glen Barber <gjb@FreeBSD.org> |
MFH
Sponsored by: Rubicon Communications, LLC (netgate.com)
|
#
e383ec74 |
| 06-Aug-2020 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r363739 through r363986.
|
#
96ad26ee |
| 04-Aug-2020 |
Mark Johnston <markj@FreeBSD.org> |
Remove free_domain() and uma_zfree_domain().
These functions were introduced before UMA started ensuring that freed memory gets placed in domain-local caches. They no longer serve any purpose since
Remove free_domain() and uma_zfree_domain().
These functions were introduced before UMA started ensuring that freed memory gets placed in domain-local caches. They no longer serve any purpose since UMA now provides their functionality by default. Remove them to simplyify the kernel memory allocator interfaces a bit.
Reviewed by: cem, kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D25937
show more ...
|
#
c8b0a88b |
| 20-Jun-2020 |
Jeff Roberson <jeff@FreeBSD.org> |
Clarify some language. Favor primary where both master and primary were used in conjunction with secondary.
|
Revision tags: release/11.4.0 |
|
#
5d25f943 |
| 23-Feb-2020 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r358239 through r358262.
|
#
0464f16e |
| 22-Feb-2020 |
Mark Johnston <markj@FreeBSD.org> |
Constify uma_zcache_create() and uma_zsecond_create()'s "name" argument.
It is already internally handled as a pointer to a const string, in particular by uma_zcreate().
Fix indentation while here.
Constify uma_zcache_create() and uma_zsecond_create()'s "name" argument.
It is already internally handled as a pointer to a const string, in particular by uma_zcreate().
Fix indentation while here.
MFC after: 1 week
show more ...
|
#
3c4ad300 |
| 17-Feb-2020 |
Dimitry Andric <dim@FreeBSD.org> |
Merge ^/head r358000 through r358048.
|
#
ed581bf6 |
| 17-Feb-2020 |
Jeff Roberson <jeff@FreeBSD.org> |
Add a simple accessor that returns the bytes of memory consumed by a zone.
|