[PATCH] KVM: x86: Assign separate names for Intel and AMD to LBR MSRs

2017-12-16 Thread Soramichi AKIYAMA
Some of the MSRs related to LBR (Last Branch Record) have different names
and layouts among Intel and AMD, but the kernel does not distinguish them.
Currently it does not invoke any bugs, but it is better to assign them separate
macros in order to avoid confusion.

Signed-off-by: Soramichi Akiyama <akiy...@m.soramichi.jp>
---
 arch/x86/include/asm/msr-index.h | 19 +++
 arch/x86/kvm/x86.c   |  8 
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index 34c4922bbc3f..a1c69de453d1 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -123,10 +123,21 @@
 #define MSR_IA32_CR_PAT0x0277
 
 #define MSR_IA32_DEBUGCTLMSR   0x01d9
-#define MSR_IA32_LASTBRANCHFROMIP  0x01db
-#define MSR_IA32_LASTBRANCHTOIP0x01dc
-#define MSR_IA32_LASTINTFROMIP 0x01dd
-#define MSR_IA32_LASTINTTOIP   0x01de
+/*
+ * 0x1db - 0x1de have different names and layouts between Intel and AMD
+ * so it is better to define dedicated macros for each of them.
+ * An Intel one (e.g. MSR_IA32_LASTBRANCH0) contains both "from" and "to"
+ * addresses (because they are used only in old 32 bit CPUs), while an AMD
+ * one (e.g. MSR_IA32_LASTBRANCHFROMIP) contains only one 64 bits address.
+ */
+#define MSR_IA32_LASTBRANCH0   0x01db /* Intel */
+#define MSR_IA32_LASTBRANCH1   0x01dc /* Intel */
+#define MSR_IA32_LASTBRANCH2   0x01dd /* Intel */
+#define MSR_IA32_LASTBRANCH3   0x01de /* Intel */
+#define MSR_IA32_LASTBRANCHFROMIP  0x01db /* AMD */
+#define MSR_IA32_LASTBRANCHTOIP0x01dc /* AMD */
+#define MSR_IA32_LASTINTFROMIP 0x01dd /* AMD */
+#define MSR_IA32_LASTINTTOIP   0x01de /* AMD */
 
 /* DEBUGCTLMSR bits (others vary by model): */
 #define DEBUGCTLMSR_LBR(1UL <<  0) /* last branch 
recording */
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 56d036b9ad75..cef109f112f5 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2434,10 +2434,10 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct 
msr_data *msr_info)
case MSR_IA32_PLATFORM_ID:
case MSR_IA32_EBL_CR_POWERON:
case MSR_IA32_DEBUGCTLMSR:
-   case MSR_IA32_LASTBRANCHFROMIP:
-   case MSR_IA32_LASTBRANCHTOIP:
-   case MSR_IA32_LASTINTFROMIP:
-   case MSR_IA32_LASTINTTOIP:
+   case MSR_IA32_LASTBRANCH0:
+   case MSR_IA32_LASTBRANCH1:
+   case MSR_IA32_LASTBRANCH2:
+   case MSR_IA32_LASTBRANCH3:
case MSR_K8_SYSCFG:
case MSR_K8_TSEG_ADDR:
case MSR_K8_TSEG_MASK:
-- 
2.11.0


[PATCH] KVM: x86: Assign separate names for Intel and AMD to LBR MSRs

2017-12-16 Thread Soramichi AKIYAMA
Some of the MSRs related to LBR (Last Branch Record) have different names
and layouts among Intel and AMD, but the kernel does not distinguish them.
Currently it does not invoke any bugs, but it is better to assign them separate
macros in order to avoid confusion.

Signed-off-by: Soramichi Akiyama 
---
 arch/x86/include/asm/msr-index.h | 19 +++
 arch/x86/kvm/x86.c   |  8 
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index 34c4922bbc3f..a1c69de453d1 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -123,10 +123,21 @@
 #define MSR_IA32_CR_PAT0x0277
 
 #define MSR_IA32_DEBUGCTLMSR   0x01d9
-#define MSR_IA32_LASTBRANCHFROMIP  0x01db
-#define MSR_IA32_LASTBRANCHTOIP0x01dc
-#define MSR_IA32_LASTINTFROMIP 0x01dd
-#define MSR_IA32_LASTINTTOIP   0x01de
+/*
+ * 0x1db - 0x1de have different names and layouts between Intel and AMD
+ * so it is better to define dedicated macros for each of them.
+ * An Intel one (e.g. MSR_IA32_LASTBRANCH0) contains both "from" and "to"
+ * addresses (because they are used only in old 32 bit CPUs), while an AMD
+ * one (e.g. MSR_IA32_LASTBRANCHFROMIP) contains only one 64 bits address.
+ */
+#define MSR_IA32_LASTBRANCH0   0x01db /* Intel */
+#define MSR_IA32_LASTBRANCH1   0x01dc /* Intel */
+#define MSR_IA32_LASTBRANCH2   0x01dd /* Intel */
+#define MSR_IA32_LASTBRANCH3   0x01de /* Intel */
+#define MSR_IA32_LASTBRANCHFROMIP  0x01db /* AMD */
+#define MSR_IA32_LASTBRANCHTOIP0x01dc /* AMD */
+#define MSR_IA32_LASTINTFROMIP 0x01dd /* AMD */
+#define MSR_IA32_LASTINTTOIP   0x01de /* AMD */
 
 /* DEBUGCTLMSR bits (others vary by model): */
 #define DEBUGCTLMSR_LBR(1UL <<  0) /* last branch 
recording */
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 56d036b9ad75..cef109f112f5 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2434,10 +2434,10 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct 
msr_data *msr_info)
case MSR_IA32_PLATFORM_ID:
case MSR_IA32_EBL_CR_POWERON:
case MSR_IA32_DEBUGCTLMSR:
-   case MSR_IA32_LASTBRANCHFROMIP:
-   case MSR_IA32_LASTBRANCHTOIP:
-   case MSR_IA32_LASTINTFROMIP:
-   case MSR_IA32_LASTINTTOIP:
+   case MSR_IA32_LASTBRANCH0:
+   case MSR_IA32_LASTBRANCH1:
+   case MSR_IA32_LASTBRANCH2:
+   case MSR_IA32_LASTBRANCH3:
case MSR_K8_SYSCFG:
case MSR_K8_TSEG_ADDR:
case MSR_K8_TSEG_MASK:
-- 
2.11.0


[PATCH] perf tools: Remove redundant variable in perf_header__adds_write

2017-01-19 Thread Soramichi AKIYAMA
The reason why p exists in perf_header__adds_write(), even though it is
initialized to point the same address as feat_sec points, is that p is
increamented in do_write_feat() while feat_sec is not.
Note:(*p)++ in do_write_feat() is equivalent to p++ in 
perf_header__adds_write().

However for this purpose feat_sec can be copied as a local variable of 
do_write_feat()
by being passed as an argument, because p is never used outside of 
do_write_feat().

Signed-off-by: Soramichi Akiyama <akiy...@m.soramichi.jp>
---
 tools/perf/util/header.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 00fd8a8..d373661 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2278,7 +2278,7 @@ int perf_header__fprintf_info(struct perf_session 
*session, FILE *fp, bool full)
 }
 
 static int do_write_feat(int fd, struct perf_header *h, int type,
-struct perf_file_section **p,
+struct perf_file_section *p,
 struct perf_evlist *evlist)
 {
int err;
@@ -2288,19 +2288,19 @@ static int do_write_feat(int fd, struct perf_header *h, 
int type,
if (!feat_ops[type].write)
return -1;
 
-   (*p)->offset = lseek(fd, 0, SEEK_CUR);
+   p->offset = lseek(fd, 0, SEEK_CUR);
 
err = feat_ops[type].write(fd, h, evlist);
if (err < 0) {
pr_debug("failed to write feature %s\n", 
feat_ops[type].name);
 
/* undo anything written */
-   lseek(fd, (*p)->offset, SEEK_SET);
+   lseek(fd, p->offset, SEEK_SET);
 
return -1;
}
-   (*p)->size = lseek(fd, 0, SEEK_CUR) - (*p)->offset;
-   (*p)++;
+   p->size = lseek(fd, 0, SEEK_CUR) - p->offset;
+   p++;
}
return ret;
 }
@@ -2309,7 +2309,7 @@ static int perf_header__adds_write(struct perf_header 
*header,
   struct perf_evlist *evlist, int fd)
 {
int nr_sections;
-   struct perf_file_section *feat_sec, *p;
+   struct perf_file_section *feat_sec;
int sec_size;
u64 sec_start;
int feat;
@@ -2319,7 +2319,7 @@ static int perf_header__adds_write(struct perf_header 
*header,
if (!nr_sections)
return 0;
 
-   feat_sec = p = calloc(nr_sections, sizeof(*feat_sec));
+   feat_sec = calloc(nr_sections, sizeof(*feat_sec));
if (feat_sec == NULL)
return -ENOMEM;
 
@@ -2329,7 +2329,7 @@ static int perf_header__adds_write(struct perf_header 
*header,
lseek(fd, sec_start + sec_size, SEEK_SET);
 
for_each_set_bit(feat, header->adds_features, HEADER_FEAT_BITS) {
-   if (do_write_feat(fd, header, feat, , evlist))
+   if (do_write_feat(fd, header, feat, feat_sec, evlist))
perf_header__clear_feat(header, feat);
}
 
-- 
2.1.4


[PATCH] perf tools: Remove redundant variable in perf_header__adds_write

2017-01-19 Thread Soramichi AKIYAMA
The reason why p exists in perf_header__adds_write(), even though it is
initialized to point the same address as feat_sec points, is that p is
increamented in do_write_feat() while feat_sec is not.
Note:(*p)++ in do_write_feat() is equivalent to p++ in 
perf_header__adds_write().

However for this purpose feat_sec can be copied as a local variable of 
do_write_feat()
by being passed as an argument, because p is never used outside of 
do_write_feat().

Signed-off-by: Soramichi Akiyama 
---
 tools/perf/util/header.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 00fd8a8..d373661 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -2278,7 +2278,7 @@ int perf_header__fprintf_info(struct perf_session 
*session, FILE *fp, bool full)
 }
 
 static int do_write_feat(int fd, struct perf_header *h, int type,
-struct perf_file_section **p,
+struct perf_file_section *p,
 struct perf_evlist *evlist)
 {
int err;
@@ -2288,19 +2288,19 @@ static int do_write_feat(int fd, struct perf_header *h, 
int type,
if (!feat_ops[type].write)
return -1;
 
-   (*p)->offset = lseek(fd, 0, SEEK_CUR);
+   p->offset = lseek(fd, 0, SEEK_CUR);
 
err = feat_ops[type].write(fd, h, evlist);
if (err < 0) {
pr_debug("failed to write feature %s\n", 
feat_ops[type].name);
 
/* undo anything written */
-   lseek(fd, (*p)->offset, SEEK_SET);
+   lseek(fd, p->offset, SEEK_SET);
 
return -1;
}
-   (*p)->size = lseek(fd, 0, SEEK_CUR) - (*p)->offset;
-   (*p)++;
+   p->size = lseek(fd, 0, SEEK_CUR) - p->offset;
+   p++;
}
return ret;
 }
@@ -2309,7 +2309,7 @@ static int perf_header__adds_write(struct perf_header 
*header,
   struct perf_evlist *evlist, int fd)
 {
int nr_sections;
-   struct perf_file_section *feat_sec, *p;
+   struct perf_file_section *feat_sec;
int sec_size;
u64 sec_start;
int feat;
@@ -2319,7 +2319,7 @@ static int perf_header__adds_write(struct perf_header 
*header,
if (!nr_sections)
return 0;
 
-   feat_sec = p = calloc(nr_sections, sizeof(*feat_sec));
+   feat_sec = calloc(nr_sections, sizeof(*feat_sec));
if (feat_sec == NULL)
return -ENOMEM;
 
@@ -2329,7 +2329,7 @@ static int perf_header__adds_write(struct perf_header 
*header,
lseek(fd, sec_start + sec_size, SEEK_SET);
 
for_each_set_bit(feat, header->adds_features, HEADER_FEAT_BITS) {
-   if (do_write_feat(fd, header, feat, , evlist))
+   if (do_write_feat(fd, header, feat, feat_sec, evlist))
perf_header__clear_feat(header, feat);
}
 
-- 
2.1.4


[tip:perf/core] tools lib subcmd: Fix missing member name

2017-01-18 Thread tip-bot for Soramichi AKIYAMA
Commit-ID:  f7ee6595a5acec78963b3de5fbdd537d8aa53b92
Gitweb: http://git.kernel.org/tip/f7ee6595a5acec78963b3de5fbdd537d8aa53b92
Author: Soramichi AKIYAMA <akiy...@m.soramichi.jp>
AuthorDate: Fri, 13 Jan 2017 21:56:23 +0900
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Mon, 16 Jan 2017 14:59:15 -0300

tools lib subcmd: Fix missing member name

This patch adds missing member names to struct initializations.

Although in C99 for struct S {int x, int y} two init codes struct S s =
{.x = (a), (b)} and struct S s = {.x = (a), .y = (b)} are the same, it
is better to explicitly write .y (.argh in this patch) for readability
and robustness against language/compiler evolutions.

Signed-off-by: Soramichi Akiyama <akiy...@m.soramichi.jp>
Cc: Alexander Shishkin <alexander.shish...@linux.intel.com>
Cc: Peter Zijlstra <pet...@infradead.org>
Link: 
http://lkml.kernel.org/r/20170113215623.32fb1ac2d862af0048c30...@m.soramichi.jp
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/lib/subcmd/parse-options.h | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/tools/lib/subcmd/parse-options.h b/tools/lib/subcmd/parse-options.h
index 37e2d1a..f054ca1 100644
--- a/tools/lib/subcmd/parse-options.h
+++ b/tools/lib/subcmd/parse-options.h
@@ -133,32 +133,32 @@ struct option {
 #define OPT_UINTEGER(s, l, v, h){ .type = OPTION_UINTEGER, .short_name = 
(s), .long_name = (l), .value = check_vtype(v, unsigned int *), .help = (h) }
 #define OPT_LONG(s, l, v, h){ .type = OPTION_LONG, .short_name = (s), 
.long_name = (l), .value = check_vtype(v, long *), .help = (h) }
 #define OPT_U64(s, l, v, h) { .type = OPTION_U64, .short_name = (s), 
.long_name = (l), .value = check_vtype(v, u64 *), .help = (h) }
-#define OPT_STRING(s, l, v, a, h)   { .type = OPTION_STRING,  .short_name = 
(s), .long_name = (l), .value = check_vtype(v, const char **), (a), .help = (h) 
}
+#define OPT_STRING(s, l, v, a, h)   { .type = OPTION_STRING,  .short_name = 
(s), .long_name = (l), .value = check_vtype(v, const char **), .argh = (a), 
.help = (h) }
 #define OPT_STRING_OPTARG(s, l, v, a, h, d) \
{ .type = OPTION_STRING,  .short_name = (s), .long_name = (l), \
- .value = check_vtype(v, const char **), (a), .help = (h), \
+ .value = check_vtype(v, const char **), .argh =(a), .help = (h), \
  .flags = PARSE_OPT_OPTARG, .defval = (intptr_t)(d) }
 #define OPT_STRING_OPTARG_SET(s, l, v, os, a, h, d) \
{ .type = OPTION_STRING, .short_name = (s), .long_name = (l), \
- .value = check_vtype(v, const char **), (a), .help = (h), \
+ .value = check_vtype(v, const char **), .argh = (a), .help = (h), \
  .flags = PARSE_OPT_OPTARG, .defval = (intptr_t)(d), \
  .set = check_vtype(os, bool *)}
-#define OPT_STRING_NOEMPTY(s, l, v, a, h)   { .type = OPTION_STRING,  
.short_name = (s), .long_name = (l), .value = check_vtype(v, const char **), 
(a), .help = (h), .flags = PARSE_OPT_NOEMPTY}
+#define OPT_STRING_NOEMPTY(s, l, v, a, h)   { .type = OPTION_STRING,  
.short_name = (s), .long_name = (l), .value = check_vtype(v, const char **), 
.argh = (a), .help = (h), .flags = PARSE_OPT_NOEMPTY}
 #define OPT_DATE(s, l, v, h) \
{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb }
 #define OPT_CALLBACK(s, l, v, a, h, f) \
