[PATCH v3 08/18] tracing: probeevent: Unify fetch type tables

2018-02-23 Thread Masami Hiramatsu
Unify {k,u}probe_fetch_type_table to probe_fetch_type_table
because the main difference of those type tables (fetcharg
methods) are gone. Now we can consolidate it.

Signed-off-by: Masami Hiramatsu 
---
 kernel/trace/trace_kprobe.c |   27 +-
 kernel/trace/trace_probe.c  |   54 +--
 kernel/trace/trace_probe.h  |6 +
 kernel/trace/trace_uprobe.c |   27 +-
 4 files changed, 39 insertions(+), 75 deletions(-)

diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 8423815ff986..4caf019b5917 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -122,30 +122,6 @@ static int kprobe_dispatcher(struct kprobe *kp, struct 
pt_regs *regs);
 static int kretprobe_dispatcher(struct kretprobe_instance *ri,
struct pt_regs *regs);
 
-/* Fetch type information table */
-static const struct fetch_type kprobes_fetch_type_table[] = {
-   /* Special types */
-   [FETCH_TYPE_STRING] = __ASSIGN_FETCH_TYPE("string", string, string,
-   sizeof(u32), 1, "__data_loc char[]"),
-   [FETCH_TYPE_STRSIZE] = __ASSIGN_FETCH_TYPE("string_size", u32,
-   string_size, sizeof(u32), 0, "u32"),
-   /* Basic types */
-   ASSIGN_FETCH_TYPE(u8,  u8,  0),
-   ASSIGN_FETCH_TYPE(u16, u16, 0),
-   ASSIGN_FETCH_TYPE(u32, u32, 0),
-   ASSIGN_FETCH_TYPE(u64, u64, 0),
-   ASSIGN_FETCH_TYPE(s8,  u8,  1),
-   ASSIGN_FETCH_TYPE(s16, u16, 1),
-   ASSIGN_FETCH_TYPE(s32, u32, 1),
-   ASSIGN_FETCH_TYPE(s64, u64, 1),
-   ASSIGN_FETCH_TYPE_ALIAS(x8,  u8,  u8,  0),
-   ASSIGN_FETCH_TYPE_ALIAS(x16, u16, u16, 0),
-   ASSIGN_FETCH_TYPE_ALIAS(x32, u32, u32, 0),
-   ASSIGN_FETCH_TYPE_ALIAS(x64, u64, u64, 0),
-
-   ASSIGN_FETCH_TYPE_END
-};
-
 /*
  * Allocate new trace_probe and initialize it (including kprobes).
  */
@@ -674,8 +650,7 @@ static int create_trace_kprobe(int argc, char **argv)
 
