Thread

  1. [PATCH v2] Make pg_numa_init() cope with Docker

    Christoph Berg <myon@debian.org> — 2025-10-16T11:24:56Z

    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--