1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-18 02:19:39 +00:00

malloc(9): Introduce M_NEVERFREED

This patch adds an additional malloc(9) flag to distinguish allocations
that are never freed during runtime.

Differential Revision:	https://reviews.freebsd.org/D45045
Reviewed by:	alc, kib, markj
Tested by:	alc
This commit is contained in:
Bojan Novković 2024-05-03 20:18:56 +02:00
parent 2204a48290
commit 78f3e0f6b3
2 changed files with 5 additions and 1 deletions

View File

@ -60,8 +60,9 @@
#define M_BESTFIT 0x2000 /* only for vmem, low fragmentation */
#define M_EXEC 0x4000 /* allocate executable space */
#define M_NEXTFIT 0x8000 /* only for vmem, follow cursor */
#define M_NEVERFREED 0x10000 /* chunk will never get freed */
#define M_VERSION 2020110501
#define M_VERSION 2024073001
/*
* Two malloc type structures are present: malloc_type, which is used by a

View File

@ -1791,6 +1791,9 @@ keg_alloc_slab(uma_keg_t keg, uma_zone_t zone, int domain, int flags,
if (keg->uk_flags & UMA_ZONE_NODUMP)
aflags |= M_NODUMP;
if (keg->uk_flags & UMA_ZONE_NOFREE)
aflags |= M_NEVERFREED;
/* zone is passed for legacy reasons. */
size = keg->uk_ppera * PAGE_SIZE;
mem = keg->uk_allocf(zone, size, domain, &sflags, aflags);