Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit699b1f4

Browse files
committed
Fix thinko in huge_tlb_pages patch.
We calculated the rounded-up size for the allocation, but then failed touse the rounded-up value in the mmap() call. Oops.Also, initialize allocsize, to silence warnings seen with some compilers,as pointed out by Jeff Janes.
1 parent626a120 commit699b1f4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

‎src/backend/port/sysv_shmem.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ PGSharedMemoryIsInUse(unsigned long id1, unsigned long id2)
329329
staticvoid*
330330
CreateAnonymousSegment(Size*size)
331331
{
332-
Sizeallocsize;
332+
Sizeallocsize=*size;
333333
void*ptr=MAP_FAILED;
334334

335335
#ifndefMAP_HUGETLB
@@ -358,11 +358,10 @@ CreateAnonymousSegment(Size *size)
358358
*/
359359
inthugepagesize=2*1024*1024;
360360

361-
allocsize=*size;
362361
if (allocsize %hugepagesize!=0)
363362
allocsize+=hugepagesize- (allocsize %hugepagesize);
364363

365-
ptr=mmap(NULL,*size,PROT_READ |PROT_WRITE,
364+
ptr=mmap(NULL,allocsize,PROT_READ |PROT_WRITE,
366365
PG_MMAP_FLAGS |MAP_HUGETLB,-1,0);
367366
if (huge_tlb_pages==HUGE_TLB_TRY&&ptr==MAP_FAILED)
368367
elog(DEBUG1,"mmap with MAP_HUGETLB failed, huge pages disabled: %m");
@@ -372,8 +371,12 @@ CreateAnonymousSegment(Size *size)
372371
if (huge_tlb_pages==HUGE_TLB_OFF||
373372
(huge_tlb_pages==HUGE_TLB_TRY&&ptr==MAP_FAILED))
374373
{
374+
/*
375+
* use the original size, not the rounded up value, when falling
376+
* back to non-huge pages.
377+
*/
375378
allocsize=*size;
376-
ptr=mmap(NULL,*size,PROT_READ |PROT_WRITE,PG_MMAP_FLAGS,-1,0);
379+
ptr=mmap(NULL,allocsize,PROT_READ |PROT_WRITE,PG_MMAP_FLAGS,-1,0);
377380
}
378381

379382
if (ptr==MAP_FAILED)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp