Add perf sampling tests as part of selftest
PATCH 1/20 selftest/powerpc/pmu: Include mmap_buffer field as part of struct event
In reply to Kajol JainFrom: Athira Rajeev <[email protected]>
To enable the capturing of samples as part of perf event, add a new field "mmap_buffer" to "struct event". This field is a place-holder for sample collection
--- tools/testing/selftests/powerpc/pmu/event.h | 5 +++++ 1 file changed, 5 insertions(+)
tools/testing/selftests/powerpc/pmu/event.h +5 -0
@@ -22,6 +22,11 @@ struct event {u64 running;u64 enabled; } result; +/* +* mmap buffer used while recording sample. +* Accessed as "struct perf_event_mmap_page" +*/ +void *mmap_buffer; };void event_init (struct event *e,u64 config);
Signature · 1 line
2.27.0
cover Add perf sampling tests as part of selftest
Patch series adds support for perf sampling tests that enables capturing sampling data in perf mmap buffer and further support for reading and processing the samples. It also addds basic utility functions to process the mmap buffer inorder to read total count of samples as well as the contents of sample.
With enablement of extended regs in powerpc, sample can also capture performance monitor registers (different Monitor Mode control Registers) by specifying sample type for extended regs. This information from sample is used to verify the perf interface, by comparing the event code fields with interrupt registers value.
Patch series also include support for macros which does the job of extracting the event code fields and specific fields from supported Monitor Mode Control Registers.
The sampling support functions and testcases are added in new folder "sampling_tests" under "selftests/powerpc/pmu" and corresponding updates are done Makefiles in "selftests/powerpc" and "sampling_tests" folder. Testcases are added for PMU registers which verifies that the perf interface programs these SPR's correctly.
Patch 1 of the series add new field "mmap_buffer" to "struct event" to enable capturing of samples as part of perf event. This field is a place-holder for the mmap-buffer incase of sample collection
Patch 2-4 adds support functions for enabling perf sampling test and adds couple of basic utility functions to post process the mmap buffer. It also adds macros to parse event codes.
Patch 5 adds event_init_sampling function to initialise event attribute fields for sampling events.
Patch 6-8 adds generic Monitor Mode Control Register(MMCR) macro to get specific field value from a specific MMCR. It also adds macros and utility functions to fetch individual fields from all MMCRx PMU registers.
Patch 9-20 adds testcases to verify if fields values of MMCRx registers are set correctly from event code via perf interface
Link to the linux-ci:
https://github.com/athira-rajeev/linux-ci/actions?query=branch%3Asefltests
Patchset contains initial set of test cases along with basic utilities to verify basic perf interface. More sampling testcases are in plan which will cover additional scenarios.
Athira Rajeev (11):
selftest/powerpc/pmu: Include mmap_buffer field as part of struct
event
selftest/powerpc/pmu: Add support for perf sampling tests selftest/powerpc/pmu: Add macro to extract mmcr0/mmcr1 fields selftest/powerpc/pmu/: Add interface test for mmcr0 exception bits selftest/powerpc/pmu/: Add interface test for mmcr0_cc56run field selftest/powerpc/pmu/: Add interface test for mmcr0_pmccext bit selftest/powerpc/pmu/: Add interface test for mmcr0_pmcjce field selftest/powerpc/pmu/: Add interface test for mmcr0_fc56 field using
pmc1
selftest/powerpc/pmu/: Add interface test for mmcr0_pmc56 using pmc5 selftest/powerpc/pmu/: Add interface test for mmcr1_comb field selftest/powerpc/pmu/: Add selftest for mmcr1 pmcxsel/unit/cache
fields
Kajol Jain (4):
selftest/powerpc/pmu: Add utility functions to post process the mmap
buffer
selftest/powerpc/pmu: Add macro to extract mmcr3 and mmcra fields selftest/powerpc/pmu/: Add interface test for mmcr3_src fields selftest/powerpc/pmu: Add interface test for mmcra register fields
Madhavan Srinivasan (5):
selftest/powerpc/pmu: Add macros to parse event codes selftest/powerpc/pmu: Add event_init_sampling function selftest/powerpc/pmu: Add macros to extract mmcr fields selftest/powerpc/pmu/: Add interface test for mmcr2_l2l3 field selftest/powerpc/pmu/: Add interface test for mmcr2_fcs_fch fields
tools/testing/selftests/powerpc/pmu/Makefile | 11 +- tools/testing/selftests/powerpc/pmu/event.c | 18 +- tools/testing/selftests/powerpc/pmu/event.h | 6 + .../powerpc/pmu/sampling_tests/Makefile | 28 + .../powerpc/pmu/sampling_tests/misc.c | 507 ++++++++++++++++++ .../powerpc/pmu/sampling_tests/misc.h | 263 +++++++++ .../pmu/sampling_tests/mmcr0_cc56run_test.c | 59 ++ .../sampling_tests/mmcr0_exceptionbits_test.c | 59 ++ .../sampling_tests/mmcr0_fc56_pmc1ce_test.c | 58 ++ .../sampling_tests/mmcr0_fc56_pmc56_test.c | 58 ++ .../pmu/sampling_tests/mmcr0_pmccext_test.c | 59 ++ .../pmu/sampling_tests/mmcr0_pmcjce_test.c | 58 ++ .../pmu/sampling_tests/mmcr1_comb_test.c | 66 +++ .../mmcr1_sel_unit_cache_test.c | 70 +++ .../pmu/sampling_tests/mmcr2_fcs_fch_test.c | 67 +++ .../pmu/sampling_tests/mmcr2_l2l3_test.c | 74 +++ .../pmu/sampling_tests/mmcr3_src_test.c | 67 +++ .../mmcra_thresh_marked_sample_test.c | 80 +++ 18 files changed, 1605 insertions(+), 3 deletions(-) create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr0_cc56run_test.c create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr0_exceptionbits_test.c create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr0_fc56_pmc1ce_test.c create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr0_fc56_pmc56_test.c create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr0_pmccext_test.c create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr0_pmcjce_test.c create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr1_comb_test.c create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr1_sel_unit_cache_test.c create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr2_fcs_fch_test.c create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr2_l2l3_test.c create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr3_src_test.c create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_thresh_marked_sample_test.c
Signature · 1 line
2.27.0
PATCH 2/20 selftest/powerpc/pmu: Add support for perf sampling tests
From: Athira Rajeev <[email protected]>
Add support functions for enabling perf sampling test in a new folder "sampling_tests" under "selftests/powerpc/pmu". This includes support functions for allocating and processing the mmap buffer. These functions are added/defined in "sampling_tests/misc.*" files.
Also updates the corresponding Makefiles in "selftests/powerpc" and "sampling_tests" folder.
--- tools/testing/selftests/powerpc/pmu/Makefile | 11 +- .../powerpc/pmu/sampling_tests/Makefile | 20 ++++ .../powerpc/pmu/sampling_tests/misc.c | 105 ++++++++++++++++++ .../powerpc/pmu/sampling_tests/misc.h | 9 ++ 4 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h
tools/testing/selftests/powerpc/pmu/Makefile +9 -2
@@ -8,7 +8,7 @@ EXTRA_SOURCES := ../harness.c event.c lib.c ../utils.c top_srcdir = ../../../../.. include ../../lib.mk -all: $(TEST_GEN_PROGS) ebb +all: $(TEST_GEN_PROGS) ebb sampling_tests $(TEST_GEN_PROGS): $(EXTRA_SOURCES)
@@ -26,25 +26,32 @@ DEFAULT_RUN_TESTS := $(RUN_TESTS) override define RUN_TESTS $(DEFAULT_RUN_TESTS) TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests + TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests endef DEFAULT_EMIT_TESTS := $(EMIT_TESTS) override define EMIT_TESTS $(DEFAULT_EMIT_TESTS) TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests + TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests endef DEFAULT_INSTALL_RULE := $(INSTALL_RULE) override define INSTALL_RULE $(DEFAULT_INSTALL_RULE) TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install + TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install endef clean: $(RM) $(TEST_GEN_PROGS) $(OUTPUT)/loop.o TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean + TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean ebb: TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $$TARGET all -.PHONY: all run_tests clean ebb +sampling_tests: + TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $$TARGET all + +.PHONY: all run_tests clean ebb sampling_tests
tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile new file +20 -0
@@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0 +include ../../../../../../scripts/Kbuild.include + +all: $(TEST_GEN_PROGS) + +noarg: + $(MAKE) -C ../../ + +CFLAGS += -m64 -I../../../../../lib/ + +# Toolchains may build PIE by default which breaks the assembly +no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ + $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie) + +LDFLAGS += $(no-pie-option) + +top_srcdir = ../../../../../.. +include ../../../lib.mk + +$(TEST_GEN_PROGS): ../../harness.c ../../utils.c ../event.c ../lib.c misc.c misc.h
tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c new file +105 -0
105 lines not on this page · raw message
tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h new file +9 -0
@@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright 2022, Athira Rajeev, IBM Corp. +*/ + +#include "../event.h" + +void *event_sample_buf_mmap (int fd,int mmap_pages); +void *__event_read_samples (void *sample_buff,size_t *size,u64 *sample_count);
Signature · 1 line
2.27.0
PATCH 3/20 selftest/powerpc/pmu: Add macros to parse event codes
In reply to Kajol JainFrom: Madhavan Srinivasan <[email protected]>
Each platform has raw event encoding format which specifies the bit positions for different fields. The fields from event code gets translated into performance monitoring mode control register (MMCRx) settings. Patch add macros to extract individual fields from the event code.
Patch adds function for sanity checks, since testcases currently are only supported in power9 and power10.
--- .../powerpc/pmu/sampling_tests/misc.c | 227 ++++++++++++++++++ .../powerpc/pmu/sampling_tests/misc.h | 50 ++++ 2 files changed, 277 insertions(+)
tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c +227 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only /* * Copyright 2022, Athira Rajeev, IBM Corp. +* Copyright 2022, Madhavan Srinivasan, IBM Corp. */ #include <unistd.h>
@@ -16,6 +17,232 @@#define PAGE_SIZE sysconf(_SC_PAGESIZE) +/* Storage for platform version */ +int pvr, pvr_dd; +u64 platform_extended_mask; +int pSeries; + +/* Mask and Shift for Event code fields */ +int ev_mask_pmcxsel, ev_shift_pmcxsel;//pmcxsel field +int ev_mask_marked, ev_shift_marked;//marked filed +int ev_mask_comb, ev_shift_comb;//combine field +int ev_mask_unit, ev_shift_unit;//unit field +int ev_mask_pmc, ev_shift_pmc;//pmc field +int ev_mask_cache, ev_shift_cache;//Cache sel field +int ev_mask_sample, ev_shift_sample;//Random sampling field +int ev_mask_thd_sel, ev_shift_thd_sel;//thresh_sel field +int ev_mask_thd_start, ev_shift_thd_start;//thresh_start field +int ev_mask_thd_stop, ev_shift_thd_stop;//thresh_stop field +int ev_mask_thd_cmp, ev_shift_thd_cmp;//thresh cmp field +int ev_mask_sm, ev_shift_sm;//SDAR mode field +int ev_mask_rsq, ev_shift_rsq;//radix scope qual field +int ev_mask_l2l3, ev_shift_l2l3;//l2l3 sel field +int ev_mask_mmcr3_src, ev_shift_mmcr3_src;//mmcr3 field + +static void init_ev_encodes (void ) +{ + ev_mask_pmcxsel =0xff ; + ev_shift_pmcxsel =0 ; + ev_mask_marked =1 ; + ev_shift_marked =8 ; + ev_mask_unit =0xf ; + ev_shift_unit =12 ; + ev_mask_pmc =0xf ; + ev_shift_pmc =16 ; + ev_mask_sample =0x1f ; + ev_shift_sample =24 ; + ev_mask_thd_sel =0x7 ; + ev_shift_thd_sel =29 ; + ev_mask_thd_start =0xf ; + ev_shift_thd_start =36 ; + ev_mask_thd_stop =0xf ; + ev_shift_thd_stop =32 ; + +switch (pvr) { +case POWER10 : + ev_mask_rsq =1 ; + ev_shift_rsq =9 ; + ev_mask_comb =3 ; + ev_shift_comb =10 ; + ev_mask_cache =3 ; + ev_shift_cache =20 ; + ev_mask_sm =0x3 ; + ev_shift_sm =22 ; + ev_mask_l2l3 =0x1f ; + ev_shift_l2l3 =40 ; + ev_mask_mmcr3_src =0x7fff ; + ev_shift_mmcr3_src =45 ; +break ; +case POWER9 : + ev_mask_comb =3 ; + ev_shift_comb =10 ; + ev_mask_cache =0xf ; + ev_shift_cache =20 ; + ev_mask_thd_cmp =0x3ff ; + ev_shift_thd_cmp =40 ; + ev_mask_sm =0x3 ; + ev_shift_sm =50 ; +break ; +default : +FAIL_IF_EXIT (1 ); + } +} + +static int __get_pvr (int flg) +{ +FILE *fd; +char *buf =NULL , *search_string ="revision" , tmp[4 ]; +size_t len =0 ; +int ret =-1 ; + + fd =fopen ("/proc/cpuinfo" ,"r" ); +if (!fd) +return -1 ; + +/* get to the line that matters */ +while (getline (&buf, &len, fd) >0 ) { + ret =strncmp (buf, search_string,strlen (search_string)); +if (!ret) +break ; + } + +switch (flg) { +case 1 :/* get processor version number */ +/* seek to pvr hex values within the line */ +while (*buf++ !='(' ) + ;/* nothing to run */ + buf +=5 ; +strncpy (tmp, buf,3 ); + +fclose (fd); +return strtol (tmp,NULL ,16 ); + +case 2 :/* get processor major revision number */ +/* seek to pvr hex values within the line */ +while (*buf++ !=':' ) + ;/* nothing to run */ +strncpy (tmp, buf,3 ); + +fclose (fd); +return (int )strtof (tmp,NULL ); +default : +return -1 ; + } +} + +static int init_platform (void ) +{ +FILE *fd; +char *buf =NULL , *search_string ="pSeries" , *sim ="Mambo" , *ptr; +size_t len =0 ; + + fd =fopen ("/proc/cpuinfo" ,"r" ); +if (!fd) +return -1 ; + +/* check for sim (like mambo) */ +while (getline (&buf, &len, fd) >0 ) { + ptr =strstr (buf, sim); +if (ptr) +return -1 ; + } + +fseek (fd,0 ,SEEK_SET ); + +/* get to the line that matters */ +while (getline (&buf, &len, fd) >0 ) { + ptr =strstr (buf, search_string); +if (ptr) { + pSeries =1 ; +break ; + } + } + +fclose (fd); +return 0 ; +} + +static int get_ver (void ) +{ +return __get_pvr (1 ); +} + +static int get_rev_maj (void ) +{ +return __get_pvr (2 ); +} + +/* Return the extended regs mask value */ +static u64 perf_get_platform_reg_mask (void ) +{ +if (have_hwcap2 (PPC_FEATURE2_ARCH_3_1 )) +return PERF_POWER10_MASK ; +if (have_hwcap2 (PPC_FEATURE2_ARCH_3_00 )) +return PERF_POWER9_MASK ; + +return -1 ; +} + +int check_extended_regs_support (void ) +{ +int fd; +struct event event; + +event_init (&event,0x1001e ); + + event.attr.type =4 ; + event.attr.sample_period =1 ; + event.attr.disabled =1 ; + event.attr.sample_type =PERF_SAMPLE_REGS_INTR ; + event.attr.sample_regs_intr = platform_extended_mask; + + fd =event_open (&event); +if (fd !=-1 ) +return 0 ; + +return -1 ; +} + +int check_pvr_for_sampling_tests (void ) +{ + pvr =get_ver (); +/* Exit if it fails to fetch pvr */ +if (pvr <0 ) { +printf ("%s: Failed to fetch pvr\n" , __func__); +FAIL_IF_EXIT (1 ); + } + + platform_extended_mask =perf_get_platform_reg_mask (); + +/* +* Check for supported platforms +* for sampling test +*/ +if ((pvr !=POWER10 ) && (pvr !=POWER9 )) + goto out; + +/* +* Check PMU driver registered by looking for +* PPC_FEATURE2_EBB bit in AT_HWCAP2 +*/ +if (!have_hwcap2 (PPC_FEATURE2_EBB )) + goto out; + +/* check if platform supports extended regs */ +if (check_extended_regs_support ()) + goto out; + + pvr_dd =get_rev_maj (); + +if (init_platform ()) + goto out; + +init_ev_encodes (); +return 0 ; +out: +printf ("%s: Sampling tests un-supported\n" , __func__); +return -1 ; +}/* * Allocate mmap buffer of "mmap_pages" number of * pages.
tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h +50 -0
59 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 4/20 selftest/powerpc/pmu: Add utility functions to post process the mmap buffer
In reply to Kajol JainAdd couple of basic utility functions to post process the mmap buffer. It includes function to read the total number of samples present in the mmap buffer and function to get the address of the first sample.
Add function "get_intr_regs" which will return pointer to interrupt registers present in the sample, incase sample type PERF_SAMPLE_REGS_INTR is set.
Add functions "get_reg_value" which can be used to read any interrupt register value from a given sample.
--- .../powerpc/pmu/sampling_tests/misc.c | 175 ++++++++++++++++++ .../powerpc/pmu/sampling_tests/misc.h | 4 + 2 files changed, 179 insertions(+)
tools/testing/selftests/powerpc/pmu/sampling_tests/misc.c +175 -0
@@ -2,6 +2,7 @@/* * Copyright 2022, Athira Rajeev, IBM Corp. * Copyright 2022, Madhavan Srinivasan, IBM Corp. +* Copyright 2022, Kajol Jain, IBM Corp. */ #include <unistd.h>
@@ -330,3 +331,177 @@ void *__event_read_samples(void *sample_buff, size_t *size, u64 *sample_count) }return NULL ; } + +int collect_samples (void *sample_buff) +{ +u64 sample_count; +size_t size =0 ; + +__event_read_samples (sample_buff, &size, &sample_count); +return sample_count; +} + +static void *perf_read_first_sample (void *sample_buff,size_t *size) +{ +return __event_read_samples (sample_buff, size,NULL ); +} + +u64 *get_intr_regs (struct event *event,void *sample_buff) +{ +u64 type = event->attr.sample_type; +u64 *intr_regs; +size_t size =0 ; + +if ((type ^PERF_SAMPLE_REGS_INTR )) +return NULL ; + + intr_regs = (u64 *)perf_read_first_sample (sample_buff, &size); +if (!intr_regs) +return NULL ; + +/* +* First entry in the sample buffer used to specify +* PERF_SAMPLE_REGS_ABI_64, skip perf regs abi to access +* interrupt registers. +*/ + ++intr_regs; + +return intr_regs; +} + +static const unsigned int __perf_reg_mask (const char *register_name) +{ +if (!strcmp (register_name,"R0" )) +return 0 ; +else if (!strcmp (register_name,"R1" )) +return 1 ; +else if (!strcmp (register_name,"R2" )) +return 2 ; +else if (!strcmp (register_name,"R3" )) +return 3 ; +else if (!strcmp (register_name,"R4" )) +return 4 ; +else if (!strcmp (register_name,"R5" )) +return 5 ; +else if (!strcmp (register_name,"R6" )) +return 6 ; +else if (!strcmp (register_name,"R7" )) +return 7 ; +else if (!strcmp (register_name,"R8" )) +return 8 ; +else if (!strcmp (register_name,"R9" )) +return 9 ; +else if (!strcmp (register_name,"R10" )) +return 10 ; +else if (!strcmp (register_name,"R11" )) +return 11 ; +else if (!strcmp (register_name,"R12" )) +return 12 ; +else if (!strcmp (register_name,"R13" )) +return 13 ; +else if (!strcmp (register_name,"R14" )) +return 14 ; +else if (!strcmp (register_name,"R15" )) +return 15 ; +else if (!strcmp (register_name,"R16" )) +return 16 ; +else if (!strcmp (register_name,"R17" )) +return 17 ; +else if (!strcmp (register_name,"R18" )) +return 18 ; +else if (!strcmp (register_name,"R19" )) +return 19 ; +else if (!strcmp (register_name,"R20" )) +return 20 ; +else if (!strcmp (register_name,"R21" )) +return 21 ; +else if (!strcmp (register_name,"R22" )) +return 22 ; +else if (!strcmp (register_name,"R23" )) +return 23 ; +else if (!strcmp (register_name,"R24" )) +return 24 ; +else if (!strcmp (register_name,"R25" )) +return 25 ; +else if (!strcmp (register_name,"R26" )) +return 26 ; +else if (!strcmp (register_name,"R27" )) +return 27 ; +else if (!strcmp (register_name,"R28" )) +return 28 ; +else if (!strcmp (register_name,"R29" )) +return 29 ; +else if (!strcmp (register_name,"R30" )) +return 30 ; +else if (!strcmp (register_name,"R31" )) +return 31 ; +else if (!strcmp (register_name,"NIP" )) +return 32 ; +else if (!strcmp (register_name,"MSR" )) +return 33 ; +else if (!strcmp (register_name,"ORIG_R3" )) +return 34 ; +else if (!strcmp (register_name,"CTR" )) +return 35 ; +else if (!strcmp (register_name,"LINK" )) +return 36 ; +else if (!strcmp (register_name,"XER" )) +return 37 ; +else if (!strcmp (register_name,"CCR" )) +return 38 ; +else if (!strcmp (register_name,"SOFTE" )) +return 39 ; +else if (!strcmp (register_name,"TRAP" )) +return 40 ; +else if (!strcmp (register_name,"DAR" )) +return 41 ; +else if (!strcmp (register_name,"DSISR" )) +return 42 ; +else if (!strcmp (register_name,"SIER" )) +return 43 ; +else if (!strcmp (register_name,"MMCRA" )) +return 44 ; +else if (!strcmp (register_name,"MMCR0" )) +return 45 ; +else if (!strcmp (register_name,"MMCR1" )) +return 46 ; +else if (!strcmp (register_name,"MMCR2" )) +return 47 ; +else if (!strcmp (register_name,"MMCR3" )) +return 48 ; +else if (!strcmp (register_name,"SIER2" )) +return 49 ; +else if (!strcmp (register_name,"SIER3" )) +return 50 ; +else if (!strcmp (register_name,"PMC1" )) +return 51 ; +else if (!strcmp (register_name,"PMC2" )) +return 52 ; +else if (!strcmp (register_name,"PMC3" )) +return 53 ; +else if (!strcmp (register_name,"PMC4" )) +return 54 ; +else if (!strcmp (register_name,"PMC5" )) +return 55 ; +else if (!strcmp (register_name,"PMC6" )) +return 56 ; +else if (!strcmp (register_name,"SDAR" )) +return 57 ; +else if (!strcmp (register_name,"SIAR" )) +return 58 ; +else +return -1 ; +} + +u64 get_reg_value (u64 *intr_regs,char *register_name) +{ +int register_bit_position; + + register_bit_position =__perf_reg_mask (register_name); + +if (register_bit_position <0 || (!((platform_extended_mask >> + (register_bit_position -1 )) &1 ))) +return -1 ; + +return *(intr_regs + register_bit_position); +}
tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h +4 -0
@@ -2,6 +2,7 @@/* * Copyright 2022, Athira Rajeev, IBM Corp. * Copyright 2022, Madhavan Srinivasan, IBM Corp. +* Copyright 2022, Kajol Jain, IBM Corp. */ #include "../event.h"
@@ -57,3 +58,6 @@ static inline int is_pSeries(void)void *event_sample_buf_mmap (int fd,int mmap_pages);void *__event_read_samples (void *sample_buff,size_t *size,u64 *sample_count); +int collect_samples (void *sample_buff); +u64 *get_intr_regs (struct event *event,void *sample_buff); +u64 get_reg_value (u64 *intr_regs,char *register_name);
Signature · 1 line
2.27.0
PATCH 5/20 selftest/powerpc/pmu: Add event_init_sampling function
In reply to Kajol JainFrom: Madhavan Srinivasan <[email protected]>
Extended event_init_opts() to include initialization of sampling testcases. Patch adds an event_init_sampling() wrapper to initialize event attribute fields for sampling events. This includes initializing sample period, sample type and event type.
--- tools/testing/selftests/powerpc/pmu/event.c | 18 +++++++++++++++++- tools/testing/selftests/powerpc/pmu/event.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-)
tools/testing/selftests/powerpc/pmu/event.c +17 -1
@@ -20,7 +20,8 @@ int perf_event_open(struct perf_event_attr *attr, pid_t pid, int cpu, group_fd, flags); } -void event_init_opts (struct event *e,u64 config,int type,char *name) +static void __event_init_opts (struct event *e,u64 config, +int type,char *name,int sampling) {memset (e,0 ,sizeof (*e));
@@ -32,6 +33,16 @@ void event_init_opts(struct event *e, u64 config, int type, char *name)/* This has to match the structure layout in the header */ e->attr.read_format =PERF_FORMAT_TOTAL_TIME_ENABLED | \PERF_FORMAT_TOTAL_TIME_RUNNING ; +if (sampling) { + e->attr.sample_period =1000 ; + e->attr.sample_type =PERF_SAMPLE_REGS_INTR ; + e->attr.disabled =1 ; + } +} + +void event_init_opts (struct event *e,u64 config,int type,char *name) +{ +__event_init_opts (e, config, type, name,0 ); }void event_init_named (struct event *e,u64 config,char *name)
@@ -44,6 +55,11 @@ void event_init(struct event *e, u64 config)event_init_opts (e, config,PERF_TYPE_RAW ,"event" ); } +void event_init_sampling (struct event *e,u64 config) +{ +__event_init_opts (e, config,PERF_TYPE_RAW ,"event" ,1 ); +} +#define PERF_CURRENT_PID 0#define PERF_NO_PID -1#define PERF_NO_CPU -1
tools/testing/selftests/powerpc/pmu/event.h +1 -0
@@ -32,6 +32,7 @@ struct event {void event_init (struct event *e,u64 config);void event_init_named (struct event *e,u64 config,char *name);void event_init_opts (struct event *e,u64 config,int type,char *name); +void event_init_sampling (struct event *e,u64 config);int event_open_with_options (struct event *e,pid_t pid,int cpu,int group_fd);int event_open_with_group (struct event *e,int group_fd);int event_open_with_pid (struct event *e,pid_t pid);
Signature · 1 line
2.27.0
PATCH 6/20 selftest/powerpc/pmu: Add macros to extract mmcr fields
In reply to Kajol JainFrom: Madhavan Srinivasan <[email protected]>
Generic macro (GET_MMCR_FIELD) added to extract specific fields of a given MMCRx. Along with it, patch also adds macro and utility functions to fetch individual fields from
Monitor Mode Control Register 2(MMCR2) register.
--- .../powerpc/pmu/sampling_tests/misc.h | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+)
tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h +70 -0
@@ -61,3 +61,73 @@ void *__event_read_samples(void *sample_buff, size_t *size, u64 *sample_count);int collect_samples (void *sample_buff);u64 *get_intr_regs (struct event *event,void *sample_buff);u64 get_reg_value (u64 *intr_regs,char *register_name); + +static inline int get_mmcr2_fcs (u64 mmcr2,int pmc) +{ +return ((mmcr2 & (1ull << (63 - (((pmc) -1 ) *9 )))) >> (63 - (((pmc) -1 ) *9 ))); +} + +static inline int get_mmcr2_fcp (u64 mmcr2,int pmc) +{ +return ((mmcr2 & (1ull << (62 - (((pmc) -1 ) *9 )))) >> (62 - (((pmc) -1 ) *9 ))); +} + +static inline int get_mmcr2_fcpc (u64 mmcr2,int pmc) +{ +return ((mmcr2 & (1ull << (61 - (((pmc) -1 ) *9 )))) >> (61 - (((pmc) -1 ) *9 ))); +} + +static inline int get_mmcr2_fcm1 (u64 mmcr2,int pmc) +{ +return ((mmcr2 & (1ull << (60 - (((pmc) -1 ) *9 )))) >> (60 - (((pmc) -1 ) *9 ))); +} + +static inline int get_mmcr2_fcm0 (u64 mmcr2,int pmc) +{ +return ((mmcr2 & (1ull << (59 - (((pmc) -1 ) *9 )))) >> (59 - (((pmc) -1 ) *9 ))); +} + +static inline int get_mmcr2_fcwait (u64 mmcr2,int pmc) +{ +return ((mmcr2 & (1ull << (58 - (((pmc) -1 ) *9 )))) >> (58 - (((pmc) -1 ) *9 ))); +} + +static inline int get_mmcr2_fch (u64 mmcr2,int pmc) +{ +return ((mmcr2 & (1ull << (57 - (((pmc) -1 ) *9 )))) >> (57 - (((pmc) -1 ) *9 ))); +} + +static inline int get_mmcr2_fcti (u64 mmcr2,int pmc) +{ +return ((mmcr2 & (1ull << (56 - (((pmc) -1 ) *9 )))) >> (56 - (((pmc) -1 ) *9 ))); +} + +static inline int get_mmcr2_fcta (u64 mmcr2,int pmc) +{ +return ((mmcr2 & (1ull << (55 - (((pmc) -1 ) *9 )))) >> (55 - (((pmc) -1 ) *9 ))); +} + +static inline int get_mmcr2_l2l3 (u64 mmcr2,int pmc) +{ +if (pvr ==POWER10 ) +return ((mmcr2 &0xf8 ) >>3 ); +return 0 ; +} + +#define GET_MMCR2 (a, b, c) get_mmcr2_##c(a, b) + +/* +* Generic MMCR macro to get specific field value +* from a specific MMCR. +* +* Input: +* 'x' - MMCRx +* 'a' - u64 +* 'b' - PMC# +* 'c' - Field# +* +* Output: +* u32 +*/ +#define GET_MMCR_FIELD (x, a, b, c) \ + GET_MMCR##x(a, b, c)
Signature · 1 line
2.27.0
PATCH 7/20 selftest/powerpc/pmu: Add macro to extract mmcr0/mmcr1 fields
In reply to Kajol JainFrom: Athira Rajeev <[email protected]>
Add macro and utility functions to fetch individual fields from Monitor Mode Control Register 0(MMCR0) and Monitor Mode Control Register 1(MMCR1) PMU register.
--- .../powerpc/pmu/sampling_tests/misc.h | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+)
tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h +66 -0
@@ -12,6 +12,10 @@#define PERF_POWER9_MASK 0x7f8ffffffffffff#define PERF_POWER10_MASK 0x7ffffffffffffff +#define MMCR0_FC56 0x00000010UL/* freeze counters 5 and 6 */ +#define MMCR0_PMCCEXT 0x00000200UL/* PMCCEXT control */ +#define MMCR1_RSQ 0x200000000000ULL/* radix scope qual field */ +extern int ev_mask_pmcxsel, ev_shift_pmcxsel;extern int ev_mask_marked, ev_shift_marked;extern int ev_mask_comb, ev_shift_comb;
@@ -62,6 +66,66 @@ int collect_samples(void *sample_buff);u64 *get_intr_regs (struct event *event,void *sample_buff);u64 get_reg_value (u64 *intr_regs,char *register_name); +static inline int get_mmcr0_fc56 (u64 mmcr0,int pmc) +{ +return (mmcr0 &MMCR0_FC56 ); +} + +static inline int get_mmcr0_pmccext (u64 mmcr0,int pmc) +{ +return (mmcr0 &MMCR0_PMCCEXT ); +} + +static inline int get_mmcr0_pmao (u64 mmcr0,int pmc) +{ +return ((mmcr0 >>7 ) &0x1 ); +} + +static inline int get_mmcr0_cc56run (u64 mmcr0,int pmc) +{ +return ((mmcr0 >>8 ) &0x1 ); +} + +static inline int get_mmcr0_pmcjce (u64 mmcr0,int pmc) +{ +return ((mmcr0 >>14 ) &0x1 ); +} + +static inline int get_mmcr0_pmc1ce (u64 mmcr0,int pmc) +{ +return ((mmcr0 >>15 ) &0x1 ); +} + +static inline int get_mmcr0_pmae (u64 mmcr0,int pmc) +{ +return ((mmcr0 >>27 ) &0x1 ); +} + +static inline int get_mmcr1_pmcxsel (u64 mmcr1,int pmc) +{ +return ((mmcr1 >> ((24 - (((pmc) -1 ) *8 ))) &0xff )); +} + +static inline int get_mmcr1_unit (u64 mmcr1,int pmc) +{ +return ((mmcr1 >> ((60 - (4 * ((pmc) -1 ))))) &0xf ); +} + +static inline int get_mmcr1_comb (u64 mmcr1,int pmc) +{ +return ((mmcr1 >> (38 - ((pmc -1 ) *2 ))) &0x3 ); +} + +static inline int get_mmcr1_cache (u64 mmcr1,int pmc) +{ +return ((mmcr1 >>46 ) &0x3 ); +} + +static inline int get_mmcr1_rsq (u64 mmcr1,int pmc) +{ +return mmcr1 &MMCR1_RSQ ; +} +static inline int get_mmcr2_fcs (u64 mmcr2,int pmc) {return ((mmcr2 & (1ull << (63 - (((pmc) -1 ) *9 )))) >> (63 - (((pmc) -1 ) *9 )));
@@ -114,6 +178,8 @@ static inline int get_mmcr2_l2l3(u64 mmcr2, int pmc)return 0 ; } +#define GET_MMCR0 (a, b, c) get_mmcr0_##c(a, b) +#define GET_MMCR1 (a, b, c) get_mmcr1_##c(a, b)#define GET_MMCR2 (a, b, c) get_mmcr2_##c(a, b)/*
Signature · 1 line
2.27.0
PATCH 8/20 selftest/powerpc/pmu: Add macro to extract mmcr3 and mmcra fields
In reply to Kajol JainAdd macro and utility functions to fetch individual fields from Monitor Mode Control Register 3(MMCR3)and Monitor Mode Control Register A(MMCRA) PMU registers
--- .../powerpc/pmu/sampling_tests/misc.h | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+)
tools/testing/selftests/powerpc/pmu/sampling_tests/misc.h +64 -0
@@ -15,6 +15,7 @@#define MMCR0_FC56 0x00000010UL/* freeze counters 5 and 6 */ #define MMCR0_PMCCEXT 0x00000200UL/* PMCCEXT control */ #define MMCR1_RSQ 0x200000000000ULL/* radix scope qual field */ +#define BHRB_DISABLE 0x2000000000ULL/* MMCRA BHRB DISABLE bit */ extern int ev_mask_pmcxsel, ev_shift_pmcxsel;extern int ev_mask_marked, ev_shift_marked;
@@ -178,9 +179,72 @@ static inline int get_mmcr2_l2l3(u64 mmcr2, int pmc)return 0 ; } +static inline int get_mmcr3_src (u64 mmcr3,int pmc) +{ +if (pvr !=POWER10 ) +return 0 ; +return ((mmcr3 >> ((49 - (15 * ((pmc) -1 ))))) &0x7fff ); +} + +static inline int get_mmcra_thd_cmp (u64 mmcra,int pmc) +{ +if (pvr ==POWER10 ) +return ((mmcra >>45 ) &0x7ff ); +return ((mmcra >>45 ) &0x3ff ); +} + +static inline int get_mmcra_sm (u64 mmcra,int pmc) +{ +return ((mmcra >>42 ) &0x3 ); +} + +static inline int get_mmcra_bhrb_disable (u64 mmcra,int pmc) +{ +if (pvr ==POWER10 ) +return mmcra &BHRB_DISABLE ; +return 0 ; +} + +static inline int get_mmcra_ifm (u64 mmcra,int pmc) +{ +return ((mmcra >>30 ) &0x3 ); +} + +static inline int get_mmcra_thd_sel (u64 mmcra,int pmc) +{ +return ((mmcra >>16 ) &0x7 ); +} + +static inline int get_mmcra_thd_start (u64 mmcra,int pmc) +{ +return ((mmcra >>12 ) &0xf ); +} + +static inline int get_mmcra_thd_stop (u64 mmcra,int pmc) +{ +return ((mmcra >>8 ) &0xf ); +} + +static inline int get_mmcra_rand_samp_elig (u64 mmcra,int pmc) +{ +return ((mmcra >>4 ) &0x7 ); +} + +static inline int get_mmcra_sample_mode (u64 mmcra,int pmc) +{ +return ((mmcra >>1 ) &0x3 ); +} + +static inline int get_mmcra_marked (u64 mmcra,int pmc) +{ +return mmcra &0x1 ; +} +#define GET_MMCR0 (a, b, c) get_mmcr0_##c(a, b)#define GET_MMCR1 (a, b, c) get_mmcr1_##c(a, b)#define GET_MMCR2 (a, b, c) get_mmcr2_##c(a, b) +#define GET_MMCR3 (a, b, c) get_mmcr3_##c(a, b) +#define GET_MMCRA (a, b, c) get_mmcra_##c(a, b)/* * Generic MMCR macro to get specific field value
Signature · 1 line
2.27.0
PATCH 10/20 selftest/powerpc/pmu/: Add interface test for mmcr0_cc56run field
In reply to Kajol JainFrom: Athira Rajeev <[email protected]>
The testcase uses event code 0x500fa ("instructions") to check the CC56RUN bit setting in Monitor Mode Control Register 0(MMCR0). In ISA v3.1 platform, this bit is expected to be set in MMCR0 when using Performance Monitor Counter 5 and 6 (PMC5 and PMC6). Verify this is done correctly by perf interface.
CC56RUN bit makes PMC5 and PMC6 count regardless of the run latch state. This bit is set in power10 since PMC5 and PMC6 is used in power10 for counting instructions and cycles. Hence added a check to skip this test in other platforms
--- .../powerpc/pmu/sampling_tests/Makefile | 4 +- .../pmu/sampling_tests/mmcr0_cc56run_test.c | 59 +++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr0_cc56run_test.c
tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile +2 -2
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 include ../../../../../../scripts/Kbuild.include -all: $(TEST_GEN_PROGS) mmcr0_exceptionbits_test.c +all: $(TEST_GEN_PROGS) mmcr0_exceptionbits_test.c mmcr0_cc56run_test.c noarg: $(MAKE) -C ../../
@@ -12,7 +12,7 @@ CFLAGS += -m64 -I../../../../../lib/ no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie) -TEST_GEN_PROGS := mmcr0_exceptionbits_test +TEST_GEN_PROGS := mmcr0_exceptionbits_test mmcr0_cc56run_test LDFLAGS += $(no-pie-option)
tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr0_cc56run_test.c new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 9/20 selftest/powerpc/pmu/: Add interface test for mmcr0 exception bits
In reply to Kajol JainFrom: Athira Rajeev <[email protected]>
The testcase uses "instructions" event to verify two bits(PMAE and PMAO) in Monitor Mode Control Register 0 (MMCR0). At the time of interrupt, pmae bit ( which enables performance monitor exception ) is expected to be cleared and pmao (which indicates performance monitor alert) bit is expected to be set in MMCR0. And testcases handles these checks.
--- .../powerpc/pmu/sampling_tests/Makefile | 6 +- .../sampling_tests/mmcr0_exceptionbits_test.c | 59 +++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr0_exceptionbits_test.c
tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile +4 -2
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 include ../../../../../../scripts/Kbuild.include -all: $(TEST_GEN_PROGS) +all: $(TEST_GEN_PROGS) mmcr0_exceptionbits_test.c noarg: $(MAKE) -C ../../
@@ -12,9 +12,11 @@ CFLAGS += -m64 -I../../../../../lib/ no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie) +TEST_GEN_PROGS := mmcr0_exceptionbits_test + LDFLAGS += $(no-pie-option) top_srcdir = ../../../../../.. include ../../../lib.mk -$(TEST_GEN_PROGS): ../../harness.c ../../utils.c ../event.c ../lib.c misc.c misc.h +$(TEST_GEN_PROGS): ../../harness.c ../../utils.c ../event.c ../lib.c misc.c misc.h ../loop.S
tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr0_exceptionbits_test.c new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 11/20 selftest/powerpc/pmu/: Add interface test for mmcr0_pmccext bit
In reply to Kajol JainFrom: Athira Rajeev <[email protected]>
The testcase uses cycles event to check the PMCCEXT bit setting in Monitor Mode Control Register 0 (MMCR0). Check if perf interface sets this control bit in MMCR0 on ISA v3.1 platform.
--- .../powerpc/pmu/sampling_tests/Makefile | 4 +- .../pmu/sampling_tests/mmcr0_pmccext_test.c | 59 +++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr0_pmccext_test.c
tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile +2 -2
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 include ../../../../../../scripts/Kbuild.include -all: $(TEST_GEN_PROGS) mmcr0_exceptionbits_test.c mmcr0_cc56run_test.c +all: $(TEST_GEN_PROGS) mmcr0_exceptionbits_test.c mmcr0_cc56run_test.c mmcr0_pmccext_test.c noarg: $(MAKE) -C ../../
@@ -12,7 +12,7 @@ CFLAGS += -m64 -I../../../../../lib/ no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie) -TEST_GEN_PROGS := mmcr0_exceptionbits_test mmcr0_cc56run_test +TEST_GEN_PROGS := mmcr0_exceptionbits_test mmcr0_cc56run_test mmcr0_pmccext_test LDFLAGS += $(no-pie-option)
tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr0_pmccext_test.c new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 12/20 selftest/powerpc/pmu/: Add interface test for mmcr0_pmcjce field
In reply to Kajol JainFrom: Athira Rajeev <[email protected]>
The testcase uses event code 0x500fa ("instructions") to verify the PMCjCE bit setting in Monitor Mode Control Register 0 (MMCR0). This bit is expected to be set in MMCR0 when using Performance Monitor Counter 5 (PMC5). Checks if perf interface sets this bit correctly.
--- .../powerpc/pmu/sampling_tests/Makefile | 6 +- .../pmu/sampling_tests/mmcr0_pmcjce_test.c | 58 +++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr0_pmcjce_test.c
tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile +4 -2
@@ -1,7 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 include ../../../../../../scripts/Kbuild.include -all: $(TEST_GEN_PROGS) mmcr0_exceptionbits_test.c mmcr0_cc56run_test.c mmcr0_pmccext_test.c +all: $(TEST_GEN_PROGS) mmcr0_exceptionbits_test.c mmcr0_cc56run_test.c mmcr0_pmccext_test.c \ + mmcr0_pmcjce_test.c noarg: $(MAKE) -C ../../
@@ -12,7 +13,8 @@ CFLAGS += -m64 -I../../../../../lib/ no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie) -TEST_GEN_PROGS := mmcr0_exceptionbits_test mmcr0_cc56run_test mmcr0_pmccext_test +TEST_GEN_PROGS := mmcr0_exceptionbits_test mmcr0_cc56run_test mmcr0_pmccext_test \ + mmcr0_pmcjce_test LDFLAGS += $(no-pie-option)
tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr0_pmcjce_test.c new file +58 -0
58 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 13/20 selftest/powerpc/pmu/: Add interface test for mmcr0_fc56 field using pmc1
In reply to Kajol JainFrom: Athira Rajeev <[email protected]>
The testcase uses event code 0x1001e to verify two bit settings (FC5-6 and PMC1CE) in Monitor Mode Control Register 0 (MMCR0). Check if FC5-6 bit to be set in MMCR0 when not using Performance Monitor Counter 5 and 6 (PMC5 and PMC6). And also PMC1CE is expected to be set when using PMC1. Test if these fields are programmed correctly via perf interface.
--- .../powerpc/pmu/sampling_tests/Makefile | 4 +- .../sampling_tests/mmcr0_fc56_pmc1ce_test.c | 58 +++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr0_fc56_pmc1ce_test.c
tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile +2 -2
@@ -2,7 +2,7 @@ include ../../../../../../scripts/Kbuild.include all: $(TEST_GEN_PROGS) mmcr0_exceptionbits_test.c mmcr0_cc56run_test.c mmcr0_pmccext_test.c \ - mmcr0_pmcjce_test.c + mmcr0_pmcjce_test.c mmcr0_fc56_pmc1ce_test.c noarg: $(MAKE) -C ../../
@@ -14,7 +14,7 @@ no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie) TEST_GEN_PROGS := mmcr0_exceptionbits_test mmcr0_cc56run_test mmcr0_pmccext_test \ - mmcr0_pmcjce_test + mmcr0_pmcjce_test mmcr0_fc56_pmc1ce_test LDFLAGS += $(no-pie-option)
tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr0_fc56_pmc1ce_test.c new file +58 -0
58 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 14/20 selftest/powerpc/pmu/: Add interface test for mmcr0_pmc56 using pmc5
In reply to Kajol JainFrom: Athira Rajeev <[email protected]>
The testcase uses event code 0x500fa to verify the FC5-6 bit setting in Monitor Mode Control Register 0 (MMCR0). Check if FC5-6 bit is not set in MMCR0 when using Performance Monitor Counter 5 and 6 (PMC5 and PMC6).
--- .../powerpc/pmu/sampling_tests/Makefile | 4 +- .../sampling_tests/mmcr0_fc56_pmc56_test.c | 58 +++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr0_fc56_pmc56_test.c
tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile +2 -2
@@ -2,7 +2,7 @@ include ../../../../../../scripts/Kbuild.include all: $(TEST_GEN_PROGS) mmcr0_exceptionbits_test.c mmcr0_cc56run_test.c mmcr0_pmccext_test.c \ - mmcr0_pmcjce_test.c mmcr0_fc56_pmc1ce_test.c + mmcr0_pmcjce_test.c mmcr0_fc56_pmc1ce_test.c mmcr0_fc56_pmc56_test.c noarg: $(MAKE) -C ../../
@@ -14,7 +14,7 @@ no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie) TEST_GEN_PROGS := mmcr0_exceptionbits_test mmcr0_cc56run_test mmcr0_pmccext_test \ - mmcr0_pmcjce_test mmcr0_fc56_pmc1ce_test + mmcr0_pmcjce_test mmcr0_fc56_pmc1ce_test mmcr0_fc56_pmc56_test LDFLAGS += $(no-pie-option)
tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr0_fc56_pmc56_test.c new file +58 -0
58 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 15/20 selftest/powerpc/pmu/: Add interface test for mmcr1_comb field
In reply to Kajol JainFrom: Athira Rajeev <[email protected]>
The testcase uses event code "0x26880" to verify the settings for different fields in Monitor Mode Control Register 1 (MMCR1). The field include PMCxCOMB. Checks if this field are translated correctly via perf interface to MMCR1
Add selftest for mmcr1 comb field.
--- .../powerpc/pmu/sampling_tests/Makefile | 6 +- .../pmu/sampling_tests/mmcr1_comb_test.c | 66 +++++++++++++++++++ 2 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr1_comb_test.c
tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile +4 -2
@@ -2,7 +2,8 @@ include ../../../../../../scripts/Kbuild.include all: $(TEST_GEN_PROGS) mmcr0_exceptionbits_test.c mmcr0_cc56run_test.c mmcr0_pmccext_test.c \ - mmcr0_pmcjce_test.c mmcr0_fc56_pmc1ce_test.c mmcr0_fc56_pmc56_test.c + mmcr0_pmcjce_test.c mmcr0_fc56_pmc1ce_test.c mmcr0_fc56_pmc56_test.c \ + mmcr1_comb_test.c noarg: $(MAKE) -C ../../
@@ -14,7 +15,8 @@ no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -no-pie -x c - -o "$$TMP", -no-pie) TEST_GEN_PROGS := mmcr0_exceptionbits_test mmcr0_cc56run_test mmcr0_pmccext_test \ - mmcr0_pmcjce_test mmcr0_fc56_pmc1ce_test mmcr0_fc56_pmc56_test + mmcr0_pmcjce_test mmcr0_fc56_pmc1ce_test mmcr0_fc56_pmc56_test \ + mmcr1_comb_test LDFLAGS += $(no-pie-option)
tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr1_comb_test.c new file +66 -0
66 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 16/20 selftest/powerpc/pmu/: Add selftest for mmcr1 pmcxsel/unit/cache fields
In reply to Kajol JainFrom: Athira Rajeev <[email protected]>
The testcase uses event code "0x1340000001c040" to verify the settings for different fields in Monitor Mode Control Register 1 (MMCR1). The fields include PMCxSEL, PMCXCOMB PMCxUNIT, cache. Checks if these fields are translated correctly via perf interface to MMCR1
--- .../powerpc/pmu/sampling_tests/Makefile | 4 +- .../mmcr1_sel_unit_cache_test.c | 70 +++++++++++++++++++ 2 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr1_sel_unit_cache_test.c
tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile +2 -2
@@ -3,7 +3,7 @@ include ../../../../../../scripts/Kbuild.include all: $(TEST_GEN_PROGS) mmcr0_exceptionbits_test.c mmcr0_cc56run_test.c mmcr0_pmccext_test.c \ mmcr0_pmcjce_test.c mmcr0_fc56_pmc1ce_test.c mmcr0_fc56_pmc56_test.c \ - mmcr1_comb_test.c + mmcr1_comb_test.c mmcr1_sel_unit_cache_test.c noarg: $(MAKE) -C ../../
@@ -16,7 +16,7 @@ no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ TEST_GEN_PROGS := mmcr0_exceptionbits_test mmcr0_cc56run_test mmcr0_pmccext_test \ mmcr0_pmcjce_test mmcr0_fc56_pmc1ce_test mmcr0_fc56_pmc56_test \ - mmcr1_comb_test + mmcr1_comb_test mmcr1_sel_unit_cache_test LDFLAGS += $(no-pie-option)
tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr1_sel_unit_cache_test.c new file +70 -0
70 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 17/20 selftest/powerpc/pmu/: Add interface test for mmcr2_l2l3 field
In reply to Kajol JainFrom: Madhavan Srinivasan <[email protected]>
The testcases uses event code 0x010000046080 to verify the l2l3 bit setting for Monitor Mode Control Register 2 (MMCR2). check if this bit is set correctly via perf interface in ISA v3.1 platform.
--- .../powerpc/pmu/sampling_tests/Makefile | 4 +- .../pmu/sampling_tests/mmcr2_l2l3_test.c | 74 +++++++++++++++++++ 2 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr2_l2l3_test.c
tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile +2 -2
@@ -3,7 +3,7 @@ include ../../../../../../scripts/Kbuild.include all: $(TEST_GEN_PROGS) mmcr0_exceptionbits_test.c mmcr0_cc56run_test.c mmcr0_pmccext_test.c \ mmcr0_pmcjce_test.c mmcr0_fc56_pmc1ce_test.c mmcr0_fc56_pmc56_test.c \ - mmcr1_comb_test.c mmcr1_sel_unit_cache_test.c + mmcr1_comb_test.c mmcr1_sel_unit_cache_test.c mmcr2_l2l3_test.c noarg: $(MAKE) -C ../../
@@ -16,7 +16,7 @@ no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ TEST_GEN_PROGS := mmcr0_exceptionbits_test mmcr0_cc56run_test mmcr0_pmccext_test \ mmcr0_pmcjce_test mmcr0_fc56_pmc1ce_test mmcr0_fc56_pmc56_test \ - mmcr1_comb_test mmcr1_sel_unit_cache_test + mmcr1_comb_test mmcr1_sel_unit_cache_test mmcr2_l2l3_test LDFLAGS += $(no-pie-option)
tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr2_l2l3_test.c new file +74 -0
74 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 18/20 selftest/powerpc/pmu/: Add interface test for mmcr2_fcs_fch fields
In reply to Kajol JainFrom: Madhavan Srinivasan <[email protected]>
The testcases uses cycles event to verify the freeze counter settings in Monitor Mode Control Register 2 (MMCR2). Event modifier (exclude_kernel) setting is used for the event attribute to check the FCxS and FCxH ( Freeze counter in privileged and hypervisor state ) settings via perf interface.
--- .../powerpc/pmu/sampling_tests/Makefile | 6 +- .../pmu/sampling_tests/mmcr2_fcs_fch_test.c | 67 +++++++++++++++++++ 2 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr2_fcs_fch_test.c
tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile +4 -2
@@ -3,7 +3,8 @@ include ../../../../../../scripts/Kbuild.include all: $(TEST_GEN_PROGS) mmcr0_exceptionbits_test.c mmcr0_cc56run_test.c mmcr0_pmccext_test.c \ mmcr0_pmcjce_test.c mmcr0_fc56_pmc1ce_test.c mmcr0_fc56_pmc56_test.c \ - mmcr1_comb_test.c mmcr1_sel_unit_cache_test.c mmcr2_l2l3_test.c + mmcr1_comb_test.c mmcr1_sel_unit_cache_test.c mmcr2_l2l3_test.c \ + mmcr2_fcs_fch_test.c noarg: $(MAKE) -C ../../
@@ -16,7 +17,8 @@ no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ TEST_GEN_PROGS := mmcr0_exceptionbits_test mmcr0_cc56run_test mmcr0_pmccext_test \ mmcr0_pmcjce_test mmcr0_fc56_pmc1ce_test mmcr0_fc56_pmc56_test \ - mmcr1_comb_test mmcr1_sel_unit_cache_test mmcr2_l2l3_test + mmcr1_comb_test mmcr1_sel_unit_cache_test mmcr2_l2l3_test \ + mmcr2_fcs_fch_test LDFLAGS += $(no-pie-option)
tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr2_fcs_fch_test.c new file +67 -0
67 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 19/20 selftest/powerpc/pmu/: Add interface test for mmcr3_src fields
In reply to Kajol JainThe testcase uses event code 0x1340000001c040 to verify the settings for different src fields in Monitor Mode Control Register 3 (MMCR3). Checks if these fields are translated correctly via perf interface to MMCR3 on ISA v3.1 platform.
--- .../powerpc/pmu/sampling_tests/Makefile | 4 +- .../pmu/sampling_tests/mmcr3_src_test.c | 67 +++++++++++++++++++ 2 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr3_src_test.c
tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile +2 -2
@@ -4,7 +4,7 @@ include ../../../../../../scripts/Kbuild.include all: $(TEST_GEN_PROGS) mmcr0_exceptionbits_test.c mmcr0_cc56run_test.c mmcr0_pmccext_test.c \ mmcr0_pmcjce_test.c mmcr0_fc56_pmc1ce_test.c mmcr0_fc56_pmc56_test.c \ mmcr1_comb_test.c mmcr1_sel_unit_cache_test.c mmcr2_l2l3_test.c \ - mmcr2_fcs_fch_test.c + mmcr2_fcs_fch_test.c mmcr3_src_test.c noarg: $(MAKE) -C ../../
@@ -18,7 +18,7 @@ no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ TEST_GEN_PROGS := mmcr0_exceptionbits_test mmcr0_cc56run_test mmcr0_pmccext_test \ mmcr0_pmcjce_test mmcr0_fc56_pmc1ce_test mmcr0_fc56_pmc56_test \ mmcr1_comb_test mmcr1_sel_unit_cache_test mmcr2_l2l3_test \ - mmcr2_fcs_fch_test + mmcr2_fcs_fch_test mmcr3_src_test LDFLAGS += $(no-pie-option)
tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr3_src_test.c new file +67 -0
67 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH 20/20 selftest/powerpc/pmu: Add interface test for mmcra register fields
In reply to Kajol JainThe testcase uses event code 0x35340401e0 to verify
the settings for different fields in Monitor Mode Control Register A (MMCRA). The fields include thresh_start, thresh_stop thresh_select, sdar mode, sample and marked bit. Checks if these fields are translated correctly via perf interface to MMCRA.
--- .../powerpc/pmu/sampling_tests/Makefile | 4 +- .../mmcra_thresh_marked_sample_test.c | 80 +++++++++++++++++++ 2 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_thresh_marked_sample_test.c
tools/testing/selftests/powerpc/pmu/sampling_tests/Makefile +2 -2
@@ -4,7 +4,7 @@ include ../../../../../../scripts/Kbuild.include all: $(TEST_GEN_PROGS) mmcr0_exceptionbits_test.c mmcr0_cc56run_test.c mmcr0_pmccext_test.c \ mmcr0_pmcjce_test.c mmcr0_fc56_pmc1ce_test.c mmcr0_fc56_pmc56_test.c \ mmcr1_comb_test.c mmcr1_sel_unit_cache_test.c mmcr2_l2l3_test.c \ - mmcr2_fcs_fch_test.c mmcr3_src_test.c + mmcr2_fcs_fch_test.c mmcr3_src_test.c mmcra_thresh_marked_sample_test.c noarg: $(MAKE) -C ../../
@@ -18,7 +18,7 @@ no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ TEST_GEN_PROGS := mmcr0_exceptionbits_test mmcr0_cc56run_test mmcr0_pmccext_test \ mmcr0_pmcjce_test mmcr0_fc56_pmc1ce_test mmcr0_fc56_pmc56_test \ mmcr1_comb_test mmcr1_sel_unit_cache_test mmcr2_l2l3_test \ - mmcr2_fcs_fch_test mmcr3_src_test + mmcr2_fcs_fch_test mmcr3_src_test mmcra_thresh_marked_sample_test LDFLAGS += $(no-pie-option)
tools/testing/selftests/powerpc/pmu/sampling_tests/mmcra_thresh_marked_sample_test.c new file +80 -0
80 lines not on this page · raw message
Signature · 1 line
2.27.0
Quoted 8 lines · Kajol Jain
Patch series adds support for perf sampling tests that enables capturing sampling data in perf mmap buffer and further support for reading and processing the samples. It also addds basic utility functions to process the mmap buffer inorder to read total count of samples as well as the contents of sample.
[...]
Patches 1-15 and 17-20 applied to powerpc/next.
[01/20] selftest/powerpc/pmu: Include mmap_buffer field as part of struct event
https://git.kernel.org/powerpc/c/f961e20f15ed35e9ca154a099897d600b78b0311 [02/20] selftest/powerpc/pmu: Add support for perf sampling tests https://git.kernel.org/powerpc/c/c315669e2fbd71bb9387066f60f0d91b0ceb28f3 [03/20] selftest/powerpc/pmu: Add macros to parse event codes https://git.kernel.org/powerpc/c/6523dce86222451e5ca2df8a46597a217084bfdf [04/20] selftest/powerpc/pmu: Add utility functions to post process the mmap buffer https://git.kernel.org/powerpc/c/5f6c3061af7ca3b0f9f8a20ec7a445671f7e6b5a [05/20] selftest/powerpc/pmu: Add event_init_sampling function https://git.kernel.org/powerpc/c/54d4ba7f22d1ed5bfbc915771cf2e3e147cf03b2 [06/20] selftest/powerpc/pmu: Add macros to extract mmcr fields https://git.kernel.org/powerpc/c/79c4e6aba8dfc9206acc68884498080f451121f7 [07/20] selftest/powerpc/pmu: Add macro to extract mmcr0/mmcr1 fields https://git.kernel.org/powerpc/c/2b49e641063e7569493371ef433b9c4ce8c8dd8b [08/20] selftest/powerpc/pmu: Add macro to extract mmcr3 and mmcra fields https://git.kernel.org/powerpc/c/13307f9584ea9408d9959302074dc4e8308b6cab [09/20] selftest/powerpc/pmu/: Add interface test for mmcr0 exception bits https://git.kernel.org/powerpc/c/eb7aa044df18c6f7a88bc17fc4c9f4524652a290 [10/20] selftest/powerpc/pmu/: Add interface test for mmcr0_cc56run field https://git.kernel.org/powerpc/c/a7c0ab2e61484c0844eae2f208a06cc940338d83 [11/20] selftest/powerpc/pmu/: Add interface test for mmcr0_pmccext bit https://git.kernel.org/powerpc/c/b24142b9d2401468bcd8df157013306d5b4f6626 [12/20] selftest/powerpc/pmu/: Add interface test for mmcr0_pmcjce field https://git.kernel.org/powerpc/c/9ac7c6d5e4b570f416d849b263a6f67a617b4fa5 [13/20] selftest/powerpc/pmu/: Add interface test for mmcr0_fc56 field using pmc1 https://git.kernel.org/powerpc/c/d5172f2585cd0fc9788aa9b25d3dce6483321792 [14/20] selftest/powerpc/pmu/: Add interface test for mmcr0_pmc56 using pmc5 https://git.kernel.org/powerpc/c/6e11374b08723b2c43ae83bd5d48000d695f13a0 [15/20] selftest/powerpc/pmu/: Add interface test for mmcr1_comb field https://git.kernel.org/powerpc/c/2becea3b6acf308642d6c0e9bd41caf7820753f5 [17/20] selftest/powerpc/pmu/: Add interface test for mmcr2_l2l3 field https://git.kernel.org/powerpc/c/ac575b2606bf99a0d01a054196e24e1ad82c194d [18/20] selftest/powerpc/pmu/: Add interface test for mmcr2_fcs_fch fields https://git.kernel.org/powerpc/c/9ee241f1b1447c7e8ca90902ab1888aa9e7a3c00 [19/20] selftest/powerpc/pmu/: Add interface test for mmcr3_src fields https://git.kernel.org/powerpc/c/02f02feb6b50c67171fd56bc3fd0fd96118c5c12 [20/20] selftest/powerpc/pmu: Add interface test for mmcra register fields https://git.kernel.org/powerpc/c/29cf373c5766e6bd1b97056d2d678a41777669aa
cheers
Re: [PATCH 16/20] selftest/powerpc/pmu/: Add selftest for mmcr1 pmcxsel/unit/cache fields
In reply to Kajol JainLe 27/01/2022 à 08:20, Kajol Jain a écrit :
Quoted 9 lines
From: Athira Rajeev <[email protected]>
The testcase uses event code "
0x1340000001c040" to verify the settings for different fields in Monitor Mode Control Register 1 (MMCR1). The fields include PMCxSEL, PMCXCOMB PMCxUNIT, cache. Checks if these fields are translated correctly via perf interface to MMCR1Signed-off-by Athira Rajeev <[email protected]>
I see the series has been accepted but this patch has been left over.
Any reason ?
Thanks
Christophe
Quoted 104 lines
--- .../powerpc/pmu/sampling_tests/Makefile | 4 +- .../mmcr1_sel_unit_cache_test.c | 70 +++++++++++++++++++ 2 files changed, 72 insertions(+), 2 deletions(-)create mode 100644
tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr1_sel_unit_cache_test.ctools/testing/selftests/powerpc/pmu/sampling_tests/Makefile +2
-2@@ -3,7 +3,7 @@ include ../../../../../../scripts/Kbuild.include all: $(TEST_GEN_PROGS) mmcr0_exceptionbits_test.c mmcr0_cc56run_test.c mmcr0_pmccext_test.c \ mmcr0_pmcjce_test.c mmcr0_fc56_pmc1ce_test.c mmcr0_fc56_pmc56_test.c \ - mmcr1_comb_test.c + mmcr1_comb_test.c mmcr1_sel_unit_cache_test.c noarg: $(MAKE) -C ../../@@ -16,7 +16,7 @@ no-pie-option := $(call try-run, echo 'int main() { return 0; }' | \ TEST_GEN_PROGS := mmcr0_exceptionbits_test mmcr0_cc56run_test mmcr0_pmccext_test \ mmcr0_pmcjce_test mmcr0_fc56_pmc1ce_test mmcr0_fc56_pmc56_test \ - mmcr1_comb_test + mmcr1_comb_test mmcr1_sel_unit_cache_test LDFLAGS += $(no-pie-option)tools/testing/selftests/powerpc/pmu/sampling_tests/mmcr1_sel_unit_cache_test.c new file +70
-0@@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright 2022, Athira Rajeev, IBM Corp. +*/ + +#include <stdio.h> +#include <stdlib.h> + +#include "../event.h" +#include "misc.h" +#include "utils.h" + +extern void thirty_two_instruction_loop_with_ll_sc (u64 loops,u64 *ll_sc_target); + +/* The data cache was reloaded from local core's L3 due to a demand load */ +#define EventCode 0x21c040 + +/* +* A perf sampling test for mmcr1 +* fields : pmcxsel, unit, cache. +*/ +static int mmcr1_sel_unit_cache (void ) +{ +struct event event; +u64 *intr_regs; +u64 dummy; + +/* Check for platform support for the test */ +SKIP_IF (check_pvr_for_sampling_tests ()); + +/* Init the event for the sampling test */ +event_init_sampling (&event, EventCode); + event.attr.sample_regs_intr = platform_extended_mask; +FAIL_IF (event_open (&event)); + event.mmap_buffer =event_sample_buf_mmap (event.fd,1 ); + +event_enable (&event); + +/* workload to make the event overflow */ +thirty_two_instruction_loop_with_ll_sc (10000000 , &dummy); + +event_disable (&event); + +/* Check for sample count */ +FAIL_IF (!collect_samples (event.mmap_buffer)); + + intr_regs =get_intr_regs (&event, event.mmap_buffer); + +/* Check for intr_regs */ +FAIL_IF (!intr_regs); + +/* +* Verify that pmcxsel, unit and cache field of MMCR1 +* match with corresponding event code fields +*/ +FAIL_IF (EV_CODE_EXTRACT (event.attr.config, pmcxsel) != +GET_MMCR_FIELD (1 ,get_reg_value (intr_regs,"MMCR1" ),1 , pmcxsel)); +FAIL_IF (EV_CODE_EXTRACT (event.attr.config, unit) != +GET_MMCR_FIELD (1 ,get_reg_value (intr_regs,"MMCR1" ),1 , unit)); +FAIL_IF (EV_CODE_EXTRACT (event.attr.config, cache) != +GET_MMCR_FIELD (1 ,get_reg_value (intr_regs,"MMCR1" ),1 , cache)); + +event_close (&event); +return 0 ; +} + +int main (void ) +{ +FAIL_IF (test_harness (mmcr1_sel_unit_cache,"mmcr1_sel_unit_cache" )); +}
Michael Ellerman
reviewerRe: [PATCH 16/20] selftest/powerpc/pmu/: Add selftest for mmcr1 pmcxsel/unit/cache fields
Quoted 9 lines · Christophe Leroy
Le 27/01/2022 à 08:20, Kajol Jain a écrit :
Quoted 8 lines
From: Athira Rajeev <[email protected]>
The testcase uses event code "
0x1340000001c040" to verify the settings for different fields in Monitor Mode Control Register 1 (MMCR1). The fields include PMCxSEL, PMCXCOMB PMCxUNIT, cache. Checks if these fields are translated correctly via perf interface to MMCR1
Quoted 5 lines
Quoted 1 line
Signed-off-by Athira Rajeev <[email protected]>I see the series has been accepted but this patch has been left over.
Any reason ?
Yeah it's flakey. It counts cache loads but the workload it runs doesn't necessarily cause any, so it sometimes fails. I've reported that privately to Kajol.
cheers
Re: [PATCH 16/20] selftest/powerpc/pmu/: Add selftest for mmcr1 pmcxsel/unit/cache fields
Quoted 12 lines · Michael Ellerman
Quoted 11 lines · Christophe Leroy
Le 27/01/2022 à 08:20, Kajol Jain a écrit :
Quoted 9 lines
From: Athira Rajeev <[email protected]>
The testcase uses event code "
0x1340000001c040" to verify the settings for different fields in Monitor Mode Control Register 1 (MMCR1). The fields include PMCxSEL, PMCXCOMB PMCxUNIT, cache. Checks if these fields are translated correctly via perf interface to MMCR1Signed-off-by Athira Rajeev <[email protected]>
Quoted 8 lines
Quoted 3 lines
I see the series has been accepted but this patch has been left over.
Any reason ?
Yeah it's flakey. It counts cache loads but the workload it runs doesn't necessarily cause any, so it sometimes fails. I've reported that privately to Kajol.
Hi Christophe,
As Michael mentioned, with the current workload we used in this
patch, the testcase was failing sometimes as required cache load not happening everytime. We will send this patch separately with proper workload in next version.
Thanks,
Kajol Jain
Quoted 1 line
cheers