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 MMCRA sample bits

Events with different "sample" field values which is used to program
Monitor Mode Control Register A (MMCRA) in a group will fail to
schedule. Testcase uses event with load only sampling mode as group
leader and event with store only sampling as sibling event. So that it
can check that using different sample bits in event code will fail in
event open for group of events

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

authored by

Athira Rajeev and committed by
Michael Ellerman
122b6b9e beebeecb

+56 -1
+2 -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 group_constraint_radix_scope_qual_test reserved_bits_mmcra_sample_elig_mode_test 5 + group_constraint_repeat_test group_constraint_radix_scope_qual_test reserved_bits_mmcra_sample_elig_mode_test \ 6 + group_constraint_mmcra_sample_test 6 7 7 8 top_srcdir = ../../../../../.. 8 9 include ../../../lib.mk
+54
tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_mmcra_sample_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 + #define EventCode_1 0x35340401e0 11 + #define EventCode_2 0x353c0101ec 12 + #define EventCode_3 0x35340101ec 13 + /* 14 + * Test that using different sample bits in 15 + * event code cause failure in schedule for 16 + * group of events. 17 + */ 18 + 19 + static int group_constraint_mmcra_sample(void) 20 + { 21 + struct event event, leader; 22 + 23 + SKIP_IF(platform_check_for_tests()); 24 + 25 + /* 26 + * Events with different "sample" field values 27 + * in a group will fail to schedule. 28 + * Use event with load only sampling mode as 29 + * group leader. Use event with store only sampling 30 + * as sibling event. 31 + */ 32 + event_init(&leader, EventCode_1); 33 + FAIL_IF(event_open(&leader)); 34 + 35 + event_init(&event, EventCode_2); 36 + 37 + /* Expected to fail as sibling event doesn't use same sampling bits as leader */ 38 + FAIL_IF(!event_open_with_group(&event, leader.fd)); 39 + 40 + event_init(&event, EventCode_3); 41 + 42 + /* Expected to pass as sibling event use same sampling bits as leader */ 43 + FAIL_IF(event_open_with_group(&event, leader.fd)); 44 + 45 + event_close(&leader); 46 + event_close(&event); 47 + 48 + return 0; 49 + } 50 + 51 + int main(void) 52 + { 53 + return test_harness(group_constraint_mmcra_sample, "group_constraint_mmcra_sample"); 54 + }