From: Christoph Berg <myon@debian.org>
To: Tomas Vondra <tomas@vondra.me>
Cc: Jakub Wartak <jakub.wartak@enterprisedb.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: failed NUMA pages inquiry status: Operation not permitted
Date: Tue, 28 Oct 2025 16:20:50 +0100
Message-ID: <aQDfUo7pkcfUSCod@msg.df7cb.de> (raw)
In-Reply-To: <aPENGAkcrLyB_NLC@msg.df7cb.de>
References: <E1u1tr8-003BbN-2E@gemulon.postgresql.org>
<aPDZOxjrmEo_1JRG@msg.df7cb.de>
<7bbc582b-cc70-4a6f-bbf2-b5fd9b13a867@vondra.me>
<aPEHINwaAxsQNAIP@msg.df7cb.de>
<aPEJ7yH7ZJAF_MYW@msg.df7cb.de>
<aPENGAkcrLyB_NLC@msg.df7cb.de>
Re: To Tomas Vondra
> So maybe PG should implement numa_available itself like that.
Following our discussion at pgconf.eu last week, I just implemented
that. The numa and pg_buffercache tests pass in Docker on Debian
bookworm now.
Christoph
Attachments:v2-0001-Make-pg_numa_init-cope-with-Docker.patch (text/x-diff, 1.4K) download
From 0b0088145b42a4316fb15a0ea4363bbebfabdfd7 Mon Sep 17 00:00:00 2001
From: Christoph Berg <myon@debian.org>
Date: Thu, 16 Oct 2025 13:24:56 +0200
Subject: [PATCH v2] Make pg_numa_init() cope with Docker
In seccomp-restricted environments like Docker, numactl versions before
2.0.19 would not properly catch EPERM. As the numa_available()
implementation is very short, just inline in here with the proper fix.
Upstream fix: https://github.com/numactl/numactl/commit/0ab9c7a0d857bea1724139c48e2e58ed6a81647f
---
src/port/pg_numa.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/port/pg_numa.c b/src/port/pg_numa.cindex 3368a43a338..932099be1e5 100644--- a/src/port/pg_numa.c+++ b/src/port/pg_numa.c@@ -43,13 +43,20 @@
#define NUMA_QUERY_CHUNK_SIZE 1024
#endif
-/* libnuma requires initialization as per numa(3) on Linux */+/*+ * libnuma requires initialization as per numa(3) on Linux.+ *+ * This should ideally just return numa_available(), but numactl versions+ * before 2.0.19 ignored EPERM from get_mempolicy(), leading to ugly error+ * messages when used in seccomp-restricted environments like Docker. We just+ * inline the 2.0.19 version of numa_available() here.+ */
int
pg_numa_init(void)
{
- int r = numa_available();-- return r;+ if (get_mempolicy(NULL, NULL, 0, 0, 0) < 0 && (errno == ENOSYS || errno == EPERM))+ return -1;+ return 0;
}
/*
--
2.39.5
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: myon@debian.org, tomas@vondra.me, jakub.wartak@enterprisedb.com, pgsql-hackers@lists.postgresql.org
Subject: Re: failed NUMA pages inquiry status: Operation not permitted
In-Reply-To: <aQDfUo7pkcfUSCod@msg.df7cb.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox