stats: Add comment about MAP_SHARED
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Wed, 2 Feb 2011 08:40:48 +0000 (09:40 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 3 Feb 2011 00:06:44 +0000 (01:06 +0100)
Clarify why MAP_SHARED is used instead of the obvious MAP_PRIVATE.

src/stats.c

index 929e09b..679a372 100644 (file)
@@ -286,6 +286,12 @@ static int stats_file_remap(struct stats_file *file, size_t size)
        }
 
        if (file->addr == NULL) {
+               /*
+                * Though the buffer is not shared between processes, we still
+                * have to take MAP_SHARED because MAP_PRIVATE does not guarantee
+                * that writes will hit the file eventually. For more details
+                * please read the mmap man pages.
+                */
                addr = mmap(NULL, new_size, PROT_READ | PROT_WRITE,
                                MAP_SHARED, file->fd, 0);
        } else {