aboutsummaryrefslogtreecommitdiff
path: root/contrib/gen_autofdo_event.py
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/gen_autofdo_event.py')
-rwxr-xr-xcontrib/gen_autofdo_event.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/contrib/gen_autofdo_event.py b/contrib/gen_autofdo_event.py
index 4364e5c..b1d373f 100755
--- a/contrib/gen_autofdo_event.py
+++ b/contrib/gen_autofdo_event.py
@@ -138,8 +138,16 @@ if [ "$1" = "--all" ] ; then
shift
fi
-if ! grep -q Intel /proc/cpuinfo ; then
- echo >&2 "Only Intel CPUs supported"
+if grep -q AuthenticAMD /proc/cpuinfo ; then
+ vendor=AMD
+ if ! grep -q " brs" /proc/cpuinfo && ! grep -q amd_lbr_v2 /proc/cpuinfo ; then
+ echo >&2 "AMD CPU with brs (Zen 3) or amd_lbr_v2 (Zen 4+) feature is required"
+ exit 1
+ fi
+elif grep -q Intel /proc/cpuinfo ; then
+ vendor=Intel
+else
+ echo >&2 "Only AMD and Intel CPUs supported"
exit 1
fi
@@ -147,7 +155,7 @@ if grep -q hypervisor /proc/cpuinfo ; then
echo >&2 "Warning: branch profiling may not be functional in VMs"
fi
-case `grep -E -q "^cpu family\s*: 6" /proc/cpuinfo &&
+case `test $vendor = Intel && grep -E -q "^cpu family\s*: 6" /proc/cpuinfo &&
grep -E "^model\s*:" /proc/cpuinfo | head -n1` in''')
for event, mod in eventmap.items():
for m in mod[:-1]:
@@ -156,8 +164,13 @@ case `grep -E -q "^cpu family\s*: 6" /proc/cpuinfo &&
print(r'''*)
if perf list br_inst_retired | grep -q br_inst_retired.near_taken ; then
E=br_inst_retired.near_taken:p
+ elif perf list ex_ret_brn_tkn | grep -q ex_ret_brn_tkn ; then
+ E=ex_ret_brn_tkn:P$FLAGS
+ elif $vendor = Intel ; then
+echo >&2 "Unknown Intel CPU. Run contrib/gen_autofdo_event.py --all --script to update script."
+ exit 1
else
-echo >&2 "Unknown CPU. Run contrib/gen_autofdo_event.py --all --script to update script."
+echo >&2 "AMD CPU without support for ex_ret_brn_tkn event"
exit 1
fi ;;''')
print(r"esac")