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

Commit34afbba

Browse files
committed
Use mmap MAP_NOSYNC option to limit shared memory writes
mmap() is rarely used for shared memory, but when it is, this option isuseful, particularly on the BSDs.Patch by Sean Chittenden
1 parent9d61b99 commit34afbba

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

‎src/backend/storage/ipc/dsm_impl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ dsm_impl_posix(dsm_op op, dsm_handle handle, Size request_size,
368368

369369
/* Map it. */
370370
address=mmap(NULL,request_size,PROT_READ |PROT_WRITE,
371-
MAP_SHARED |MAP_HASSEMAPHORE,fd,0);
371+
MAP_SHARED |MAP_HASSEMAPHORE |MAP_NOSYNC,fd,0);
372372
if (address==MAP_FAILED)
373373
{
374374
intsave_errno;
@@ -960,7 +960,7 @@ dsm_impl_mmap(dsm_op op, dsm_handle handle, Size request_size,
960960

961961
/* Map it. */
962962
address=mmap(NULL,request_size,PROT_READ |PROT_WRITE,
963-
MAP_SHARED |MAP_HASSEMAPHORE,fd,0);
963+
MAP_SHARED |MAP_HASSEMAPHORE |MAP_NOSYNC,fd,0);
964964
if (address==MAP_FAILED)
965965
{
966966
intsave_errno;

‎src/include/portability/mem.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@
3030
#defineMAP_HASSEMAPHORE0
3131
#endif
3232

33+
/*
34+
* BSD-derived systems use the MAP_NOSYNC flag to prevent dirty mmap(2)
35+
* pages from being gratuitously flushed to disk.
36+
*/
37+
#ifndefMAP_NOSYNC
38+
#defineMAP_NOSYNC0
39+
#endif
40+
3341
#definePG_MMAP_FLAGS(MAP_SHARED|MAP_ANONYMOUS|MAP_HASSEMAPHORE)
3442

3543
/* Some really old systems don't define MAP_FAILED. */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp