Commit 672f67bd authored by Gabriel Marin's avatar Gabriel Marin Committed by Commit Bot

Enable cycles precise=3 for FP callgraphs.

perf record with callstacks is not impacted by the large PEBS kernel bug
https://lore.kernel.org/patchwork/project/lkml/list/?series=470855.

BUG=b:168312716

Change-Id: I47b8a9eb3d7fcf72a06b47d3ee11166a07f8bc43
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2536095Reviewed-by: default avatarGeorge Burgess <gbiv@chromium.org>
Reviewed-by: default avatarGabriel Marin <gmx@chromium.org>
Commit-Queue: Gabriel Marin <gmx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827069}
parent 845c445e
......@@ -89,7 +89,8 @@ void ExtractVersionNumbers(const std::string& version,
// Returns if a micro-architecture supports the cycles:ppp event.
bool MicroarchitectureHasCyclesPPPEvent(const std::string& uarch) {
return false;
return uarch == "Goldmont" || uarch == "GoldmontPlus" ||
uarch == "Broadwell" || uarch == "Kabylake" || uarch == "Tigerlake";
}
// Returns if a micro-architecture supports LBR callgraph profiling.
......@@ -109,14 +110,9 @@ bool KernelReleaseHasLBRCallgraph(const std::string& release) {
const char kPerfCommandDelimiter[] = " ";
// Collect precise=3 (:ppp) cycle events on microarchitectures that support it.
const char kPerfCyclesPPPCmd[] = "perf record -a -e cycles:ppp -c 1000003";
const char kPerfFPCallgraphPPPCmd[] =
"perf record -a -e cycles:ppp -g -c 4000037";
const char kPerfLBRCallgraphPPPCmd[] =
"perf record -a -e cycles:ppp -c 4000037 --call-graph lbr";
// Collect default (imprecise) cycle events everywhere else.
const char kPerfCyclesCmd[] = "perf record -a -e cycles -c 1000003";
......@@ -190,9 +186,7 @@ const std::vector<RandomSelector::WeightAndValue> GetDefaultCommands_x86_64(
lbr_cmd = kPerfLBRCmdAtom;
}
if (MicroarchitectureHasCyclesPPPEvent(cpu_uarch)) {
cycles_cmd = kPerfCyclesPPPCmd;
fp_callgraph_cmd = kPerfFPCallgraphPPPCmd;
lbr_callgraph_cmd = kPerfLBRCallgraphPPPCmd;
}
cmds.emplace_back(WeightAndValue(50.0, cycles_cmd));
......
......@@ -36,6 +36,8 @@ const char kPerfCyclesCmd[] = "perf record -a -e cycles -c 1000003";
const char kPerfFPCallgraphCmd[] = "perf record -a -e cycles -g -c 4000037";
const char kPerfLBRCallgraphCmd[] =
"perf record -a -e cycles -c 4000037 --call-graph lbr";
const char kPerfFPCallgraphPPPCmd[] =
"perf record -a -e cycles:ppp -g -c 4000037";
const char kPerfLBRCmd[] = "perf record -a -e r20c4 -b -c 200011";
const char kPerfLBRCmdAtom[] = "perf record -a -e rc4 -b -c 300001";
const char kPerfITLBMissCyclesCmdIvyBridge[] =
......@@ -516,7 +518,7 @@ TEST_F(PerfCollectorTest, DefaultCommandsBasedOnUarch_Tigerlake) {
ASSERT_GE(cmds.size(), 3UL);
EXPECT_EQ(cmds[0].value, kPerfCyclesCmd);
// We have both FP and LBR based callstacks.
EXPECT_EQ(cmds[1].value, kPerfFPCallgraphCmd);
EXPECT_EQ(cmds[1].value, kPerfFPCallgraphPPPCmd);
EXPECT_TRUE(DoesCommandSampleCycles(cmds[0].value));
EXPECT_EQ(cmds[2].value, kPerfLBRCallgraphCmd);
EXPECT_TRUE(DoesCommandSampleCycles(cmds[1].value));
......@@ -551,7 +553,7 @@ TEST_F(PerfCollectorTest, DefaultCommandsBasedOnUarch_Goldmont) {
ASSERT_GE(cmds.size(), 2UL);
EXPECT_EQ(cmds[0].value, kPerfCyclesCmd);
EXPECT_TRUE(DoesCommandSampleCycles(cmds[0].value));
EXPECT_EQ(cmds[1].value, kPerfFPCallgraphCmd);
EXPECT_EQ(cmds[1].value, kPerfFPCallgraphPPPCmd);
EXPECT_TRUE(DoesCommandSampleCycles(cmds[1].value));
// No LBR callstacks because the microarchitecture doesn't support it.
auto found =
......@@ -590,7 +592,7 @@ TEST_F(PerfCollectorTest, DefaultCommandsBasedOnUarch_GoldmontPlus) {
ASSERT_GE(cmds.size(), 2UL);
EXPECT_EQ(cmds[0].value, kPerfCyclesCmd);
EXPECT_TRUE(DoesCommandSampleCycles(cmds[0].value));
EXPECT_EQ(cmds[1].value, kPerfFPCallgraphCmd);
EXPECT_EQ(cmds[1].value, kPerfFPCallgraphPPPCmd);
EXPECT_TRUE(DoesCommandSampleCycles(cmds[1].value));
// No LBR callstacks because the microarchitecture doesn't support it.
auto found =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment