Re: Fix rounding method used to compute huge pages - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Fix rounding method used to compute huge pages
Date
Msg-id aXKs_Y4NucBznm0j@paquier.xyz
Whole thread Raw
In response to Re: Fix rounding method used to compute huge pages  (Nathan Bossart <nathandbossart@gmail.com>)
Responses Re: Fix rounding method used to compute huge pages
List pgsql-hackers
On Thu, Jan 22, 2026 at 03:24:13PM -0600, Nathan Bossart wrote:
> Oops, it looks like this is my fault.  I doubt this causes any practical
> problems, but we might as well fix it.

And it's something I have committed.

> +        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);

FWIW, we have always been kind of sloppy with slightly overestimating
the shmem size required in the backend code, and here it's just a one.
I don't see a strong need for a backpatch here.  Of course, no
objections in adjusting that on HEAD.  Nathan, you are planning to
take care of that as original author?  This should fall under my
bucket as original committer, but as you were an author, feel free to
take priority here of course.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Sami Imseih
Date:
Subject: Re: Optional skipping of unchanged relations during ANALYZE?
Next
From: Chao Li
Date:
Subject: Re: Add WALRCV_CONNECTING state to walreceiver