mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>,
	Namhyung Kim <namhyung.kim@lge.com>,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Ingo Molnar <mingo@redhat.com>, Jiri Olsa <jolsa@redhat.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] tracing: Kill FETCH_MTD_retval, reimplement $retval via pseudo_reg_retval()
Date: Mon, 25 Nov 2013 20:30:16 +0100	[thread overview]
Message-ID: <20131125193016.GC9737@redhat.com> (raw)
In-Reply-To: <20131125192926.GA9737@redhat.com>

Now that we have pseudo_reg_table[] we can kill FETCH_MTD_retval
and related code, we can simply add the new pseudo_reg_retval()
entry into the pseudo_reg_table[],

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
 kernel/trace/trace_probe.c |   42 +++++++++++++++++++-----------------------
 kernel/trace/trace_probe.h |    1 -
 2 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index b066e9d..fce222f 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -135,17 +135,6 @@ DEFINE_BASIC_FETCH_FUNCS(stack)
 #define fetch_stack_string	NULL
 #define fetch_stack_string_size	NULL
 
-#define DEFINE_FETCH_retval(type)					\
-static __kprobes void FETCH_FUNC_NAME(retval, type)(struct pt_regs *regs,\
-					  void *dummy, void *dest)	\
-{									\
-	*(type *)dest = (type)regs_return_value(regs);			\
-}
-DEFINE_BASIC_FETCH_FUNCS(retval)
-/* No string on the retval */
-#define fetch_retval_string		NULL
-#define fetch_retval_string_size	NULL
-
 #define DEFINE_FETCH_memory(type)					\
 static __kprobes void FETCH_FUNC_NAME(memory, type)(struct pt_regs *regs,\
 					  void *addr, void *dest)	\
@@ -394,7 +383,6 @@ free_bitfield_fetch_param(struct bitfield_fetch_param *data)
 	 .fetch = {					\
 ASSIGN_FETCH_FUNC(reg, ftype),				\
 ASSIGN_FETCH_FUNC(stack, ftype),			\
-ASSIGN_FETCH_FUNC(retval, ftype),			\
 ASSIGN_FETCH_FUNC(memory, ftype),			\
 ASSIGN_FETCH_FUNC(symbol, ftype),			\
 ASSIGN_FETCH_FUNC(deref, ftype),			\
@@ -514,22 +502,31 @@ int traceprobe_split_symbol_offset(char *symbol, unsigned long *offset)
 	return 0;
 }
 
-static unsigned long pseudo_reg_cpu(void)
+static unsigned long pseudo_reg_retval(struct pt_regs *regs)
+{
+	return regs_return_value(regs);
+}
+
+static unsigned long pseudo_reg_cpu(struct pt_regs *regs)
 {
 	return (unsigned long)raw_smp_processor_id();
 }
 
-static unsigned long pseudo_reg_current(void)
+static unsigned long pseudo_reg_current(struct pt_regs *regs)
 {
 	return (unsigned long)current;
 }
 
 static struct {
 	const char *name;
-	unsigned long (*fetch)(void);
+	unsigned long (*fetch)(struct pt_regs *regs);
 }
 const pseudo_reg_table[] = {
 	{
+		.name	= "retval",
+		.fetch	= pseudo_reg_retval,
+	},
+	{
 		.name	= "cpu",
 		.fetch	= pseudo_reg_cpu,
 	},
@@ -546,7 +543,7 @@ static unsigned long probe_get_register(struct pt_regs *regs, unsigned long offs
 	if (offset < PSEUDO_REG_OFFSET)
 		return regs_get_register(regs, offset);
 
-	return pseudo_reg_table[offset - PSEUDO_REG_OFFSET].fetch();
+	return pseudo_reg_table[offset - PSEUDO_REG_OFFSET].fetch(regs);
 }
 
 static int pseudo_reg_query_offset(const char *name)
@@ -568,12 +565,7 @@ static int parse_probe_vars(char *arg, const struct fetch_type *t,
 	int ret = 0;
 	unsigned long param;
 
-	if (strcmp(arg, "retval") == 0) {
-		if (is_return)
-			f->fn = t->fetch[FETCH_MTD_retval];
-		else
-			ret = -EINVAL;
-	} else if (strncmp(arg, "stack", 5) == 0) {
+	if (strncmp(arg, "stack", 5) == 0) {
 		if (arg[5] == '\0') {
 			if (strcmp(t->name, DEFAULT_FETCH_TYPE_STR) == 0)
 				f->fn = fetch_stack_address;
@@ -590,7 +582,11 @@ static int parse_probe_vars(char *arg, const struct fetch_type *t,
 		} else
 			ret = -EINVAL;
 	} else {
-		ret = pseudo_reg_query_offset(arg);
+		if (strcmp(arg, "retval") == 0 && !is_return)
+			ret = -EINVAL;
+		else
+			ret = pseudo_reg_query_offset(arg);
+
 		if (ret >= 0) {
 			f->fn = t->fetch[FETCH_MTD_reg];
 			f->data = (void *)(unsigned long)ret;
diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h
index 5c7e09d..b6f33b1 100644
--- a/kernel/trace/trace_probe.h
+++ b/kernel/trace/trace_probe.h
@@ -90,7 +90,6 @@ typedef int (*print_type_func_t)(struct trace_seq *, const char *, void *, void
 enum {
 	FETCH_MTD_reg = 0,
 	FETCH_MTD_stack,
-	FETCH_MTD_retval,
 	FETCH_MTD_memory,
 	FETCH_MTD_symbol,
 	FETCH_MTD_deref,
-- 
1.5.5.1



      parent reply	other threads:[~2013-11-25 19:29 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-23 20:15 [PATCH 0/1] tracing: Introduce "pseudo registers" for FETCH_MTD_reg Oleg Nesterov
2013-11-23 20:16 ` [PATCH 1/1] " Oleg Nesterov
2013-11-24  7:32   ` Masami Hiramatsu
2013-11-25  8:04     ` Namhyung Kim
2013-11-25 14:35       ` Oleg Nesterov
2013-11-25 17:21 ` [RFC PATCH 0/3] tracing: Teach FETCH_MTD_{symbol,deref} to handle per-cpu data Oleg Nesterov
2013-11-25 17:21   ` [RFC PATCH 1/3] tracing: Don't mangle sc->addr in update_symbol_cache() Oleg Nesterov
2013-11-25 17:21   ` [RFC PATCH 2/3] tracing: introduce {calc,parse}_probe_offset() for FETCH_MTD_{symbol,deref} Oleg Nesterov
2013-11-25 17:22   ` [RFC PATCH 3/3] tracing: Teach FETCH_MTD_{symbol,deref} to handle per-cpu data Oleg Nesterov
2013-11-26  9:34     ` Masami Hiramatsu
2013-11-26 17:43       ` [RFC PATCH 0/2] tracing: Teach FETCH_MTD_symbol " Oleg Nesterov
2013-11-26 17:44         ` [RFC PATCH 1/2] tracing: Don't update sc->addr in update_symbol_cache() Oleg Nesterov
2013-11-26 17:44         ` [RFC PATCH 2/2] tracing: Teach FETCH_MTD_symbol to handle per-cpu data Oleg Nesterov
2013-11-26 17:50           ` modules, add_kallsyms() && DEFINE_PER_CPU Oleg Nesterov
2013-11-27  2:23             ` Masami Hiramatsu
2013-11-27  8:20               ` Namhyung Kim
2013-11-27 11:22                 ` Masami Hiramatsu
2013-11-27 13:35               ` Oleg Nesterov
2013-11-28  2:02                 ` Masami Hiramatsu
2013-11-27 11:30           ` [RFC PATCH 2/2] tracing: Teach FETCH_MTD_symbol to handle per-cpu data Masami Hiramatsu
2013-11-27  0:37         ` [RFC PATCH 0/2] " Namhyung Kim
2013-11-27 10:01         ` Masami Hiramatsu
2013-11-27 17:41           ` Oleg Nesterov
2013-11-28  2:55             ` Masami Hiramatsu
2013-11-25 19:29 ` [PATCH 0/2] tracing: Add $cpu and $current probe-vars Oleg Nesterov
2013-11-25 19:29   ` [PATCH 1/2] " Oleg Nesterov
2013-11-26  2:21     ` Masami Hiramatsu
2013-11-26 17:23       ` Oleg Nesterov
2013-11-27  8:22         ` Masami Hiramatsu
2013-11-27 17:05           ` Oleg Nesterov
2013-11-28  2:51             ` Masami Hiramatsu
2013-11-25 19:30   ` Oleg Nesterov [this message]

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=20131125193016.GC9737@redhat.com \
    --to=oleg@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@redhat.com \
    --cc=namhyung.kim@lge.com \
    --cc=rostedt@goodmis.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

Powered by JetHome