Remove some of the false positives when sorting by utilizing the MAP_SHARED bit.

This helps deal with the COW cases where a virtual address is modified but is
mapped to a read-only shared library area because the perf tool doesn't 
understand
COW faults.

Using the MAP_SHARED bit tells the tool in this example the memory is private
and will not cause contention with other processes accessing the same shared
library area.

Signed-off-by: Don Zickus <[email protected]>
---
 tools/perf/util/sort.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index e016fc1..be675f4 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -1,3 +1,4 @@
+#include <sys/mman.h>
 #include "sort.h"
 #include "hist.h"
 #include "comm.h"
@@ -1001,7 +1002,8 @@ sort__physid_daddr_cmp(struct hist_entry *left, struct 
hist_entry *right)
         * assumed to be unity mapped.  Sort those on address then pid.
         */
 
-       if (l_map->maj || l_map->min || l_map->ino || l_map->ino_generation) {
+       if ((l_map->flags & MAP_SHARED) &&
+          (l_map->maj || l_map->min || l_map->ino || l_map->ino_generation)) {
                /* mmapped areas */
 
                if (l_map->maj > r_map->maj) return -1;
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to