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

selftests/powerpc/pmu: Add selftest for group constraint check for PMC5 and PMC6

Events using Performance Monitor Counter 5 (PMC5) and Performance
Monitor Counter 6 (PMC6) can't have other fields in event code like
cache bits, thresholding or marked bit. PMC5 and PMC6 only supports base
events: ie 500fa and 600f4. Other combinations should fail. Testcase
tries setting other bits in event code for 500fa and 600f4 to check this
scenario.

Signed-off-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220610134113.62991-17-atrajeev@linux.vnet.ibm.com

authored by

Athira Rajeev and committed by
Michael Ellerman
9258c0aa 0a110a4b

+64 -1
+1 -1
tools/testing/selftests/powerpc/pmu/event_code_tests/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 CFLAGS += -m64 3 3 4 - TEST_GEN_PROGS := 4 + TEST_GEN_PROGS := group_constraint_pmc56_test 5 5 6 6 top_srcdir = ../../../../../.. 7 7 include ../../../lib.mk
+63
tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_pmc56_test.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Copyright 2022, Athira Rajeev, IBM Corp. 4 + */ 5 + 6 + #include <stdio.h> 7 + #include "../event.h" 8 + #include "../sampling_tests/misc.h" 9 + 10 + /* 11 + * Testcase for checking constraint checks for 12 + * Performance Monitor Counter 5 (PMC5) and also 13 + * Performance Monitor Counter 6 (PMC6). Events using 14 + * PMC5/PMC6 shouldn't have other fields in event 15 + * code like cache bits, thresholding or marked bit. 16 + */ 17 + 18 + static int group_constraint_pmc56(void) 19 + { 20 + struct event event; 21 + 22 + /* Check for platform support for the test */ 23 + SKIP_IF(platform_check_for_tests()); 24 + 25 + /* 26 + * Events using PMC5 and PMC6 with cache bit 27 + * set in event code is expected to fail. 28 + */ 29 + event_init(&event, 0x2500fa); 30 + FAIL_IF(!event_open(&event)); 31 + 32 + event_init(&event, 0x2600f4); 33 + FAIL_IF(!event_open(&event)); 34 + 35 + /* 36 + * PMC5 and PMC6 only supports base events: 37 + * ie 500fa and 600f4. Other combinations 38 + * should fail. 39 + */ 40 + event_init(&event, 0x501e0); 41 + FAIL_IF(!event_open(&event)); 42 + 43 + event_init(&event, 0x6001e); 44 + FAIL_IF(!event_open(&event)); 45 + 46 + event_init(&event, 0x501fa); 47 + FAIL_IF(!event_open(&event)); 48 + 49 + /* 50 + * Events using PMC5 and PMC6 with random 51 + * sampling bits set in event code should fail 52 + * to schedule. 53 + */ 54 + event_init(&event, 0x35340500fa); 55 + FAIL_IF(!event_open(&event)); 56 + 57 + return 0; 58 + } 59 + 60 + int main(void) 61 + { 62 + return test_harness(group_constraint_pmc56, "group_constraint_pmc56"); 63 + }