Skip to content

Commit b1f323e

Browse files
committed
Merge: Updates for perf threshold Value
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/5224 Description: Updates for perf threshold Value JIRA: https://issues.redhat.com/browse/RHEL-50637 Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=64126547 Tested: Verified Brew build test kernel RPMs and confirmed issue is resovled Signed-off-by: Mamatha Inamdar <minamdar@redhat.com> commit 505d316 Author: Kajol Jain <kjain@linux.ibm.com> Date: Fri May 6 11:40:14 2022 +0530 powerpc/perf: Fix the threshold compare group constraint for power10 Thresh compare bits for a event is used to program thresh compare field in Monitor Mode Control Register A (MMCRA: 8-18 bits for power10). When scheduling events as a group, all events in that group should match value in threshold bits. Otherwise event open for the sibling events should fail. But in the current code, incase thresh compare bits are not valid, we are not failing in group_constraint function which can result in invalid group schduling. Fix the issue by returning -1 incase event is threshold and threshold compare value is not valid in group_constraint function. Patch also fixes the p10_thresh_cmp_val function to return -1, incase threshold bits are not valid and changes corresponding check in is_thresh_cmp_valid function to return false only when the thresh_cmp value is less then 0. Thresh control bits in the event code is used to program thresh_ctl field in Monitor Mode Control Register A (MMCRA: 48-55). In below example, the scheduling of group events PM_MRK_INST_CMPL (3534401e0) and PM_THRESH_MET (34340101ec) is expected to fail as both event request different thresh control bits. Result before the patch changes: [command]# perf stat -e "{r35340401e0,r34340101ec}" sleep 1 Performance counter stats for 'sleep 1': 8,482 r35340401e0 0 r34340101ec 1.001474838 seconds time elapsed 0.001145000 seconds user 0.000000000 seconds sys Result after the patch changes: [command]# perf stat -e "{r35340401e0,r34340101ec}" sleep 1 Performance counter stats for 'sleep 1': <not counted> r35340401e0 <not supported> r34340101ec 1.001499607 seconds time elapsed 0.000204000 seconds user 0.000760000 seconds sys Fixes: 82d2c16 ("powerpc/perf: Adds support for programming of Thresholding in P10") Signed-off-by: Kajol Jain <kjain@linux.ibm.com> Reviewed-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20220506061015.43916-1-kjain@linux.ibm.com Signed-off-by: Mamatha Inamdar <minamdar@redhat.com> Approved-by: Steve Best <sbest@redhat.com> Approved-by: Tony Camuso <tcamuso@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Rado Vrbovsky <rvrbovsk@redhat.com>
2 parents a45fb45 + a62522f commit b1f323e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

arch/powerpc/perf/isa207-common.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static void mmcra_sdar_mode(u64 event, unsigned long *mmcra)
108108
*mmcra |= MMCRA_SDAR_MODE_TLB;
109109
}
110110

111-
static u64 p10_thresh_cmp_val(u64 value)
111+
static int p10_thresh_cmp_val(u64 value)
112112
{
113113
int exp = 0;
114114
u64 result = value;
@@ -139,7 +139,7 @@ static u64 p10_thresh_cmp_val(u64 value)
139139
* exponent is also zero.
140140
*/
141141
if (!(value & 0xC0) && exp)
142-
result = 0;
142+
result = -1;
143143
else
144144
result = (exp << 8) | value;
145145
}
@@ -187,7 +187,7 @@ static bool is_thresh_cmp_valid(u64 event)
187187
unsigned int cmp, exp;
188188

189189
if (cpu_has_feature(CPU_FTR_ARCH_31))
190-
return p10_thresh_cmp_val(event) != 0;
190+
return p10_thresh_cmp_val(event) >= 0;
191191

192192
/*
193193
* Check the mantissa upper two bits are not zero, unless the
@@ -502,7 +502,8 @@ int isa207_get_constraint(u64 event, unsigned long *maskp, unsigned long *valp,
502502
value |= CNST_THRESH_CTL_SEL_VAL(event >> EVENT_THRESH_SHIFT);
503503
mask |= p10_CNST_THRESH_CMP_MASK;
504504
value |= p10_CNST_THRESH_CMP_VAL(p10_thresh_cmp_val(event_config1));
505-
}
505+
} else if (event_is_threshold(event))
506+
return -1;
506507
} else if (cpu_has_feature(CPU_FTR_ARCH_300)) {
507508
if (event_is_threshold(event) && is_thresh_cmp_valid(event)) {
508509
mask |= CNST_THRESH_MASK;

0 commit comments

Comments
 (0)