public inbox for [email protected]  
help / color / mirror / Atom feed
From: Nathan Bossart <[email protected]>
To: Anthonin Bonnefoy <[email protected]>
Cc: Michael Paquier <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Fix rounding method used to compute huge pages
Date: Fri, 23 Jan 2026 10:49:16 -0600
Message-ID: <aXOmjM69GVTbzhGE@nathan> (raw)
In-Reply-To: <CAO6_Xqp8NVAeNuDgWaMW_+AKHSQTC4nARbJVW23DkXT6KGh81Q@mail.gmail.com>
References: <CAO6_Xqq2vZbva0R9eQSY0p2kfksX2aP4r=+Z_q1HBYNU=m8bBg@mail.gmail.com>
	<aXKVfaTntXRn1V0m@nathan>
	<[email protected]>
	<aXKuUOhBzjb6ovtz@nathan>
	<[email protected]>
	<CAO6_Xqp8NVAeNuDgWaMW_+AKHSQTC4nARbJVW23DkXT6KGh81Q@mail.gmail.com>

Committed.

On Fri, Jan 23, 2026 at 09:21:53AM +0100, Anthonin Bonnefoy wrote:
> From my understanding, 'add_size(hp_required, 1)' will never overflow
> since size_b was checked for overflow, and hp_size should always be >1
> (except if huge pages of 1 byte exist somewhere).

That's true, but for this sort of thing, I usually prefer to avoid relying
on those kinds of assumptions to reason about the correctness of the code.
The overflow check costs little, and IIUC this function is run exactly once
for the lifetime of the server.

> For consistency with CreateAnonymousSegment, using 'add_size(size_b,
> hp_size - (size_b % hp_size))' will also check that the final
> requested allocation doesn't overflow.

*shrug*  I don't see a strong reason for consistency here.  AFAICT you'd
have to be trying to allocate something like 18 exabytes on most systems
for there to be a problem, at which point there are probably bigger issues
to sort out.

Thanks for the patch!

-- 
nathan






view thread (7+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Fix rounding method used to compute huge pages
  In-Reply-To: <aXOmjM69GVTbzhGE@nathan>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox