huge_pages_log_v10.diff
application/octet-stream
Filename: huge_pages_log_v10.diff
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
Series: patch v10
| File | + | − |
|---|---|---|
| src/backend/port/sysv_shmem.c | 18 | 3 |
| src/backend/port/win32_shmem.c | 9 | 0 |
diff --git a/src/backend/port/sysv_shmem.c b/src/backend/port/sysv_shmem.c
index e7474ce..9b221d9 100644
--- a/src/backend/port/sysv_shmem.c
+++ b/src/backend/port/sysv_shmem.c
@@ -587,6 +587,7 @@ CreateAnonymousSegment(Size *size)
Size allocsize = *size;
void *ptr = MAP_FAILED;
int mmap_errno = 0;
+ bool with_hugepages = false;
#ifndef MAP_HUGETLB
/* PGSharedMemoryCreate should have dealt with this case */
@@ -608,9 +609,14 @@ CreateAnonymousSegment(Size *size)
ptr = mmap(NULL, allocsize, PROT_READ | PROT_WRITE,
PG_MMAP_FLAGS | mmap_flags, -1, 0);
mmap_errno = errno;
- if (huge_pages == HUGE_PAGES_TRY && ptr == MAP_FAILED)
- elog(DEBUG1, "mmap(%zu) with MAP_HUGETLB failed, huge pages disabled: %m",
- allocsize);
+ if (ptr == MAP_FAILED)
+ {
+ if (huge_pages == HUGE_PAGES_TRY)
+ elog(DEBUG1, "mmap(%zu) with MAP_HUGETLB failed, huge pages disabled: %m",
+ allocsize);
+ }
+ else
+ with_hugepages = true;
}
#endif
@@ -639,6 +645,15 @@ CreateAnonymousSegment(Size *size)
"memory usage, perhaps by reducing shared_buffers or "
"max_connections.",
allocsize) : 0));
+ }
+
+ if (huge_pages == HUGE_PAGES_TRY && IsPostmasterEnvironment)
+ {
+ if (with_hugepages)
+ ereport(LOG, errmsg("anonymous shared memory was allocated with huge pages"));
+ else
+ ereport(LOG, errmsg("anonymous shared memory was allocated without huge pages"),
+ errhint("The amount of memory requested for huge pages is %zu bytes.", allocsize));
}
*size = allocsize;
diff --git a/src/backend/port/win32_shmem.c b/src/backend/port/win32_shmem.c
index 64fde8d..41a082a 100644
--- a/src/backend/port/win32_shmem.c
+++ b/src/backend/port/win32_shmem.c
@@ -390,6 +390,15 @@ retry:
/* Register on-exit routine to delete the new segment */
on_shmem_exit(pgwin32_SharedMemoryDelete, PointerGetDatum(hmap2));
+ if (huge_pages == HUGE_PAGES_TRY && IsPostmasterEnvironment)
+ {
+ if (flProtect & SEC_LARGE_PAGES)
+ ereport(LOG, errmsg("anonymous shared memory was allocated with huge pages"));
+ else
+ ereport(LOG, errmsg("anonymous shared memory was allocated without huge pages"),
+ errhint("The amount of memory requested for huge pages is %zu bytes.", size));
+ }
+
*shim = hdr;
return hdr;
}