From 9d84396d22c5484fa84934e29eb70a34aaf353aa Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Tue, 26 May 2026 18:12:28 -0400 Subject: [PATCH v2 3/3] Fix spurious valgrind errors within NUMA views Author: Reviewed-by: Discussion: https://postgr.es/m/ Backpatch-through: --- src/include/port/pg_numa.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/include/port/pg_numa.h b/src/include/port/pg_numa.h index 1b668fe1d91..fca9f1318db 100644 --- a/src/include/port/pg_numa.h +++ b/src/include/port/pg_numa.h @@ -20,6 +20,8 @@ extern PGDLLIMPORT int pg_numa_get_max_node(void); #ifdef USE_LIBNUMA +#include "utils/memdebug.h" + /* * This is required on Linux, before pg_numa_query_pages() as we * need to page-fault before move_pages(2) syscall returns valid results. @@ -29,6 +31,14 @@ pg_numa_touch_mem_if_required(void *ptr) { volatile uint64 touch pg_attribute_unused(); + /* + * Other annotations, like in UnpinBufferNoOwner(), might have made this + * inaccessible. We don't know what the state is, so we can't restore the + * prior state afterwards. That seems ok, this isn't used commonly while + * other things are going on. + */ + PG_ANNOTATE_MEM_DEFINED(ptr, sizeof(uint64)); + touch = *(volatile uint64 *) ptr; } -- 2.54.0.450.g9ac3f193c0