public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND 0/5] kprobes cleanups
@ 2010-09-15  1:04 Namhyung Kim
  2010-09-15  1:04 ` [PATCH 1/5] kprobes: remove redundant address check Namhyung Kim
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Namhyung Kim @ 2010-09-15  1:04 UTC (permalink / raw)
  To: Andrew Morton, Ingo Molnar; +Cc: Masami Hiramatsu, linux-kernel

Hello,

This is a resend of my previous works on kprobes. All patches in this
series are small cleanups and got acked by Masami. Please consider
applying it.

Thanks.

---

Namhyung Kim (5):
  kprobes: remove redundant address check
  kprobes: verify jprobe entry point
  kprobes: make functions static
  kprobes: remove __dummy_buf
  kprobes: add sparse context annotations

 arch/x86/kernel/kprobes.c |   11 +++--------
 kernel/kprobes.c          |   22 ++++++++++++++--------
 2 files changed, 17 insertions(+), 16 deletions(-)

--
1.7.2.2


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/5] kprobes: remove redundant address check
  2010-09-15  1:04 [PATCH RESEND 0/5] kprobes cleanups Namhyung Kim
@ 2010-09-15  1:04 ` Namhyung Kim
  2010-09-15 10:04   ` [tip:perf/core] kprobes: Remove " tip-bot for Namhyung Kim
  2010-09-15  1:04 ` [PATCH 2/5] kprobes: verify jprobe entry point Namhyung Kim
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Namhyung Kim @ 2010-09-15  1:04 UTC (permalink / raw)
  To: Andrew Morton, Ingo Molnar; +Cc: Masami Hiramatsu, linux-kernel

remove call to kernel_text_address() in register_jprobes()
because it is called right after in register_kprobe().

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
 kernel/kprobes.c |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 282035f..8f96701 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1343,14 +1343,11 @@ int __kprobes register_jprobes(struct jprobe **jps, int num)
 		jp = jps[i];
 		addr = arch_deref_entry_point(jp->entry);
 
-		if (!kernel_text_address(addr))
-			ret = -EINVAL;
-		else {
-			/* Todo: Verify probepoint is a function entry point */
-			jp->kp.pre_handler = setjmp_pre_handler;
-			jp->kp.break_handler = longjmp_break_handler;
-			ret = register_kprobe(&jp->kp);
-		}
+		/* Todo: Verify probepoint is a function entry point */
+		jp->kp.pre_handler = setjmp_pre_handler;
+		jp->kp.break_handler = longjmp_break_handler;
+		ret = register_kprobe(&jp->kp);
+
 		if (ret < 0) {
 			if (i > 0)
 				unregister_jprobes(jps, i);
-- 
1.7.2.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/5] kprobes: verify jprobe entry point
  2010-09-15  1:04 [PATCH RESEND 0/5] kprobes cleanups Namhyung Kim
  2010-09-15  1:04 ` [PATCH 1/5] kprobes: remove redundant address check Namhyung Kim
@ 2010-09-15  1:04 ` Namhyung Kim
  2010-09-15 10:04   ` [tip:perf/core] kprobes: Verify " tip-bot for Namhyung Kim
  2010-09-15  1:04 ` [PATCH 3/5] kprobes: make functions static Namhyung Kim
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Namhyung Kim @ 2010-09-15  1:04 UTC (permalink / raw)
  To: Andrew Morton, Ingo Molnar; +Cc: Masami Hiramatsu, linux-kernel

verify jprobe's entry point is a function entry point
using kallsyms' offset value.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
 kernel/kprobes.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 8f96701..1b0dbe0 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1339,14 +1339,18 @@ int __kprobes register_jprobes(struct jprobe **jps, int num)
 	if (num <= 0)
 		return -EINVAL;
 	for (i = 0; i < num; i++) {
-		unsigned long addr;
+		unsigned long addr, offset;
 		jp = jps[i];
 		addr = arch_deref_entry_point(jp->entry);
 
-		/* Todo: Verify probepoint is a function entry point */
-		jp->kp.pre_handler = setjmp_pre_handler;
-		jp->kp.break_handler = longjmp_break_handler;
-		ret = register_kprobe(&jp->kp);
+		/* Verify probepoint is a function entry point */
+		if (kallsyms_lookup_size_offset(addr, NULL, &offset) &&
+		    offset == 0) {
+			jp->kp.pre_handler = setjmp_pre_handler;
+			jp->kp.break_handler = longjmp_break_handler;
+			ret = register_kprobe(&jp->kp);
+		} else
+			ret = -EINVAL;
 
 		if (ret < 0) {
 			if (i > 0)
-- 
1.7.2.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/5] kprobes: make functions static
  2010-09-15  1:04 [PATCH RESEND 0/5] kprobes cleanups Namhyung Kim
  2010-09-15  1:04 ` [PATCH 1/5] kprobes: remove redundant address check Namhyung Kim
  2010-09-15  1:04 ` [PATCH 2/5] kprobes: verify jprobe entry point Namhyung Kim
@ 2010-09-15  1:04 ` Namhyung Kim
  2010-09-15 10:04   ` [tip:perf/core] kprobes: Make " tip-bot for Namhyung Kim
  2010-09-15  1:04 ` [PATCH 4/5] kprobes: remove __dummy_buf Namhyung Kim
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Namhyung Kim @ 2010-09-15  1:04 UTC (permalink / raw)
  To: Andrew Morton, Ingo Molnar; +Cc: Masami Hiramatsu, linux-kernel

make following (internal) functions static to make sparse happier :-)

 * get_optimized_kprobe: only called from static functions
 * kretprobe_table_unlock: _lock function is static
 * kprobes_optinsn_template_holder: never called but holding asm code

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
 arch/x86/kernel/kprobes.c |    2 +-
 kernel/kprobes.c          |    5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
index 770ebfb..05c20a4 100644
--- a/arch/x86/kernel/kprobes.c
+++ b/arch/x86/kernel/kprobes.c
@@ -1129,7 +1129,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr,
 	*(unsigned long *)addr = val;
 }
 
-void __kprobes kprobes_optinsn_template_holder(void)
+static void __used __kprobes kprobes_optinsn_template_holder(void)
 {
 	asm volatile (
 			".global optprobe_template_entry\n"
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 1b0dbe0..c53aad5 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -399,7 +399,7 @@ static inline int kprobe_optready(struct kprobe *p)
  * Return an optimized kprobe whose optimizing code replaces
  * instructions including addr (exclude breakpoint).
  */
-struct kprobe *__kprobes get_optimized_kprobe(unsigned long addr)
+static struct kprobe *__kprobes get_optimized_kprobe(unsigned long addr)
 {
 	int i;
 	struct kprobe *p = NULL;
@@ -857,7 +857,8 @@ void __kprobes kretprobe_hash_unlock(struct task_struct *tsk,
 	spin_unlock_irqrestore(hlist_lock, *flags);
 }
 
-void __kprobes kretprobe_table_unlock(unsigned long hash, unsigned long *flags)
+static void __kprobes kretprobe_table_unlock(unsigned long hash,
+       unsigned long *flags)
 {
 	spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash);
 	spin_unlock_irqrestore(hlist_lock, *flags);
-- 
1.7.2.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 4/5] kprobes: remove __dummy_buf
  2010-09-15  1:04 [PATCH RESEND 0/5] kprobes cleanups Namhyung Kim
                   ` (2 preceding siblings ...)
  2010-09-15  1:04 ` [PATCH 3/5] kprobes: make functions static Namhyung Kim
@ 2010-09-15  1:04 ` Namhyung Kim
  2010-09-15 10:05   ` [tip:perf/core] kprobes: Remove __dummy_buf tip-bot for Namhyung Kim
  2010-09-15  1:04 ` [PATCH 5/5] kprobes: add sparse context annotations Namhyung Kim
  2010-09-15  2:42 ` [PATCH RESEND 0/5] kprobes cleanups Masami Hiramatsu
  5 siblings, 1 reply; 13+ messages in thread
From: Namhyung Kim @ 2010-09-15  1:04 UTC (permalink / raw)
  To: Andrew Morton, Ingo Molnar; +Cc: Masami Hiramatsu, linux-kernel

remove __dummy_buf which is needed for kallsyms_lookup only.
use kallsysm_lookup_size_offset instead.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
 arch/x86/kernel/kprobes.c |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
index 05c20a4..e05952a 100644
--- a/arch/x86/kernel/kprobes.c
+++ b/arch/x86/kernel/kprobes.c
@@ -230,9 +230,6 @@ static int recover_probed_instruction(kprobe_opcode_t *buf, unsigned long addr)
 	return 0;
 }
 
-/* Dummy buffers for kallsyms_lookup */
-static char __dummy_buf[KSYM_NAME_LEN];
-
 /* Check if paddr is at an instruction boundary */
 static int __kprobes can_probe(unsigned long paddr)
 {
@@ -241,7 +238,7 @@ static int __kprobes can_probe(unsigned long paddr)
 	struct insn insn;
 	kprobe_opcode_t buf[MAX_INSN_SIZE];
 
-	if (!kallsyms_lookup(paddr, NULL, &offset, NULL, __dummy_buf))
+	if (!kallsyms_lookup_size_offset(paddr, NULL, &offset))
 		return 0;
 
 	/* Decode instructions */
@@ -1269,11 +1266,9 @@ static int __kprobes can_optimize(unsigned long paddr)
 	unsigned long addr, size = 0, offset = 0;
 	struct insn insn;
 	kprobe_opcode_t buf[MAX_INSN_SIZE];
-	/* Dummy buffers for lookup_symbol_attrs */
-	static char __dummy_buf[KSYM_NAME_LEN];
 
 	/* Lookup symbol including addr */
-	if (!kallsyms_lookup(paddr, &size, &offset, NULL, __dummy_buf))
+	if (!kallsyms_lookup_size_offset(paddr, &size, &offset))
 		return 0;
 
 	/* Check there is enough space for a relative jump. */
-- 
1.7.2.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 5/5] kprobes: add sparse context annotations
  2010-09-15  1:04 [PATCH RESEND 0/5] kprobes cleanups Namhyung Kim
                   ` (3 preceding siblings ...)
  2010-09-15  1:04 ` [PATCH 4/5] kprobes: remove __dummy_buf Namhyung Kim
@ 2010-09-15  1:04 ` Namhyung Kim
  2010-09-15 10:05   ` [tip:perf/core] kprobes: Add " tip-bot for Namhyung Kim
  2010-09-15  2:42 ` [PATCH RESEND 0/5] kprobes cleanups Masami Hiramatsu
  5 siblings, 1 reply; 13+ messages in thread
From: Namhyung Kim @ 2010-09-15  1:04 UTC (permalink / raw)
  To: Andrew Morton, Ingo Molnar; +Cc: Masami Hiramatsu, linux-kernel

this removes following warnings when build with C=1

 warning: context imbalance in 'kretprobe_hash_lock' - wrong count at exit
 warning: context imbalance in 'kretprobe_table_lock' - wrong count at exit
 warning: context imbalance in 'kretprobe_hash_unlock' - unexpected unlock
 warning: context imbalance in 'kretprobe_table_unlock' - unexpected unlock

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
 kernel/kprobes.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index c53aad5..6dd5359 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -831,6 +831,7 @@ void __kprobes recycle_rp_inst(struct kretprobe_instance *ri,
 
 void __kprobes kretprobe_hash_lock(struct task_struct *tsk,
 			 struct hlist_head **head, unsigned long *flags)
+__acquires(hlist_lock)
 {
 	unsigned long hash = hash_ptr(tsk, KPROBE_HASH_BITS);
 	spinlock_t *hlist_lock;
@@ -842,6 +843,7 @@ void __kprobes kretprobe_hash_lock(struct task_struct *tsk,
 
 static void __kprobes kretprobe_table_lock(unsigned long hash,
 	unsigned long *flags)
+__acquires(hlist_lock)
 {
 	spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash);
 	spin_lock_irqsave(hlist_lock, *flags);
@@ -849,6 +851,7 @@ static void __kprobes kretprobe_table_lock(unsigned long hash,
 
 void __kprobes kretprobe_hash_unlock(struct task_struct *tsk,
 	unsigned long *flags)
+__releases(hlist_lock)
 {
 	unsigned long hash = hash_ptr(tsk, KPROBE_HASH_BITS);
 	spinlock_t *hlist_lock;
@@ -859,6 +862,7 @@ void __kprobes kretprobe_hash_unlock(struct task_struct *tsk,
 
 static void __kprobes kretprobe_table_unlock(unsigned long hash,
        unsigned long *flags)
+__releases(hlist_lock)
 {
 	spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash);
 	spin_unlock_irqrestore(hlist_lock, *flags);
-- 
1.7.2.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH RESEND 0/5] kprobes cleanups
  2010-09-15  1:04 [PATCH RESEND 0/5] kprobes cleanups Namhyung Kim
                   ` (4 preceding siblings ...)
  2010-09-15  1:04 ` [PATCH 5/5] kprobes: add sparse context annotations Namhyung Kim
@ 2010-09-15  2:42 ` Masami Hiramatsu
  2010-09-15  8:39   ` Ingo Molnar
  5 siblings, 1 reply; 13+ messages in thread
From: Masami Hiramatsu @ 2010-09-15  2:42 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Namhyung Kim, Andrew Morton, linux-kernel, 2nddept-manager

Hi Ingo,

Could you pull it to -tip tree?
I've checked this series can be applied to the latest tip/master. :)

Thank you,

(2010/09/15 10:04), Namhyung Kim wrote:
> Hello,
> 
> This is a resend of my previous works on kprobes. All patches in this
> series are small cleanups and got acked by Masami. Please consider
> applying it.
> 
> Thanks.
> 
> ---
> 
> Namhyung Kim (5):
>   kprobes: remove redundant address check
>   kprobes: verify jprobe entry point
>   kprobes: make functions static
>   kprobes: remove __dummy_buf
>   kprobes: add sparse context annotations
> 
>  arch/x86/kernel/kprobes.c |   11 +++--------
>  kernel/kprobes.c          |   22 ++++++++++++++--------
>  2 files changed, 17 insertions(+), 16 deletions(-)
> 
> --
> 1.7.2.2
> 


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH RESEND 0/5] kprobes cleanups
  2010-09-15  2:42 ` [PATCH RESEND 0/5] kprobes cleanups Masami Hiramatsu
@ 2010-09-15  8:39   ` Ingo Molnar
  0 siblings, 0 replies; 13+ messages in thread
From: Ingo Molnar @ 2010-09-15  8:39 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Namhyung Kim, Andrew Morton, linux-kernel, 2nddept-manager


* Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> wrote:

> Hi Ingo,
> 
> Could you pull it to -tip tree?
> I've checked this series can be applied to the latest tip/master. :)

Sure, i've applied them to tip:perf/core, thanks guys!

	Ingo

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [tip:perf/core] kprobes: Remove redundant address check
  2010-09-15  1:04 ` [PATCH 1/5] kprobes: remove redundant address check Namhyung Kim
@ 2010-09-15 10:04   ` tip-bot for Namhyung Kim
  0 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Namhyung Kim @ 2010-09-15 10:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, masami.hiramatsu.pt, tglx, namhyung,
	mingo

Commit-ID:  edbaadbe42b0b790618ec49d29626223529d8195
Gitweb:     http://git.kernel.org/tip/edbaadbe42b0b790618ec49d29626223529d8195
Author:     Namhyung Kim <namhyung@gmail.com>
AuthorDate: Wed, 15 Sep 2010 10:04:26 +0900
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 15 Sep 2010 10:44:00 +0200

kprobes: Remove redundant address check

Remove call to kernel_text_address() in register_jprobes()
because it is called right after in register_kprobe().

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
LKML-Reference: <1284512670-2369-2-git-send-email-namhyung@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/kprobes.c |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 282035f..8f96701 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1343,14 +1343,11 @@ int __kprobes register_jprobes(struct jprobe **jps, int num)
 		jp = jps[i];
 		addr = arch_deref_entry_point(jp->entry);
 
-		if (!kernel_text_address(addr))
-			ret = -EINVAL;
-		else {
-			/* Todo: Verify probepoint is a function entry point */
-			jp->kp.pre_handler = setjmp_pre_handler;
-			jp->kp.break_handler = longjmp_break_handler;
-			ret = register_kprobe(&jp->kp);
-		}
+		/* Todo: Verify probepoint is a function entry point */
+		jp->kp.pre_handler = setjmp_pre_handler;
+		jp->kp.break_handler = longjmp_break_handler;
+		ret = register_kprobe(&jp->kp);
+
 		if (ret < 0) {
 			if (i > 0)
 				unregister_jprobes(jps, i);

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [tip:perf/core] kprobes: Verify jprobe entry point
  2010-09-15  1:04 ` [PATCH 2/5] kprobes: verify jprobe entry point Namhyung Kim
@ 2010-09-15 10:04   ` tip-bot for Namhyung Kim
  0 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Namhyung Kim @ 2010-09-15 10:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, masami.hiramatsu.pt, tglx, namhyung,
	mingo

Commit-ID:  05662bdb64c746079de7ac4dc4fb4caa5e8e119f
Gitweb:     http://git.kernel.org/tip/05662bdb64c746079de7ac4dc4fb4caa5e8e119f
Author:     Namhyung Kim <namhyung@gmail.com>
AuthorDate: Wed, 15 Sep 2010 10:04:27 +0900
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 15 Sep 2010 10:44:01 +0200

kprobes: Verify jprobe entry point

Verify jprobe's entry point is a function entry point
using kallsyms' offset value.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
LKML-Reference: <1284512670-2369-3-git-send-email-namhyung@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/kprobes.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 8f96701..1b0dbe0 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1339,14 +1339,18 @@ int __kprobes register_jprobes(struct jprobe **jps, int num)
 	if (num <= 0)
 		return -EINVAL;
 	for (i = 0; i < num; i++) {
-		unsigned long addr;
+		unsigned long addr, offset;
 		jp = jps[i];
 		addr = arch_deref_entry_point(jp->entry);
 
-		/* Todo: Verify probepoint is a function entry point */
-		jp->kp.pre_handler = setjmp_pre_handler;
-		jp->kp.break_handler = longjmp_break_handler;
-		ret = register_kprobe(&jp->kp);
+		/* Verify probepoint is a function entry point */
+		if (kallsyms_lookup_size_offset(addr, NULL, &offset) &&
+		    offset == 0) {
+			jp->kp.pre_handler = setjmp_pre_handler;
+			jp->kp.break_handler = longjmp_break_handler;
+			ret = register_kprobe(&jp->kp);
+		} else
+			ret = -EINVAL;
 
 		if (ret < 0) {
 			if (i > 0)

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [tip:perf/core] kprobes: Make functions static
  2010-09-15  1:04 ` [PATCH 3/5] kprobes: make functions static Namhyung Kim
@ 2010-09-15 10:04   ` tip-bot for Namhyung Kim
  0 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Namhyung Kim @ 2010-09-15 10:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, masami.hiramatsu.pt, tglx, namhyung,
	mingo

Commit-ID:  6376b2297502e72255b7eb2893c6044ad5a7b5f4
Gitweb:     http://git.kernel.org/tip/6376b2297502e72255b7eb2893c6044ad5a7b5f4
Author:     Namhyung Kim <namhyung@gmail.com>
AuthorDate: Wed, 15 Sep 2010 10:04:28 +0900
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 15 Sep 2010 10:44:01 +0200

kprobes: Make functions static

Make following (internal) functions static to make sparse
happier :-)

 * get_optimized_kprobe: only called from static functions
 * kretprobe_table_unlock: _lock function is static
 * kprobes_optinsn_template_holder: never called but holding asm code

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
LKML-Reference: <1284512670-2369-4-git-send-email-namhyung@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/kernel/kprobes.c |    2 +-
 kernel/kprobes.c          |    5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
index 770ebfb..05c20a4 100644
--- a/arch/x86/kernel/kprobes.c
+++ b/arch/x86/kernel/kprobes.c
@@ -1129,7 +1129,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr,
 	*(unsigned long *)addr = val;
 }
 
-void __kprobes kprobes_optinsn_template_holder(void)
+static void __used __kprobes kprobes_optinsn_template_holder(void)
 {
 	asm volatile (
 			".global optprobe_template_entry\n"
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 1b0dbe0..c53aad5 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -399,7 +399,7 @@ static inline int kprobe_optready(struct kprobe *p)
  * Return an optimized kprobe whose optimizing code replaces
  * instructions including addr (exclude breakpoint).
  */
-struct kprobe *__kprobes get_optimized_kprobe(unsigned long addr)
+static struct kprobe *__kprobes get_optimized_kprobe(unsigned long addr)
 {
 	int i;
 	struct kprobe *p = NULL;
@@ -857,7 +857,8 @@ void __kprobes kretprobe_hash_unlock(struct task_struct *tsk,
 	spin_unlock_irqrestore(hlist_lock, *flags);
 }
 
-void __kprobes kretprobe_table_unlock(unsigned long hash, unsigned long *flags)
+static void __kprobes kretprobe_table_unlock(unsigned long hash,
+       unsigned long *flags)
 {
 	spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash);
 	spin_unlock_irqrestore(hlist_lock, *flags);

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [tip:perf/core] kprobes: Remove __dummy_buf
  2010-09-15  1:04 ` [PATCH 4/5] kprobes: remove __dummy_buf Namhyung Kim
@ 2010-09-15 10:05   ` tip-bot for Namhyung Kim
  0 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Namhyung Kim @ 2010-09-15 10:05 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, masami.hiramatsu.pt, tglx, namhyung,
	mingo

Commit-ID:  6abded71d730322df96c5b7f4ab952ffd5a0080d
Gitweb:     http://git.kernel.org/tip/6abded71d730322df96c5b7f4ab952ffd5a0080d
Author:     Namhyung Kim <namhyung@gmail.com>
AuthorDate: Wed, 15 Sep 2010 10:04:29 +0900
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 15 Sep 2010 10:44:02 +0200

kprobes: Remove __dummy_buf

Remove __dummy_buf which is needed for kallsyms_lookup only.
use kallsysm_lookup_size_offset instead.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
LKML-Reference: <1284512670-2369-5-git-send-email-namhyung@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/kernel/kprobes.c |    9 ++-------
 1 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
index 05c20a4..e05952a 100644
--- a/arch/x86/kernel/kprobes.c
+++ b/arch/x86/kernel/kprobes.c
@@ -230,9 +230,6 @@ static int recover_probed_instruction(kprobe_opcode_t *buf, unsigned long addr)
 	return 0;
 }
 
-/* Dummy buffers for kallsyms_lookup */
-static char __dummy_buf[KSYM_NAME_LEN];
-
 /* Check if paddr is at an instruction boundary */
 static int __kprobes can_probe(unsigned long paddr)
 {
@@ -241,7 +238,7 @@ static int __kprobes can_probe(unsigned long paddr)
 	struct insn insn;
 	kprobe_opcode_t buf[MAX_INSN_SIZE];
 
-	if (!kallsyms_lookup(paddr, NULL, &offset, NULL, __dummy_buf))
+	if (!kallsyms_lookup_size_offset(paddr, NULL, &offset))
 		return 0;
 
 	/* Decode instructions */
@@ -1269,11 +1266,9 @@ static int __kprobes can_optimize(unsigned long paddr)
 	unsigned long addr, size = 0, offset = 0;
 	struct insn insn;
 	kprobe_opcode_t buf[MAX_INSN_SIZE];
-	/* Dummy buffers for lookup_symbol_attrs */
-	static char __dummy_buf[KSYM_NAME_LEN];
 
 	/* Lookup symbol including addr */
-	if (!kallsyms_lookup(paddr, &size, &offset, NULL, __dummy_buf))
+	if (!kallsyms_lookup_size_offset(paddr, &size, &offset))
 		return 0;
 
 	/* Check there is enough space for a relative jump. */

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [tip:perf/core] kprobes: Add sparse context annotations
  2010-09-15  1:04 ` [PATCH 5/5] kprobes: add sparse context annotations Namhyung Kim
@ 2010-09-15 10:05   ` tip-bot for Namhyung Kim
  0 siblings, 0 replies; 13+ messages in thread
From: tip-bot for Namhyung Kim @ 2010-09-15 10:05 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, masami.hiramatsu.pt, tglx, namhyung,
	mingo

Commit-ID:  635c17c2b2b4e5cd34f5dcba19d751b4e58533c2
Gitweb:     http://git.kernel.org/tip/635c17c2b2b4e5cd34f5dcba19d751b4e58533c2
Author:     Namhyung Kim <namhyung@gmail.com>
AuthorDate: Wed, 15 Sep 2010 10:04:30 +0900
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Wed, 15 Sep 2010 10:44:02 +0200

kprobes: Add sparse context annotations

This removes following warnings when build with C=1

 warning: context imbalance in 'kretprobe_hash_lock' - wrong count at exit
 warning: context imbalance in 'kretprobe_table_lock' - wrong count at exit
 warning: context imbalance in 'kretprobe_hash_unlock' - unexpected unlock
 warning: context imbalance in 'kretprobe_table_unlock' - unexpected unlock

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
LKML-Reference: <1284512670-2369-6-git-send-email-namhyung@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 kernel/kprobes.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index c53aad5..6dd5359 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -831,6 +831,7 @@ void __kprobes recycle_rp_inst(struct kretprobe_instance *ri,
 
 void __kprobes kretprobe_hash_lock(struct task_struct *tsk,
 			 struct hlist_head **head, unsigned long *flags)
+__acquires(hlist_lock)
 {
 	unsigned long hash = hash_ptr(tsk, KPROBE_HASH_BITS);
 	spinlock_t *hlist_lock;
@@ -842,6 +843,7 @@ void __kprobes kretprobe_hash_lock(struct task_struct *tsk,
 
 static void __kprobes kretprobe_table_lock(unsigned long hash,
 	unsigned long *flags)
+__acquires(hlist_lock)
 {
 	spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash);
 	spin_lock_irqsave(hlist_lock, *flags);
@@ -849,6 +851,7 @@ static void __kprobes kretprobe_table_lock(unsigned long hash,
 
 void __kprobes kretprobe_hash_unlock(struct task_struct *tsk,
 	unsigned long *flags)
+__releases(hlist_lock)
 {
 	unsigned long hash = hash_ptr(tsk, KPROBE_HASH_BITS);
 	spinlock_t *hlist_lock;
@@ -859,6 +862,7 @@ void __kprobes kretprobe_hash_unlock(struct task_struct *tsk,
 
 static void __kprobes kretprobe_table_unlock(unsigned long hash,
        unsigned long *flags)
+__releases(hlist_lock)
 {
 	spinlock_t *hlist_lock = kretprobe_table_lock_ptr(hash);
 	spin_unlock_irqrestore(hlist_lock, *flags);

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2010-09-15 10:06 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-15  1:04 [PATCH RESEND 0/5] kprobes cleanups Namhyung Kim
2010-09-15  1:04 ` [PATCH 1/5] kprobes: remove redundant address check Namhyung Kim
2010-09-15 10:04   ` [tip:perf/core] kprobes: Remove " tip-bot for Namhyung Kim
2010-09-15  1:04 ` [PATCH 2/5] kprobes: verify jprobe entry point Namhyung Kim
2010-09-15 10:04   ` [tip:perf/core] kprobes: Verify " tip-bot for Namhyung Kim
2010-09-15  1:04 ` [PATCH 3/5] kprobes: make functions static Namhyung Kim
2010-09-15 10:04   ` [tip:perf/core] kprobes: Make " tip-bot for Namhyung Kim
2010-09-15  1:04 ` [PATCH 4/5] kprobes: remove __dummy_buf Namhyung Kim
2010-09-15 10:05   ` [tip:perf/core] kprobes: Remove __dummy_buf tip-bot for Namhyung Kim
2010-09-15  1:04 ` [PATCH 5/5] kprobes: add sparse context annotations Namhyung Kim
2010-09-15 10:05   ` [tip:perf/core] kprobes: Add " tip-bot for Namhyung Kim
2010-09-15  2:42 ` [PATCH RESEND 0/5] kprobes cleanups Masami Hiramatsu
2010-09-15  8:39   ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox