From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
"Keshavamurthy, Anil S" <anil.s.keshavamurthy@intel.com>,
Prasanna S Panchamukhi <prasanna@in.ibm.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
SystemTAP <systemtap@sources.redhat.com>,
Satoshi Oshima <soshima@redhat.com>,
Hideo Aoki <haoki@redhat.com>,
Yumiko Sugita <yumiko.sugita.yf@hitachi.com>,
"Frank Ch. Eigler" <fche@redhat.com>
Subject: [RFC][Patch 2/4] kretprobe fast unregisteration
Date: Fri, 23 Mar 2007 23:45:36 +0900 [thread overview]
Message-ID: <4603E810.10800@hitachi.com> (raw)
In-Reply-To: <4603E7A4.50300@hitachi.com>
This patch introduces unregister_kretprobe_fast() for kretprobe.
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
include/linux/kprobes.h | 12 +++++++++++-
kernel/kprobes.c | 44 ++++++++++++++++++++++++++++----------------
2 files changed, 39 insertions(+), 17 deletions(-)
Index: linux-2.6.21-rc4-mm1/include/linux/kprobes.h
===================================================================
--- linux-2.6.21-rc4-mm1.orig/include/linux/kprobes.h
+++ linux-2.6.21-rc4-mm1/include/linux/kprobes.h
@@ -202,7 +202,14 @@ void unregister_jprobe(struct jprobe *p)
void jprobe_return(void);
int register_kretprobe(struct kretprobe *rp);
-void unregister_kretprobe(struct kretprobe *rp);
+static inline void unregister_kretprobe(struct kretprobe *rp)
+{
+ unregister_kprobe(&rp->kp);
+}
+static inline void unregister_kretprobe_fast(struct kretprobe *rp)
+{
+ unregister_kprobe_fast(&rp->kp);
+}
struct kretprobe_instance *get_free_rp_inst(struct kretprobe *rp);
void add_rp_inst(struct kretprobe_instance *ri);
@@ -245,6 +252,9 @@ static inline int register_kretprobe(str
static inline void unregister_kretprobe(struct kretprobe *rp)
{
}
+static inline void unregister_kretprobe_fast(struct kretprobe *rp)
+{
+}
static inline void kprobe_flush_task(struct task_struct *tk)
{
}
Index: linux-2.6.21-rc4-mm1/kernel/kprobes.c
===================================================================
--- linux-2.6.21-rc4-mm1.orig/kernel/kprobes.c
+++ linux-2.6.21-rc4-mm1/kernel/kprobes.c
@@ -74,6 +74,8 @@ static struct notifier_block kprobe_page
.priority = 0x7fffffff /* we need to notified first */
};
+static int __kprobes is_kretprobe(struct kprobe *p);
+
#ifdef __ARCH_WANT_KPROBES_INSN_SLOT
/*
* kprobe->ainsn.insn points to the copy of the instruction to be
@@ -462,6 +464,20 @@ static inline void free_rp_inst(struct k
}
}
+static void __kprobes cleanup_rp_inst(struct kretprobe *rp)
+{
+ unsigned long flags;
+ struct kretprobe_instance *ri;
+ /* No race here */
+ spin_lock_irqsave(&kretprobe_lock, flags);
+ while ((ri = get_used_rp_inst(rp)) != NULL) {
+ ri->rp = NULL;
+ hlist_del(&ri->uflist);
+ }
+ spin_unlock_irqrestore(&kretprobe_lock, flags);
+ free_rp_inst(rp);
+}
+
/*
* Keep all fields in the kprobe consistent
*/
@@ -697,6 +713,9 @@ static void __kprobes __unregister_kprob
if (atomic_add_return(-1, &kprobe_count) == \
ARCH_INACTIVE_KPROBE_COUNT)
unregister_page_fault_notifier(&kprobe_page_fault_nb);
+ if (is_kretprobe(p)) {
+ cleanup_rp_inst(container_of(p, struct kretprobe, kp));
+ }
return;
}
@@ -841,6 +860,11 @@ int __kprobes register_kretprobe(struct
return ret;
}
+static int __kprobes is_kretprobe(struct kprobe *p)
+{
+ return p->pre_handler == pre_handler_kretprobe;
+}
+
#else /* ARCH_SUPPORTS_KRETPROBES */
int __kprobes register_kretprobe(struct kretprobe *rp)
@@ -854,24 +878,13 @@ static int __kprobes pre_handler_kretpro
return 0;
}
-#endif /* ARCH_SUPPORTS_KRETPROBES */
-
-void __kprobes unregister_kretprobe(struct kretprobe *rp)
+static int __kprobes is_kretprobe(struct kprobe *p)
{
- unsigned long flags;
- struct kretprobe_instance *ri;
-
- unregister_kprobe(&rp->kp);
- /* No race here */
- spin_lock_irqsave(&kretprobe_lock, flags);
- while ((ri = get_used_rp_inst(rp)) != NULL) {
- ri->rp = NULL;
- hlist_del(&ri->uflist);
- }
- spin_unlock_irqrestore(&kretprobe_lock, flags);
- free_rp_inst(rp);
+ return 0;
}
+#endif /* ARCH_SUPPORTS_KRETPROBES */
+
static int __init init_kprobes(void)
{
int i, err = 0;
@@ -1003,4 +1016,3 @@ EXPORT_SYMBOL_GPL(register_jprobe);
EXPORT_SYMBOL_GPL(unregister_jprobe);
EXPORT_SYMBOL_GPL(jprobe_return);
EXPORT_SYMBOL_GPL(register_kretprobe);
-EXPORT_SYMBOL_GPL(unregister_kretprobe);
next prev parent reply other threads:[~2007-03-23 14:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-23 14:43 [RFC][Patch 1/4] kprobe fast unregistration Masami Hiramatsu
2007-03-23 14:45 ` Masami Hiramatsu [this message]
2007-03-23 14:46 ` [RFC][Patch 3/4] jprobe fast unregisteration Masami Hiramatsu
2007-03-23 14:47 ` [RFC][Patch 4/4] kprobes fast unregisteration documentation Masami Hiramatsu
2007-03-23 17:23 ` [RFC][Patch 1/4] kprobe fast unregistration Christoph Hellwig
[not found] ` <20070323180527.GA13728@bambi.jf.intel.com>
2007-03-23 18:12 ` Stone, Joshua I
2007-03-23 18:22 ` Frank Ch. Eigler
[not found] ` <20070323190127.GA13974@bambi.jf.intel.com>
2007-03-26 2:29 ` Frank Ch. Eigler
2007-03-31 13:01 ` Christoph Hellwig
2007-03-31 13:06 ` Christoph Hellwig
2007-03-26 3:17 ` Masami Hiramatsu
[not found] ` <20070326181518.GA28384@bambi.jf.intel.com>
2007-03-27 3:24 ` Masami Hiramatsu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4603E810.10800@hitachi.com \
--to=masami.hiramatsu.pt@hitachi.com \
--cc=ananth@in.ibm.com \
--cc=anil.s.keshavamurthy@intel.com \
--cc=fche@redhat.com \
--cc=haoki@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=prasanna@in.ibm.com \
--cc=soshima@redhat.com \
--cc=systemtap@sources.redhat.com \
--cc=yumiko.sugita.yf@hitachi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.