Skip to contentSkip to conversation

perf diff: bug fix, donot overwrite valid build id

PATCH In review [email protected] 3 participants 4 messages Dec 13, 2016 – Dec 20, 2016 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf diff: bug fix, donot overwrite valid build id

From: Kan Liang <[email protected]>

Fixes a perf diff regression issue which was introduced by commit 5baecbcd9c9a ("perf symbols: we can now read separate debug-info files based on a build ID")

The binary name could be same when perf diff different binaries. Build id is used to distinguish between them.
However, the previous patch assumes the same binary name has same build id. So it overwrites the build id according to the binary name, regardless of whether the build id is set or not.

Check the has_build_id in dso__load. If the build id is already set, use it.

Before the fix applies,
sudo ./perf diff 1.perf.data 2.perf.data
# Event 'cycles'
#

 # Baseline    Delta  Shared Object     Symbol
 # ........  .......  ................  .............................
 #
    99.83%  -99.80%  tchain_edit       [.] f2
     0.12%  +99.81%  tchain_edit       [.] f3
     0.02%   -0.01%  [ixgbe]           [k] ixgbe_read_reg

After the fix applies,
sudo ./perf diff 1.perf.data 2.perf.data
# Event 'cycles'
#

 # Baseline    Delta  Shared Object     Symbol
 # ........  .......  ................  .............................
 #
    99.83%   +0.10%  tchain_edit       [.] f3
     0.12%   -0.08%  tchain_edit       [.] f2
---
 tools/perf/util/symbol.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/symbol.c +2 -1
index df2482b..dc93940 100644
@@ -1459,7 +1459,8 @@ int dso__load(struct dso *dso, struct map *map)
 	 * Read the build id if possible. This is required for
 	 * DSO_BINARY_TYPE__BUILDID_DEBUGINFO to work
 	 */
