-
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 check for MM…
…CRA thresh_ctl field Thresh control bits in the event code is used to program thresh_ctl field in Monitor Mode Control Register A (MMCRA: 48-55). 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 PM_MRK_INST_CMPL (0x401e0) as leader and another event PM_THRESH_MET (101ec) as sibling event, and checks if group constraint checks for thresh_ctl field added correctly via perf interface. 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-34-atrajeev@linux.vnet.ibm.com
- Loading branch information
Kajol Jain
authored and
Michael Ellerman
committed
Jun 28, 2022
1 parent
142c9bd
commit c178606
Showing
2 changed files
with
65 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
64 changes: 64 additions & 0 deletions
64
tools/testing/selftests/powerpc/pmu/event_code_tests/group_constraint_thresh_ctl_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,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"); | ||
} |