Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf record: Add auto counter reload parse and regression tests

Include event parsing and regression tests for auto counter reload
and ratio-to-prev event term.

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Thomas Falcon <thomas.falcon@intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Thomas Falcon and committed by
Arnaldo Carvalho de Melo
56be0fe5 6b9c0261

+94
+54
tools/perf/tests/parse-events.c
··· 1736 1736 return TEST_OK; 1737 1737 } 1738 1738 1739 + static bool test__acr_valid(void) 1740 + { 1741 + struct perf_pmu *pmu = NULL; 1742 + 1743 + while ((pmu = perf_pmus__scan_core(pmu)) != NULL) { 1744 + if (perf_pmu__has_format(pmu, "acr_mask")) 1745 + return true; 1746 + } 1747 + 1748 + return false; 1749 + } 1750 + 1751 + static int test__ratio_to_prev(struct evlist *evlist) 1752 + { 1753 + struct evsel *evsel; 1754 + int ret; 1755 + 1756 + TEST_ASSERT_VAL("wrong number of entries", 2 * perf_pmus__num_core_pmus() == evlist->core.nr_entries); 1757 + 1758 + evlist__for_each_entry(evlist, evsel) { 1759 + if (!perf_pmu__has_format(evsel->pmu, "acr_mask")) 1760 + return TEST_OK; 1761 + 1762 + if (evsel == evlist__first(evlist)) { 1763 + TEST_ASSERT_VAL("wrong config2", 0 == evsel->core.attr.config2); 1764 + TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); 1765 + TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2); 1766 + TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0); 1767 + ret = assert_hw(&evsel->core, PERF_COUNT_HW_CPU_CYCLES, "cycles"); 1768 + } else { 1769 + TEST_ASSERT_VAL("wrong config2", 0 == evsel->core.attr.config2); 1770 + TEST_ASSERT_VAL("wrong leader", !evsel__is_group_leader(evsel)); 1771 + TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 0); 1772 + TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1); 1773 + ret = assert_hw(&evsel->core, PERF_COUNT_HW_INSTRUCTIONS, "instructions"); 1774 + } 1775 + if (ret) 1776 + return ret; 1777 + /* 1778 + * The period value gets configured within evlist__config, 1779 + * while this test executes only parse events method. 1780 + */ 1781 + TEST_ASSERT_VAL("wrong period", 0 == evsel->core.attr.sample_period); 1782 + } 1783 + return TEST_OK; 1784 + } 1785 + 1739 1786 static int test__checkevent_complex_name(struct evlist *evlist) 1740 1787 { 1741 1788 struct evsel *evsel = evlist__first(evlist); ··· 2296 2249 .check = test__checkevent_tracepoint, 2297 2250 /* 4 */ 2298 2251 }, 2252 + { 2253 + .name = "{cycles,instructions/period=200000,ratio-to-prev=2.0/}", 2254 + .valid = test__acr_valid, 2255 + .check = test__ratio_to_prev, 2256 + /* 5 */ 2257 + }, 2258 + 2299 2259 }; 2300 2260 2301 2261 static const struct evlist_test test__events_pmu[] = {
+40
tools/perf/tests/shell/record.sh
··· 388 388 echo "Callgraph test [Success]" 389 389 } 390 390 391 + test_ratio_to_prev() { 392 + echo "ratio-to-prev test" 393 + if ! perf record -o /dev/null -e "{instructions, cycles/period=100000,ratio-to-prev=0.5/}" \ 394 + true 2> /dev/null 395 + then 396 + echo "ratio-to-prev [Skipped not supported]" 397 + return 398 + fi 399 + if ! perf record -o /dev/null -e "instructions, cycles/period=100000,ratio-to-prev=0.5/" \ 400 + true |& grep -q 'Invalid use of ratio-to-prev term without preceding element in group' 401 + then 402 + echo "ratio-to-prev test [Failed elements must be in same group]" 403 + err=1 404 + return 405 + fi 406 + if ! perf record -o /dev/null -e "{instructions,dummy,cycles/period=100000,ratio-to-prev=0.5/}" \ 407 + true |& grep -q 'must have same PMU' 408 + then 409 + echo "ratio-to-prev test [Failed elements must have same PMU]" 410 + err=1 411 + return 412 + fi 413 + if ! perf record -o /dev/null -e "{instructions,cycles/ratio-to-prev=0.5/}" \ 414 + true |& grep -q 'Event period term or count (-c) must be set when using ratio-to-prev term.' 415 + then 416 + echo "ratio-to-prev test [Failed period must be set]" 417 + err=1 418 + return 419 + fi 420 + if ! perf record -o /dev/null -e "{cycles/ratio-to-prev=0.5/}" \ 421 + true |& grep -q 'Invalid use of ratio-to-prev term without preceding element in group' 422 + then 423 + echo "ratio-to-prev test [Failed need 2+ events]" 424 + err=1 425 + return 426 + fi 427 + echo "Basic ratio-to-prev record test [Success]" 428 + } 429 + 391 430 # raise the limit of file descriptors to minimum 392 431 if [[ $default_fd_limit -lt $min_fd_limit ]]; then 393 432 ulimit -Sn $min_fd_limit ··· 443 404 test_topdown_leader_sampling 444 405 test_precise_max 445 406 test_callgraph 407 + test_ratio_to_prev 446 408 447 409 # restore the default value 448 410 ulimit -Sn $default_fd_limit