[PATCH 1/2] kprobes: make arch_init_kprobes as weak

Yipeng Zou zouyipeng at huawei.com
Fri Sep 16 18:55:21 PDT 2022


The function implementation under some arch does nothing.
We can mark it with weak attributes to improve.

Signed-off-by: Yipeng Zou <zouyipeng at huawei.com>
---
 arch/csky/kernel/probes/kprobes.c  | 5 -----
 arch/riscv/kernel/probes/kprobes.c | 5 -----
 arch/s390/kernel/kprobes.c         | 5 -----
 arch/x86/kernel/kprobes/core.c     | 5 -----
 kernel/kprobes.c                   | 5 +++++
 5 files changed, 5 insertions(+), 20 deletions(-)

diff --git a/arch/csky/kernel/probes/kprobes.c b/arch/csky/kernel/probes/kprobes.c
index 3c6e5c725d81..d31b6ab5cea0 100644
--- a/arch/csky/kernel/probes/kprobes.c
+++ b/arch/csky/kernel/probes/kprobes.c
@@ -405,8 +405,3 @@ int __kprobes arch_trampoline_kprobe(struct kprobe *p)
 {
 	return 0;
 }
-
-int __init arch_init_kprobes(void)
-{
-	return 0;
-}
diff --git a/arch/riscv/kernel/probes/kprobes.c b/arch/riscv/kernel/probes/kprobes.c
index e6e950b7cf32..d4577108e5c9 100644
--- a/arch/riscv/kernel/probes/kprobes.c
+++ b/arch/riscv/kernel/probes/kprobes.c
@@ -362,8 +362,3 @@ int __kprobes arch_trampoline_kprobe(struct kprobe *p)
 {
 	return 0;
 }
-
-int __init arch_init_kprobes(void)
-{
-	return 0;
-}
diff --git a/arch/s390/kernel/kprobes.c b/arch/s390/kernel/kprobes.c
index 0032bdbe8e3f..aaf9329a7cf4 100644
--- a/arch/s390/kernel/kprobes.c
+++ b/arch/s390/kernel/kprobes.c
@@ -544,11 +544,6 @@ int kprobe_exceptions_notify(struct notifier_block *self,
 }
 NOKPROBE_SYMBOL(kprobe_exceptions_notify);
 
-int __init arch_init_kprobes(void)
-{
-	return 0;
-}
-
 int arch_trampoline_kprobe(struct kprobe *p)
 {
 	return 0;
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
index 4c3c27b6aea3..e26b336f8b18 100644
--- a/arch/x86/kernel/kprobes/core.c
+++ b/arch/x86/kernel/kprobes/core.c
@@ -1055,11 +1055,6 @@ int __init arch_populate_kprobe_blacklist(void)
 					 (unsigned long)__entry_text_end);
 }
 
-int __init arch_init_kprobes(void)
-{
-	return 0;
-}
-
 int arch_trampoline_kprobe(struct kprobe *p)
 {
 	return 0;
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index ca9d834d0b84..23f6d329b53b 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -2684,6 +2684,11 @@ void kprobe_free_init_mem(void)
 	mutex_unlock(&kprobe_mutex);
 }
 
+int __init __weak arch_init_kprobes(void)
+{
+	return 0;
+}
+
 static int __init init_kprobes(void)
 {
 	int i, err = 0;
-- 
2.17.1




More information about the linux-riscv mailing list