-   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), (a), .help = (h), .callback = (f) }
+   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), .argh = (a), .help = (h), .callback = (f) }
 #define OPT_CALLBACK_NOOPT(s, l, v, a, h, f) \
-   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), (a), .help = (h), .callback = (f), .flags = PARSE_OPT_NOARG }
+   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), .argh = (a), .help = (h), .callback = (f), .flags = PARSE_OPT_NOARG }
 #define OPT_CALLBACK_DEFAULT(s, l, v, a, h, f, d) \
-   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), (a), .help = (h), .callback = (f), .defval = (intptr_t)d, .flags = 
PARSE_OPT_LASTARG_DEFAULT }
+   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), .argh = (a), .help = (h), .callback = (f), .defval = (intptr_t)d, .flags 
= PARSE_OPT_LASTARG_DEFAULT }
 #define OPT_CALLBACK_DEFAULT_NOOPT(s, l, v, a, h, f, d) \
{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l),\
-   .value = (v), (a), .help = (h), .callback = (f), .defval = (intptr_t)d,\
+   .value = (v), .arg = (a), .help = (h), .callback = (f), .defval = 
(intptr_t)d,\
.flags = PARSE_OPT_LASTARG_DEFAULT | PARSE_OPT_NOARG}
 #define OPT_CALLBACK_OPTARG(s, l, v, d, a, h, f) \
{ .type = OPTIO

[tip:perf/core] tools lib subcmd: Fix missing member name

2017-01-18 Thread tip-bot for Soramichi AKIYAMA
Commit-ID:  f7ee6595a5acec78963b3de5fbdd537d8aa53b92
Gitweb: http://git.kernel.org/tip/f7ee6595a5acec78963b3de5fbdd537d8aa53b92
Author: Soramichi AKIYAMA 
AuthorDate: Fri, 13 Jan 2017 21:56:23 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Mon, 16 Jan 2017 14:59:15 -0300

tools lib subcmd: Fix missing member name

This patch adds missing member names to struct initializations.

Although in C99 for struct S {int x, int y} two init codes struct S s =
{.x = (a), (b)} and struct S s = {.x = (a), .y = (b)} are the same, it
is better to explicitly write .y (.argh in this patch) for readability
and robustness against language/compiler evolutions.

Signed-off-by: Soramichi Akiyama 
Cc: Alexander Shishkin 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/20170113215623.32fb1ac2d862af0048c30...@m.soramichi.jp
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/lib/subcmd/parse-options.h | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/tools/lib/subcmd/parse-options.h b/tools/lib/subcmd/parse-options.h
index 37e2d1a..f054ca1 100644
--- a/tools/lib/subcmd/parse-options.h
+++ b/tools/lib/subcmd/parse-options.h
@@ -133,32 +133,32 @@ struct option {
 #define OPT_UINTEGER(s, l, v, h){ .type = OPTION_UINTEGER, .short_name = 
(s), .long_name = (l), .value = check_vtype(v, unsigned int *), .help = (h) }
 #define OPT_LONG(s, l, v, h){ .type = OPTION_LONG, .short_name = (s), 
.long_name = (l), .value = check_vtype(v, long *), .help = (h) }
 #define OPT_U64(s, l, v, h) { .type = OPTION_U64, .short_name = (s), 
.long_name = (l), .value = check_vtype(v, u64 *), .help = (h) }
-#define OPT_STRING(s, l, v, a, h)   { .type = OPTION_STRING,  .short_name = 
(s), .long_name = (l), .value = check_vtype(v, const char **), (a), .help = (h) 
}
+#define OPT_STRING(s, l, v, a, h)   { .type = OPTION_STRING,  .short_name = 
(s), .long_name = (l), .value = check_vtype(v, const char **), .argh = (a), 
.help = (h) }
 #define OPT_STRING_OPTARG(s, l, v, a, h, d) \
{ .type = OPTION_STRING,  .short_name = (s), .long_name = (l), \
- .value = check_vtype(v, const char **), (a), .help = (h), \
+ .value = check_vtype(v, const char **), .argh =(a), .help = (h), \
  .flags = PARSE_OPT_OPTARG, .defval = (intptr_t)(d) }
 #define OPT_STRING_OPTARG_SET(s, l, v, os, a, h, d) \
{ .type = OPTION_STRING, .short_name = (s), .long_name = (l), \
- .value = check_vtype(v, const char **), (a), .help = (h), \
+ .value = check_vtype(v, const char **), .argh = (a), .help = (h), \
  .flags = PARSE_OPT_OPTARG, .defval = (intptr_t)(d), \
  .set = check_vtype(os, bool *)}
-#define OPT_STRING_NOEMPTY(s, l, v, a, h)   { .type = OPTION_STRING,  
.short_name = (s), .long_name = (l), .value = check_vtype(v, const char **), 
(a), .help = (h), .flags = PARSE_OPT_NOEMPTY}
+#define OPT_STRING_NOEMPTY(s, l, v, a, h)   { .type = OPTION_STRING,  
.short_name = (s), .long_name = (l), .value = check_vtype(v, const char **), 
.argh = (a), .help = (h), .flags = PARSE_OPT_NOEMPTY}
 #define OPT_DATE(s, l, v, h) \
{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb }
 #define OPT_CALLBACK(s, l, v, a, h, f) \
-   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), (a), .help = (h), .callback = (f) }
+   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), .argh = (a), .help = (h), .callback = (f) }
 #define OPT_CALLBACK_NOOPT(s, l, v, a, h, f) \
-   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), (a), .help = (h), .callback = (f), .flags = PARSE_OPT_NOARG }
+   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), .argh = (a), .help = (h), .callback = (f), .flags = PARSE_OPT_NOARG }
 #define OPT_CALLBACK_DEFAULT(s, l, v, a, h, f, d) \
-   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), (a), .help = (h), .callback = (f), .defval = (intptr_t)d, .flags = 
PARSE_OPT_LASTARG_DEFAULT }
+   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), .argh = (a), .help = (h), .callback = (f), .defval = (intptr_t)d, .flags 
= PARSE_OPT_LASTARG_DEFAULT }
 #define OPT_CALLBACK_DEFAULT_NOOPT(s, l, v, a, h, f, d) \
{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l),\
-   .value = (v), (a), .help = (h), .callback = (f), .defval = (intptr_t)d,\
+   .value = (v), .arg = (a), .help = (h), .callback = (f), .defval = 
(intptr_t)d,\
.flags = PARSE_OPT_LASTARG_DEFAULT | PARSE_OPT_NOARG}
 #define OPT_CALLBACK_OPTARG(s, l, v, d, a, h, f) \
{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), \
- .value = (v), (a), .help = (h), .callback = (f), \
+ .value = (v), .argh = (a), .help = (h), .callback = (f), \
  

[tip:perf/core] perf evlist: Fix typo in deliver_sample()

2017-01-18 Thread tip-bot for Soramichi AKIYAMA
Commit-ID:  d94386f28abad0c5879f0760712e34e71f88a7da
Gitweb: http://git.kernel.org/tip/d94386f28abad0c5879f0760712e34e71f88a7da
Author: Soramichi AKIYAMA <akiy...@m.soramichi.jp>
AuthorDate: Tue, 17 Jan 2017 22:22:33 +0900
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Tue, 17 Jan 2017 11:36:45 -0300

perf evlist: Fix typo in deliver_sample()

This patch fixes a typo: s/delievery/delivery/

Signed-off-by: Soramichi Akiyama <akiy...@m.soramichi.jp>
Cc: Alexander Shishkin <alexander.shish...@linux.intel.com>
Cc: Peter Zijlstra <pet...@infradead.org>
Link: 
http://lkml.kernel.org/r/2017011733.dfd92de0ad701e7c53396...@m.soramichi.jp
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/util/session.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index f268201..349c681 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1191,7 +1191,7 @@ static int
u64 sample_type = evsel->attr.sample_type;
u64 read_format = evsel->attr.read_format;
 
-   /* Standard sample delievery. */
+   /* Standard sample delivery. */
if (!(sample_type & PERF_SAMPLE_READ))
return tool->sample(tool, event, sample, evsel, machine);
 


[tip:perf/core] perf evlist: Fix typo in deliver_sample()

2017-01-18 Thread tip-bot for Soramichi AKIYAMA
Commit-ID:  d94386f28abad0c5879f0760712e34e71f88a7da
Gitweb: http://git.kernel.org/tip/d94386f28abad0c5879f0760712e34e71f88a7da
Author: Soramichi AKIYAMA 
AuthorDate: Tue, 17 Jan 2017 22:22:33 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 17 Jan 2017 11:36:45 -0300

perf evlist: Fix typo in deliver_sample()

This patch fixes a typo: s/delievery/delivery/

Signed-off-by: Soramichi Akiyama 
Cc: Alexander Shishkin 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/2017011733.dfd92de0ad701e7c53396...@m.soramichi.jp
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/session.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index f268201..349c681 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1191,7 +1191,7 @@ static int
u64 sample_type = evsel->attr.sample_type;
u64 read_format = evsel->attr.read_format;
 
-   /* Standard sample delievery. */
+   /* Standard sample delivery. */
if (!(sample_type & PERF_SAMPLE_READ))
return tool->sample(tool, event, sample, evsel, machine);
 


[tip:perf/core] perf tools: Move two variables usied in libperf from perf.c

2017-01-18 Thread tip-bot for Soramichi AKIYAMA
Commit-ID:  d25ed5d9fad98fd36ffca0bb5c3a0761a11e3f3c
Gitweb: http://git.kernel.org/tip/d25ed5d9fad98fd36ffca0bb5c3a0761a11e3f3c
Author: Soramichi AKIYAMA <akiy...@m.soramichi.jp>
AuthorDate: Tue, 17 Jan 2017 00:22:37 +0900
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Tue, 17 Jan 2017 11:36:45 -0300

perf tools: Move two variables usied in libperf from perf.c

The use_browser and perf_version_string variables are both declared in
perf.c but they are also referenced by other functions of libperf.a.

Therefore a user linking an own main() with libperf.a must declare those
two variables in their files even if the files never use the browser or
the version information.

This patch fixes this issue by moving use_browser and
perf_version_string out of perf.c to some other files.

Signed-off-by: Soramichi Akiyama <akiy...@m.soramichi.jp>
Cc: Alexander Shishkin <alexander.shish...@linux.intel.com>
Cc: Peter Zijlstra <pet...@infradead.org>
Link: 
http://lkml.kernel.org/r/20170117002237.c1aec0ce3b4d675dca018...@m.soramichi.jp
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/Build | 3 +--
 tools/perf/perf.c| 3 ---
 tools/perf/ui/setup.c| 1 +
 tools/perf/util/Build| 1 +
 tools/perf/util/header.c | 2 ++
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/perf/Build b/tools/perf/Build
index 0b48806..7039ecb 100644
--- a/tools/perf/Build
+++ b/tools/perf/Build
@@ -40,8 +40,7 @@ CFLAGS_builtin-help.o  += $(paths)
 CFLAGS_builtin-timechart.o += $(paths)
 CFLAGS_perf.o  += -DPERF_HTML_PATH="BUILD_STR($(htmldir_SQ))"  
\
  -DPERF_EXEC_PATH="BUILD_STR($(perfexecdir_SQ))"   
\
- -DPREFIX="BUILD_STR($(prefix_SQ))"
\
- -include $(OUTPUT)PERF-VERSION-FILE
+ -DPREFIX="BUILD_STR($(prefix_SQ))"
 CFLAGS_builtin-trace.o+= 
-DSTRACE_GROUPS_DIR="BUILD_STR($(STRACE_GROUPS_DIR_SQ))"
 CFLAGS_builtin-report.o   += -DTIPDIR="BUILD_STR($(tipdir_SQ))"
 CFLAGS_builtin-report.o   += 
-DDOCDIR="BUILD_STR($(srcdir_SQ)/Documentation)"
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 13c8a7d..0324cd1 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -29,7 +29,6 @@ const char perf_usage_string[] =
 const char perf_more_info_string[] =
"See 'perf help COMMAND' for more information on a specific command.";
 
-int use_browser = -1;
 static int use_pager = -1;
 const char *input_name;
 
@@ -330,8 +329,6 @@ static int handle_alias(int *argcp, const char ***argv)
return ret;
 }
 
-const char perf_version_string[] = PERF_VERSION;
-
 #define RUN_SETUP  (1<<0)
 #define USE_PAGER  (1<<1)
 
diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c
index 1f6b099..50d13e58 100644
--- a/tools/perf/ui/setup.c
+++ b/tools/perf/ui/setup.c
@@ -7,6 +7,7 @@
 
 pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
 void *perf_gtk_handle;
+int use_browser = -1;
 
 #ifdef HAVE_GTK2_SUPPORT
 static int setup_gtk_browser(void)
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 3840e3a..5da376b 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -162,6 +162,7 @@ CFLAGS_rbtree.o+= -Wno-unused-parameter 
-DETC_PERFCONFIG="BUILD_STR($(ET
 CFLAGS_libstring.o += -Wno-unused-parameter 
-DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
 CFLAGS_hweight.o   += -Wno-unused-parameter 
-DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
 CFLAGS_parse-events.o  += -Wno-redundant-decls
+CFLAGS_header.o+= -include $(OUTPUT)PERF-VERSION-FILE
 
 $(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c FORCE
$(call rule_mkdir)
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index d89c9c7..00fd8a8 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -41,6 +41,8 @@ static const u64 __perf_magic2_sw = 0x50455246494c4532ULL;
 
 #define PERF_MAGIC __perf_magic2
 
+const char perf_version_string[] = PERF_VERSION;
+
 struct perf_file_attr {
struct perf_event_attr  attr;
struct perf_file_sectionids;


[tip:perf/core] perf tools: Move two variables usied in libperf from perf.c

2017-01-18 Thread tip-bot for Soramichi AKIYAMA
Commit-ID:  d25ed5d9fad98fd36ffca0bb5c3a0761a11e3f3c
Gitweb: http://git.kernel.org/tip/d25ed5d9fad98fd36ffca0bb5c3a0761a11e3f3c
Author: Soramichi AKIYAMA 
AuthorDate: Tue, 17 Jan 2017 00:22:37 +0900
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 17 Jan 2017 11:36:45 -0300

perf tools: Move two variables usied in libperf from perf.c

The use_browser and perf_version_string variables are both declared in
perf.c but they are also referenced by other functions of libperf.a.

Therefore a user linking an own main() with libperf.a must declare those
two variables in their files even if the files never use the browser or
the version information.

This patch fixes this issue by moving use_browser and
perf_version_string out of perf.c to some other files.

Signed-off-by: Soramichi Akiyama 
Cc: Alexander Shishkin 
Cc: Peter Zijlstra 
Link: 
http://lkml.kernel.org/r/20170117002237.c1aec0ce3b4d675dca018...@m.soramichi.jp
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Build | 3 +--
 tools/perf/perf.c| 3 ---
 tools/perf/ui/setup.c| 1 +
 tools/perf/util/Build| 1 +
 tools/perf/util/header.c | 2 ++
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/perf/Build b/tools/perf/Build
index 0b48806..7039ecb 100644
--- a/tools/perf/Build
+++ b/tools/perf/Build
@@ -40,8 +40,7 @@ CFLAGS_builtin-help.o  += $(paths)
 CFLAGS_builtin-timechart.o += $(paths)
 CFLAGS_perf.o  += -DPERF_HTML_PATH="BUILD_STR($(htmldir_SQ))"  
\
  -DPERF_EXEC_PATH="BUILD_STR($(perfexecdir_SQ))"   
\
- -DPREFIX="BUILD_STR($(prefix_SQ))"
\
- -include $(OUTPUT)PERF-VERSION-FILE
+ -DPREFIX="BUILD_STR($(prefix_SQ))"
 CFLAGS_builtin-trace.o+= 
-DSTRACE_GROUPS_DIR="BUILD_STR($(STRACE_GROUPS_DIR_SQ))"
 CFLAGS_builtin-report.o   += -DTIPDIR="BUILD_STR($(tipdir_SQ))"
 CFLAGS_builtin-report.o   += 
-DDOCDIR="BUILD_STR($(srcdir_SQ)/Documentation)"
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 13c8a7d..0324cd1 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -29,7 +29,6 @@ const char perf_usage_string[] =
 const char perf_more_info_string[] =
"See 'perf help COMMAND' for more information on a specific command.";
 
-int use_browser = -1;
 static int use_pager = -1;
 const char *input_name;
 
@@ -330,8 +329,6 @@ static int handle_alias(int *argcp, const char ***argv)
return ret;
 }
 
-const char perf_version_string[] = PERF_VERSION;
-
 #define RUN_SETUP  (1<<0)
 #define USE_PAGER  (1<<1)
 
diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c
index 1f6b099..50d13e58 100644
--- a/tools/perf/ui/setup.c
+++ b/tools/perf/ui/setup.c
@@ -7,6 +7,7 @@
 
 pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
 void *perf_gtk_handle;
+int use_browser = -1;
 
 #ifdef HAVE_GTK2_SUPPORT
 static int setup_gtk_browser(void)
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 3840e3a..5da376b 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -162,6 +162,7 @@ CFLAGS_rbtree.o+= -Wno-unused-parameter 
-DETC_PERFCONFIG="BUILD_STR($(ET
 CFLAGS_libstring.o += -Wno-unused-parameter 
-DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
 CFLAGS_hweight.o   += -Wno-unused-parameter 
-DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
 CFLAGS_parse-events.o  += -Wno-redundant-decls
+CFLAGS_header.o+= -include $(OUTPUT)PERF-VERSION-FILE
 
 $(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c FORCE
$(call rule_mkdir)
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index d89c9c7..00fd8a8 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -41,6 +41,8 @@ static const u64 __perf_magic2_sw = 0x50455246494c4532ULL;
 
 #define PERF_MAGIC __perf_magic2
 
+const char perf_version_string[] = PERF_VERSION;
+
 struct perf_file_attr {
struct perf_event_attr  attr;
struct perf_file_sectionids;


[PATCH] perf session: Fix typo in perf_evlist__deliver_sample()

2017-01-17 Thread Soramichi AKIYAMA
This patch fixes a typo: s/delievery/delivery/

Signed-off-by: Soramichi Akiyama <akiy...@m.soramichi.jp>
---
 tools/perf/util/session.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index f268201..349c681 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1191,7 +1191,7 @@ static int
u64 sample_type = evsel->attr.sample_type;
u64 read_format = evsel->attr.read_format;
 
-   /* Standard sample delievery. */
+   /* Standard sample delivery. */
if (!(sample_type & PERF_SAMPLE_READ))
return tool->sample(tool, event, sample, evsel, machine);
 
-- 
2.1.4


[PATCH] perf session: Fix typo in perf_evlist__deliver_sample()

2017-01-17 Thread Soramichi AKIYAMA
This patch fixes a typo: s/delievery/delivery/

Signed-off-by: Soramichi Akiyama 
---
 tools/perf/util/session.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index f268201..349c681 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1191,7 +1191,7 @@ static int
u64 sample_type = evsel->attr.sample_type;
u64 read_format = evsel->attr.read_format;
 
-   /* Standard sample delievery. */
+   /* Standard sample delivery. */
if (!(sample_type & PERF_SAMPLE_READ))
return tool->sample(tool, event, sample, evsel, machine);
 
-- 
2.1.4


[PATCH] perf: move two mandatory variables out of perf.c

2017-01-16 Thread Soramichi AKIYAMA
use_browser and perf_version_string are both declared in perf.c
but they are also referenced by other functions of libperf.a.

Therefore a user linking an own main() with libperf.a must
declare those two variables in their files even if the files
never use the browser or the version information.

This patch fixes this issue by moving use_browser and
perf_version_string out of perf.c to some other files.

Signed-off-by: Soramichi Akiyama <akiy...@m.soramichi.jp>
---
 tools/perf/Build | 3 +--
 tools/perf/perf.c| 3 ---
 tools/perf/ui/setup.c| 1 +
 tools/perf/util/Build| 1 +
 tools/perf/util/header.c | 2 ++
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/perf/Build b/tools/perf/Build
index 0b48806..7039ecb 100644
--- a/tools/perf/Build
+++ b/tools/perf/Build
@@ -40,8 +40,7 @@ CFLAGS_builtin-help.o  += $(paths)
 CFLAGS_builtin-timechart.o += $(paths)
 CFLAGS_perf.o  += -DPERF_HTML_PATH="BUILD_STR($(htmldir_SQ))"  
\
  -DPERF_EXEC_PATH="BUILD_STR($(perfexecdir_SQ))"   
\
- -DPREFIX="BUILD_STR($(prefix_SQ))"
\
- -include $(OUTPUT)PERF-VERSION-FILE
+ -DPREFIX="BUILD_STR($(prefix_SQ))"
 CFLAGS_builtin-trace.o+= 
-DSTRACE_GROUPS_DIR="BUILD_STR($(STRACE_GROUPS_DIR_SQ))"
 CFLAGS_builtin-report.o   += -DTIPDIR="BUILD_STR($(tipdir_SQ))"
 CFLAGS_builtin-report.o   += 
-DDOCDIR="BUILD_STR($(srcdir_SQ)/Documentation)"
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 13c8a7d..0324cd1 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -29,7 +29,6 @@ const char perf_usage_string[] =
 const char perf_more_info_string[] =
"See 'perf help COMMAND' for more information on a specific command.";
 
-int use_browser = -1;
 static int use_pager = -1;
 const char *input_name;
 
@@ -330,8 +329,6 @@ static int handle_alias(int *argcp, const char ***argv)
return ret;
 }
 
-const char perf_version_string[] = PERF_VERSION;
-
 #define RUN_SETUP  (1<<0)
 #define USE_PAGER  (1<<1)
 
diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c
index 1f6b099..50d13e58 100644
--- a/tools/perf/ui/setup.c
+++ b/tools/perf/ui/setup.c
@@ -7,6 +7,7 @@
 
 pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
 void *perf_gtk_handle;
+int use_browser = -1;
 
 #ifdef HAVE_GTK2_SUPPORT
 static int setup_gtk_browser(void)
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 3840e3a..5da376b 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -162,6 +162,7 @@ CFLAGS_rbtree.o+= -Wno-unused-parameter 
-DETC_PERFCONFIG="BUILD_STR($(ET
 CFLAGS_libstring.o += -Wno-unused-parameter 
-DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
 CFLAGS_hweight.o   += -Wno-unused-parameter 
-DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
 CFLAGS_parse-events.o  += -Wno-redundant-decls
+CFLAGS_header.o+= -include $(OUTPUT)PERF-VERSION-FILE
 
 $(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c FORCE
$(call rule_mkdir)
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index d89c9c7..00fd8a8 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -41,6 +41,8 @@ static const u64 __perf_magic2_sw = 0x50455246494c4532ULL;
 
 #define PERF_MAGIC __perf_magic2
 
+const char perf_version_string[] = PERF_VERSION;
+
 struct perf_file_attr {
struct perf_event_attr  attr;
struct perf_file_sectionids;
-- 
2.1.4


[PATCH] perf: move two mandatory variables out of perf.c

2017-01-16 Thread Soramichi AKIYAMA
use_browser and perf_version_string are both declared in perf.c
but they are also referenced by other functions of libperf.a.

Therefore a user linking an own main() with libperf.a must
declare those two variables in their files even if the files
never use the browser or the version information.

This patch fixes this issue by moving use_browser and
perf_version_string out of perf.c to some other files.

Signed-off-by: Soramichi Akiyama 
---
 tools/perf/Build | 3 +--
 tools/perf/perf.c| 3 ---
 tools/perf/ui/setup.c| 1 +
 tools/perf/util/Build| 1 +
 tools/perf/util/header.c | 2 ++
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/perf/Build b/tools/perf/Build
index 0b48806..7039ecb 100644
--- a/tools/perf/Build
+++ b/tools/perf/Build
@@ -40,8 +40,7 @@ CFLAGS_builtin-help.o  += $(paths)
 CFLAGS_builtin-timechart.o += $(paths)
 CFLAGS_perf.o  += -DPERF_HTML_PATH="BUILD_STR($(htmldir_SQ))"  
\
  -DPERF_EXEC_PATH="BUILD_STR($(perfexecdir_SQ))"   
\
- -DPREFIX="BUILD_STR($(prefix_SQ))"
\
- -include $(OUTPUT)PERF-VERSION-FILE
+ -DPREFIX="BUILD_STR($(prefix_SQ))"
 CFLAGS_builtin-trace.o+= 
-DSTRACE_GROUPS_DIR="BUILD_STR($(STRACE_GROUPS_DIR_SQ))"
 CFLAGS_builtin-report.o   += -DTIPDIR="BUILD_STR($(tipdir_SQ))"
 CFLAGS_builtin-report.o   += 
-DDOCDIR="BUILD_STR($(srcdir_SQ)/Documentation)"
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 13c8a7d..0324cd1 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -29,7 +29,6 @@ const char perf_usage_string[] =
 const char perf_more_info_string[] =
"See 'perf help COMMAND' for more information on a specific command.";
 
-int use_browser = -1;
 static int use_pager = -1;
 const char *input_name;
 
@@ -330,8 +329,6 @@ static int handle_alias(int *argcp, const char ***argv)
return ret;
 }
 
-const char perf_version_string[] = PERF_VERSION;
-
 #define RUN_SETUP  (1<<0)
 #define USE_PAGER  (1<<1)
 
diff --git a/tools/perf/ui/setup.c b/tools/perf/ui/setup.c
index 1f6b099..50d13e58 100644
--- a/tools/perf/ui/setup.c
+++ b/tools/perf/ui/setup.c
@@ -7,6 +7,7 @@
 
 pthread_mutex_t ui__lock = PTHREAD_MUTEX_INITIALIZER;
 void *perf_gtk_handle;
+int use_browser = -1;
 
 #ifdef HAVE_GTK2_SUPPORT
 static int setup_gtk_browser(void)
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 3840e3a..5da376b 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -162,6 +162,7 @@ CFLAGS_rbtree.o+= -Wno-unused-parameter 
-DETC_PERFCONFIG="BUILD_STR($(ET
 CFLAGS_libstring.o += -Wno-unused-parameter 
-DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
 CFLAGS_hweight.o   += -Wno-unused-parameter 
-DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
 CFLAGS_parse-events.o  += -Wno-redundant-decls
+CFLAGS_header.o+= -include $(OUTPUT)PERF-VERSION-FILE
 
 $(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c FORCE
$(call rule_mkdir)
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index d89c9c7..00fd8a8 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -41,6 +41,8 @@ static const u64 __perf_magic2_sw = 0x50455246494c4532ULL;
 
 #define PERF_MAGIC __perf_magic2
 
+const char perf_version_string[] = PERF_VERSION;
+
 struct perf_file_attr {
struct perf_event_attr  attr;
struct perf_file_sectionids;
-- 
2.1.4


[PATCH] tools/lib/subcmd: Fix missing member name

2017-01-13 Thread Soramichi AKIYAMA
This patch adds missing member names to struct initializations.
Although in C99 for struct S {int x, int y} two init codes
struct S s = {.x = (a), (b)} and struct S s = {.x = (a), .y = (b)}
are the same, it is better to explicitly write .y (.argh in this patch)
for readability and robustness against language/compiler evolutions.

Signed-off-by: Soramichi Akiyama <akiy...@m.soramichi.jp>
---
 tools/lib/subcmd/parse-options.h | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/tools/lib/subcmd/parse-options.h b/tools/lib/subcmd/parse-options.h
index 37e2d1a..f054ca1 100644
--- a/tools/lib/subcmd/parse-options.h
+++ b/tools/lib/subcmd/parse-options.h
@@ -133,32 +133,32 @@ struct option {
 #define OPT_UINTEGER(s, l, v, h){ .type = OPTION_UINTEGER, .short_name = 
(s), .long_name = (l), .value = check_vtype(v, unsigned int *), .help = (h) }
 #define OPT_LONG(s, l, v, h){ .type = OPTION_LONG, .short_name = (s), 
.long_name = (l), .value = check_vtype(v, long *), .help = (h) }
 #define OPT_U64(s, l, v, h) { .type = OPTION_U64, .short_name = (s), 
.long_name = (l), .value = check_vtype(v, u64 *), .help = (h) }
-#define OPT_STRING(s, l, v, a, h)   { .type = OPTION_STRING,  .short_name = 
(s), .long_name = (l), .value = check_vtype(v, const char **), (a), .help = (h) 
}
+#define OPT_STRING(s, l, v, a, h)   { .type = OPTION_STRING,  .short_name = 
(s), .long_name = (l), .value = check_vtype(v, const char **), .argh = (a), 
.help = (h) }
 #define OPT_STRING_OPTARG(s, l, v, a, h, d) \
{ .type = OPTION_STRING,  .short_name = (s), .long_name = (l), \
- .value = check_vtype(v, const char **), (a), .help = (h), \
+ .value = check_vtype(v, const char **), .argh =(a), .help = (h), \
  .flags = PARSE_OPT_OPTARG, .defval = (intptr_t)(d) }
 #define OPT_STRING_OPTARG_SET(s, l, v, os, a, h, d) \
{ .type = OPTION_STRING, .short_name = (s), .long_name = (l), \
- .value = check_vtype(v, const char **), (a), .help = (h), \
+ .value = check_vtype(v, const char **), .argh = (a), .help = (h), \
  .flags = PARSE_OPT_OPTARG, .defval = (intptr_t)(d), \
  .set = check_vtype(os, bool *)}
-#define OPT_STRING_NOEMPTY(s, l, v, a, h)   { .type = OPTION_STRING,  
.short_name = (s), .long_name = (l), .value = check_vtype(v, const char **), 
(a), .help = (h), .flags = PARSE_OPT_NOEMPTY}
+#define OPT_STRING_NOEMPTY(s, l, v, a, h)   { .type = OPTION_STRING,  
.short_name = (s), .long_name = (l), .value = check_vtype(v, const char **), 
.argh = (a), .help = (h), .flags = PARSE_OPT_NOEMPTY}
 #define OPT_DATE(s, l, v, h) \
{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb }
 #define OPT_CALLBACK(s, l, v, a, h, f) \
