Fix incorrect comment in pg_get_shmem_allocations_numa()
Started by Bertrand Drouvot6 months ago2 messages
Hi hackers,
One comment in pg_get_shmem_allocations_numa() incorrectly describes the function
as dealing with database blocks when it actually processes shared memory allocations
from the shmem index.
PFA, a patch to $SUBJECT.
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
Attachments:
v1-0001-Fix-comment-in-pg_get_shmem_allocations_numa.patchtext/x-diff; charset=us-asciiDownload
From 59423c6a83ba69f00c929257f49faa79a19c8662 Mon Sep 17 00:00:00 2001
From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Date: Mon, 21 Jul 2025 08:08:23 +0000
Subject: [PATCH v1] Fix comment in pg_get_shmem_allocations_numa()
The comment incorrectly described the function as dealing with database
blocks when it actually processes shared memory allocations from the shmem
index.
---
src/backend/storage/ipc/shmem.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c
index ca3656fc76f..ff3a738c19c 100644
--- a/src/backend/storage/ipc/shmem.c
+++ b/src/backend/storage/ipc/shmem.c
@@ -606,16 +606,13 @@ pg_get_shmem_allocations_numa(PG_FUNCTION_ARGS)
nodes = palloc(sizeof(Size) * (max_nodes + 1));
/*
- * Different database block sizes (4kB, 8kB, ..., 32kB) can be used, while
- * the OS may have different memory page sizes.
+ * Shared memory allocations can vary in size and may not align with OS
+ * memory page boundaries, while NUMA queries work on pages.
*
- * To correctly map between them, we need to: 1. Determine the OS memory
- * page size 2. Calculate how many OS pages are used by all buffer blocks
- * 3. Calculate how many OS pages are contained within each database
- * block.
- *
- * This information is needed before calling move_pages() for NUMA memory
- * node inquiry.
+ * To correctly map each allocation to NUMA nodes, we need to: 1.
+ * Determine the OS memory page size. 2. Align each allocation's start/end
+ * addresses to page boundaries. 3. Query NUMA node information for all
+ * pages spanning the allocation.
*/
os_page_size = pg_get_shmem_pagesize();
--
2.34.1
Re: Fix incorrect comment in pg_get_shmem_allocations_numa()
On Mon, Jul 21, 2025 at 09:06:22AM +0000, Bertrand Drouvot wrote:
One comment in pg_get_shmem_allocations_numa() incorrectly describes the function
as dealing with database blocks when it actually processes shared memory allocations
from the shmem index.
(Noticed this one while browsing the CF app.)
Yep, agreed that the comment deserves a better explanation, so applied
down to v18.
--
Michael