Re: Fix rounding method used to compute huge pages
| От | Anthonin Bonnefoy |
|---|---|
| Тема | Re: Fix rounding method used to compute huge pages |
| Дата | |
| Msg-id | CAO6_Xqp8NVAeNuDgWaMW_+AKHSQTC4nARbJVW23DkXT6KGh81Q@mail.gmail.com обсуждение исходный текст |
| Ответ на | Re: Fix rounding method used to compute huge pages (Michael Paquier <michael@paquier.xyz>) |
| Ответы |
Re: Fix rounding method used to compute huge pages
|
| Список | pgsql-hackers |
On Thu, Jan 22, 2026 at 10:24 PM Nathan Bossart <nathandbossart@gmail.com> wrote: > Oops, it looks like this is my fault. I doubt this causes any practical > problems, but we might as well fix it. Yeah, the chance of this being a problem is pretty low. > + 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); 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). 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.
В списке pgsql-hackers по дате отправления: