LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: mingo@elte.hu, rostedt@goodmis.org, fweisbec@gmail.com
Cc: linux-kernel@vger.kernel.org, masami.hiramatsu.pt@hitachi.com
Subject: [PATCH 1/4] kprobe - ktrace instruction slot cache interface
Date: Thu,  3 Feb 2011 16:42:38 +0100	[thread overview]
Message-ID: <1296747761-9082-2-git-send-email-jolsa@redhat.com> (raw)
In-Reply-To: <1296747761-9082-1-git-send-email-jolsa@redhat.com>

using kprobe detour buffer allocation, adding interface
to use it from trace framework

wbr,
jirka
---
 include/linux/kprobes.h |    8 ++++++++
 kernel/kprobes.c        |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index dd7c12e..1e984e9 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -436,4 +436,12 @@ static inline int enable_jprobe(struct jprobe *jp)
 	return enable_kprobe(&jp->kp);
 }
 
+#ifdef CONFIG_KTRACE
+
+extern kprobe_opcode_t __kprobes *get_ktrace_insn_slot(void);
+extern void __kprobes free_ktrace_insn_slot(kprobe_opcode_t * slot, int dirty);
+extern void __init ktrace_insn_init(int size);
+
+#endif /* CONFIG_KTRACE */
+
 #endif /* _LINUX_KPROBES_H */
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 7798181..5bc31d6 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -285,6 +285,39 @@ void __kprobes free_insn_slot(kprobe_opcode_t * slot, int dirty)
 	__free_insn_slot(&kprobe_insn_slots, slot, dirty);
 	mutex_unlock(&kprobe_insn_mutex);
 }
+
+#ifdef CONFIG_KTRACE
+static DEFINE_MUTEX(ktrace_insn_mutex);
+static struct kprobe_insn_cache ktrace_insn_slots = {
+	.pages = LIST_HEAD_INIT(ktrace_insn_slots.pages),
+	.insn_size = MAX_INSN_SIZE,
+	.nr_garbage = 0,
+};
+
+kprobe_opcode_t __kprobes *get_ktrace_insn_slot(void)
+{
+	kprobe_opcode_t *ret = NULL;
+
+	mutex_lock(&ktrace_insn_mutex);
+	ret = __get_insn_slot(&ktrace_insn_slots);
+	mutex_unlock(&ktrace_insn_mutex);
+
+	return ret;
+}
+
+void __kprobes free_ktrace_insn_slot(kprobe_opcode_t * slot, int dirty)
+{
+	mutex_lock(&ktrace_insn_mutex);
+	__free_insn_slot(&ktrace_insn_slots, slot, dirty);
+	mutex_unlock(&ktrace_insn_mutex);
+}
+
+void __init ktrace_insn_init(int size)
+{
+	ktrace_insn_slots.insn_size = size;
+}
+#endif /* CONFIG_KTRACE */
+
 #ifdef CONFIG_OPTPROBES
 /* For optimized_kprobe buffer */
 static DEFINE_MUTEX(kprobe_optinsn_mutex); /* Protects kprobe_optinsn_slots */
-- 
1.7.1


  reply	other threads:[~2011-02-03 15:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-03 15:42 [RFC 0/4] tracing,x86_64 - function/graph trace without mcount/-pg/framepointer Jiri Olsa
2011-02-03 15:42 ` Jiri Olsa [this message]
2011-02-03 15:42 ` [PATCH 2/4] tracing - adding size parameter to do_ftrace_mod_code Jiri Olsa
2011-02-03 15:42 ` [PATCH 3/4] ktrace - function trace support Jiri Olsa
2011-02-03 15:42 ` [PATCH 4/4] ktrace - function graph " Jiri Olsa
2011-02-03 16:33 ` [RFC 0/4] tracing,x86_64 - function/graph trace without mcount/-pg/framepointer Steven Rostedt
2011-02-03 17:35   ` Frederic Weisbecker
2011-02-03 19:00     ` Steven Rostedt
2011-02-04  6:03 ` 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=1296747761-9082-2-git-send-email-jolsa@redhat.com \
    --to=jolsa@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    --subject='Re: [PATCH 1/4] kprobe - ktrace instruction slot cache interface' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).