madvise() flags for not to sync dirty pages to the disk in shared mapping

From: dharmendra hans
Date: Wed Jun 12 2019 - 01:33:07 EST


Hi,
I was searching for some madvise() flag options which allow my
application to have choice of not syncing dirty pages created through
shared mmap() to the disk. Issue is that currently dirty pages created
by the application will be synced to the disk and there is no way
application can avoid that except MADV_REMOVE. But MADV_REMOVE punches
the hole in the file and it takes a lot of time if mapping size was
big, therefore one wants to avoid this option as it delays the further
state change in application.

So one seems to have two issue.
1) Application is forced to wait during munmap() as dirty pages are synced.
2) if one kill the application process, it lands in process defunct
state for long time and it seems pages which were created by
application are being synced to the disk.

MADV_REMOVE seems to solve it but it is really slow due to file
truncation on mapped file.
What is desired is that application should be allowed choice of no
dirty pages sync without creating hole in the mapped file.

-Dharmendra