-   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), (a), .help = (h), .callback = (f) }
+   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), .argh = (a), .help = (h), .callback = (f) }
 #define OPT_CALLBACK_NOOPT(s, l, v, a, h, f) \
-   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), (a), .help = (h), .callback = (f), .flags = PARSE_OPT_NOARG }
+   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), .argh = (a), .help = (h), .callback = (f), .flags = PARSE_OPT_NOARG }
 #define OPT_CALLBACK_DEFAULT(s, l, v, a, h, f, d) \
-   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), (a), .help = (h), .callback = (f), .defval = (intptr_t)d, .flags = 
PARSE_OPT_LASTARG_DEFAULT }
+   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), .argh = (a), .help = (h), .callback = (f), .defval = (intptr_t)d, .flags 
= PARSE_OPT_LASTARG_DEFAULT }
 #define OPT_CALLBACK_DEFAULT_NOOPT(s, l, v, a, h, f, d) \
{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l),\
-   .value = (v), (a), .help = (h), .callback = (f), .defval = (intptr_t)d,\
+   .value = (v), .arg = (a), .help = (h), .callback = (f), .defval = 
(intptr_t)d,\
.flags = PARSE_OPT_LASTARG_DEFAULT | PARSE_OPT_NOARG}
 #define OPT_CALLBACK_OPTARG(s, l, v, d, a, h, f) \
{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), \
- .value = (v), (a), .help = (h), .callback = (f), \
+ .value = (v), .argh = (a), .help = (h), .callback = (f), \
  .flags = PARSE_OPT_OPTARG, .data = (d) }
 
 /* parse_options() will filter out the processed options and leave the
-- 
2.1.4


[PATCH] tools/lib/subcmd: Fix missing member name

2017-01-13 Thread Soramichi AKIYAMA
This patch adds missing member names to struct initializations.
Although in C99 for struct S {int x, int y} two init codes
struct S s = {.x = (a), (b)} and struct S s = {.x = (a), .y = (b)}
are the same, it is better to explicitly write .y (.argh in this patch)
for readability and robustness against language/compiler evolutions.

Signed-off-by: Soramichi Akiyama 
---
 tools/lib/subcmd/parse-options.h | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/tools/lib/subcmd/parse-options.h b/tools/lib/subcmd/parse-options.h
index 37e2d1a..f054ca1 100644
--- a/tools/lib/subcmd/parse-options.h
+++ b/tools/lib/subcmd/parse-options.h
@@ -133,32 +133,32 @@ struct option {
 #define OPT_UINTEGER(s, l, v, h){ .type = OPTION_UINTEGER, .short_name = 
(s), .long_name = (l), .value = check_vtype(v, unsigned int *), .help = (h) }
 #define OPT_LONG(s, l, v, h){ .type = OPTION_LONG, .short_name = (s), 
.long_name = (l), .value = check_vtype(v, long *), .help = (h) }
 #define OPT_U64(s, l, v, h) { .type = OPTION_U64, .short_name = (s), 
.long_name = (l), .value = check_vtype(v, u64 *), .help = (h) }
-#define OPT_STRING(s, l, v, a, h)   { .type = OPTION_STRING,  .short_name = 
(s), .long_name = (l), .value = check_vtype(v, const char **), (a), .help = (h) 
}
+#define OPT_STRING(s, l, v, a, h)   { .type = OPTION_STRING,  .short_name = 
(s), .long_name = (l), .value = check_vtype(v, const char **), .argh = (a), 
.help = (h) }
 #define OPT_STRING_OPTARG(s, l, v, a, h, d) \
{ .type = OPTION_STRING,  .short_name = (s), .long_name = (l), \
- .value = check_vtype(v, const char **), (a), .help = (h), \
+ .value = check_vtype(v, const char **), .argh =(a), .help = (h), \
  .flags = PARSE_OPT_OPTARG, .defval = (intptr_t)(d) }
 #define OPT_STRING_OPTARG_SET(s, l, v, os, a, h, d) \
{ .type = OPTION_STRING, .short_name = (s), .long_name = (l), \
- .value = check_vtype(v, const char **), (a), .help = (h), \
+ .value = check_vtype(v, const char **), .argh = (a), .help = (h), \
  .flags = PARSE_OPT_OPTARG, .defval = (intptr_t)(d), \
  .set = check_vtype(os, bool *)}
-#define OPT_STRING_NOEMPTY(s, l, v, a, h)   { .type = OPTION_STRING,  
.short_name = (s), .long_name = (l), .value = check_vtype(v, const char **), 
(a), .help = (h), .flags = PARSE_OPT_NOEMPTY}
+#define OPT_STRING_NOEMPTY(s, l, v, a, h)   { .type = OPTION_STRING,  
.short_name = (s), .long_name = (l), .value = check_vtype(v, const char **), 
.argh = (a), .help = (h), .flags = PARSE_OPT_NOEMPTY}
 #define OPT_DATE(s, l, v, h) \
{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), .argh = "time", .help = (h), .callback = parse_opt_approxidate_cb }
 #define OPT_CALLBACK(s, l, v, a, h, f) \
-   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), (a), .help = (h), .callback = (f) }
+   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), .argh = (a), .help = (h), .callback = (f) }
 #define OPT_CALLBACK_NOOPT(s, l, v, a, h, f) \
-   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), (a), .help = (h), .callback = (f), .flags = PARSE_OPT_NOARG }
+   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), .argh = (a), .help = (h), .callback = (f), .flags = PARSE_OPT_NOARG }
 #define OPT_CALLBACK_DEFAULT(s, l, v, a, h, f, d) \
-   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), (a), .help = (h), .callback = (f), .defval = (intptr_t)d, .flags = 
PARSE_OPT_LASTARG_DEFAULT }
+   { .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), .value 
= (v), .argh = (a), .help = (h), .callback = (f), .defval = (intptr_t)d, .flags 
= PARSE_OPT_LASTARG_DEFAULT }
 #define OPT_CALLBACK_DEFAULT_NOOPT(s, l, v, a, h, f, d) \
{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l),\
-   .value = (v), (a), .help = (h), .callback = (f), .defval = (intptr_t)d,\
+   .value = (v), .arg = (a), .help = (h), .callback = (f), .defval = 
(intptr_t)d,\
.flags = PARSE_OPT_LASTARG_DEFAULT | PARSE_OPT_NOARG}
 #define OPT_CALLBACK_OPTARG(s, l, v, d, a, h, f) \
{ .type = OPTION_CALLBACK, .short_name = (s), .long_name = (l), \
- .value = (v), (a), .help = (h), .callback = (f), \
+ .value = (v), .argh = (a), .help = (h), .callback = (f), \
  .flags = PARSE_OPT_OPTARG, .data = (d) }
 
 /* parse_options() will filter out the processed options and leave the
-- 
2.1.4


[tip:perf/core] perf evlist: Fix typo in perf_evlist__start_workload()

2017-01-12 Thread tip-bot for Soramichi Akiyama
Commit-ID:  e978be9ea2990f1af60fe10eadd2312a6250e0b8
Gitweb: http://git.kernel.org/tip/e978be9ea2990f1af60fe10eadd2312a6250e0b8
Author: Soramichi Akiyama <akiy...@m.soramichi.jp>
AuthorDate: Tue, 10 Jan 2017 10:41:00 -0300
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Wed, 11 Jan 2017 16:48:01 -0300

perf evlist: Fix typo in perf_evlist__start_workload()

This patch fixes a typo: s/enable to/unable to/

Signed-off-by: Soramichi AKIYAMA <akiy...@m.soramichi.jp>
Cc: Alexander Shishkin <alexander.shish...@linux.intel.com>
Cc: Namhyung Kim <namhyung@lge.com>
Cc: Peter Zijlstra <pet...@infradead.org>
Fixes: bcf3145fbeb1 ("perf evlist: Enhance perf_evlist__start_workload()")
Link: 
http://lkml.kernel.org/r/2017011026.e1f7a766b4faf1f107ae2...@m.soramichi.jp
[ Wasn't applying, fixed it up by hand, added Fixes: tag ]
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/util/evlist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index d92e020..23e6f33 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1797,7 +1797,7 @@ int perf_evlist__start_workload(struct perf_evlist 
*evlist)
 */
