]> git.baikalelectronics.ru Git - kernel.git/commitdiff
perf tools: Fix dso_id inode generation comparison
authorAdrian Hunter <adrian.hunter@intel.com>
Mon, 11 Jul 2022 09:31:44 +0000 (12:31 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:24:09 +0000 (14:24 +0200)
[ Upstream commit de86678cc804b10106b1f5a75649250cc895cf01 ]

Synthesized MMAP events have zero ino_generation, so do not compare
them to DSOs with a real ino_generation otherwise we end up with a DSO
without a build id.

Fixes: ceaa237406369b2d ("perf dso: Move dso_id from 'struct map' to 'struct dso'")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: kvm@vger.kernel.org
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20220711093218.10967-2-adrian.hunter@intel.com
[ Added clarification to the comment from Ian + more detailed explanation from Adrian ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/perf/util/dsos.c

index 183a81d5b2f92c8dead68962fdd7d33862aa03a4..2db91121bdafee4154365cc74565d5dd51aa0ae1 100644 (file)
@@ -20,8 +20,19 @@ static int __dso_id__cmp(struct dso_id *a, struct dso_id *b)
        if (a->ino > b->ino) return -1;
        if (a->ino < b->ino) return 1;
 
-       if (a->ino_generation > b->ino_generation) return -1;
-       if (a->ino_generation < b->ino_generation) return 1;
+       /*
+        * Synthesized MMAP events have zero ino_generation, avoid comparing
+        * them with MMAP events with actual ino_generation.
+        *
+        * I found it harmful because the mismatch resulted in a new
+        * dso that did not have a build ID whereas the original dso did have a
+        * build ID. The build ID was essential because the object was not found
+        * otherwise. - Adrian
+        */
+       if (a->ino_generation && b->ino_generation) {
+               if (a->ino_generation > b->ino_generation) return -1;
+               if (a->ino_generation < b->ino_generation) return 1;
+       }
 
        return 0;
 }