From: Kefu Chai Date: Fri, 19 Mar 2021 11:04:03 +0000 (+0800) Subject: script/run-cbt.sh: set kernel.perf_event_paranoid for running perf X-Git-Tag: v17.1.0~2557^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=151719590dc30bfe9957460dc79a25c7c2aef0cb;p=ceph.git script/run-cbt.sh: set kernel.perf_event_paranoid for running perf Signed-off-by: Kefu Chai --- diff --git a/src/script/run-cbt.sh b/src/script/run-cbt.sh index 116cc77f22f0..6ed21701c987 100755 --- a/src/script/run-cbt.sh +++ b/src/script/run-cbt.sh @@ -108,6 +108,17 @@ if ! $use_existing; then cd - || exit fi +# i need to read the performance events, +# see https://www.kernel.org/doc/Documentation/sysctl/kernel.txt +if /sbin/capsh --supports=cap_sys_admin; then + perf_event_paranoid=$(/sbin/sysctl --values kernel.perf_event_paranoid) + if test $perf_event_paranoid -gt 0; then + sudo /sbin/sysctl -q -w kernel.perf_event_paranoid=0 + fi +else + echo "without cap_sys_admin, $(whoami) cannot read the perf events" +fi + for config_file in $config_files; do echo "testing $config_file" cbt_config=$(mktemp $config_file.XXXX.yaml) @@ -122,6 +133,11 @@ for config_file in $config_files; do rm -f $cbt_config done +if test -n "$perf_event_paranoid"; then + # restore the setting + sudo /sbin/sysctl -q -w kernel.perf_event_paranoid=$perf_event_paranoid +fi + if ! $use_existing; then cd $build_dir || exit if $classical; then