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 1uU1YI-00EDFv-EF for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Jun 2025 11:10:58 +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 1uU1YG-00BWff-IO for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Jun 2025 11:10:57 +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 1uU1YF-00BWfC-MO for pgsql-hackers@lists.postgresql.org; Tue, 24 Jun 2025 11:10:56 +0000 Received: from fout-a8-smtp.messagingengine.com ([103.168.172.151]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1uU1YD-003iZz-3D for pgsql-hackers@lists.postgresql.org; Tue, 24 Jun 2025 11:10:55 +0000 Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id BED021380D87; Tue, 24 Jun 2025 07:10:52 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Tue, 24 Jun 2025 07:10:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1750763452; x=1750849852; bh=Q/7djbDiqb ODDMR3y0ysvchRYlwNuPAgD4HwkPs/6Us=; b=X8GtIB0kbw4QxxdcuFM9tf147a TnztddD3J0N1jzaqr9Rg9a7ldnMlYuWq6twvp5taCRHAZp8s/5ZSwIDf4Jnk5TJA FDVA4bLtf0H0CgCFT1qwgL7y6KQ4zEZhObFi41MCW+LpKjZFDsEfn9yzrXx0H4mr ua9nSk3PkLusTgU5CmRIK9wcuVHTQhwBNKQuA2PEsi75e8mLSlZxBlAM/2FmIQrw pXnPUR5qEB/tKS1qJzhUqfeVpB+uvVYWckXSDcEWIK6tumRaHNaQs4Bjx+bsOgqd srZZq/4qWwPH/GNMz8WM+8NHP00+WchL8ctotj0Ew81gKwhTiFtaUkYiEZuw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1750763452; x=1750849852; bh=Q/7djbDiqbODDMR3y0ysvchRYlwNuPAgD4H wkPs/6Us=; b=BKEbL/ynebkgR3fR6ipw5Npcp1aBcoNZgigYhM0dc4bQx4GeWag YkXxRjif/pelL6210rgtYVqnw1kDLR4ZBA4zPrBPaGiVfU9L2OhDHlWHZiMDZVcV CTGWpboQ/tjU3RBmauNm60wjnPUxMJxrWbusEdz0WELZmIW64lKJUwEZycnuagKk 1C9AaTGBkysfSusk0noG39KdwHkQPe5/MjVCJvlu0gOA2uaBl1HK0KN+XBp2yxTr D2ZI1xoKqwQth596VNka68eItyxSyz9BX54frbEm4o1ibauqbFWQZBEm2/33LqlF X5YULmu+NUEtISmHdxM8Py9dVX716pTx7Iw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddvgdduleejfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpeffhffvvefukfhfgggtuggjsehttdfstddttddvnecuhfhrohhmpeetnhgurhgvshcu hfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrghtth gvrhhnpeeffffgledvffegtdevlefgtdeggffhvdekgfegteeiveejkeetudelveejhfeu geenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnh gurhgvshesrghnrghrrgiivghlrdguvgdpnhgspghrtghpthhtohepgedpmhhouggvpehs mhhtphhouhhtpdhrtghpthhtohepmhihohhnseguvggsihgrnhdrohhrghdprhgtphhtth hopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhr ghdprhgtphhtthhopehtohhmrghsrdhvohhnughrrgesphhoshhtghhrvghsqhhlrdhorh hgpdhrtghpthhtohepthhomhgrshesvhhonhgurhgrrdhmvg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 24 Jun 2025 07:10:52 -0400 (EDT) Date: Tue, 24 Jun 2025 07:10:50 -0400 From: Andres Freund To: Tomas Vondra Cc: Christoph Berg , Tomas Vondra , pgsql-hackers@lists.postgresql.org Subject: Re: pgsql: Introduce pg_shmem_allocations_numa view Message-ID: References: <6c9f9f7e-947b-4fc3-bdb6-b0696d7492e5@vondra.me> <0643ae61-cf9d-482c-9b2c-fb861b24fd22@vondra.me> <6342f601-77de-4ee0-8c2a-3deb50ceac5b@vondra.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6342f601-77de-4ee0-8c2a-3deb50ceac5b@vondra.me> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2025-06-24 03:43:19 +0200, Tomas Vondra wrote: > FWIW while looking into this, I tried running this under valgrind (on a > regular 64-bit system, not in the chroot), and I get this report: > > ==65065== Invalid read of size 8 > ==65065== at 0x113B0EBE: pg_buffercache_numa_pages > (pg_buffercache_pages.c:380) > ==65065== by 0x6B539D: ExecMakeTableFunctionResult (execSRF.c:234) > ==65065== by 0x6CEB7E: FunctionNext (nodeFunctionscan.c:94) > ==65065== by 0x6B6ACA: ExecScanFetch (execScan.h:126) > ==65065== by 0x6B6B31: ExecScanExtended (execScan.h:170) > ==65065== by 0x6B6C9D: ExecScan (execScan.c:59) > ==65065== by 0x6CEF0F: ExecFunctionScan (nodeFunctionscan.c:269) > ==65065== by 0x6B29FA: ExecProcNodeFirst (execProcnode.c:469) > ==65065== by 0x6A6F56: ExecProcNode (executor.h:313) > ==65065== by 0x6A9533: ExecutePlan (execMain.c:1679) > ==65065== by 0x6A7422: standard_ExecutorRun (execMain.c:367) > ==65065== by 0x6A7330: ExecutorRun (execMain.c:304) > ==65065== by 0x934EF0: PortalRunSelect (pquery.c:921) > ==65065== by 0x934BD8: PortalRun (pquery.c:765) > ==65065== by 0x92E4CD: exec_simple_query (postgres.c:1273) > ==65065== by 0x93301E: PostgresMain (postgres.c:4766) > ==65065== by 0x92A88B: BackendMain (backend_startup.c:124) > ==65065== by 0x85A7C7: postmaster_child_launch (launch_backend.c:290) > ==65065== by 0x860111: BackendStartup (postmaster.c:3580) > ==65065== by 0x85DE6F: ServerLoop (postmaster.c:1702) > ==65065== Address 0x7b6c000 is in a rw- anonymous segment > > > This fails here (on the pg_numa_touch_mem_if_required call): > > for (char *ptr = startptr; ptr < endptr; ptr += os_page_size) > { > os_page_ptrs[idx++] = ptr; > > /* Only need to touch memory once per backend process */ > if (firstNumaTouch) > pg_numa_touch_mem_if_required(touch, ptr); > } That's because we mark unpinned pages as inaccessible / mark them as accessible when pinning. See logic related to that in PinBuffer(): /* * Assume that we acquired a buffer pin for the purposes of * Valgrind buffer client checks (even in !result case) to * keep things simple. Buffers that are unsafe to access are * not generally guaranteed to be marked undefined or * non-accessible in any case. */ > The 0x7b6c000 is the very first pointer, and it's the only pointer that > triggers this warning. I suspect that that's because valgrind combines different reports or such. Greetings, Andres Freund