mmap/munmap

80 views
Skip to first unread message

Christian S. Perone

unread,
Aug 28, 2015, 2:56:13 PM8/28/15
to pmem
I was looking the example:


And I saw that there is no munmap() in the end of the file, wouldn't it be a good practice to add it even if it is soon exiting the process ? This may confuse some developers that may forget to add munmap in other situations. As far as I understand mmap, the mappings aren't removed when the descriptor is closed.

Also, have you guys evaluated the effects of the madvise() calls for this mmape'd region (when there is no page-cache) ?

Thanks !

--
"Forgive, O Lord, my little jokes on Thee, and I'll forgive Thy great big joke on me."

Andy Rudoff

unread,
Aug 28, 2015, 4:50:13 PM8/28/15
to pmem
Yep, agree with your munmap points.  Closing the file descriptor doesn't remove the mappings (note in this example we close the file descriptor immediately after mapping the source file and then go use the mappings), and when a program is done with a mapping, the way to delete it is to call munmap().  In an effort to keep the program really short & simple, I didn't bother with the munmap() call, but in a real program calling it is a reasonable practice.

Most of the madvise() options (like MADV_SEQUENTIAL) don't apply to DAX mappings and would have no impact.  These options are really meant for page-cache-backed pages.

Christian S. Perone

unread,
Aug 28, 2015, 5:25:51 PM8/28/15
to Andy Rudoff, pmem

Makes complete sense, thanks for the quick reply Andy.

--
You received this message because you are subscribed to the Google Groups "pmem" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pmem+uns...@googlegroups.com.
To post to this group, send email to pm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pmem/7fc7aa1f-581f-4aba-9714-a8cbf87f62d1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages