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 radix_scope_qual field

Testcase for group constraint check for radix_scope_qual field which is
used to program Monitor Mode Control Register (MMCR1) bit 18. All events
in the group should match radix_scope_qual bit, otherwise event_open for
the group should fail. Testcase uses "0x14242" (PM_DATA_RADIX_PROCESS_L2_PTE_FROM_L2)
with radix_scope_qual bit set for power10.

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

authored by

Athira Rajeev and committed by
Michael Ellerman
dc431be3 38b6da45

+57 -1
+1 -1
tools/testing/selftests/powerpc/pmu/event_code_tests/Makefile
··· 2 2 CFLAGS += -m64 3 3 4 4 TEST_GEN_PROGS := group_constraint_pmc56_test group_pmc56_exclude_constraints_test group_constraint_pmc_count_test \ 5 - group_constraint_repeat_test 5 + group_constraint_repeat_test group_constraint_radix_scope_qual_test 6 6 7 7 top_srcdir = ../../../../../.. 8 8 include ../../../lib.mk
+56
tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_radix_scope_qual_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 + /* PM_DATA_RADIX_PROCESS_L2_PTE_FROM_L2 */ 11 + #define EventCode_1 0x14242 12 + /* PM_DATA_RADIX_PROCESS_L2_PTE_FROM_L3 */ 13 + #define EventCode_2 0x24242 14 + 15 + /* 16 + * Testcase for group constraint check for radix_scope_qual 17 + * field which is used to program Monitor Mode Control 18 + * egister (MMCR1) bit 18. 19 + * All events in the group should match radix_scope_qual, 20 + * bits otherwise event_open for the group should fail. 21 + */ 22 + 23 + static int group_constraint_radix_scope_qual(void) 24 + { 25 + struct event event, leader; 26 + 27 + /* 28 + * Check for platform support for the test. 29 + * This test is aplicable on power10 only. 30 + */ 31 + SKIP_IF(platform_check_for_tests()); 32 + SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_3_1)); 33 + 34 + /* Init the events for the group contraint check for radix_scope_qual bits */ 35 + event_init(&leader, EventCode_1); 36 + FAIL_IF(event_open(&leader)); 37 + 38 + event_init(&event, 0x200fc); 39 + 40 + /* Expected to fail as sibling event doesn't request same radix_scope_qual bits as leader */ 41 + FAIL_IF(!event_open_with_group(&event, leader.fd)); 42 + 43 + event_init(&event, EventCode_2); 44 + /* Expected to pass as sibling event request same radix_scope_qual bits as leader */ 45 + FAIL_IF(event_open_with_group(&event, leader.fd)); 46 + 47 + event_close(&leader); 48 + event_close(&event); 49 + return 0; 50 + } 51 + 52 + int main(void) 53 + { 54 + return test_harness(group_constraint_radix_scope_qual, 55 + "group_constraint_radix_scope_qual"); 56 + }