]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
script/run-cbt.sh: set kernel.perf_event_paranoid for running perf
authorKefu Chai <kchai@redhat.com>
Fri, 19 Mar 2021 11:04:03 +0000 (19:04 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 19 Mar 2021 11:04:03 +0000 (19:04 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/script/run-cbt.sh

index 116cc77f22f0eb982f7b9b10c67d2f163a410f40..6ed21701c9870f77c084d1ab8e7ed3a8b9599d1d 100755 (executable)
@@ -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