-	if (is_regular_file(dso->long_name) &&
+	if (!dso->has_build_id &&
+	    is_regular_file(dso->long_name) &&
 	    filename__read_build_id(dso->long_name, build_id, BUILD_ID_SIZE) > 0)
 		dso__set_build_id(dso, build_id);
 
Signature · 1 line
2.4.3
author
#1 lore raw

Hi Arnaldo,

Ping

Are you OK with the fix?

Thanks,
Kan

Quoted 56 lines

From: Kan Liang <[email protected]>

Fixes a perf diff regression issue which was introduced by commit 5baecbcd9c9a ("perf symbols: we can now read separate debug-info files based on a build ID")

The binary name could be same when perf diff different binaries. Build id is used to distinguish between them.
However, the previous patch assumes the same binary name has same build id. So it overwrites the build id according to the binary name, regardless of whether the build id is set or not.

Check the has_build_id in dso__load. If the build id is already set, use it.

Before the fix applies,
sudo ./perf diff 1.perf.data 2.perf.data # Event 'cycles' #

 # Baseline    Delta  Shared Object     Symbol
 # ........  .......  ................  .............................
 #
    99.83%  -99.80%  tchain_edit       [.] f2
     0.12%  +99.81%  tchain_edit       [.] f3
     0.02%   -0.01%  [ixgbe]           [k] ixgbe_read_reg

After the fix applies,
sudo ./perf diff 1.perf.data 2.perf.data # Event 'cycles' #

 # Baseline    Delta  Shared Object     Symbol
 # ........  .......  ................  .............................
 #
    99.83%   +0.10%  tchain_edit       [.] f3
     0.12%   -0.08%  tchain_edit       [.] f2
---
 tools/perf/util/symbol.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/symbol.c index renamed from tools/perf/util/symbol.c +0 -0

df2482b..dc93940 100644

tools/perf/util/symbol.c +2 -2
@@ -1459,7 +1459,8 @@ int dso__load(struct dso *dso, struct map *map)
 	 * Read the build id if possible. This is required for
 	 * DSO_BINARY_TYPE__BUILDID_DEBUGINFO to work
 	 */
-	if (is_regular_file(dso->long_name) &&
+	if (!dso->has_build_id &&
+	    is_regular_file(dso->long_name) &&
 	    filename__read_build_id(dso->long_name, build_id,
 BUILD_ID_SIZE) > 0)
 		dso__set_build_id(dso, build_id);
 
--

2.4.3

#2 lore raw

Em Mon, Dec 19, 2016 at 02:53:30PM +0000, Liang, Kan escreveu:

Quoted 5 lines

Hi Arnaldo,

Ping

Are you OK with the fix?

Yeah, looks ok, will merge it.

- Arnaldo

Quoted 59 lines

Thanks,
Kan

Quoted 56 lines

From: Kan Liang <[email protected]>

Fixes a perf diff regression issue which was introduced by commit 5baecbcd9c9a ("perf symbols: we can now read separate debug-info files based on a build ID")

The binary name could be same when perf diff different binaries. Build id is used to distinguish between them.
However, the previous patch assumes the same binary name has same build id. So it overwrites the build id according to the binary name, regardless of whether the build id is set or not.

Check the has_build_id in dso__load. If the build id is already set, use it.

Before the fix applies,
sudo ./perf diff 1.perf.data 2.perf.data # Event 'cycles' #

 # Baseline    Delta  Shared Object     Symbol
 # ........  .......  ................  .............................
 #
    99.83%  -99.80%  tchain_edit       [.] f2
     0.12%  +99.81%  tchain_edit       [.] f3
     0.02%   -0.01%  [ixgbe]           [k] ixgbe_read_reg

After the fix applies,
sudo ./perf diff 1.perf.data 2.perf.data # Event 'cycles' #

 # Baseline    Delta  Shared Object     Symbol
 # ........  .......  ................  .............................
 #
    99.83%   +0.10%  tchain_edit       [.] f3
     0.12%   -0.08%  tchain_edit       [.] f2
---
 tools/perf/util/symbol.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/symbol.c index renamed from tools/perf/util/symbol.c +0 -0

df2482b..dc93940 100644

tools/perf/util/symbol.c +2 -2
@@ -1459,7 +1459,8 @@ int dso__load(struct dso *dso, struct map *map)
 	 * Read the build id if possible. This is required for
 	 * DSO_BINARY_TYPE__BUILDID_DEBUGINFO to work
 	 */
-	if (is_regular_file(dso->long_name) &&
+	if (!dso->has_build_id &&
+	    is_regular_file(dso->long_name) &&
 	    filename__read_build_id(dso->long_name, build_id,
 BUILD_ID_SIZE) > 0)
 		dso__set_build_id(dso, build_id);
 
--

2.4.3

#3 lore raw

[tip:perf/urgent] perf diff: Do not overwrite valid build id

In reply to [email protected]
perf diff: Do not overwrite valid build id
Commit-ID:  ed6c166cc7dc329736cace3affd2df984fb22ec8
Gitweb:     http://git.kernel.org/tip/ed6c166cc7dc329736cace3affd2df984fb22ec8
Author:     Kan Liang <[email protected]>
AuthorDate: Tue, 13 Dec 2016 10:29:44 -0500
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 20 Dec 2016 12:00:38 -0300

perf diff: Do not overwrite valid build id

Fixes a perf diff regression issue which was introduced by commit 5baecbcd9c9a ("perf symbols: we can now read separate debug-info files based on a build ID")

The binary name could be same when perf diff different binaries. Build id is used to distinguish between them.
However, the previous patch assumes the same binary name has same build id. So it overwrites the build id according to the binary name, regardless of whether the build id is set or not.

Check the has_build_id in dso__load. If the build id is already set, use it.

Before the fix:

  $ perf diff 1.perf.data 2.perf.data
  # Event 'cycles'
  #
  # Baseline    Delta  Shared Object     Symbol
  # ........  .......  ................  .............................
  #
    99.83%  -99.80%  tchain_edit       [.] f2
     0.12%  +99.81%  tchain_edit       [.] f3
     0.02%   -0.01%  [ixgbe]           [k] ixgbe_read_reg

After the fix:

  $ perf diff 1.perf.data 2.perf.data
  # Event 'cycles'
  #
  # Baseline    Delta  Shared Object     Symbol
  # ........  .......  ................  .............................
  #
    99.83%   +0.10%  tchain_edit       [.] f3
     0.12%   -0.08%  tchain_edit       [.] f2
Cc Andi Kleen <[email protected]>
CC Dima Kogan <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Fixes 5baecbcd9c9a ("perf symbols: we can now read separate debug-info files based on a build ID")
---
 tools/perf/util/symbol.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/symbol.c +2 -1
index df2482b..dc93940 100644
@@ -1459,7 +1459,8 @@ int dso__load(struct dso *dso, struct map *map)
 	 * Read the build id if possible. This is required for
 	 * DSO_BINARY_TYPE__BUILDID_DEBUGINFO to work
 	 */
-	if (is_regular_file(dso->long_name) &&
+	if (!dso->has_build_id &&
+	    is_regular_file(dso->long_name) &&
 	    filename__read_build_id(dso->long_name, build_id, BUILD_ID_SIZE) > 0)
 		dso__set_build_id(dso, build_id);