-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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: Kajol Jain <kjain@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20220610134113.62991-33-atrajeev@linux.vnet.ibm.com
- Loading branch information
Kajol Jain
authored and
Michael Ellerman
committed
Jun 28, 2022
1 parent
8eaca8c
commit 142c9bd
Showing
2 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_unit_test.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
} |