Date: Tue, 30 Jul 2024 15:38:44 GMT From: Bojan =?utf-8?Q?Novkovi=C4=87?= <bnovkov@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 78f3e0f6b3ad - main - malloc(9): Introduce M_NEVERFREED Message-ID: <202407301538.46UFciDs049498@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by bnovkov: URL: https://cgit.FreeBSD.org/src/commit/?id=78f3e0f6b3ad70d9574730fc3338474376ef8ebd commit 78f3e0f6b3ad70d9574730fc3338474376ef8ebd Author: Bojan Novković <bnovkov@FreeBSD.org> AuthorDate: 2024-05-03 18:18:56 +0000 Commit: Bojan Novković <bnovkov@FreeBSD.org> CommitDate: 2024-07-30 15:38:18 +0000 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 --- sys/sys/malloc.h | 3 ++- sys/vm/uma_core.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h index dfd7928fc258..9b281da4b4d4 100644 --- a/sys/sys/malloc.h +++ b/sys/sys/malloc.h @@ -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 diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c index 516ac2c2965a..e93c561d759a 100644 --- a/sys/vm/uma_core.c +++ b/sys/vm/uma_core.c @@ -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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202407301538.46UFciDs049498>