Commit 142c9bd1 authored by Kajol Jain's avatar Kajol Jain Committed by Michael Ellerman

selftests/powerpc/pmu: Add selftest for group constraint for unit and pmc field in p9

Unit and pmu bits in the event code is used to program unit and pmc
fields in Monitor Mode Control Register 1 (MMCR1). For power9 platform,
incase unit field value is within 6 to 9, one of the event in the group
should use PMC4. Otherwise event_open should fail for that group.
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-33-atrajeev@linux.vnet.ibm.com
parent 8eaca8c4
......@@ -5,7 +5,8 @@ TEST_GEN_PROGS := group_constraint_pmc56_test group_pmc56_exclude_constraints_te
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 \
blacklisted_events_test event_alternatives_tests_p9 event_alternatives_tests_p10 generic_events_valid_test \
group_constraint_l2l3_sel_test group_constraint_cache_test group_constraint_thresh_cmp_test
group_constraint_l2l3_sel_test group_constraint_cache_test group_constraint_thresh_cmp_test \
group_constraint_unit_test
top_srcdir = ../../../../../..
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 with PMC 2 */
#define EventCode_1 0x26080
/* All successful D-side store dispatches for this thread with PMC 4 */
#define EventCode_2 0x46080
/* All successful D-side store dispatches for this thread that were L2 Miss with PMC 3 */
#define EventCode_3 0x36880
/*
* Testcase for group constraint check of unit and pmc bits which is
* used to program corresponding unit and pmc field in Monitor Mode
* Control Register 1 (MMCR1)
* One of the event in the group should use PMC 4 incase units field
* value is within 6 to 9 otherwise event_open for the group will fail.
*/
static int group_constraint_unit(void)
{
struct event *e, events[3];
/*
* Check for platform support for the test.
* Constraint to use PMC4 with one of the event in group,
* when the unit is within 6 to 9 is only applicable on
* power9.
*/
SKIP_IF(platform_check_for_tests());
SKIP_IF(have_hwcap2(PPC_FEATURE2_ARCH_3_1));
/* Init the events for the group contraint check for unit bits */
e = &events[0];
event_init(e, EventCode_1);
/* Expected to fail as PMC 4 is not used with unit field value 6 to 9 */
FAIL_IF(!event_open(&events[0]));
/* Init the events for the group contraint check for unit bits */
e = &events[1];
event_init(e, EventCode_2);
/* Expected to pass as PMC 4 is used with unit field value 6 to 9 */
FAIL_IF(event_open(&events[1]));
/* Init the event for the group contraint unit test */
e = &events[2];
event_init(e, EventCode_3);
/* Expected to fail as PMC4 is not being used */
FAIL_IF(!event_open_with_group(&events[2], events[0].fd));
/* Expected to succeed as event using PMC4 */
FAIL_IF(event_open_with_group(&events[2], events[1].fd));
event_close(&events[0]);
event_close(&events[1]);
event_close(&events[2]);
return 0;
}
int main(void)
{
return test_harness(group_constraint_unit, "group_constraint_unit");
}
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