| From: | Anthonin Bonnefoy <anthonin(dot)bonnefoy(at)datadoghq(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Fix rounding method used to compute huge pages |
| Date: | 2026-01-22 16:42:44 |
| Message-ID: | CAO6_Xqq2vZbva0R9eQSY0p2kfksX2aP4r=+Z_q1HBYNU=m8bBg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
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.
On CreateAnonymousSegment's side, the allocation size is rounded up to
the next required huge pages when necessary. However, there's no
overflow check when doing this round up.
0001: This patch replicates CreateAnonymousSegment's rounding method
to InitializeShmemGUCs, only rounding up when the value is not
divisible by hp_size.
0002: This patch uses add_size in CreateAnonymousSegment when the
allocation size is rounded up, to check for possible overflow.
Regards,
Anthonin Bonnefoy
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Fix-rounding-method-used-to-compute-shared_memory.patch | application/octet-stream | 1.3 KB |
| v1-0002-Check-for-overflow-when-rounding-up-allocsize.patch | application/octet-stream | 1.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bertrand Drouvot | 2026-01-22 16:45:31 | Re: Flush some statistics within running transactions |
| Previous Message | Tom Lane | 2026-01-22 16:35:16 | Re: Mystery with REVOKE PRIVILEGE |