ret = write(evlist->workload.cork_fd, , 1);
if (ret < 0)
-   perror("enable to write to pipe");
+   perror("unable to write to pipe");
 
close(evlist->workload.cork_fd);
return ret;


[tip:perf/core] perf evlist: Fix typo in perf_evlist__start_workload()

2017-01-12 Thread tip-bot for Soramichi Akiyama
Commit-ID:  e978be9ea2990f1af60fe10eadd2312a6250e0b8
Gitweb: http://git.kernel.org/tip/e978be9ea2990f1af60fe10eadd2312a6250e0b8
Author: Soramichi Akiyama 
AuthorDate: Tue, 10 Jan 2017 10:41:00 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 11 Jan 2017 16:48:01 -0300

perf evlist: Fix typo in perf_evlist__start_workload()

This patch fixes a typo: s/enable to/unable to/

Signed-off-by: Soramichi AKIYAMA 
Cc: Alexander Shishkin 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Fixes: bcf3145fbeb1 ("perf evlist: Enhance perf_evlist__start_workload()")
Link: 
http://lkml.kernel.org/r/2017011026.e1f7a766b4faf1f107ae2...@m.soramichi.jp
[ Wasn't applying, fixed it up by hand, added Fixes: tag ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/evlist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index d92e020..23e6f33 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1797,7 +1797,7 @@ int perf_evlist__start_workload(struct perf_evlist 
*evlist)
 */
