make weak attributes in {k,u}probes
Subsystems (9)
cover make weak attributes in {k,u}probes
We have some function implementation under some arch does nothing. We can mark it with weak attributes to improve.
1. arch_init_kprobes in kprobes
2. arch_uprobe_exception_notify in uprobes
Yipeng Zou (2):
kprobes: make arch_init_kprobes as weak
uprobes: make arch_uprobe_exception_notify as weak
arch/arm/probes/uprobes/core.c | 6 ------ arch/arm64/kernel/probes/uprobes.c | 6 ------ arch/csky/kernel/probes/kprobes.c | 5 ----- arch/csky/kernel/probes/uprobes.c | 6 ------ arch/riscv/kernel/probes/kprobes.c | 5 ----- arch/riscv/kernel/probes/uprobes.c | 6 ------ arch/s390/kernel/kprobes.c | 5 ----- arch/x86/kernel/kprobes/core.c | 5 ----- kernel/events/uprobes.c | 6 ++++++ kernel/kprobes.c | 5 +++++ 10 files changed, 11 insertions(+), 44 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/2 kprobes: make arch_init_kprobes as weak
The function implementation under some arch does nothing. We can mark it with weak attributes to improve.
--- 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(-)
arch/csky/kernel/probes/kprobes.c +0 -5
@@ -405,8 +405,3 @@ int __kprobes arch_trampoline_kprobe(struct kprobe *p) {return 0 ; } - -int __init arch_init_kprobes (void ) -{ -return 0 ; -}
arch/riscv/kernel/probes/kprobes.c +0 -5
@@ -362,8 +362,3 @@ int __kprobes arch_trampoline_kprobe(struct kprobe *p) {return 0 ; } - -int __init arch_init_kprobes (void ) -{ -return 0 ; -}
arch/s390/kernel/kprobes.c +0 -5
@@ -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 ;
arch/x86/kernel/kprobes/core.c +0 -5
@@ -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 ;
kernel/kprobes.c +5 -0
@@ -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 ;
Signature · 1 line
2.17.1
PATCH 2/2 uprobes: make arch_uprobe_exception_notify as weak
In reply to Yipeng ZouThe function implementation under some arch does nothing. We can mark it with weak attributes to improve.
--- arch/arm/probes/uprobes/core.c | 6 ------ arch/arm64/kernel/probes/uprobes.c | 6 ------ arch/csky/kernel/probes/uprobes.c | 6 ------ arch/riscv/kernel/probes/uprobes.c | 6 ------ kernel/events/uprobes.c | 6 ++++++ 5 files changed, 6 insertions(+), 24 deletions(-)
arch/arm/probes/uprobes/core.c +0 -6
@@ -175,12 +175,6 @@ void arch_uprobe_abort_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)instruction_pointer_set (regs, utask->vaddr); } -int arch_uprobe_exception_notify (struct notifier_block *self, -unsigned long val,void *data) -{ -return NOTIFY_DONE ; -} -static int uprobe_trap_handler (struct pt_regs *regs,unsigned int instr) {unsigned long flags;
arch/arm64/kernel/probes/uprobes.c +0 -6
@@ -159,12 +159,6 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr,return orig_ret_vaddr; } -int arch_uprobe_exception_notify (struct notifier_block *self, -unsigned long val,void *data) -{ -return NOTIFY_DONE ; -} -static int uprobe_breakpoint_handler (struct pt_regs *regs,unsigned long esr) {
arch/csky/kernel/probes/uprobes.c +0 -6
@@ -132,12 +132,6 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr,return ra; } -int arch_uprobe_exception_notify (struct notifier_block *self, -unsigned long val,void *data) -{ -return NOTIFY_DONE ; -} -int uprobe_breakpoint_handler (struct pt_regs *regs) {if (uprobe_pre_sstep_notifier (regs))
arch/riscv/kernel/probes/uprobes.c +0 -6
@@ -131,12 +131,6 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr,return ra; } -int arch_uprobe_exception_notify (struct notifier_block *self, -unsigned long val,void *data) -{ -return NOTIFY_DONE ; -} -bool uprobe_breakpoint_handler (struct pt_regs *regs) {if (uprobe_pre_sstep_notifier (regs))
kernel/events/uprobes.c +6 -0
@@ -2343,6 +2343,12 @@ int uprobe_post_sstep_notifier(struct pt_regs *regs)return 1 ; } +int __weak arch_uprobe_exception_notify (struct notifier_block *self, +unsigned long val,void *data) +{ +return NOTIFY_DONE ; +} +static struct notifier_block uprobe_exception_nb = { .notifier_call = arch_uprobe_exception_notify, .priority =INT_MAX -1 ,/* notified after kprobes, kgdb */
Signature · 1 line
2.17.1
It's a riskless cleanup.
Quoted 25 lines · Yipeng Zou
We have some function implementation under some arch does nothing. We can mark it with weak attributes to improve.
1.arch_init_kprobesin kprobes
2.arch_uprobe_exception_notifyin uprobesYipeng Zou (2):
kprobes: makearch_init_kprobesas weak
uprobes: makearch_uprobe_exception_notifyas weakarch/arm/probes/uprobes/core.c | 6 ------ arch/arm64/kernel/probes/uprobes.c | 6 ------ arch/csky/kernel/probes/kprobes.c | 5 ----- arch/csky/kernel/probes/uprobes.c | 6 ------ arch/riscv/kernel/probes/kprobes.c | 5 ----- arch/riscv/kernel/probes/uprobes.c | 6 ------ arch/s390/kernel/kprobes.c | 5 ----- arch/x86/kernel/kprobes/core.c | 5 ----- kernel/events/uprobes.c | 6 ++++++ kernel/kprobes.c | 5 +++++ 10 files changed, 11 insertions(+), 44 deletions(-)--
2.17.1
Signature · 2 lines
Best Regards Guo Ren
Quoted 2 lines · Yipeng Zou
We have some function implementation under some arch does nothing. We can mark it with weak attributes to improve.
That's not always an improvement. See [1] for an example, among many other patches to reduce use of __weak functions in the kernel.
As an alternative, please consider the approach used in [1].
- Naveen
Peter Zijlstra
maintainerQuoted 6 lines · Naveen N. Rao
Quoted 2 lines · Yipeng Zou
We have some function implementation under some arch does nothing. We can mark it with weak attributes to improve.
That's not always an improvement. See [1] for an example, among many other patches to reduce use of
__weakfunctions in the kernel.
More weak 'fun':