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

Commitfdd8937

Browse files
committed
Fix huge_pages on Windows
Since Windows 10 1703, it is additionally necessary to pass a flagcalled FILE_MAP_LARGE_PAGES to MapViewOfFile() to enable large pages atmap time. This flag is ignored on older versions of Windows, wherelarge pages should still be able to work properly without setting it.Note that the flag would be set only for binaries that knew about it atcompile-time, which should be more or less all the Windows environmentsthese days.Since495ed0e, Windows 10 is the minimum version of Windows supported byPostgres, making this change easy to reason about on HEAD. Perdiscussion, no backpatch is done for the moment.Reported-by: Okano NaokiAuthor: Thomas MunroReviewed-by: Tom Lane, Michael Paquier, Julien RouhaudDiscussion:https://postgr.es/m/17448-0a96583a67edb1f7@postgresql.org
1 parenta0b6515 commitfdd8937

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

‎src/backend/port/win32_shmem.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ PGSharedMemoryCreate(Size size,
218218
SIZE_TlargePageSize=0;
219219
Sizeorig_size=size;
220220
DWORDflProtect=PAGE_READWRITE;
221+
DWORDdesiredAccess;
221222

222223
ShmemProtectiveRegion=VirtualAlloc(NULL,PROTECTIVE_REGION_SIZE,
223224
MEM_RESERVE,PAGE_NOACCESS);
@@ -355,12 +356,19 @@ PGSharedMemoryCreate(Size size,
355356
if (!CloseHandle(hmap))
356357
elog(LOG,"could not close handle to shared memory: error code %lu",GetLastError());
357358

359+
desiredAccess=FILE_MAP_WRITE |FILE_MAP_READ;
360+
361+
#ifdefFILE_MAP_LARGE_PAGES
362+
/* Set large pages if wanted. */
363+
if ((flProtect&SEC_LARGE_PAGES)!=0)
364+
desiredAccess |=FILE_MAP_LARGE_PAGES;
365+
#endif
358366

359367
/*
360368
* Get a pointer to the new shared memory segment. Map the whole segment
361369
* at once, and let the system decide on the initial address.
362370
*/
363-
memAddress=MapViewOfFileEx(hmap2,FILE_MAP_WRITE |FILE_MAP_READ,0,0,0,NULL);
371+
memAddress=MapViewOfFileEx(hmap2,desiredAccess,0,0,0,NULL);
364372
if (!memAddress)
365373
ereport(FATAL,
366374
(errmsg("could not create shared memory segment: error code %lu",GetLastError()),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp