Commit 20b3073f authored by Kajol Jain's avatar Kajol Jain Committed by Michael Ellerman

selftests/powerpc/pmu: Add selftest for group constraint check for MMCR0 l2l3_sel bits

In power10, L2L3 select bits in the event code is used to program
l2l3_sel field in Monitor Mode Control Register 0 (MMCR0: 56-60). When
scheduling events as a group, all events in that group should match
value in these bits. Otherwise event open for the sibling events will
fail.

Testcase uses event code "0x010000046080" as leader and another events
"0x26880" and "0x010000026880" as sibling events, and checks for
l2l3_sel constraints via perf interface for ISA v3.1 platform.
Signed-off-by: default avatarKajol Jain <kjain@linux.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220610134113.62991-30-atrajeev@linux.vnet.ibm.com
parent 8efeedf5
...@@ -4,7 +4,8 @@ CFLAGS += -m64 ...@@ -4,7 +4,8 @@ CFLAGS += -m64
TEST_GEN_PROGS := group_constraint_pmc56_test group_pmc56_exclude_constraints_test group_constraint_pmc_count_test \ TEST_GEN_PROGS := group_constraint_pmc56_test group_pmc56_exclude_constraints_test group_constraint_pmc_count_test \
group_constraint_repeat_test group_constraint_radix_scope_qual_test reserved_bits_mmcra_sample_elig_mode_test \ group_constraint_repeat_test group_constraint_radix_scope_qual_test reserved_bits_mmcra_sample_elig_mode_test \
group_constraint_mmcra_sample_test invalid_event_code_test reserved_bits_mmcra_thresh_ctl_test \ group_constraint_mmcra_sample_test invalid_event_code_test reserved_bits_mmcra_thresh_ctl_test \
blacklisted_events_test event_alternatives_tests_p9 event_alternatives_tests_p10 generic_events_valid_test blacklisted_events_test event_alternatives_tests_p9 event_alternatives_tests_p10 generic_events_valid_test \
group_constraint_l2l3_sel_test
top_srcdir = ../../../../../.. top_srcdir = ../../../../../..
include ../../../lib.mk include ../../../lib.mk
......
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2022, Kajol Jain, IBM Corp.
*/
#include <stdio.h>
#include <stdlib.h>
#include "../event.h"
#include "utils.h"
#include "../sampling_tests/misc.h"
/* All successful D-side store dispatches for this thread */
#define EventCode_1 0x010000046080
/* All successful D-side store dispatches for this thread that were L2 Miss */
#define EventCode_2 0x26880
/* All successful D-side store dispatches for this thread that were L2 Miss */
#define EventCode_3 0x010000026880
/*
* Testcase for group constraint check of l2l3_sel bits which is
* used to program l2l3 select field in Monitor Mode Control Register 0
* (MMCR0: 56-60).
* All events in the group should match l2l3_sel bits otherwise
* event_open for the group should fail.
*/
static int group_constraint_l2l3_sel(void)
{
struct event event, leader;
/*
* Check for platform support for the test.
* This test is only aplicable on power10
*/
SKIP_IF(platform_check_for_tests());
SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_3_1));
/* Init the events for the group contraint check for l2l3_sel bits */
event_init(&leader, EventCode_1);
FAIL_IF(event_open(&leader));
event_init(&event, EventCode_2);
/* Expected to fail as sibling event doesn't request same l2l3_sel bits as leader */
FAIL_IF(!event_open_with_group(&event, leader.fd));
event_close(&event);
/* Init the event for the group contraint l2l3_sel test */
event_init(&event, EventCode_3);
/* Expected to succeed as sibling event request same l2l3_sel bits as leader */
FAIL_IF(event_open_with_group(&event, leader.fd));
event_close(&leader);
event_close(&event);
return 0;
}
int main(void)
{
return test_harness(group_constraint_l2l3_sel, "group_constraint_l2l3_sel");
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment