Skip to contentSkip to conversation

ntb_perf: Fix 64-bit division on 32-bit architectures

PATCH In review Nathan Chancellor 2 participants 3 messages Jun 22, 2022 – Aug 15, 2022 NTB driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ntb_perf: Fix 64-bit division on 32-bit architectures

When compiling for a 32-bit architecture, such as arm, an error occurs during modpost:

ERROR: modpost: "__aeabi_uldivmod" [drivers/ntb/test/ntb_perf.ko] undefined!

The tries member of struct perf_thread is u64 so a 64-bit division helper is needed. Use div_u64_rem() to get the remainder of the division so that it can be checked against zero.

Fixes dc150dfb081f ("ntb_perf: extend with burst latency measurement")
---
 drivers/ntb/test/ntb_perf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/ntb/test/ntb_perf.c +3 -1
index 23e154bd41b9..4e05c7aa070d 100644
@@ -1118,6 +1118,7 @@ static int perf_run_latency(struct perf_thread *pthr)
 	void __iomem *flt_dst, *bnd_dst;
 	void *flt_src;
 	u64 stop_at;
+	u32 rem;
 	int ret;
 
 	pthr->tries = 0;
@@ -1146,7 +1147,8 @@ static int perf_run_latency(struct perf_thread *pthr)
 		}
 
 		/* Avoid processor soft lock-ups */
-		if (!(pthr->tries % RESCHEDULE_RATIO))
+		div_u64_rem(pthr->tries, RESCHEDULE_RATIO, &rem);
+		if (!rem)
 			schedule();
 	}
 

base-commit: 0c4b285d9636cc850f55151fa6a250dd131e5192

Signature · 1 line
2.37.0.rc1
maintainer
#1 lore raw
Quoted 39 lines · Nathan Chancellor

When compiling for a 32-bit architecture, such as arm, an error occurs during modpost:

ERROR: modpost: "__aeabi_uldivmod" [drivers/ntb/test/ntb_perf.ko] undefined!

The tries member of struct perf_thread is u64 so a 64-bit division helper is needed. Use div_u64_rem() to get the remainder of the division so that it can be checked against zero.

Fixes dc150dfb081f ("ntb_perf: extend with burst latency measurement")
---
 drivers/ntb/test/ntb_perf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/ntb/test/ntb_perf.c +3 -1
index 23e154bd41b9..4e05c7aa070d 100644
@@ -1118,6 +1118,7 @@ static int perf_run_latency(struct perf_thread *pthr)
 	void __iomem *flt_dst, *bnd_dst;
 	void *flt_src;
 	u64 stop_at;
+	u32 rem;
 	int ret;
 
 	pthr->tries = 0;
@@ -1146,7 +1147,8 @@ static int perf_run_latency(struct perf_thread *pthr)
 		}
 
 		/* Avoid processor soft lock-ups */
-		if (!(pthr->tries % RESCHEDULE_RATIO))
+		div_u64_rem(pthr->tries, RESCHEDULE_RATIO, &rem);
+		if (!rem)
 			schedule();
 	}
 
Quoted 4 lines

base-commit: 0c4b285d9636cc850f55151fa6a250dd131e5192

Signature · 1 line
2.37.0.rc1

Sorry for the extremely long delay in response. This patch is in my ntb branch and will be in my pull request for v5.20 which should be going out later today.

Thanks,
Jon

#2 lore raw

Hi Jon,

Quoted 40 lines · Jon Mason
Quoted 39 lines · Nathan Chancellor

When compiling for a 32-bit architecture, such as arm, an error occurs during modpost:

ERROR: modpost: "__aeabi_uldivmod" [drivers/ntb/test/ntb_perf.ko] undefined!

The tries member of struct perf_thread is u64 so a 64-bit division helper is needed. Use div_u64_rem() to get the remainder of the division so that it can be checked against zero.

Fixes dc150dfb081f ("ntb_perf: extend with burst latency measurement")
---
 drivers/ntb/test/ntb_perf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/ntb/test/ntb_perf.c +3 -1
index 23e154bd41b9..4e05c7aa070d 100644
@@ -1118,6 +1118,7 @@ static int perf_run_latency(struct perf_thread *pthr)
 	void __iomem *flt_dst, *bnd_dst;
 	void *flt_src;
 	u64 stop_at;
+	u32 rem;
 	int ret;
 
 	pthr->tries = 0;
@@ -1146,7 +1147,8 @@ static int perf_run_latency(struct perf_thread *pthr)
 		}
 
 		/* Avoid processor soft lock-ups */
-		if (!(pthr->tries % RESCHEDULE_RATIO))
+		div_u64_rem(pthr->tries, RESCHEDULE_RATIO, &rem);
+		if (!rem)
 			schedule();
 	}
 
Quoted 8 lines
Quoted 4 lines

base-commit: 0c4b285d9636cc850f55151fa6a250dd131e5192

Signature · 1 line
2.37.0.rc1

Sorry for the extremely long delay in response. This patch is in my ntb branch and will be in my pull request for v5.20 which should be going out later today.

No worries, we all get busy :)

For the record, I believe this was addressed by Max's patch [1], which I did see in -next for a time. It doesn't matter to me which one goes in, just so long as the build doesn't break :)

[1]: https://lore.kernel.org/[email protected]/

Cheers,
Nathan