/* Parse fetch argument */
ret = traceprobe_parse_probe_arg(arg, >tp.size, parg,
-is_return, true,
-kprobes_fetch_type_table);
+is_return, true);
if (ret) {
pr_info("Parse error at argument[%d]. (%d)\n", i, ret);
goto error;
diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index a7e36606718a..9ffc07c7c949 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -73,8 +73,29 @@ int PRINT_TYPE_FUNC_NAME(string)(struct trace_seq *s, void 
*data, void *ent)
 
 const char PRINT_TYPE_FMT_NAME(string)[] = "\\\"%s\\\"";
 
-static const struct fetch_type *find_fetch_type(const char *type,
-   const struct fetch_type *ftbl)
+/* Fetch type information table */
+static const struct fetch_type probe_fetch_types[] = {
+   /* Special types */
+   __ASSIGN_FETCH_TYPE("string", string, string, sizeof(u32), 1,
+   "__data_loc char[]"),
+   /* Basic types */
+   ASSIGN_FETCH_TYPE(u8,  u8,  0),
+   ASSIGN_FETCH_TYPE(u16, u16, 0),
+   ASSIGN_FETCH_TYPE(u32, u32, 0),
+   ASSIGN_FETCH_TYPE(u64, u64, 0),
+   ASSIGN_FETCH_TYPE(s8,  u8,  1),
+   ASSIGN_FETCH_TYPE(s16, u16, 1),
+   ASSIGN_FETCH_TYPE(s32, u32, 1),
+   ASSIGN_FETCH_TYPE(s64, u64, 1),
+   ASSIGN_FETCH_TYPE_ALIAS(x8,  u8,  u8,  0),
+   ASSIGN_FETCH_TYPE_ALIAS(x16, u16, u16, 0),
+   ASSIGN_FETCH_TYPE_ALIAS(x32, u32, u32, 0),
+   ASSIGN_FETCH_TYPE_ALIAS(x64, u64, u64, 0),
+
+   ASSIGN_FETCH_TYPE_END
+};
+
+static const struct fetch_type *find_fetch_type(const char *type)
 {
int i;
 
@@ -95,21 +116,21 @@ static const struct fetch_type *find_fetch_type(const char 
*type,
 
switch (bs) {
case 8:
-   return find_fetch_type("u8", ftbl);
+   return find_fetch_type("u8");
case 16:
-   return find_fetch_type("u16", ftbl);
+   return find_fetch_type("u16");
case 32:
-   return find_fetch_type("u32", ftbl);
+   return find_fetch_type("u32");
case 64:
-   return find_fetch_type("u64", ftbl);
+   return find_fetch_type("u64");
default:
goto fail;
}
}
 
-   for (i = 0; ftbl[i].name; i++) {
-   if (strcmp(type, ftbl[i].name) == 0)
-   return [i];
+   for (i = 0; probe_fetch_types[i].name; i++) {
+   if (strcmp(type, probe_fetch_types[i].name) == 0)
+   return 

[PATCH v3 08/18] tracing: probeevent: Unify fetch type tables

2018-02-23 Thread Masami Hiramatsu
Unify {k,u}probe_fetch_type_table to probe_fetch_type_table
because the main difference of those type tables (fetcharg
methods) are gone. Now we can consolidate it.

Signed-off-by: Masami Hiramatsu 
---
 kernel/trace/trace_kprobe.c |   27 +-
 kernel/trace/trace_probe.c  |   54 +--
 kernel/trace/trace_probe.h  |6 +
 kernel/trace/trace_uprobe.c |   27 +-
 4 files changed, 39 insertions(+), 75 deletions(-)

diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c
index 8423815ff986..4caf019b5917 100644
--- a/kernel/trace/trace_kprobe.c
+++ b/kernel/trace/trace_kprobe.c
@@ -122,30 +122,6 @@ static int kprobe_dispatcher(struct kprobe *kp, struct 
pt_regs *regs);
 static int kretprobe_dispatcher(struct kretprobe_instance *ri,
struct pt_regs *regs);
 
-/* Fetch type information table */
-static const struct fetch_type kprobes_fetch_type_table[] = {
-   /* Special types */
-   [FETCH_TYPE_STRING] = __ASSIGN_FETCH_TYPE("string", string, string,
-   sizeof(u32), 1, "__data_loc char[]"),
-   [FETCH_TYPE_STRSIZE] = __ASSIGN_FETCH_TYPE("string_size", u32,
-   string_size, sizeof(u32), 0, "u32"),
-   /* Basic types */
-   ASSIGN_FETCH_TYPE(u8,  u8,  0),
-   ASSIGN_FETCH_TYPE(u16, u16, 0),
-   ASSIGN_FETCH_TYPE(u32, u32, 0),
-   ASSIGN_FETCH_TYPE(u64, u64, 0),
-   ASSIGN_FETCH_TYPE(s8,  u8,  1),
-   ASSIGN_FETCH_TYPE(s16, u16, 1),
-   ASSIGN_FETCH_TYPE(s32, u32, 1),
-   ASSIGN_FETCH_TYPE(s64, u64, 1),
-   ASSIGN_FETCH_TYPE_ALIAS(x8,  u8,  u8,  0),
-   ASSIGN_FETCH_TYPE_ALIAS(x16, u16, u16, 0),
-   ASSIGN_FETCH_TYPE_ALIAS(x32, u32, u32, 0),
-   ASSIGN_FETCH_TYPE_ALIAS(x64, u64, u64, 0),
-
-   ASSIGN_FETCH_TYPE_END
-};
-
 /*
  * Allocate new trace_probe and initialize it (including kprobes).
  */
@@ -674,8 +650,7 @@ static int create_trace_kprobe(int argc, char **argv)
 
/* Parse fetch argument */
ret = traceprobe_parse_probe_arg(arg, >tp.size, parg,
-is_return, true,
-kprobes_fetch_type_table);
+is_return, true);
if (ret) {
pr_info("Parse error at argument[%d]. (%d)\n", i, ret);
goto error;
diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
index a7e36606718a..9ffc07c7c949 100644
--- a/kernel/trace/trace_probe.c
+++ b/kernel/trace/trace_probe.c
@@ -73,8 +73,29 @@ int PRINT_TYPE_FUNC_NAME(string)(struct trace_seq *s, void 
*data, void *ent)
 
 const char PRINT_TYPE_FMT_NAME(string)[] = "\\\"%s\\\"";
 
-static const struct fetch_type *find_fetch_type(const char *type,
-   const struct fetch_type *ftbl)
+/* Fetch type information table */
+static const struct fetch_type probe_fetch_types[] = {
+   /* Special types */
+   __ASSIGN_FETCH_TYPE("string", string, string, sizeof(u32), 1,
+   "__data_loc char[]"),
+   /* Basic types */
+   ASSIGN_FETCH_TYPE(u8,  u8,  0),
+   ASSIGN_FETCH_TYPE(u16, u16, 0),
+   ASSIGN_FETCH_TYPE(u32, u32, 0),
+   ASSIGN_FETCH_TYPE(u64, u64, 0),
+   ASSIGN_FETCH_TYPE(s8,  u8,  1),
+   ASSIGN_FETCH_TYPE(s16, u16, 1),
+   ASSIGN_FETCH_TYPE(s32, u32, 1),
+   ASSIGN_FETCH_TYPE(s64, u64, 1),
+   ASSIGN_FETCH_TYPE_ALIAS(x8,  u8,  u8,  0),
+   ASSIGN_FETCH_TYPE_ALIAS(x16, u16, u16, 0),
+   ASSIGN_FETCH_TYPE_ALIAS(x32, u32, u32, 0),
+   ASSIGN_FETCH_TYPE_ALIAS(x64, u64, u64, 0),
+
+   ASSIGN_FETCH_TYPE_END
+};
+
+static const struct fetch_type *find_fetch_type(const char *type)
 {
int i;
 
@@ -95,21 +116,21 @@ static const struct fetch_type *find_fetch_type(const char 
*type,
 
switch (bs) {
case 8:
-   return find_fetch_type("u8", ftbl);
+   return find_fetch_type("u8");
case 16:
-   return find_fetch_type("u16", ftbl);
+   return find_fetch_type("u16");
case 32:
-   return find_fetch_type("u32", ftbl);
+   return find_fetch_type("u32");
case 64:
-   return find_fetch_type("u64", ftbl);
+   return find_fetch_type("u64");
default:
goto fail;
}
}
 
-   for (i = 0; ftbl[i].name; i++) {
-   if (strcmp(type, ftbl[i].name) == 0)
-   return [i];
+   for (i = 0; probe_fetch_types[i].name; i++) {
+   if (strcmp(type, probe_fetch_types[i].name) == 0)
+   return _fetch_types[i];
}