[PATCH 16/24] perf annotate: Remove arch::cpuid_parse callback

2017-10-23 Thread Arnaldo Carvalho de Melo
From: Jiri Olsa 

There's no need for extra cpuid_parse arch callback, it can be handled
directly in init callback.

Adding the init function to x86 to cover the cpuid initialization.

Signed-off-by: Jiri Olsa 
Cc: Andi Kleen 
Cc: David Ahern 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20171011150158.11895-2-jo...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/arch/arm/annotate/instructions.c |  3 ++-
 tools/perf/arch/arm64/annotate/instructions.c   |  3 ++-
 tools/perf/arch/powerpc/annotate/instructions.c |  4 +++-
 tools/perf/arch/s390/annotate/instructions.c|  4 +++-
 tools/perf/arch/x86/annotate/instructions.c | 14 ++
 tools/perf/util/annotate.c  | 10 +++---
 6 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/tools/perf/arch/arm/annotate/instructions.c 
b/tools/perf/arch/arm/annotate/instructions.c
index 1ce0872b1726..6dfec7c23696 100644
--- a/tools/perf/arch/arm/annotate/instructions.c
+++ b/tools/perf/arch/arm/annotate/instructions.c
@@ -1,3 +1,4 @@
+#include 
 #include 
 #include 
 
@@ -23,7 +24,7 @@ static struct ins_ops *arm__associate_instruction_ops(struct 
arch *arch, const c
return ops;
 }
 
-static int arm__annotate_init(struct arch *arch)
+static int arm__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
 {
struct arm_annotate *arm;
int err;
diff --git a/tools/perf/arch/arm64/annotate/instructions.c 
b/tools/perf/arch/arm64/annotate/instructions.c
index 8f1908756cb6..a2c32be4132a 100644
--- a/tools/perf/arch/arm64/annotate/instructions.c
+++ b/tools/perf/arch/arm64/annotate/instructions.c
@@ -1,3 +1,4 @@
+#include 
 #include 
 #include 
 
@@ -25,7 +26,7 @@ static struct ins_ops 
*arm64__associate_instruction_ops(struct arch *arch, const
return ops;
 }
 
-static int arm64__annotate_init(struct arch *arch)
+static int arm64__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
 {
struct arm64_annotate *arm;
int err;
diff --git a/tools/perf/arch/powerpc/annotate/instructions.c 
b/tools/perf/arch/powerpc/annotate/instructions.c
index 3c4004db81b9..b6b0ef5952d0 100644
--- a/tools/perf/arch/powerpc/annotate/instructions.c
+++ b/tools/perf/arch/powerpc/annotate/instructions.c
@@ -1,3 +1,5 @@
+#include 
+
 static struct ins_ops *powerpc__associate_instruction_ops(struct arch *arch, 
const char *name)
 {
int i;
@@ -46,7 +48,7 @@ static struct ins_ops 
*powerpc__associate_instruction_ops(struct arch *arch, con
return ops;
 }
 
-static int powerpc__annotate_init(struct arch *arch)
+static int powerpc__annotate_init(struct arch *arch, char *cpuid 
__maybe_unused)
 {
if (!arch->initialized) {
arch->initialized = true;
diff --git a/tools/perf/arch/s390/annotate/instructions.c 
b/tools/perf/arch/s390/annotate/instructions.c
index 745b4b1b8b21..b8676ccbed76 100644
--- a/tools/perf/arch/s390/annotate/instructions.c
+++ b/tools/perf/arch/s390/annotate/instructions.c
@@ -1,3 +1,5 @@
+#include 
+
 static struct ins_ops *s390__associate_ins_ops(struct arch *arch, const char 
*name)
 {
struct ins_ops *ops = NULL;
@@ -19,7 +21,7 @@ static struct ins_ops *s390__associate_ins_ops(struct arch 
*arch, const char *na
return ops;
 }
 
-static int s390__annotate_init(struct arch *arch)
+static int s390__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
 {
if (!arch->initialized) {
arch->initialized = true;
diff --git a/tools/perf/arch/x86/annotate/instructions.c 
b/tools/perf/arch/x86/annotate/instructions.c
index d84b72063a30..563cd4564041 100644
--- a/tools/perf/arch/x86/annotate/instructions.c
+++ b/tools/perf/arch/x86/annotate/instructions.c
@@ -122,3 +122,17 @@ static int x86__cpuid_parse(struct arch *arch, char *cpuid)
 
return -1;
 }
+
+static int x86__annotate_init(struct arch *arch, char *cpuid)
+{
+   int err = 0;
+
+   if (arch->initialized)
+   return 0;
+
+   if (cpuid)
+   err = x86__cpuid_parse(arch, cpuid);
+
+   arch->initialized = true;
+   return err;
+}
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 4397a8b6e6cd..08164162c345 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -49,10 +49,9 @@ struct arch {
void*priv;
unsigned intmodel;
unsigned intfamily;
-   int (*init)(struct arch *arch);
+   int (*init)(struct arch *arch, char *cpuid);
bool(*ins_is_fused)(struct arch *arch, const char *ins1,
const char *ins2);
-   int (*cpuid_parse)(struct arch *arch, char *cpuid);
struct  {
char comment_char;
char 

[PATCH 16/24] perf annotate: Remove arch::cpuid_parse callback

2017-10-23 Thread Arnaldo Carvalho de Melo
From: Jiri Olsa 

There's no need for extra cpuid_parse arch callback, it can be handled
directly in init callback.

Adding the init function to x86 to cover the cpuid initialization.

Signed-off-by: Jiri Olsa 
Cc: Andi Kleen 
Cc: David Ahern 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20171011150158.11895-2-jo...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/arch/arm/annotate/instructions.c |  3 ++-
 tools/perf/arch/arm64/annotate/instructions.c   |  3 ++-
 tools/perf/arch/powerpc/annotate/instructions.c |  4 +++-
 tools/perf/arch/s390/annotate/instructions.c|  4 +++-
 tools/perf/arch/x86/annotate/instructions.c | 14 ++
 tools/perf/util/annotate.c  | 10 +++---
 6 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/tools/perf/arch/arm/annotate/instructions.c 
b/tools/perf/arch/arm/annotate/instructions.c
index 1ce0872b1726..6dfec7c23696 100644
--- a/tools/perf/arch/arm/annotate/instructions.c
+++ b/tools/perf/arch/arm/annotate/instructions.c
@@ -1,3 +1,4 @@
+#include 
 #include 
 #include 
 
@@ -23,7 +24,7 @@ static struct ins_ops *arm__associate_instruction_ops(struct 
arch *arch, const c
return ops;
 }
 
-static int arm__annotate_init(struct arch *arch)
+static int arm__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
 {
struct arm_annotate *arm;
int err;
diff --git a/tools/perf/arch/arm64/annotate/instructions.c 
b/tools/perf/arch/arm64/annotate/instructions.c
index 8f1908756cb6..a2c32be4132a 100644
--- a/tools/perf/arch/arm64/annotate/instructions.c
+++ b/tools/perf/arch/arm64/annotate/instructions.c
@@ -1,3 +1,4 @@
+#include 
 #include 
 #include 
 
@@ -25,7 +26,7 @@ static struct ins_ops 
*arm64__associate_instruction_ops(struct arch *arch, const
return ops;
 }
 
-static int arm64__annotate_init(struct arch *arch)
+static int arm64__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
 {
struct arm64_annotate *arm;
int err;
diff --git a/tools/perf/arch/powerpc/annotate/instructions.c 
b/tools/perf/arch/powerpc/annotate/instructions.c
index 3c4004db81b9..b6b0ef5952d0 100644
--- a/tools/perf/arch/powerpc/annotate/instructions.c
+++ b/tools/perf/arch/powerpc/annotate/instructions.c
@@ -1,3 +1,5 @@
+#include 
+
 static struct ins_ops *powerpc__associate_instruction_ops(struct arch *arch, 
const char *name)
 {
int i;
@@ -46,7 +48,7 @@ static struct ins_ops 
*powerpc__associate_instruction_ops(struct arch *arch, con
return ops;
 }
 
-static int powerpc__annotate_init(struct arch *arch)
+static int powerpc__annotate_init(struct arch *arch, char *cpuid 
__maybe_unused)
 {
if (!arch->initialized) {
arch->initialized = true;
diff --git a/tools/perf/arch/s390/annotate/instructions.c 
b/tools/perf/arch/s390/annotate/instructions.c
index 745b4b1b8b21..b8676ccbed76 100644
--- a/tools/perf/arch/s390/annotate/instructions.c
+++ b/tools/perf/arch/s390/annotate/instructions.c
@@ -1,3 +1,5 @@
+#include 
+
 static struct ins_ops *s390__associate_ins_ops(struct arch *arch, const char 
*name)
 {
struct ins_ops *ops = NULL;
@@ -19,7 +21,7 @@ static struct ins_ops *s390__associate_ins_ops(struct arch 
*arch, const char *na
return ops;
 }
 
-static int s390__annotate_init(struct arch *arch)
+static int s390__annotate_init(struct arch *arch, char *cpuid __maybe_unused)
 {
if (!arch->initialized) {
arch->initialized = true;
diff --git a/tools/perf/arch/x86/annotate/instructions.c 
b/tools/perf/arch/x86/annotate/instructions.c
index d84b72063a30..563cd4564041 100644
--- a/tools/perf/arch/x86/annotate/instructions.c
+++ b/tools/perf/arch/x86/annotate/instructions.c
@@ -122,3 +122,17 @@ static int x86__cpuid_parse(struct arch *arch, char *cpuid)
 
return -1;
 }
+
+static int x86__annotate_init(struct arch *arch, char *cpuid)
+{
+   int err = 0;
+
+   if (arch->initialized)
+   return 0;
+
+   if (cpuid)
+   err = x86__cpuid_parse(arch, cpuid);
+
+   arch->initialized = true;
+   return err;
+}
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 4397a8b6e6cd..08164162c345 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -49,10 +49,9 @@ struct arch {
void*priv;
unsigned intmodel;
unsigned intfamily;
-   int (*init)(struct arch *arch);
+   int (*init)(struct arch *arch, char *cpuid);
bool(*ins_is_fused)(struct arch *arch, const char *ins1,
const char *ins2);
-   int (*cpuid_parse)(struct arch *arch, char *cpuid);
struct  {
char comment_char;
char skip_functions_char;
@@ -132,10 +131,10 @@ static struct arch architectures[] = {
},
{
.name = "x86",
+