ret = write(evlist->workload.cork_fd, , 1);
if (ret < 0)
-   perror("enable to write to pipe");
+   perror("unable to write to pipe");
 
close(evlist->workload.cork_fd);
return ret;


[PATCH] [Performance Events] Fix typo in tools/perf/evlist.c

2017-01-10 Thread Soramichi AKIYAMA
This patch fixes a typo: s/enable to/unable to/

Signed-off-by: Soramichi Akiyama <akiy...@m.soramichi.jp>
---
 tools/perf/util/evlist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index d92e020..23e6f33 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1797,7 +1797,7 @@ int perf_evlist__start_workload(struct perf_evlist 
*evlist)
 */
ret = write(evlist->workload.cork_fd, , 1);
if (ret < 0)
-   perror("enable to write to pipe");
+   perror("unable to write to pipe");
 
close(evlist->workload.cork_fd);
return ret;
-- 
2.1.4


[PATCH] [Performance Events] Fix typo in tools/perf/evlist.c

2017-01-10 Thread Soramichi AKIYAMA
This patch fixes a typo: s/enable to/unable to/

Signed-off-by: Soramichi Akiyama 
---
 tools/perf/util/evlist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index d92e020..23e6f33 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1797,7 +1797,7 @@ int perf_evlist__start_workload(struct perf_evlist 
*evlist)
 */
ret = write(evlist->workload.cork_fd, , 1);
if (ret < 0)
-   perror("enable to write to pipe");
+   perror("unable to write to pipe");
 
close(evlist->workload.cork_fd);
return ret;
-- 
2.1.4