aboutsummaryrefslogtreecommitdiff
path: root/src/include/utils/memutils_internal.h
diff options
context:
space:
mode:
authorDavid Rowley <drowley@postgresql.org>2024-04-07 23:32:00 +1200
committerDavid Rowley <drowley@postgresql.org>2024-04-07 23:32:00 +1200
commit0ba8b75e7ea6b7b3090c81239ebcb866772a624b (patch)
tree3015678f6979d3f4fff6dedf80fb0ff938ee273c /src/include/utils/memutils_internal.h
parentc4ab7da60617f020e8d75b1584d0754005d71830 (diff)
downloadpostgresql-0ba8b75e7ea6b7b3090c81239ebcb866772a624b.tar.gz
postgresql-0ba8b75e7ea6b7b3090c81239ebcb866772a624b.zip
Enlarge bit-space for MemoryContextMethodID
Reserve 4 bits for MemoryContextMethodID rather than 3. 3 bits did technically allow a maximum of 8 memory context types, however, we've opted to reserve some bit patterns which left us with only 4 slots, all of which were used. Here we add another bit which frees up 8 slots for future memory context types. In passing, adjust the enum names in MemoryContextMethodID to make it more clear which ones can be used and which ones are reserved. Author: Matthias van de Meent, David Rowley Discussion: https://postgr.es/m/CAApHDvqGSpCU95TmM=Bp=6xjL_nLys4zdZOpfNyWBk97Xrdj2w@mail.gmail.com
Diffstat (limited to 'src/include/utils/memutils_internal.h')
-rw-r--r--src/include/utils/memutils_internal.h18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/include/utils/memutils_internal.h b/src/include/utils/memutils_internal.h
index ad1048fd829..2d032611556 100644
--- a/src/include/utils/memutils_internal.h
+++ b/src/include/utils/memutils_internal.h
@@ -104,21 +104,29 @@ extern Size AlignedAllocGetChunkSpace(void *pointer);
*/
typedef enum MemoryContextMethodID
{
- MCTX_UNUSED1_ID, /* 000 occurs in never-used memory */
- MCTX_UNUSED2_ID, /* glibc malloc'd chunks usually match 001 */
- MCTX_UNUSED3_ID, /* glibc malloc'd chunks > 128kB match 010 */
+ MCTX_0_RESERVED_UNUSEDMEM_ID, /* 0000 occurs in never-used memory */
+ MCTX_1_RESERVED_GLIBC_ID, /* glibc malloc'd chunks usually match 0001 */
+ MCTX_2_RESERVED_GLIBC_ID, /* glibc malloc'd chunks > 128kB match 0010 */
MCTX_ASET_ID,
MCTX_GENERATION_ID,
MCTX_SLAB_ID,
MCTX_ALIGNED_REDIRECT_ID,
- MCTX_UNUSED4_ID, /* 111 occurs in wipe_mem'd memory */
+ MCTX_7_UNUSED_ID,
+ MCTX_8_UNUSED_ID,
+ MCTX_9_UNUSED_ID,
+ MCTX_10_UNUSED_ID,
+ MCTX_11_UNUSED_ID,
+ MCTX_12_UNUSED_ID,
+ MCTX_13_UNUSED_ID,
+ MCTX_14_UNUSED_ID,
+ MCTX_15_RESERVED_WIPEDMEM_ID /* 1111 occurs in wipe_mem'd memory */
} MemoryContextMethodID;
/*
* The number of bits that 8-byte memory chunk headers can use to encode the
* MemoryContextMethodID.
*/
-#define MEMORY_CONTEXT_METHODID_BITS 3
+#define MEMORY_CONTEXT_METHODID_BITS 4
#define MEMORY_CONTEXT_METHODID_MASK \
((((uint64) 1) << MEMORY_CONTEXT_METHODID_BITS) - 1)