* [PATCH 1/2] kprobes: make arch_init_kprobes as weak
2022-09-17 1:55 [PATCH 0/2] make weak attributes in {k,u}probes Yipeng Zou
@ 2022-09-17 1:55 ` Yipeng Zou
2022-09-17 1:55 ` [PATCH 2/2] uprobes: make arch_uprobe_exception_notify " Yipeng Zou
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Yipeng Zou @ 2022-09-17 1:55 UTC (permalink / raw)
To: x86, linux-arm-kernel, linux-kernel, linux-csky, linux-riscv,
linux-perf-users, linux-s390, guoren, paul.walmsley, palmer, hca,
gor, borntraeger, dave.hansen, hpa, naveen.n.rao,
anil.s.keshavamurthy, mhiramat, namit, catalin.marinas, peterz,
mark.rutland
Cc: liaochang1, chris.zjh, zouyipeng
The function implementation under some arch does nothing.
We can mark it with weak attributes to improve.
Signed-off-by: Yipeng Zou <zouyipeng@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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] uprobes: make arch_uprobe_exception_notify as weak
2022-09-17 1:55 [PATCH 0/2] make weak attributes in {k,u}probes Yipeng Zou
2022-09-17 1:55 ` [PATCH 1/2] kprobes: make arch_init_kprobes as weak Yipeng Zou
@ 2022-09-17 1:55 ` Yipeng Zou
2022-09-17 10:58 ` [PATCH 0/2] make weak attributes in {k,u}probes Guo Ren
2022-09-20 17:02 ` Naveen N. Rao
3 siblings, 0 replies; 6+ messages in thread
From: Yipeng Zou @ 2022-09-17 1:55 UTC (permalink / raw)
To: x86, linux-arm-kernel, linux-kernel, linux-csky, linux-riscv,
linux-perf-users, linux-s390, guoren, paul.walmsley, palmer, hca,
gor, borntraeger, dave.hansen, hpa, naveen.n.rao,
anil.s.keshavamurthy, mhiramat, namit, catalin.marinas, peterz,
mark.rutland
Cc: liaochang1, chris.zjh, zouyipeng
The function implementation under some arch does nothing.
We can mark it with weak attributes to improve.
Signed-off-by: Yipeng Zou <zouyipeng@huawei.com>
---
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(-)
diff --git a/arch/arm/probes/uprobes/core.c b/arch/arm/probes/uprobes/core.c
index f5f790c6e5f8..535ea1b355ed 100644
--- a/arch/arm/probes/uprobes/core.c
+++ b/arch/arm/probes/uprobes/core.c
@@ -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;
diff --git a/arch/arm64/kernel/probes/uprobes.c b/arch/arm64/kernel/probes/uprobes.c
index d49aef2657cd..687ede3375a6 100644
--- a/arch/arm64/kernel/probes/uprobes.c
+++ b/arch/arm64/kernel/probes/uprobes.c
@@ -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)
{
diff --git a/arch/csky/kernel/probes/uprobes.c b/arch/csky/kernel/probes/uprobes.c
index 2d31a12e46cf..67ff13d960e8 100644
--- a/arch/csky/kernel/probes/uprobes.c
+++ b/arch/csky/kernel/probes/uprobes.c
@@ -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))
diff --git a/arch/riscv/kernel/probes/uprobes.c b/arch/riscv/kernel/probes/uprobes.c
index c976a21cd4bd..770f16c6e00f 100644
--- a/arch/riscv/kernel/probes/uprobes.c
+++ b/arch/riscv/kernel/probes/uprobes.c
@@ -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))
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index d9e357b7e17c..33e637f7a202 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -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 */
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] make weak attributes in {k,u}probes
2022-09-17 1:55 [PATCH 0/2] make weak attributes in {k,u}probes Yipeng Zou
2022-09-17 1:55 ` [PATCH 1/2] kprobes: make arch_init_kprobes as weak Yipeng Zou
2022-09-17 1:55 ` [PATCH 2/2] uprobes: make arch_uprobe_exception_notify " Yipeng Zou
@ 2022-09-17 10:58 ` Guo Ren
2022-09-20 17:02 ` Naveen N. Rao
3 siblings, 0 replies; 6+ messages in thread
From: Guo Ren @ 2022-09-17 10:58 UTC (permalink / raw)
To: Yipeng Zou
Cc: x86, linux-arm-kernel, linux-kernel, linux-csky, linux-riscv,
linux-perf-users, linux-s390, paul.walmsley, palmer, hca, gor,
borntraeger, dave.hansen, hpa, naveen.n.rao,
anil.s.keshavamurthy, mhiramat, namit, catalin.marinas, peterz,
mark.rutland, liaochang1, chris.zjh
It's a riskless cleanup.
Acked-by: Guo Ren <guoren@kernel.org>
On Sat, Sep 17, 2022 at 9:59 AM Yipeng Zou <zouyipeng@huawei.com> wrote:
>
> 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(-)
>
> --
> 2.17.1
>
--
Best Regards
Guo Ren
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] make weak attributes in {k,u}probes
2022-09-17 1:55 [PATCH 0/2] make weak attributes in {k,u}probes Yipeng Zou
` (2 preceding siblings ...)
2022-09-17 10:58 ` [PATCH 0/2] make weak attributes in {k,u}probes Guo Ren
@ 2022-09-20 17:02 ` Naveen N. Rao
2022-09-21 8:25 ` Peter Zijlstra
3 siblings, 1 reply; 6+ messages in thread
From: Naveen N. Rao @ 2022-09-20 17:02 UTC (permalink / raw)
To: anil.s.keshavamurthy, borntraeger, catalin.marinas, dave.hansen,
gor, guoren, hca, hpa, linux-arm-kernel, linux-csky,
linux-kernel, linux-perf-users, linux-riscv, linux-s390,
mark.rutland, mhiramat, namit, palmer, paul.walmsley, peterz,
x86, Yipeng Zou
Cc: chris.zjh, liaochang1
Yipeng Zou wrote:
> 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
[1] https://lore.kernel.org/all/20220519091237.676736-1-naveen.n.rao@linux.vnet.ibm.com/
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] make weak attributes in {k,u}probes
2022-09-20 17:02 ` Naveen N. Rao
@ 2022-09-21 8:25 ` Peter Zijlstra
0 siblings, 0 replies; 6+ messages in thread
From: Peter Zijlstra @ 2022-09-21 8:25 UTC (permalink / raw)
To: Naveen N. Rao
Cc: anil.s.keshavamurthy, borntraeger, catalin.marinas, dave.hansen,
gor, guoren, hca, hpa, linux-arm-kernel, linux-csky,
linux-kernel, linux-perf-users, linux-riscv, linux-s390,
mark.rutland, mhiramat, namit, palmer, paul.walmsley, x86,
Yipeng Zou, chris.zjh, liaochang1
On Tue, Sep 20, 2022 at 10:32:46PM +0530, Naveen N. Rao wrote:
> Yipeng Zou wrote:
> > 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.
More weak 'fun':
https://lkml.kernel.org/r/20220419203807.655552918@infradead.org
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread