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 when using same PMC

Testcase for group constraint check when using events with same PMC.
Multiple events in a group asking for same PMC should fail. Testcase
uses "0x22C040" on PMC2 as leader and also subling which is expected to
fail. Using PMC1 for sibling event should pass the test.

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

authored by

Athira Rajeev and committed by
Michael Ellerman
38b6da45 827765a4

+58 -1
+2 -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 group_pmc56_exclude_constraints_test group_constraint_pmc_count_test 4 + TEST_GEN_PROGS := group_constraint_pmc56_test group_pmc56_exclude_constraints_test group_constraint_pmc_count_test \ 5 + group_constraint_repeat_test 5 6 6 7 top_srcdir = ../../../../../.. 7 8 include ../../../lib.mk
+56
tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_repeat_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 + /* The processor's L1 data cache was reloaded */ 11 + #define EventCode1 0x21C040 12 + #define EventCode2 0x22C040 13 + 14 + /* 15 + * Testcase for group constraint check 16 + * when using events with same PMC. 17 + * Multiple events in a group shouldn't 18 + * ask for same PMC. If so it should fail. 19 + */ 20 + 21 + static int group_constraint_repeat(void) 22 + { 23 + struct event event, leader; 24 + 25 + /* Check for platform support for the test */ 26 + SKIP_IF(platform_check_for_tests()); 27 + 28 + /* 29 + * Two events in a group using same PMC 30 + * should fail to get scheduled. Usei same PMC2 31 + * for leader and sibling event which is expected 32 + * to fail. 33 + */ 34 + event_init(&leader, EventCode1); 35 + FAIL_IF(event_open(&leader)); 36 + 37 + event_init(&event, EventCode1); 38 + 39 + /* Expected to fail since sibling event is requesting same PMC as leader */ 40 + FAIL_IF(!event_open_with_group(&event, leader.fd)); 41 + 42 + event_init(&event, EventCode2); 43 + 44 + /* Expected to pass since sibling event is requesting different PMC */ 45 + FAIL_IF(event_open_with_group(&event, leader.fd)); 46 + 47 + event_close(&leader); 48 + event_close(&event); 49 + 50 + return 0; 51 + } 52 + 53 + int main(void) 54 + { 55 + return test_harness(group_constraint_repeat, "group_constraint_repeat"); 56 + }