tools/perf/tests/shell/lib/stat_output.sh

Source file repositories/reference/linux-study-clean/tools/perf/tests/shell/lib/stat_output.sh

File Facts

System
Linux kernel
Corpus path
tools/perf/tests/shell/lib/stat_output.sh
Extension
.sh
Size
4017 bytes
Lines
196
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

# Return true if perf_event_paranoid is > $1 and not running as root.
function ParanoidAndNotRoot()
{
	 [ "$(id -u)" != 0 ] && [ "$(cat /proc/sys/kernel/perf_event_paranoid)" -gt $1 ]
}

# $1 name $2 extra_opt
check_no_args()
{
        echo -n "Checking $1 output: no args "
        perf stat $2 true
        commachecker --no-args
        echo "[Success]"
}

check_system_wide()
{
	echo -n "Checking $1 output: system wide "
	if ParanoidAndNotRoot 0
	then
		echo "[Skip] paranoid and not root"
		return
	fi
	perf stat -a $2 true
	commachecker --system-wide
	echo "[Success]"
}

check_system_wide_no_aggr()
{
	echo -n "Checking $1 output: system wide no aggregation "
	if ParanoidAndNotRoot 0
	then
		echo "[Skip] paranoid and not root"
		return
	fi
	perf stat -A -a --no-merge $2 true
	commachecker --system-wide-no-aggr
	echo "[Success]"
}

check_interval()
{
	echo -n "Checking $1 output: interval "
	perf stat -I 1000 $2 true
	commachecker --interval
	echo "[Success]"
}

check_event()
{
	echo -n "Checking $1 output: event "
	perf stat -e cpu-clock $2 true
	commachecker --event
	echo "[Success]"
}

check_per_core()
{
	echo -n "Checking $1 output: per core "
	if ParanoidAndNotRoot 0
	then
		echo "[Skip] paranoid and not root"
		return
	fi
	perf stat --per-core -a $2 true
	commachecker --per-core

Annotation

Implementation Notes