Resguardo inicial

This commit is contained in:
lastdragon
2026-09-06 12:53:21 -06:00
parent 662efe3c2a
commit ad2088d178
94853 changed files with 43200404 additions and 0 deletions
@@ -0,0 +1,20 @@
blacklisted_events_test
event_alternatives_tests_p10
event_alternatives_tests_p9
generic_events_valid_test
group_constraint_cache_test
group_constraint_l2l3_sel_test
group_constraint_mmcra_sample_test
group_constraint_pmc56_test
group_constraint_pmc_count_test
group_constraint_radix_scope_qual_test
group_constraint_repeat_test
group_constraint_thresh_cmp_test
group_constraint_thresh_ctl_test
group_constraint_thresh_sel_test
group_constraint_unit_test
group_pmc56_exclude_constraints_test
hw_cache_event_type_test
invalid_event_code_test
reserved_bits_mmcra_sample_elig_mode_test
reserved_bits_mmcra_thresh_ctl_test
@@ -0,0 +1,16 @@
# SPDX-License-Identifier: GPL-2.0
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_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_unit_test group_constraint_thresh_ctl_test group_constraint_thresh_sel_test \
hw_cache_event_type_test
top_srcdir = ../../../../../..
include ../../../lib.mk
include ../../flags.mk
CFLAGS += -m64
$(TEST_GEN_PROGS): ../../harness.c ../../utils.c ../event.c ../lib.c ../sampling_tests/misc.h ../sampling_tests/misc.c
@@ -0,0 +1,132 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2022, Athira Rajeev, IBM Corp.
*/
#include <stdio.h>
#include <sys/prctl.h>
#include <limits.h>
#include "../event.h"
#include "../sampling_tests/misc.h"
#define PM_DTLB_MISS_16G 0x1c058
#define PM_DERAT_MISS_2M 0x1c05a
#define PM_DTLB_MISS_2M 0x1c05c
#define PM_MRK_DTLB_MISS_1G 0x1d15c
#define PM_DTLB_MISS_4K 0x2c056
#define PM_DERAT_MISS_1G 0x2c05a
#define PM_MRK_DERAT_MISS_2M 0x2d152
#define PM_MRK_DTLB_MISS_4K 0x2d156
#define PM_MRK_DTLB_MISS_16G 0x2d15e
#define PM_DTLB_MISS_64K 0x3c056
#define PM_MRK_DERAT_MISS_1G 0x3d152
#define PM_MRK_DTLB_MISS_64K 0x3d156
#define PM_DISP_HELD_SYNC_HOLD 0x4003c
#define PM_DTLB_MISS_16M 0x4c056
#define PM_DTLB_MISS_1G 0x4c05a
#define PM_MRK_DTLB_MISS_16M 0x4c15e
#define PM_MRK_ST_DONE_L2 0x10134
#define PM_RADIX_PWC_L1_HIT 0x1f056
#define PM_FLOP_CMPL 0x100f4
#define PM_MRK_NTF_FIN 0x20112
#define PM_RADIX_PWC_L2_HIT 0x2d024
#define PM_IFETCH_THROTTLE 0x3405e
#define PM_MRK_L2_TM_ST_ABORT_SISTER 0x3e15c
#define PM_RADIX_PWC_L3_HIT 0x3f056
#define PM_RUN_CYC_SMT2_MODE 0x3006c
#define PM_TM_TX_PASS_RUN_INST 0x4e014
#define PVR_POWER9_CUMULUS 0x00002000
int blacklist_events_dd21[] = {
PM_MRK_ST_DONE_L2,
PM_RADIX_PWC_L1_HIT,
PM_FLOP_CMPL,
PM_MRK_NTF_FIN,
PM_RADIX_PWC_L2_HIT,
PM_IFETCH_THROTTLE,
PM_MRK_L2_TM_ST_ABORT_SISTER,
PM_RADIX_PWC_L3_HIT,
PM_RUN_CYC_SMT2_MODE,
PM_TM_TX_PASS_RUN_INST,
PM_DISP_HELD_SYNC_HOLD,
};
int blacklist_events_dd22[] = {
PM_DTLB_MISS_16G,
PM_DERAT_MISS_2M,
PM_DTLB_MISS_2M,
PM_MRK_DTLB_MISS_1G,
PM_DTLB_MISS_4K,
PM_DERAT_MISS_1G,
PM_MRK_DERAT_MISS_2M,
PM_MRK_DTLB_MISS_4K,
PM_MRK_DTLB_MISS_16G,
PM_DTLB_MISS_64K,
PM_MRK_DERAT_MISS_1G,
PM_MRK_DTLB_MISS_64K,
PM_DISP_HELD_SYNC_HOLD,
PM_DTLB_MISS_16M,
PM_DTLB_MISS_1G,
PM_MRK_DTLB_MISS_16M,
};
int pvr_min;
/*
* check for power9 support for 2.1 and
* 2.2 model where blacklist is applicable.
*/
int check_for_power9_version(void)
{
pvr_min = PVR_MIN(mfspr(SPRN_PVR));
SKIP_IF(PVR_VER(pvr) != POWER9);
SKIP_IF(!(pvr & PVR_POWER9_CUMULUS));
SKIP_IF(!(3 - pvr_min));
return 0;
}
/*
* Testcase to ensure that using blacklisted bits in
* event code should cause event_open to fail in power9
*/
static int blacklisted_events(void)
{
struct event event;
int i = 0;
/* Check for platform support for the test */
SKIP_IF(platform_check_for_tests());
/*
* check for power9 support for 2.1 and
* 2.2 model where blacklist is applicable.
*/
SKIP_IF(check_for_power9_version());
/* Skip for Generic compat mode */
SKIP_IF(check_for_generic_compat_pmu());
if (pvr_min == 1) {
for (i = 0; i < ARRAY_SIZE(blacklist_events_dd21); i++) {
event_init(&event, blacklist_events_dd21[i]);
FAIL_IF(!event_open(&event));
}
} else if (pvr_min == 2) {
for (i = 0; i < ARRAY_SIZE(blacklist_events_dd22); i++) {
event_init(&event, blacklist_events_dd22[i]);
FAIL_IF(!event_open(&event));
}
}
return 0;
}
int main(void)
{
return test_harness(blacklisted_events, "blacklisted_events");
}
@@ -0,0 +1,110 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2022, Athira Rajeev, IBM Corp.
*/
#include <stdio.h>
#include "../event.h"
#include "../sampling_tests/misc.h"
#define PM_RUN_CYC_ALT 0x200f4
#define PM_INST_DISP 0x200f2
#define PM_BR_2PATH 0x20036
#define PM_LD_MISS_L1 0x3e054
#define PM_RUN_INST_CMPL_ALT 0x400fa
#define EventCode_1 0x100fc
#define EventCode_2 0x200fa
#define EventCode_3 0x300fc
#define EventCode_4 0x400fc
/*
* Check for event alternatives.
*/
static int event_alternatives_tests_p10(void)
{
struct event *e, events[5];
int i;
int pvr = PVR_VER(mfspr(SPRN_PVR));
/* Check for platform support for the test */
SKIP_IF(platform_check_for_tests());
/*
* PVR check is used here since PMU specific data like
* alternative events is handled by respective PMU driver
* code and using PVR will work correctly for all cases
* including generic compat mode.
*/
SKIP_IF((pvr != POWER10) && (pvr != POWER11));
SKIP_IF(check_for_generic_compat_pmu());
/*
* Test for event alternative for 0x0001e
* and 0x00002.
*/
e = &events[0];
event_init(e, 0x0001e);
e = &events[1];
event_init(e, EventCode_1);
e = &events[2];
event_init(e, EventCode_2);
e = &events[3];
event_init(e, EventCode_3);
e = &events[4];
event_init(e, EventCode_4);
FAIL_IF(event_open(&events[0]));
/*
* Expected to pass since 0x0001e has alternative event
* 0x600f4 in PMC6. So it can go in with other events
* in PMC1 to PMC4.
*/
for (i = 1; i < 5; i++)
FAIL_IF(event_open_with_group(&events[i], events[0].fd));
for (i = 0; i < 5; i++)
event_close(&events[i]);
e = &events[0];
event_init(e, 0x00002);
e = &events[1];
event_init(e, EventCode_1);
e = &events[2];
event_init(e, EventCode_2);
e = &events[3];
event_init(e, EventCode_3);
e = &events[4];
event_init(e, EventCode_4);
FAIL_IF(event_open(&events[0]));
/*
* Expected to pass since 0x00020 has alternative event
* 0x500fa in PMC5. So it can go in with other events
* in PMC1 to PMC4.
*/
for (i = 1; i < 5; i++)
FAIL_IF(event_open_with_group(&events[i], events[0].fd));
for (i = 0; i < 5; i++)
event_close(&events[i]);
return 0;
}
int main(void)
{
return test_harness(event_alternatives_tests_p10, "event_alternatives_tests_p10");
}
@@ -0,0 +1,116 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2022, Athira Rajeev, IBM Corp.
*/
#include <stdio.h>
#include "../event.h"
#include "../sampling_tests/misc.h"
#define PM_RUN_CYC_ALT 0x200f4
#define PM_INST_DISP 0x200f2
#define PM_BR_2PATH 0x20036
#define PM_LD_MISS_L1 0x3e054
#define PM_RUN_INST_CMPL_ALT 0x400fa
#define EventCode_1 0x200fa
#define EventCode_2 0x200fc
#define EventCode_3 0x300fc
#define EventCode_4 0x400fc
/*
* Check for event alternatives.
*/
static int event_alternatives_tests_p9(void)
{
struct event event, leader;
/* Check for platform support for the test */
SKIP_IF(platform_check_for_tests());
/*
* PVR check is used here since PMU specific data like
* alternative events is handled by respective PMU driver
* code and using PVR will work correctly for all cases
* including generic compat mode.
*/
SKIP_IF(PVR_VER(mfspr(SPRN_PVR)) != POWER9);
/* Skip for generic compat PMU */
SKIP_IF(check_for_generic_compat_pmu());
/* Init the event for PM_RUN_CYC_ALT */
event_init(&leader, PM_RUN_CYC_ALT);
FAIL_IF(event_open(&leader));
event_init(&event, EventCode_1);
/*
* Expected to pass since PM_RUN_CYC_ALT in PMC2 has alternative event
* 0x600f4. So it can go in with EventCode_1 which is using PMC2
*/
FAIL_IF(event_open_with_group(&event, leader.fd));
event_close(&leader);
event_close(&event);
event_init(&leader, PM_INST_DISP);
FAIL_IF(event_open(&leader));
event_init(&event, EventCode_2);
/*
* Expected to pass since PM_INST_DISP in PMC2 has alternative event
* 0x300f2 in PMC3. So it can go in with EventCode_2 which is using PMC2
*/
FAIL_IF(event_open_with_group(&event, leader.fd));
event_close(&leader);
event_close(&event);
event_init(&leader, PM_BR_2PATH);
FAIL_IF(event_open(&leader));
event_init(&event, EventCode_2);
/*
* Expected to pass since PM_BR_2PATH in PMC2 has alternative event
* 0x40036 in PMC4. So it can go in with EventCode_2 which is using PMC2
*/
FAIL_IF(event_open_with_group(&event, leader.fd));
event_close(&leader);
event_close(&event);
event_init(&leader, PM_LD_MISS_L1);
FAIL_IF(event_open(&leader));
event_init(&event, EventCode_3);
/*
* Expected to pass since PM_LD_MISS_L1 in PMC3 has alternative event
* 0x400f0 in PMC4. So it can go in with EventCode_3 which is using PMC3
*/
FAIL_IF(event_open_with_group(&event, leader.fd));
event_close(&leader);
event_close(&event);
event_init(&leader, PM_RUN_INST_CMPL_ALT);
FAIL_IF(event_open(&leader));
event_init(&event, EventCode_4);
/*
* Expected to pass since PM_RUN_INST_CMPL_ALT in PMC4 has alternative event
* 0x500fa in PMC5. So it can go in with EventCode_4 which is using PMC4
*/
FAIL_IF(event_open_with_group(&event, leader.fd));
event_close(&leader);
event_close(&event);
return 0;
}
int main(void)
{
return test_harness(event_alternatives_tests_p9, "event_alternatives_tests_p9");
}
@@ -0,0 +1,131 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2022, Athira Rajeev, IBM Corp.
*/
#include <stdio.h>
#include <sys/prctl.h>
#include <limits.h>
#include "../event.h"
#include "../sampling_tests/misc.h"
/*
* Testcase to ensure that using invalid event in generic
* event for PERF_TYPE_HARDWARE should fail
*/
static int generic_events_valid_test(void)
{
struct event event;
int pvr = mfspr(SPRN_PVR);
/* Check for platform support for the test */
SKIP_IF(platform_check_for_tests());
/* generic events is different in compat_mode */
SKIP_IF(check_for_generic_compat_pmu());
/*
* Invalid generic events in power10:
* - PERF_COUNT_HW_BUS_CYCLES
* - PERF_COUNT_HW_STALLED_CYCLES_FRONTEND
* - PERF_COUNT_HW_STALLED_CYCLES_BACKEND
* - PERF_COUNT_HW_REF_CPU_CYCLES
*/
if ((pvr == POWER10) || (pvr == POWER11)) {
event_init_opts(&event, PERF_COUNT_HW_CPU_CYCLES, PERF_TYPE_HARDWARE, "event");
FAIL_IF(event_open(&event));
event_close(&event);
event_init_opts(&event, PERF_COUNT_HW_INSTRUCTIONS,
PERF_TYPE_HARDWARE, "event");
FAIL_IF(event_open(&event));
event_close(&event);
event_init_opts(&event, PERF_COUNT_HW_CACHE_REFERENCES,
PERF_TYPE_HARDWARE, "event");
FAIL_IF(event_open(&event));
event_close(&event);
event_init_opts(&event, PERF_COUNT_HW_CACHE_MISSES, PERF_TYPE_HARDWARE, "event");
FAIL_IF(event_open(&event));
event_close(&event);
event_init_opts(&event, PERF_COUNT_HW_BRANCH_INSTRUCTIONS,
PERF_TYPE_HARDWARE, "event");
FAIL_IF(event_open(&event));
event_close(&event);
event_init_opts(&event, PERF_COUNT_HW_BRANCH_MISSES, PERF_TYPE_HARDWARE, "event");
FAIL_IF(event_open(&event));
event_close(&event);
event_init_opts(&event, PERF_COUNT_HW_BUS_CYCLES, PERF_TYPE_HARDWARE, "event");
FAIL_IF(!event_open(&event));
event_init_opts(&event, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND,
PERF_TYPE_HARDWARE, "event");
FAIL_IF(!event_open(&event));
event_init_opts(&event, PERF_COUNT_HW_STALLED_CYCLES_BACKEND,
PERF_TYPE_HARDWARE, "event");
FAIL_IF(!event_open(&event));
event_init_opts(&event, PERF_COUNT_HW_REF_CPU_CYCLES, PERF_TYPE_HARDWARE, "event");
FAIL_IF(!event_open(&event));
} else if (PVR_VER(mfspr(SPRN_PVR)) == POWER9) {
/*
* Invalid generic events in power9:
* - PERF_COUNT_HW_BUS_CYCLES
* - PERF_COUNT_HW_REF_CPU_CYCLES
*/
event_init_opts(&event, PERF_COUNT_HW_CPU_CYCLES, PERF_TYPE_HARDWARE, "event");
FAIL_IF(event_open(&event));
event_close(&event);
event_init_opts(&event, PERF_COUNT_HW_INSTRUCTIONS, PERF_TYPE_HARDWARE, "event");
FAIL_IF(event_open(&event));
event_close(&event);
event_init_opts(&event, PERF_COUNT_HW_CACHE_REFERENCES,
PERF_TYPE_HARDWARE, "event");
FAIL_IF(event_open(&event));
event_close(&event);
event_init_opts(&event, PERF_COUNT_HW_CACHE_MISSES, PERF_TYPE_HARDWARE, "event");
FAIL_IF(event_open(&event));
event_close(&event);
event_init_opts(&event, PERF_COUNT_HW_BRANCH_INSTRUCTIONS,
PERF_TYPE_HARDWARE, "event");
FAIL_IF(event_open(&event));
event_close(&event);
event_init_opts(&event, PERF_COUNT_HW_BRANCH_MISSES, PERF_TYPE_HARDWARE, "event");
FAIL_IF(event_open(&event));
event_close(&event);
event_init_opts(&event, PERF_COUNT_HW_BUS_CYCLES, PERF_TYPE_HARDWARE, "event");
FAIL_IF(!event_open(&event));
event_init_opts(&event, PERF_COUNT_HW_STALLED_CYCLES_FRONTEND,
PERF_TYPE_HARDWARE, "event");
FAIL_IF(event_open(&event));
event_close(&event);
event_init_opts(&event, PERF_COUNT_HW_STALLED_CYCLES_BACKEND,
PERF_TYPE_HARDWARE, "event");
FAIL_IF(event_open(&event));
event_close(&event);
event_init_opts(&event, PERF_COUNT_HW_REF_CPU_CYCLES, PERF_TYPE_HARDWARE, "event");
FAIL_IF(!event_open(&event));
}
return 0;
}
int main(void)
{
return test_harness(generic_events_valid_test, "generic_events_valid_test");
}
@@ -0,0 +1,60 @@
// 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 L1 D cache load references counted at finish, gated by reject */
#define EventCode_1 0x1100fc
/* Load Missed L1 */
#define EventCode_2 0x23e054
/* Load Missed L1 */
#define EventCode_3 0x13e054
/*
* Testcase for group constraint check of data and instructions
* cache qualifier bits which is used to program cache select field in
* Monitor Mode Control Register 1 (MMCR1: 16-17) for l1 cache.
* All events in the group should match cache select bits otherwise
* event_open for the group will fail.
*/
static int group_constraint_cache(void)
{
struct event event, leader;
/* Check for platform support for the test */
SKIP_IF(platform_check_for_tests());
/* Init the events for the group contraint check for l1 cache select 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 l1 cache select bits as leader */
FAIL_IF(!event_open_with_group(&event, leader.fd));
event_close(&event);
/* Init the event for the group contraint l1 cache select test */
event_init(&event, EventCode_3);
/* Expected to succeed as sibling event request same l1 cache select 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_cache, "group_constraint_cache");
}
@@ -0,0 +1,64 @@
// 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 ISA v3.1
*/
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");
}
@@ -0,0 +1,54 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2022, Athira Rajeev, IBM Corp.
*/
#include <stdio.h>
#include "../event.h"
#include "../sampling_tests/misc.h"
#define EventCode_1 0x35340401e0
#define EventCode_2 0x353c0101ec
#define EventCode_3 0x35340101ec
/*
* Test that using different sample bits in
* event code cause failure in schedule for
* group of events.
*/
static int group_constraint_mmcra_sample(void)
{
struct event event, leader;
SKIP_IF(platform_check_for_tests());
/*
* Events with different "sample" field values
* in a group will fail to schedule.
* Use event with load only sampling mode as
* group leader. Use event with store only sampling
* as sibling event.
*/
event_init(&leader, EventCode_1);
FAIL_IF(event_open(&leader));
event_init(&event, EventCode_2);
/* Expected to fail as sibling event doesn't use same sampling bits as leader */
FAIL_IF(!event_open_with_group(&event, leader.fd));
event_init(&event, EventCode_3);
/* Expected to pass as sibling event use same sampling 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_mmcra_sample, "group_constraint_mmcra_sample");
}
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2022, Athira Rajeev, IBM Corp.
*/
#include <stdio.h>
#include "../event.h"
#include "../sampling_tests/misc.h"
/*
* Testcase for checking constraint checks for
* Performance Monitor Counter 5 (PMC5) and also
* Performance Monitor Counter 6 (PMC6). Events using
* PMC5/PMC6 shouldn't have other fields in event
* code like cache bits, thresholding or marked bit.
*/
static int group_constraint_pmc56(void)
{
struct event event;
/* Check for platform support for the test */
SKIP_IF(platform_check_for_tests());
/*
* Events using PMC5 and PMC6 with cache bit
* set in event code is expected to fail.
*/
event_init(&event, 0x2500fa);
FAIL_IF(!event_open(&event));
event_init(&event, 0x2600f4);
FAIL_IF(!event_open(&event));
/*
* PMC5 and PMC6 only supports base events:
* ie 500fa and 600f4. Other combinations
* should fail.
*/
event_init(&event, 0x501e0);
FAIL_IF(!event_open(&event));
event_init(&event, 0x6001e);
FAIL_IF(!event_open(&event));
event_init(&event, 0x501fa);
FAIL_IF(!event_open(&event));
/*
* Events using PMC5 and PMC6 with random
* sampling bits set in event code should fail
* to schedule.
*/
event_init(&event, 0x35340500fa);
FAIL_IF(!event_open(&event));
return 0;
}
int main(void)
{
return test_harness(group_constraint_pmc56, "group_constraint_pmc56");
}
@@ -0,0 +1,70 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2022, Athira Rajeev, IBM Corp.
*/
#include <stdio.h>
#include "../event.h"
#include "../sampling_tests/misc.h"
/*
* Testcase for number of counters in use.
* The number of programmable counters is from
* performance monitor counter 1 to performance
* monitor counter 4 (PMC1-PMC4). If number of
* counters in use exceeds the limit, next event
* should fail to schedule.
*/
static int group_constraint_pmc_count(void)
{
struct event *e, events[5];
int i;
/* Check for platform support for the test */
SKIP_IF(platform_check_for_tests());
/*
* Test for number of counters in use.
* Use PMC1 to PMC4 for leader and 3 sibling
* events. Trying to open fourth event should
* fail here.
*/
e = &events[0];
event_init(e, 0x1001a);
e = &events[1];
event_init(e, 0x200fc);
e = &events[2];
event_init(e, 0x30080);
e = &events[3];
event_init(e, 0x40054);
e = &events[4];
event_init(e, 0x0002c);
FAIL_IF(event_open(&events[0]));
/*
* The event_open will fail on event 4 if constraint
* check fails
*/
for (i = 1; i < 5; i++) {
if (i == 4)
FAIL_IF(!event_open_with_group(&events[i], events[0].fd));
else
FAIL_IF(event_open_with_group(&events[i], events[0].fd));
}
for (i = 1; i < 4; i++)
event_close(&events[i]);
return 0;
}
int main(void)
{
return test_harness(group_constraint_pmc_count, "group_constraint_pmc_count");
}
@@ -0,0 +1,56 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2022, Athira Rajeev, IBM Corp.
*/
#include <stdio.h>
#include "../event.h"
#include "../sampling_tests/misc.h"
/* PM_DATA_RADIX_PROCESS_L2_PTE_FROM_L2 */
#define EventCode_1 0x14242
/* PM_DATA_RADIX_PROCESS_L2_PTE_FROM_L3 */
#define EventCode_2 0x24242
/*
* Testcase for group constraint check for radix_scope_qual
* field which is used to program Monitor Mode Control
* egister (MMCR1) bit 18.
* All events in the group should match radix_scope_qual,
* bits otherwise event_open for the group should fail.
*/
static int group_constraint_radix_scope_qual(void)
{
struct event event, leader;
/*
* Check for platform support for the test.
* This test is aplicable on ISA v3.1 only.
*/
SKIP_IF(platform_check_for_tests());
SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_3_1));
/* Init the events for the group contraint check for radix_scope_qual bits */
event_init(&leader, EventCode_1);
FAIL_IF(event_open(&leader));
event_init(&event, 0x200fc);
/* Expected to fail as sibling event doesn't request same radix_scope_qual bits as leader */
FAIL_IF(!event_open_with_group(&event, leader.fd));
event_init(&event, EventCode_2);
/* Expected to pass as sibling event request same radix_scope_qual 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_radix_scope_qual,
"group_constraint_radix_scope_qual");
}
@@ -0,0 +1,56 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2022, Athira Rajeev, IBM Corp.
*/
#include <stdio.h>
#include "../event.h"
#include "../sampling_tests/misc.h"
/* The processor's L1 data cache was reloaded */
#define EventCode1 0x21C040
#define EventCode2 0x22C040
/*
* Testcase for group constraint check
* when using events with same PMC.
* Multiple events in a group shouldn't
* ask for same PMC. If so it should fail.
*/
static int group_constraint_repeat(void)
{
struct event event, leader;
/* Check for platform support for the test */
SKIP_IF(platform_check_for_tests());
/*
* Two events in a group using same PMC
* should fail to get scheduled. Usei same PMC2
* for leader and sibling event which is expected
* to fail.
*/
event_init(&leader, EventCode1);
FAIL_IF(event_open(&leader));
event_init(&event, EventCode1);
/* Expected to fail since sibling event is requesting same PMC as leader */
FAIL_IF(!event_open_with_group(&event, leader.fd));
event_init(&event, EventCode2);
/* Expected to pass since sibling event is requesting different PMC */
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_repeat, "group_constraint_repeat");
}
@@ -0,0 +1,96 @@
// 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"
/*
* Primary PMU events used here is PM_MRK_INST_CMPL (0x401e0) and
* PM_THRESH_MET (0x101ec)
* Threshold event selection used is issue to complete for cycles
* Sampling criteria is Load or Store only sampling
*/
#define p9_EventCode_1 0x13e35340401e0
#define p9_EventCode_2 0x17d34340101ec
#define p9_EventCode_3 0x13e35340101ec
#define p10_EventCode_1 0x35340401e0
#define p10_EventCode_2 0x35340101ec
/*
* Testcase for group constraint check of thresh_cmp bits which is
* used to program thresh compare field in Monitor Mode Control Register A
* (MMCRA: 9-18 bits for power9 and MMCRA: 8-18 bits for power10/power11).
* All events in the group should match thresh compare bits otherwise
* event_open for the group will fail.
*/
static int group_constraint_thresh_cmp(void)
{
struct event event, leader;
/* Check for platform support for the test */
SKIP_IF(platform_check_for_tests());
if (have_hwcap2(PPC_FEATURE2_ARCH_3_1)) {
/* Init the events for the group contraint check for thresh_cmp bits */
event_init(&leader, p10_EventCode_1);
/* Add the thresh_cmp value for leader in config1 */
leader.attr.config1 = 1000;
FAIL_IF(event_open(&leader));
event_init(&event, p10_EventCode_2);
/* Add the different thresh_cmp value from the leader event in config1 */
event.attr.config1 = 2000;
/* Expected to fail as sibling and leader event request different thresh_cmp bits */
FAIL_IF(!event_open_with_group(&event, leader.fd));
event_close(&event);
/* Init the event for the group contraint thresh compare test */
event_init(&event, p10_EventCode_2);
/* Add the same thresh_cmp value for leader and sibling event in config1 */
event.attr.config1 = 1000;
/* Expected to succeed as sibling and leader event request same thresh_cmp bits */
FAIL_IF(event_open_with_group(&event, leader.fd));
event_close(&leader);
event_close(&event);
} else {
/* Init the events for the group contraint check for thresh_cmp bits */
event_init(&leader, p9_EventCode_1);
FAIL_IF(event_open(&leader));
event_init(&event, p9_EventCode_2);
/* Expected to fail as sibling and leader event request different thresh_cmp bits */
FAIL_IF(!event_open_with_group(&event, leader.fd));
event_close(&event);
/* Init the event for the group contraint thresh compare test */
event_init(&event, p9_EventCode_3);
/* Expected to succeed as sibling and leader event request same thresh_cmp bits */
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_thresh_cmp, "group_constraint_thresh_cmp");
}
@@ -0,0 +1,64 @@
// 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"
/*
* Primary PMU events used here are PM_MRK_INST_CMPL (0x401e0) and
* PM_THRESH_MET (0x101ec).
* Threshold event selection used is issue to complete and issue to
* finished for cycles
* Sampling criteria is Load or Store only sampling
*/
#define EventCode_1 0x35340401e0
#define EventCode_2 0x34340101ec
#define EventCode_3 0x35340101ec
/*
* Testcase for group constraint check of thresh_ctl bits which is
* used to program thresh compare field in Monitor Mode Control Register A
* (MMCR0: 48-55).
* All events in the group should match thresh ctl bits otherwise
* event_open for the group will fail.
*/
static int group_constraint_thresh_ctl(void)
{
struct event event, leader;
/* Check for platform support for the test */
SKIP_IF(platform_check_for_tests());
/* Init the events for the group contraint thresh control test */
event_init(&leader, EventCode_1);
FAIL_IF(event_open(&leader));
event_init(&event, EventCode_2);
/* Expected to fail as sibling and leader event request different thresh_ctl bits */
FAIL_IF(!event_open_with_group(&event, leader.fd));
event_close(&event);
/* Init the event for the group contraint thresh control test */
event_init(&event, EventCode_3);
/* Expected to succeed as sibling and leader event request same thresh_ctl bits */
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_thresh_ctl, "group_constraint_thresh_ctl");
}
@@ -0,0 +1,63 @@
// 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"
/*
* Primary PMU events used here are PM_MRK_INST_CMPL (0x401e0) and
* PM_THRESH_MET (0x101ec).
* Threshold event selection used is issue to complete
* Sampling criteria is Load or Store only sampling
*/
#define EventCode_1 0x35340401e0
#define EventCode_2 0x35540101ec
#define EventCode_3 0x35340101ec
/*
* Testcase for group constraint check of thresh_sel bits which is
* used to program thresh select field in Monitor Mode Control Register A
* (MMCRA: 45-57).
* All events in the group should match thresh sel bits otherwise
* event_open for the group will fail.
*/
static int group_constraint_thresh_sel(void)
{
struct event event, leader;
/* Check for platform support for the test */
SKIP_IF(platform_check_for_tests());
/* Init the events for the group contraint thresh select test */
event_init(&leader, EventCode_1);
FAIL_IF(event_open(&leader));
event_init(&event, EventCode_2);
/* Expected to fail as sibling and leader event request different thresh_sel bits */
FAIL_IF(!event_open_with_group(&event, leader.fd));
event_close(&event);
/* Init the event for the group contraint thresh select test */
event_init(&event, EventCode_3);
/* Expected to succeed as sibling and leader event request same thresh_sel bits */
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_thresh_sel, "group_constraint_thresh_sel");
}
@@ -0,0 +1,74 @@
// 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");
}
@@ -0,0 +1,64 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2022, Athira Rajeev, IBM Corp.
*/
#include <stdio.h>
#include "../event.h"
#include <sys/prctl.h>
#include <limits.h>
#include "../sampling_tests/misc.h"
/*
* Testcase for group constraint check for
* Performance Monitor Counter 5 (PMC5) and also
* Performance Monitor Counter 6 (PMC6).
* Test that pmc5/6 is excluded from constraint
* check when scheduled along with group of events.
*/
static int group_pmc56_exclude_constraints(void)
{
struct event *e, events[3];
int i;
/* Check for platform support for the test */
SKIP_IF(platform_check_for_tests());
/*
* PMC5/6 is excluded from constraint bit
* check along with group of events. Use
* group of events with PMC5, PMC6 and also
* event with cache bit (dc_ic) set. Test expects
* this set of events to go in as a group.
*/
e = &events[0];
event_init(e, 0x500fa);
e = &events[1];
event_init(e, 0x600f4);
e = &events[2];
event_init(e, 0x22C040);
FAIL_IF(event_open(&events[0]));
/*
* The event_open will fail if constraint check fails.
* Since we are asking for events in a group and since
* PMC5/PMC6 is excluded from group constraints, even_open
* should pass.
*/
for (i = 1; i < 3; i++)
FAIL_IF(event_open_with_group(&events[i], events[0].fd));
for (i = 0; i < 3; i++)
event_close(&events[i]);
return 0;
}
int main(void)
{
return test_harness(group_pmc56_exclude_constraints, "group_pmc56_exclude_constraints");
}
@@ -0,0 +1,88 @@
// 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"
/*
* Load Missed L1, for power9 its pointing to PM_LD_MISS_L1_FIN (0x2c04e) and
* for power10 its pointing to PM_LD_MISS_L1 (0x3e054)
*
* Hardware cache level : PERF_COUNT_HW_CACHE_L1D
* Hardware cache event operation type : PERF_COUNT_HW_CACHE_OP_READ
* Hardware cache event result type : PERF_COUNT_HW_CACHE_RESULT_MISS
*/
#define EventCode_1 0x10000
/*
* Hardware cache level : PERF_COUNT_HW_CACHE_L1D
* Hardware cache event operation type : PERF_COUNT_HW_CACHE_OP_WRITE
* Hardware cache event result type : PERF_COUNT_HW_CACHE_RESULT_ACCESS
*/
#define EventCode_2 0x0100
/*
* Hardware cache level : PERF_COUNT_HW_CACHE_DTLB
* Hardware cache event operation type : PERF_COUNT_HW_CACHE_OP_WRITE
* Hardware cache event result type : PERF_COUNT_HW_CACHE_RESULT_ACCESS
*/
#define EventCode_3 0x0103
/*
* Hardware cache level : PERF_COUNT_HW_CACHE_L1D
* Hardware cache event operation type : PERF_COUNT_HW_CACHE_OP_READ
* Hardware cache event result type : Invalid ( > PERF_COUNT_HW_CACHE_RESULT_MAX)
*/
#define EventCode_4 0x030000
/*
* A perf test to check valid hardware cache events.
*/
static int hw_cache_event_type_test(void)
{
struct event event;
/* Check for platform support for the test */
SKIP_IF(platform_check_for_tests());
/* Skip for Generic compat PMU */
SKIP_IF(check_for_generic_compat_pmu());
/* Init the event to test hardware cache event */
event_init_opts(&event, EventCode_1, PERF_TYPE_HW_CACHE, "event");
/* Expected to success as its pointing to L1 load miss */
FAIL_IF(event_open(&event));
event_close(&event);
/* Init the event to test hardware cache event */
event_init_opts(&event, EventCode_2, PERF_TYPE_HW_CACHE, "event");
/* Expected to fail as the corresponding cache event entry have 0 in that index */
FAIL_IF(!event_open(&event));
event_close(&event);
/* Init the event to test hardware cache event */
event_init_opts(&event, EventCode_3, PERF_TYPE_HW_CACHE, "event");
/* Expected to fail as the corresponding cache event entry have -1 in that index */
FAIL_IF(!event_open(&event));
event_close(&event);
/* Init the event to test hardware cache event */
event_init_opts(&event, EventCode_4, PERF_TYPE_HW_CACHE, "event");
/* Expected to fail as hardware cache event result type is Invalid */
FAIL_IF(!event_open(&event));
event_close(&event);
return 0;
}
int main(void)
{
return test_harness(hw_cache_event_type_test, "hw_cache_event_type_test");
}
@@ -0,0 +1,67 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2022, Athira Rajeev, IBM Corp.
*/
#include <stdio.h>
#include <sys/prctl.h>
#include <limits.h>
#include "../event.h"
#include "../sampling_tests/misc.h"
/* The data cache was reloaded from local core's L3 due to a demand load */
#define EventCode_1 0x1340000001c040
/* PM_DATA_RADIX_PROCESS_L2_PTE_FROM_L2 */
#define EventCode_2 0x14242
/* Event code with IFM, EBB, BHRB bits set in event code */
#define EventCode_3 0xf00000000000001e
/*
* Some of the bits in the event code is
* reserved for specific platforms.
* Event code bits 52-59 are reserved in power9,
* whereas in ISA v3.1, these are used for programming
* Monitor Mode Control Register 3 (MMCR3).
* Bit 9 in event code is reserved in power9,
* whereas it is used for programming "radix_scope_qual"
* bit 18 in Monitor Mode Control Register 1 (MMCR1).
*
* Testcase to ensure that using reserved bits in
* event code should cause event_open to fail.
*/
static int invalid_event_code(void)
{
struct event event;
/* Check for platform support for the test */
SKIP_IF(platform_check_for_tests());
/*
* Events using MMCR3 bits and radix scope qual bits
* should fail in power9 and should succeed in power10 ( ISA v3.1 )
* Init the events and check for pass/fail in event open.
*/
if (have_hwcap2(PPC_FEATURE2_ARCH_3_1)) {
event_init(&event, EventCode_1);
FAIL_IF(event_open(&event));
event_close(&event);
event_init(&event, EventCode_2);
FAIL_IF(event_open(&event));
event_close(&event);
} else {
event_init(&event, EventCode_1);
FAIL_IF(!event_open(&event));
event_init(&event, EventCode_2);
FAIL_IF(!event_open(&event));
}
return 0;
}
int main(void)
{
return test_harness(invalid_event_code, "invalid_event_code");
}
@@ -0,0 +1,78 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2022, Athira Rajeev, IBM Corp.
*/
#include <stdio.h>
#include "../event.h"
#include "../sampling_tests/misc.h"
/*
* Testcase for reserved bits in Monitor Mode Control
* Register A (MMCRA) Random Sampling Mode (SM) value.
* As per Instruction Set Architecture (ISA), the values
* 0x5, 0x9, 0xD, 0x19, 0x1D, 0x1A, 0x1E are reserved
* for sampling mode field. Test that having these reserved
* bit values should cause event_open to fail.
* Input event code uses these sampling bits along with
* 401e0 (PM_MRK_INST_CMPL).
*/
static int reserved_bits_mmcra_sample_elig_mode(void)
{
struct event event;
int pvr = PVR_VER(mfspr(SPRN_PVR));
/* Check for platform support for the test */
SKIP_IF(platform_check_for_tests());
/* Skip for Generic compat PMU */
SKIP_IF(check_for_generic_compat_pmu());
/*
* MMCRA Random Sampling Mode (SM) values: 0x5
* 0x9, 0xD, 0x19, 0x1D, 0x1A, 0x1E is reserved.
* Expected to fail when using these reserved values.
*/
event_init(&event, 0x50401e0);
FAIL_IF(!event_open(&event));
event_init(&event, 0x90401e0);
FAIL_IF(!event_open(&event));
event_init(&event, 0xD0401e0);
FAIL_IF(!event_open(&event));
event_init(&event, 0x190401e0);
FAIL_IF(!event_open(&event));
event_init(&event, 0x1D0401e0);
FAIL_IF(!event_open(&event));
event_init(&event, 0x1A0401e0);
FAIL_IF(!event_open(&event));
event_init(&event, 0x1E0401e0);
FAIL_IF(!event_open(&event));
/*
* MMCRA Random Sampling Mode (SM) value 0x10
* is reserved in power10/power11 and 0xC is reserved in
* power9.
*/
if ((pvr == POWER10) || (pvr == POWER11)) {
event_init(&event, 0x100401e0);
FAIL_IF(!event_open(&event));
} else if (PVR_VER(mfspr(SPRN_PVR)) == POWER9) {
event_init(&event, 0xC0401e0);
FAIL_IF(!event_open(&event));
}
return 0;
}
int main(void)
{
return test_harness(reserved_bits_mmcra_sample_elig_mode,
"reserved_bits_mmcra_sample_elig_mode");
}
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2022, Athira Rajeev, IBM Corp.
*/
#include <stdio.h>
#include "../event.h"
#include "../sampling_tests/misc.h"
/*
* Testcase for reserved bits in Monitor Mode
* Control Register A (MMCRA) thresh_ctl bits.
* For MMCRA[48:51]/[52:55]) Threshold Start/Stop,
* 0b11110000/0b00001111 is reserved.
*/
static int reserved_bits_mmcra_thresh_ctl(void)
{
struct event event;
/* Check for platform support for the test */
SKIP_IF(platform_check_for_tests());
/* Skip for Generic compat PMU */
SKIP_IF(check_for_generic_compat_pmu());
/*
* MMCRA[48:51]/[52:55]) Threshold Start/Stop
* events Selection. 0b11110000/0b00001111 is reserved.
* Expected to fail when using these reserved values.
*/
event_init(&event, 0xf0340401e0);
FAIL_IF(!event_open(&event));
event_init(&event, 0x0f340401e0);
FAIL_IF(!event_open(&event));
return 0;
}
int main(void)
{
return test_harness(reserved_bits_mmcra_thresh_ctl, "reserved_bits_mmcra_thresh_ctl");
}