Skip to contentSkip to conversation

linux/dim: Fix divide 0 in RDMA DIM.

PATCH Superseded Tao Liu 3 participants 3 messages Jun 27, 2022

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Tao Liu

author
#0 lore raw

PATCH v2 1/1 linux/dim: Fix divide 0 in RDMA DIM.

We hit a divide 0 error in ofed 5.1.2.3.7.1. It is caused in rdma_dim_stats_compare() when prev->cpe_ratio == 0.

dim.c and rdma_dim.c in ofed share same code with upstream. We check the 0 case in IS_SIGNIFICANT_DIFF(), and do not change decision order.

---
 include/linux/dim.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/dim.h +1 -1
index b698266d0035..6c5733981563 100644
@@ -21,7 +21,7 @@
  * We consider 10% difference as significant.
  */
 #define IS_SIGNIFICANT_DIFF(val, ref) \
-	(((100UL * abs((val) - (ref))) / (ref)) > 10)
+	((ref) && (((100UL * abs((val) - (ref))) / (ref)) > 10))
 
 /*
  * Calculate the gap between two values.
Signature · 1 line
2.30.1 (Apple Git-130)
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 11 lines · Tao Liu

We hit a divide 0 error in ofed 5.1.2.3.7.1. It is caused in rdma_dim_stats_compare() when prev->cpe_ratio == 0.

dim.c and rdma_dim.c in ofed share same code with upstream. We check the 0 case in IS_SIGNIFICANT_DIFF(), and do not change decision order.

---
 include/linux/dim.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

I liked the commit message from v1 more.
It had proper kernel panic dump together with Fixes line.
https://lore.kernel.org/all/[email protected]

The change itself is ok.

Thanks,

Reviewed-by
#2 lore raw
Quoted 8 lines · Leon Romanovsky
Quoted 7 lines · Tao Liu

We hit a divide 0 error in ofed 5.1.2.3.7.1. It is caused in rdma_dim_stats_compare() when prev->cpe_ratio == 0.

dim.c and rdma_dim.c in ofed share same code with upstream. We check the 0 case in IS_SIGNIFICANT_DIFF(), and do not change decision order.

Quoted 5 lines
Quoted 4 lines
---
  include/linux/dim.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

I liked the commit message from v1 more.

I think you need to do a combination of the commit msg (remove the ofed notion):

"fix a divide 0 error in rdma_dim_stats_compare() when prev->cpe_ratio == 0.

CallTrace:

....

Fixes(...)"

Otherwise,

Looks good,

Quoted 7 lines

It had proper kernel panic dump together with Fixes line.
https://lore.kernel.org/all/[email protected]

The change itself is ok.

Thanks,