Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vDlVV-00FPO6-M8 for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Oct 2025 15:21:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1vDlVU-00DeDc-K1 for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Oct 2025 15:21:07 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vDlVU-00DeDU-A7 for pgsql-hackers@lists.postgresql.org; Tue, 28 Oct 2025 15:21:07 +0000 Received: from mout-p-102.mailbox.org ([80.241.56.152]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vDlVO-004E5k-0D for pgsql-hackers@lists.postgresql.org; Tue, 28 Oct 2025 15:21:06 +0000 Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4cwvGC2F3pz9sq6; Tue, 28 Oct 2025 16:20:51 +0100 (CET) Date: Tue, 28 Oct 2025 16:20:50 +0100 From: Christoph Berg To: Tomas Vondra Cc: Jakub Wartak , pgsql-hackers@lists.postgresql.org Subject: Re: failed NUMA pages inquiry status: Operation not permitted Message-ID: References: <7bbc582b-cc70-4a6f-bbf2-b5fd9b13a867@vondra.me> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="J3H232Pne8aWMmeW" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --J3H232Pne8aWMmeW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --J3H232Pne8aWMmeW Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0001-Make-pg_numa_init-cope-with-Docker.patch" From 0b0088145b42a4316fb15a0ea4363bbebfabdfd7 Mon Sep 17 00:00:00 2001 From: Christoph Berg 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.c index 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 --J3H232Pne8aWMmeW--