* [PATCH] riscv: module: Use generic cmp_int() instead of custom cmp_3way()
@ 2026-05-12 6:32 Florian Schmaus
2026-05-19 21:29 ` Paul Walmsley
2026-05-22 3:08 ` patchwork-bot+linux-riscv
0 siblings, 2 replies; 3+ messages in thread
From: Florian Schmaus @ 2026-05-12 6:32 UTC (permalink / raw)
To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti
Cc: Samuel Holland, Andrew Jones, Conor Dooley, Sean Chang,
Miaoqian Lin, linux-riscv, linux-kernel, Florian Schmaus
The module-sections.c file defines a custom cmp_3way() macro to perform
3-way comparisons during relocation sorting.
Instead of maintaining our own implementation, use the generic
cmp_int() macro provided by the already included <linux/sort.h>. This
removes redundant code and relies on standard kernel interfaces.
Signed-off-by: Florian Schmaus <florian.schmaus@codasip.com>
---
arch/riscv/kernel/module-sections.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/arch/riscv/kernel/module-sections.c b/arch/riscv/kernel/module-sections.c
index 98eaac6f6606..b3b11b7f7ed9 100644
--- a/arch/riscv/kernel/module-sections.c
+++ b/arch/riscv/kernel/module-sections.c
@@ -56,17 +56,15 @@ unsigned long module_emit_plt_entry(struct module *mod, unsigned long val)
return (unsigned long)&plt[i];
}
-#define cmp_3way(a, b) ((a) < (b) ? -1 : (a) > (b))
-
static int cmp_rela(const void *a, const void *b)
{
const Elf_Rela *x = a, *y = b;
int i;
/* sort by type, symbol index and addend */
- i = cmp_3way(x->r_info, y->r_info);
+ i = cmp_int(x->r_info, y->r_info);
if (i == 0)
- i = cmp_3way(x->r_addend, y->r_addend);
+ i = cmp_int(x->r_addend, y->r_addend);
return i;
}
--
2.53.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] riscv: module: Use generic cmp_int() instead of custom cmp_3way()
2026-05-12 6:32 [PATCH] riscv: module: Use generic cmp_int() instead of custom cmp_3way() Florian Schmaus
@ 2026-05-19 21:29 ` Paul Walmsley
2026-05-22 3:08 ` patchwork-bot+linux-riscv
1 sibling, 0 replies; 3+ messages in thread
From: Paul Walmsley @ 2026-05-19 21:29 UTC (permalink / raw)
To: Florian Schmaus
Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
Samuel Holland, Andrew Jones, Conor Dooley, Sean Chang,
Miaoqian Lin, linux-riscv, linux-kernel
On Tue, 12 May 2026, Florian Schmaus wrote:
> The module-sections.c file defines a custom cmp_3way() macro to perform
> 3-way comparisons during relocation sorting.
>
> Instead of maintaining our own implementation, use the generic
> cmp_int() macro provided by the already included <linux/sort.h>. This
> removes redundant code and relies on standard kernel interfaces.
>
> Signed-off-by: Florian Schmaus <florian.schmaus@codasip.com>
Thanks, queued for v7.2. Looks like arm, arm64, and loongarch have the
same problem. Care to fix those too (in separate patches)?
- Paul
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] riscv: module: Use generic cmp_int() instead of custom cmp_3way()
2026-05-12 6:32 [PATCH] riscv: module: Use generic cmp_int() instead of custom cmp_3way() Florian Schmaus
2026-05-19 21:29 ` Paul Walmsley
@ 2026-05-22 3:08 ` patchwork-bot+linux-riscv
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+linux-riscv @ 2026-05-22 3:08 UTC (permalink / raw)
To: Florian Schmaus
Cc: linux-riscv, pjw, palmer, aou, alex, samuel.holland, ajones,
conor.dooley, seanwascoding, linmq006, linux-kernel
Hello:
This patch was applied to riscv/linux.git (for-next)
by Paul Walmsley <pjw@kernel.org>:
On Tue, 12 May 2026 08:32:31 +0200 you wrote:
> The module-sections.c file defines a custom cmp_3way() macro to perform
> 3-way comparisons during relocation sorting.
>
> Instead of maintaining our own implementation, use the generic
> cmp_int() macro provided by the already included <linux/sort.h>. This
> removes redundant code and relies on standard kernel interfaces.
>
> [...]
Here is the summary with links:
- riscv: module: Use generic cmp_int() instead of custom cmp_3way()
https://git.kernel.org/riscv/c/7a6fbb72a489
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-22 3:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-12 6:32 [PATCH] riscv: module: Use generic cmp_int() instead of custom cmp_3way() Florian Schmaus
2026-05-19 21:29 ` Paul Walmsley
2026-05-22 3:08 ` patchwork-bot+linux-riscv
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome