linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "tip-bot for Naveen N. Rao" <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: mingo@kernel.org, ananth@linux.vnet.ibm.com,
	peterz@infradead.org, torvalds@linux-foundation.org,
	linux-kernel@vger.kernel.org, mhiramat@kernel.org,
	naveen.n.rao@linux.vnet.ibm.com, tglx@linutronix.de,
	hpa@zytor.com
Subject: [tip:perf/urgent] kprobes: Simplify register_jprobes()
Date: Sat, 8 Jul 2017 04:10:30 -0700	[thread overview]
Message-ID: <tip-0f73ff80b751b39ff539a550e65c5bd131ff0316@git.kernel.org> (raw)
In-Reply-To: <089cae4bfe73767f765291ee0e6fb0c3d240e5f1.1499443367.git.naveen.n.rao@linux.vnet.ibm.com>

Commit-ID:  0f73ff80b751b39ff539a550e65c5bd131ff0316
Gitweb:     http://git.kernel.org/tip/0f73ff80b751b39ff539a550e65c5bd131ff0316
Author:     Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
AuthorDate: Fri, 7 Jul 2017 22:37:25 +0530
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 8 Jul 2017 11:05:34 +0200

kprobes: Simplify register_jprobes()

Re-factor jprobe registration functions as the current version is
getting too unwieldy. Move the actual jprobe registration to
register_jprobe() and re-organize code accordingly.

Suggested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/089cae4bfe73767f765291ee0e6fb0c3d240e5f1.1499443367.git.naveen.n.rao@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/kprobes.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index a519219..db3cd3e 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1771,24 +1771,13 @@ unsigned long __weak arch_deref_entry_point(void *entry)
 
 int register_jprobes(struct jprobe **jps, int num)
 {
-	struct jprobe *jp;
 	int ret = 0, i;
 
 	if (num <= 0)
 		return -EINVAL;
+
 	for (i = 0; i < num; i++) {
-		unsigned long addr, offset;
-		jp = jps[i];
-		addr = arch_deref_entry_point(jp->entry);
-
-		/* 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;
+		ret = register_jprobe(jps[i]);
 
 		if (ret < 0) {
 			if (i > 0)
@@ -1796,13 +1785,26 @@ int register_jprobes(struct jprobe **jps, int num)
 			break;
 		}
 	}
+
 	return ret;
 }
 EXPORT_SYMBOL_GPL(register_jprobes);
 
 int register_jprobe(struct jprobe *jp)
 {
-	return register_jprobes(&jp, 1);
+	unsigned long addr, offset;
+	struct kprobe *kp = &jp->kp;
+
+	/* Verify probepoint is a function entry point */
+	addr = arch_deref_entry_point(jp->entry);
+
+	if (kallsyms_lookup_size_offset(addr, NULL, &offset) && offset == 0) {
+		kp->pre_handler = setjmp_pre_handler;
+		kp->break_handler = longjmp_break_handler;
+		return register_kprobe(kp);
+	}
+
+	return -EINVAL;
 }
 EXPORT_SYMBOL_GPL(register_jprobe);
 

  reply	other threads:[~2017-07-08 11:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-07 17:07 [PATCH v2 0/3] kernel/kprobes: A few trivial updates to jprobes Naveen N. Rao
2017-07-07 17:07 ` [PATCH v2 1/3] kernel/kprobes: Rename [arch_]function_offset_within_entry() to [arch_]kprobe_on_func_entry() Naveen N. Rao
2017-07-08 11:10   ` [tip:perf/urgent] kprobes: " tip-bot for Naveen N. Rao
2017-07-07 17:07 ` [PATCH v2 2/3] kernel/kprobes: Simplify register_jprobes() Naveen N. Rao
2017-07-08 11:10   ` tip-bot for Naveen N. Rao [this message]
2017-07-07 17:07 ` [PATCH v2 3/3] kernel/kprobes: Ensure that jprobe probepoints are at function entry Naveen N. Rao
2017-07-08 11:10   ` [tip:perf/urgent] kprobes: " tip-bot for Naveen N. Rao
2017-07-09 12:28 ` [PATCH v2 0/3] kernel/kprobes: A few trivial updates to jprobes 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=tip-0f73ff80b751b39ff539a550e65c5bd131ff0316@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=ananth@linux.vnet.ibm.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=naveen.n.rao@linux.vnet.ibm.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /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 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).