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 1t6mDZ-00FSDo-Vx for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Nov 2024 07:37:14 +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 1t6mDY-00AqJm-5z for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Nov 2024 07:37:12 +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 1t6mDW-00AqJc-R1 for pgsql-hackers@lists.postgresql.org; Fri, 01 Nov 2024 07:37:12 +0000 Received: from fhigh-a6-smtp.messagingengine.com ([103.168.172.157]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t6mDT-0048xh-Mn for pgsql-hackers@lists.postgresql.org; Fri, 01 Nov 2024 07:37:10 +0000 Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfhigh.phl.internal (Postfix) with ESMTP id C490C1140136; Fri, 1 Nov 2024 03:37:05 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-10.internal (MEProxy); Fri, 01 Nov 2024 03:37:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; 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=fm3; t=1730446625; x=1730533025; bh=tewqNe3ZSR ML+4gYFQu/QzDCxayHjRTASEM2goixGMk=; b=RewuT2DFZQ0WbLXxuLmWTNSOnP R+L3fuXfzuvnLuExK+EU4GKeaWdUjgTpUAbaye58zY+aLcewgOsascJ9REu8T/0F ggkuavMmdRp7H1dKPaOps2RPVgd4xdbjKBGY5l18/rrrJOpEoEq4b9aNzYZK3P0m F/A4JRzVEK4El3P+pv46vUi2+ayN+jcL9J1+AkoMD0xR4gkRBNTDk194Ml58wwUT EURLpWIDu4hEKsfAucFNa2OeZva0lbXe7MFkA8gyJni66jwvQIvnzyHK1IDyKObj Vm7K5boPEDMiDC7S2qBH10cp1wYOIrS3wxyLXmFfy8tX+wN6nPbSBSzj71YQ== 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=fm3; t= 1730446625; x=1730533025; bh=tewqNe3ZSRML+4gYFQu/QzDCxayHjRTASEM 2goixGMk=; b=HwESybpiZ3iwAbz2pY3n3ZKedcIaagNseU0WkTZGNz/0sKZnx12 RAHH8HC6vw1wY/Y1osFDmNiBz8/AdU2GtFSFXqYcr8mZOuYdH/FxnNzZxMbvDNMp a+QPX+UAg5i7OdmTF4oCsxregxWcR+WoyLM6YtjTZu6HnlRbgxl28ENpcM6/EUnX wjPeEfBZ2iVdGkOoIZxcqqOgI2jm4xkL/MiceG4QMw4gVjoxjpD/HQpNAvOfpsNM YOrLp/my6JhSx3XILlGQocTFm01ffzrZVca0B2yWD/Zxr8Xz+natmcZdPnbEmp1M ajJJK/O/cXiOPaDCimS3AMWw0DT15UOSdrg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdekkedguddtjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenfghrlhcuvffnffculdejtddmnecujfgurhepfffhvfevuffk fhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrh cuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpeet leeifedufffhhfdtteelgeeggeffhfekueevteeigfduudevudetgfegiedvjeenucevlh hushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghl sehprghquhhivghrrdighiiipdhnsggprhgtphhtthhopeeipdhmohguvgepshhmthhpoh huthdprhgtphhtthhopegughhrohiflhgvhihmlhesghhmrghilhdrtghomhdprhgtphht thhopegsvghrthhrrghnuggurhhouhhvohhtrdhpghesghhmrghilhdrtghomhdprhgtph htthhopehsmhhithhhphgsvddvhedtsehgmhgrihhlrdgtohhmpdhrtghpthhtohepphgv thgvrhesvghishgvnhhtrhgruhhtrdhorhhgpdhrtghpthhtohephhhlihhnnhgrkhgrse hikhhirdhfihdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhp ohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 1 Nov 2024 03:37:03 -0400 (EDT) Date: Fri, 1 Nov 2024 16:36:45 +0900 From: Michael Paquier To: David Rowley Cc: Bertrand Drouvot , Peter Smith , Peter Eisentraut , Heikki Linnakangas , pgsql-hackers@lists.postgresql.org Subject: Re: define pg_structiszero(addr, s, r) Message-ID: References: <36371fab-f90c-427c-9c14-210e93e9cd12@eisentraut.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="/ASwScr+1E4aCu2h" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --/ASwScr+1E4aCu2h Content-Type: multipart/mixed; boundary="e/w6sn4FvaarzwQg" Content-Disposition: inline --e/w6sn4FvaarzwQg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Nov 01, 2024 at 08:21:50PM +1300, David Rowley wrote: > My vote is to just revert this usage of the function. Anything more > elaborate would need to check pointer alignment before using any types > larger than char. The previous code does not need to do that because > the page is going to be at least MAXALIGNed. Fine, here you go. The attached reverts back this part in bufpage.c to what it was in 49d6c7d8daba. -- Michael --e/w6sn4FvaarzwQg Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="bufpage-revert.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/storage/page/bufpage.c b/src/backend/storage/page/= bufpage.c index 5ee1e58cd4..be6f1f62d2 100644 --- a/src/backend/storage/page/bufpage.c +++ b/src/backend/storage/page/bufpage.c @@ -89,8 +89,10 @@ PageIsVerifiedExtended(Page page, BlockNumber blkno, int= flags) { PageHeader p =3D (PageHeader) page; size_t *pagebytes; + int i; bool checksum_failure =3D false; bool header_sane =3D false; + bool all_zeroes =3D false; uint16 checksum =3D 0; =20 /* @@ -124,9 +126,18 @@ PageIsVerifiedExtended(Page page, BlockNumber blkno, i= nt flags) } =20 /* Check all-zeroes case */ + all_zeroes =3D true; pagebytes =3D (size_t *) page; + for (i =3D 0; i < (BLCKSZ / sizeof(size_t)); i++) + { + if (pagebytes[i] !=3D 0) + { + all_zeroes =3D false; + break; + } + } =20 - if (pg_memory_is_all_zeros(pagebytes, (BLCKSZ / sizeof(size_t)))) + if (all_zeroes) return true; =20 /* --e/w6sn4FvaarzwQg-- --/ASwScr+1E4aCu2h Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmckhQ0ACgkQnvQgOdby QH06IxAAk3hzR0XfgluHOmcQsJquottRDF45+EevuL+tbdYEndW1FdZ+lUNlXWQO jmBX5crSKkdNjvgHXFJfVJw74aIcp0O4lcGnbRYUvHqxudG0/AEOXT0BoDeeC8f0 ykKK3JlhYTU0vSAE5Pg5wVTAB2qptdgJudFZUCNFRkQC18/wYSdw7FNeD2QLyzJs KZnN4Ip4b8mFHC9jMoSvCMfziRfF7RHU1/TKThX0nzNce0nfU1+mkH02sXlz3fTr GNx8ArzYIAdlQKZ7ziWH+iGKznfGLhBUQF+HzvZSXS6CTHkWLdldOLohOaSHuksK 4PqFg+4FfKpHdvtI4hgA4k6g3kIGzRM/0WSNhZu6lrxpcjo5b1lWGmLzewuXgkrp iWemKAyJ46HVdzLU4TO/LDTt9+yyRYKynvN2tE3CHV1LvzNARoFWSDKwJLklsFwN yvs7FY6WOnC0qyE8DAUsXGavggoPaAEVuWMrkrvcnMvpT/e9pld7H6msI73SEm8E VMUFjXhCT1BOjPR707VWHH8AZjAuxH8LHm5rcsuSxz7rAAWKLO3a2yZFq9I4bO83 W978n1Vxn6148Bnhb8/mxhx6BjaUobSXoQ9XoUwbGti/z9WvhrpDxC+mjVCtlWGU vls7P+74r09fKoREvDn+lLWX2nHnckMWNGys0iSSnbKBlAR9kY4= =DCcn -----END PGP SIGNATURE----- --/ASwScr+1E4aCu2h--