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

selftests/powerpc/pmu: Add selftest to check PMC5/6 is excluded from some constraint checks

Events using Performance Monitor Counter 5 (PMC5) and Performance
Monitor Counter 6 (PMC6) should be excluded from constraint check when
scheduled along with group of events. Example, combination of PMC5,
PMC6, and an event with cache bit will succeed to schedule though first
two events doesn't have cache bit set. Testcase use three events, ie,
600f4(cycles), 500fa(instructions), 22C040 with cache bit (dc_ic) set to
test this constraint check.

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-18-atrajeev@linux.vnet.ibm.com

authored by

Athira Rajeev and committed by
Michael Ellerman
4000c2e5 9258c0aa

+65 -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 := group_constraint_pmc56_test 4 + TEST_GEN_PROGS := group_constraint_pmc56_test group_pmc56_exclude_constraints_test 5 5 6 6 top_srcdir = ../../../../../.. 7 7 include ../../../lib.mk
+64
tools/testing/selftests/powerpc/pmu/event_code_tests/group_pmc56_exclude_constraints_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 <sys/prctl.h> 9 + #include <limits.h> 10 + #include "../sampling_tests/misc.h" 11 + 12 + /* 13 + * Testcase for group constraint check for 14 + * Performance Monitor Counter 5 (PMC5) and also 15 + * Performance Monitor Counter 6 (PMC6). 16 + * Test that pmc5/6 is excluded from constraint 17 + * check when scheduled along with group of events. 18 + */ 19 + 20 + static int group_pmc56_exclude_constraints(void) 21 + { 22 + struct event *e, events[3]; 23 + int i; 24 + 25 + /* Check for platform support for the test */ 26 + SKIP_IF(platform_check_for_tests()); 27 + 28 + /* 29 + * PMC5/6 is excluded from constraint bit 30 + * check along with group of events. Use 31 + * group of events with PMC5, PMC6 and also 32 + * event with cache bit (dc_ic) set. Test expects 33 + * this set of events to go in as a group. 34 + */ 35 + e = &events[0]; 36 + event_init(e, 0x500fa); 37 + 38 + e = &events[1]; 39 + event_init(e, 0x600f4); 40 + 41 + e = &events[2]; 42 + event_init(e, 0x22C040); 43 + 44 + FAIL_IF(event_open(&events[0])); 45 + 46 + /* 47 + * The event_open will fail if constraint check fails. 48 + * Since we are asking for events in a group and since 49 + * PMC5/PMC6 is excluded from group constraints, even_open 50 + * should pass. 51 + */ 52 + for (i = 1; i < 3; i++) 53 + FAIL_IF(event_open_with_group(&events[i], events[0].fd)); 54 + 55 + for (i = 0; i < 3; i++) 56 + event_close(&events[i]); 57 + 58 + return 0; 59 + } 60 + 61 + int main(void) 62 + { 63 + return test_harness(group_pmc56_exclude_constraints, "group_pmc56_exclude_constraints"); 64 + }