2013-03-07 10:44:36

by Oskar Andero

[permalink] [raw]
Subject: [PATCH] Kprobes blacklist: Conditionally add x86-specific symbols

From: Bj?rn Davidsson <[email protected]>

The kprobes blacklist contains x86-specific symbols.
Looking for these in kallsyms takes unnecessary time
during startup on non-X86 platform.
Added #ifdef CONFIG_X86 around them.

Reviewed-by: Radovan Lekanovic <[email protected]>
Signed-off-by: Björn Davidsson <[email protected]>
Signed-off-by: Oskar Andero <[email protected]>
---
kernel/kprobes.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index e35be53..8c3796f 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -95,9 +95,11 @@ static raw_spinlock_t *kretprobe_table_lock_ptr(unsigned long hash)
*/
static struct kprobe_blackpoint kprobe_blacklist[] = {
{"preempt_schedule",},
+#ifdef CONFIG_X86
{"native_get_debugreg",},
{"irq_entries_start",},
{"common_interrupt",},
+#endif
{"mcount",}, /* mcount can be called from everywhere */
{NULL} /* Terminator */
};
--
1.7.8.6


Subject: Re: [PATCH] Kprobes blacklist: Conditionally add x86-specific symbols

(2013/03/07 19:44), [email protected] wrote:
> From: Bjorn Davidsson <[email protected]>
>
> The kprobes blacklist contains x86-specific symbols.
> Looking for these in kallsyms takes unnecessary time
> during startup on non-X86 platform.
> Added #ifdef CONFIG_X86 around them.

Right. however, it might be better break that into
common and arch-specific lists, because there may be
other arch-specific non-probe-able functions on each
architecture...

Would you know some other black points on your platform?

Thank you,

>
> Reviewed-by: Radovan Lekanovic <[email protected]>
> Signed-off-by: Björn Davidsson <[email protected]>
> Signed-off-by: Oskar Andero <[email protected]>
> ---
> kernel/kprobes.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index e35be53..8c3796f 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -95,9 +95,11 @@ static raw_spinlock_t *kretprobe_table_lock_ptr(unsigned long hash)
> */
> static struct kprobe_blackpoint kprobe_blacklist[] = {
> {"preempt_schedule",},
> +#ifdef CONFIG_X86
> {"native_get_debugreg",},
> {"irq_entries_start",},
> {"common_interrupt",},
> +#endif
> {"mcount",}, /* mcount can be called from everywhere */
> {NULL} /* Terminator */
> };
>


--
Masami HIRAMATSU
IT Management Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: [email protected]

Subject: Re: [PATCH] Kprobes blacklist: Conditionally add x86-specific symbols

On Fri, Mar 08, 2013 at 01:23:25PM +0900, Masami Hiramatsu wrote:
> (2013/03/07 19:44), [email protected] wrote:
> > From: Bjorn Davidsson <[email protected]>
> >
> > The kprobes blacklist contains x86-specific symbols.
> > Looking for these in kallsyms takes unnecessary time
> > during startup on non-X86 platform.
> > Added #ifdef CONFIG_X86 around them.
>
> Right. however, it might be better break that into
> common and arch-specific lists, because there may be
> other arch-specific non-probe-able functions on each
> architecture...

Agreed. CONFIG_<arch> in kernel/* is not the right thing to do IMO.

You are moving the blacklist initialization to later in the next patch,
so how much overhead will it then be?

Ananth

2013-03-08 13:15:40

by Oskar Andero

[permalink] [raw]
Subject: Re: [PATCH] Kprobes blacklist: Conditionally add x86-specific symbols

On 05:23 Fri 08 Mar , Masami Hiramatsu wrote:
> (2013/03/07 19:44), [email protected] wrote:
> > From: Bjorn Davidsson <[email protected]>
> >
> > The kprobes blacklist contains x86-specific symbols.
> > Looking for these in kallsyms takes unnecessary time
> > during startup on non-X86 platform.
> > Added #ifdef CONFIG_X86 around them.
>
> Right. however, it might be better break that into
> common and arch-specific lists, because there may be
> other arch-specific non-probe-able functions on each
> architecture...

Ok. You mean adding, for instance, a kprobe_blacklist_arch[] in arch/x86
somewhere or did you have something else in mind? I guess we preferably want
to get rid of the #ifdef.

> Would you know some other black points on your platform?

Not that we are aware of.

> Thank you,
>
> >
> > Reviewed-by: Radovan Lekanovic <[email protected]>
> > Signed-off-by: Bj?rn Davidsson <[email protected]>
> > Signed-off-by: Oskar Andero <[email protected]>
> > ---
> > kernel/kprobes.c | 2 ++
> > 1 files changed, 2 insertions(+), 0 deletions(-)
> >
> > diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> > index e35be53..8c3796f 100644
> > --- a/kernel/kprobes.c
> > +++ b/kernel/kprobes.c
> > @@ -95,9 +95,11 @@ static raw_spinlock_t *kretprobe_table_lock_ptr(unsigned long hash)
> > */
> > static struct kprobe_blackpoint kprobe_blacklist[] = {
> > {"preempt_schedule",},
> > +#ifdef CONFIG_X86
> > {"native_get_debugreg",},
> > {"irq_entries_start",},
> > {"common_interrupt",},
> > +#endif
> > {"mcount",}, /* mcount can be called from everywhere */
> > {NULL} /* Terminator */
> > };
> >
>
>
> --
> Masami HIRAMATSU
> IT Management Research Dept. Linux Technology Center
> Hitachi, Ltd., Yokohama Research Laboratory
> E-mail: [email protected]
>
>

-Oskar

2013-03-08 13:17:40

by Oskar Andero

[permalink] [raw]
Subject: Re: [PATCH] Kprobes blacklist: Conditionally add x86-specific symbols

On 07:03 Fri 08 Mar , Ananth N Mavinakayanahalli wrote:
> On Fri, Mar 08, 2013 at 01:23:25PM +0900, Masami Hiramatsu wrote:
> > (2013/03/07 19:44), [email protected] wrote:
> > > From: Bjorn Davidsson <[email protected]>
> > >
> > > The kprobes blacklist contains x86-specific symbols.
> > > Looking for these in kallsyms takes unnecessary time
> > > during startup on non-X86 platform.
> > > Added #ifdef CONFIG_X86 around them.
> >
> > Right. however, it might be better break that into
> > common and arch-specific lists, because there may be
> > other arch-specific non-probe-able functions on each
> > architecture...
>
> Agreed. CONFIG_<arch> in kernel/* is not the right thing to do IMO.
>
> You are moving the blacklist initialization to later in the next patch,
> so how much overhead will it then be?

Well, it's not crucial for the boot time, but it is still a small
optimization.

-Oskar

Subject: Re: Re: [PATCH] Kprobes blacklist: Conditionally add x86-specific symbols

(2013/03/08 22:15), [email protected] wrote:
> On 05:23 Fri 08 Mar , Masami Hiramatsu wrote:
>> (2013/03/07 19:44), [email protected] wrote:
>>> From: Bjorn Davidsson <[email protected]>
>>>
>>> The kprobes blacklist contains x86-specific symbols.
>>> Looking for these in kallsyms takes unnecessary time
>>> during startup on non-X86 platform.
>>> Added #ifdef CONFIG_X86 around them.
>>
>> Right. however, it might be better break that into
>> common and arch-specific lists, because there may be
>> other arch-specific non-probe-able functions on each
>> architecture...
>
> Ok. You mean adding, for instance, a kprobe_blacklist_arch[] in arch/x86
> somewhere or did you have something else in mind? I guess we preferably want
> to get rid of the #ifdef.

Yes, we can have symbol tables (const char *arch_kprobes_blacksyms[],
common_kprobes_blacksyms[]) to list it up, and when initializing
the blacklist table, we can check whether kprobes_blacklist == NULL
and initialize it.

Thank you,

--
Masami HIRAMATSU
IT Management Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: [email protected]