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 1uTiNX-008g2e-Ic for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Jun 2025 14:42:35 +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 1uTiNV-003fU9-La for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Jun 2025 14:42:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uTiNV-003fU1-An for pgsql-hackers@lists.postgresql.org; Mon, 23 Jun 2025 14:42:34 +0000 Received: from mout-p-102.mailbox.org ([80.241.56.152]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uTiNT-003ehU-28 for pgsql-hackers@lists.postgresql.org; Mon, 23 Jun 2025 14:42:33 +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 4bQrQW09m9z9skk; Mon, 23 Jun 2025 16:42:27 +0200 (CEST) Date: Mon, 23 Jun 2025 16:42:26 +0200 From: Christoph Berg To: Tomas Vondra Cc: pgsql-hackers@lists.postgresql.org Subject: Re: pgsql: Introduce pg_shmem_allocations_numa view Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="p321qshW2LpuyTKe" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --p321qshW2LpuyTKe Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Re: To Tomas Vondra > This is acting up on Debian's 32-bit architectures, namely i386, armel > and armhf: ... and x32 (x86_64 instruction set with 32-bit pointers). > SELECT COUNT(*) >= 0 AS ok FROM pg_shmem_allocations_numa; > +ERROR: invalid NUMA node id outside of allowed range [0, 0]: -14 > > -14 seems to be -EFAULT, and move_pages(2) says: > -EFAULT > This is a zero page or the memory area is not mapped by the process. I did some debugging on i386 and made it print the page numbers: SELECT COUNT(*) >= 0 AS ok FROM pg_shmem_allocations_numa; +WARNING: invalid NUMA node id outside of allowed range [0, 0]: -14 for page 35 +WARNING: invalid NUMA node id outside of allowed range [0, 0]: -14 for page 36 ... +WARNING: invalid NUMA node id outside of allowed range [0, 0]: -14 for page 32768 +WARNING: invalid NUMA node id outside of allowed range [0, 0]: -14 for page 32769 So it works for the first few pages and then the rest is EFAULT. I think the pg_numa_touch_mem_if_required() hack might not be enough to force the pages to be allocated. Changing that to a memcpy() didn't help. Is there some optimization that zero pages aren't allocated until being written to? Why do we try to force the pages to be allocated at all? This is just a monitoring function, it should not change the actual system state. Why not just skip any page where the status is <0 ? The attached patch removes that logic. Regression tests pass, but we probably have to think about whether to report these negative numbers as-is or perhaps convert them to NULL. Christoph --p321qshW2LpuyTKe Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Don-t-force-allocate-pages-for-pg_get_shmem_allocati.patch"