Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

arm_mpam: Consider overflow in bandwidth counter state

Use the overflow status bit to track overflow on each bandwidth counter
read and add the counter size to the correction when overflow is detected.

This assumes that only a single overflow has occurred since the last read
of the counter. Overflow interrupts, on hardware that supports them could
be used to remove this limitation.

Cc: Zeng Heng <zengheng4@huawei.com>
Reviewed-by: Gavin Shan <gshan@redhat.com>
Reviewed-by: Zeng Heng <zengheng4@huawei.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Reviewed-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Reviewed-by: Fenghua Yu <fenghuay@nvidia.com>
Tested-by: Carl Worth <carl@os.amperecomputing.com>
Tested-by: Gavin Shan <gshan@redhat.com>
Tested-by: Zeng Heng <zengheng4@huawei.com>
Tested-by: Shaopeng Tan <tan.shaopeng@jp.fujitsu.com>
Tested-by: Hanjun Guo <guohanjun@huawei.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

authored by

Ben Horgan and committed by
Catalin Marinas
b3536379 41e8a149

+24 -3
+22 -2
drivers/resctrl/mpam_devices.c
··· 985 985 } 986 986 } 987 987 988 + static u64 mpam_msmon_overflow_val(enum mpam_device_features type) 989 + { 990 + /* TODO: scaling, and long counters */ 991 + return BIT_ULL(hweight_long(MSMON___VALUE)); 992 + } 993 + 988 994 static void __ris_msmon_read(void *arg) 989 995 { 990 996 u64 now; 991 997 bool nrdy = false; 992 998 bool config_mismatch; 999 + bool overflow; 993 1000 struct mon_read *m = arg; 994 1001 struct mon_cfg *ctx = m->ctx; 995 1002 struct mpam_msc_ris *ris = m->ris; ··· 1018 1011 * This saves waiting for 'nrdy' on subsequent reads. 1019 1012 */ 1020 1013 read_msmon_ctl_flt_vals(m, &cur_ctl, &cur_flt); 1014 + overflow = cur_ctl & MSMON_CFG_x_CTL_OFLOW_STATUS; 1015 + 1021 1016 clean_msmon_ctl_val(&cur_ctl); 1022 1017 gen_msmon_ctl_flt_vals(m, &ctl_val, &flt_val); 1023 1018 config_mismatch = cur_flt != flt_val || 1024 1019 cur_ctl != (ctl_val | MSMON_CFG_x_CTL_EN); 1025 1020 1026 - if (config_mismatch) 1021 + if (config_mismatch) { 1027 1022 write_msmon_ctl_flt_vals(m, ctl_val, flt_val); 1023 + overflow = false; 1024 + } else if (overflow) { 1025 + mpam_write_monsel_reg(msc, CFG_MBWU_CTL, 1026 + cur_ctl & ~MSMON_CFG_x_CTL_OFLOW_STATUS); 1027 + } 1028 1028 1029 1029 switch (m->type) { 1030 1030 case mpam_feat_msmon_csu: ··· 1051 1037 1052 1038 mbwu_state = &ris->mbwu_state[ctx->mon]; 1053 1039 1054 - /* Include bandwidth consumed before the last hardware reset */ 1040 + if (overflow) 1041 + mbwu_state->correction += mpam_msmon_overflow_val(m->type); 1042 + 1043 + /* 1044 + * Include bandwidth consumed before the last hardware reset and 1045 + * a counter size increment for each overflow. 1046 + */ 1055 1047 now += mbwu_state->correction; 1056 1048 break; 1057 1049 default:
+2 -1
drivers/resctrl/mpam_internal.h
··· 211 211 struct mon_cfg cfg; 212 212 213 213 /* 214 - * The value to add to the new reading to account for power management. 214 + * The value to add to the new reading to account for power management, 215 + * and overflow. 215 216 */ 216 217 u64 correction; 217 218