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.96) (envelope-from ) id 1vj2A8-004K0N-2R for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Jan 2026 21:24:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vj2A7-00Ep0R-2k for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Jan 2026 21:24:20 +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.96) (envelope-from ) id 1vj2A7-00Ep0J-1q for pgsql-hackers@lists.postgresql.org; Thu, 22 Jan 2026 21:24:19 +0000 Received: from mail-oa1-x34.google.com ([2001:4860:4864:20::34]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vj2A5-000000001Oy-39BZ for pgsql-hackers@postgresql.org; Thu, 22 Jan 2026 21:24:19 +0000 Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-404254ffe8aso873744fac.0 for ; Thu, 22 Jan 2026 13:24:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769117055; x=1769721855; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=IJlkzpzpp9aGTNBwWJaJgag9L7qGw+Ab192Fbl5mkcM=; b=JlmP31L7mElRumFBaecVxM3TIv7gZnNVBbRfMAC1sRDpBemicxBwLYl2oDQnaPZLCi 9KpCZH9/nkiKlmdvFj1k9oBcz9IHsBXPS3rDKLYaJyuSfOVGj7dRjt1bvY/8OinZBftC zgFu1t/n8Bh2j1SDGM8LIiwxUIarNCfPXnifnAZUiiBh+3BPVfiFdhFecxrqpwQXMvxN ibW5XB8MW964bLssIhmqcsa96vZgO8kV0L1iopvLs33ru87sqGhPJI2FoQoTSvVDHHDY +fM9apzLcGUIQ5d0Fk7DS3PUMESG7IxRWvUxOoDDXsAVAxkmmD1t7lwGioGeptYhxhxk y5JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769117055; x=1769721855; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IJlkzpzpp9aGTNBwWJaJgag9L7qGw+Ab192Fbl5mkcM=; b=qGEaySZYCqUoDE2ey7NCORd0mQElvPDUsR2SCqNEgF5DSPJM23kr2R9u0uu2N30x3b XkEoLO0qovJHNqJUhLwJrgj3cGI70aNW22Fi4P0E01gcIvzhnRkxbME1A+6qXhYUo0c/ /KMvV6PBGZzwzunaJ8BRB0doMxgaJ8fhruy1+u2c52JqCj7RWVwfdEDLPiCf74ZGuy2R 5FGCwFdnvTKWmvovB0mx2MtOjO7tJsYb3CGhZJzyuBVHBLGDMhhp6NxQuvX2Fv/M7b4i s3ETWFsdTEAJ8ZdRnABI4KtRY6fxi8Gfa5M//irBPdMFQruiquPXK2a7m0viZFY8x2JO 5cyw== X-Gm-Message-State: AOJu0Yw8t61dN1dvIUPsUVcurPI/BWjJoPWmxQE5oNBfWJFJRe8qoSY3 cW15NC4NuSHEm6Ni/VgrqeAqdhoa5l7i+h63nuMGjqd3XjYWQQC0eslV X-Gm-Gg: AZuq6aLtg2w9hzz/YSl2vVjCNLJnzWdqf9es/OpEN5XVPv96rXK3Li9KjOE5U+jEwOC MoDJ1xqati+MERQJh506zyFzYnKTa0KNYBEgVTYAoxEXZy/fF1GXQ5A9i4uEkuCwuGHXy4w8ynf FKJT2nLA7m7vcvsCcwgagPta9Q0Ecokcir5ADH0N2ry3HMBEVTFoUMQteOD4D1gKIbD2qexp4h2 wsVcR7G9OZeLnWWILIoe4YJIo3Xl4l4ymp9DVOtVwYRcHzPKGf1CZro00tTF/gQ52ISBKL2vPBv w0AXcdmjFm0W3PIaFqGGIYs/yst+HpqYhf7YE9iOGD3Z5NrYiUKnu5ku3RlBMn4gsFzxqgf4Uza WGYx1YqKoKoH8FHI4XbKJzZSv3RViqytJm5Gt6RkLii2F7x1Ltk9LbmfjnllMIpbZkDhE6aQPBL pnRScNXT4oZehLWCoXM9lMlY/Ad9K5MCtB6P7/ruSo8JLGMsN6H7ciBGGDTdGkkaY0xG292W+oy nJ1 X-Received: by 2002:a05:6870:2383:b0:3e0:bd2c:f459 with SMTP id 586e51a60fabf-408ac19fb08mr544263fac.12.1769117055631; Thu, 22 Jan 2026 13:24:15 -0800 (PST) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-408afc0a17bsm216435fac.19.2026.01.22.13.24.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jan 2026 13:24:15 -0800 (PST) Date: Thu, 22 Jan 2026 15:24:13 -0600 From: Nathan Bossart To: Anthonin Bonnefoy Cc: PostgreSQL Hackers Subject: Re: Fix rounding method used to compute huge pages Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Jan 22, 2026 at 05:42:44PM +0100, Anthonin Bonnefoy wrote: > When computing the dynamic value of shared_memory_size_in_huge_pages, > (1+size_b/hp_size) is currently used. This works when size_b is not > divisible by hp_size. However, it will yield an additional huge page > when size_b is divisible by hp_size. Oops, it looks like this is my fault. I doubt this causes any practical problems, but we might as well fix it. + if (size_b % hp_size != 0) + size_b = add_size(size_b, hp_size - (size_b % hp_size)); + hp_required = size_b / hp_size; I think we could simplify this a tad: hp_required = size_b / hp_size; if (size_b % hp_size != 0) hp_required = add_size(hp_required, 1); > 0002: This patch uses add_size in CreateAnonymousSegment when the > allocation size is rounded up, to check for possible overflow. Seems reasonable. -- nathan