From 84738668ca79fadec096192eb0d339f0380fb47e Mon Sep 17 00:00:00 2001 From: Mete Durlu Date: Wed, 16 Aug 2023 18:28:28 +0200 Subject: [PATCH] hyptop/helper: fix smt utilization calculation When calculating smt utiliziation field, subresults are capped to a minimum value of zero to prevent wrap around while converting values from signed to unsigned integers. The capping of subresults cause slight inaccuracies therefore capping has been moved from intermediate steps and done at the end. Fixes: 0209c11bc196 ("hyptop: Add real SMT utilization field") Reviewed-by: Steffen Eiden Signed-off-by: Mete Durlu Signed-off-by: Steffen Eiden --- hyptop/helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hyptop/helper.c b/hyptop/helper.c index 9c0f6c89..0495ac1b 100644 --- a/hyptop/helper.c +++ b/hyptop/helper.c @@ -404,11 +404,11 @@ s64 ht_calculate_smt_util(u64 core_us, u64 thr_us, u64 mgm_us, int thread_per_co s64 component1, component2, smt_us; double smt_factor = g.o.smt_factor; - component1 = G0(thread_per_core * core_us - thr_us); + component1 = thread_per_core * core_us - thr_us; if (thread_per_core > 1) component1 /= smt_factor; - component2 = G0(thr_us - core_us); - smt_us = component1 + component2 + mgm_us; + component2 = thr_us - core_us; + smt_us = G0(component1 + component2 + mgm_us); return smt_us; }