Skip to contentSkip to conversation

perf tools: set no branch type for dummy event in PT

PATCH In review [email protected] 2 participants 7 messages Jun 28, 2017 – Jun 30, 2017 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf tools: set no branch type for dummy event in PT

From: Kan Liang <[email protected]>

An earlier kernel patch allowed enabling PT and LBR at the same time on Goldmont.
commit ccbebba4c6bf ("perf/x86/intel/pt: Bypass PT vs. LBR exclusivity if the core supports it")
However, users still cannot use Intel PT and LBRs simultaneously.

    $ sudo perf record -e cycles,intel_pt//u -b  -- sleep 1
    Error:
    PMU Hardware doesn't support sampling/overflow-interrupts.

PT implicitly adds dummy event in perf tool. dummy event is software event which doesn't support LBR.

Always setting branch_type=no for dummy event in Intel PT.

---
 tools/perf/arch/x86/util/intel-pt.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
tools/perf/arch/x86/util/intel-pt.c +19 -0
index f630de0..651ab9e 100644
@@ -544,6 +544,22 @@ static int intel_pt_validate_config(struct perf_pmu *intel_pt_pmu,
 					evsel->attr.config);
 }
 
+static int add_no_lbr_config_term(struct list_head *config_terms)
+{
+	struct perf_evsel_config_term *lbr_term;
+
+	lbr_term = zalloc(sizeof(*lbr_term));
+	if (!lbr_term)
+		return -ENOMEM;
+
+	INIT_LIST_HEAD(&lbr_term->list);
+	lbr_term->type = PERF_EVSEL__CONFIG_TERM_BRANCH;
+	lbr_term->val.branch = strdup("no");
+	list_add_tail(&lbr_term->list, config_terms);
+
+	return 0;
+}
+
 static int intel_pt_recording_options(struct auxtrace_record *itr,
 				      struct perf_evlist *evlist,
 				      struct record_opts *opts)
@@ -701,6 +717,8 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
 				perf_evsel__set_sample_bit(switch_evsel, TIME);
 				perf_evsel__set_sample_bit(switch_evsel, CPU);
 
+				add_no_lbr_config_term(&switch_evsel->config_terms);
+
 				opts->record_switch_events = false;
 				ptr->have_sched_switch = 3;
 			} else {
@@ -760,6 +778,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
 			/* And the CPU for switch events */
 			perf_evsel__set_sample_bit(tracking_evsel, CPU);
 		}
+		add_no_lbr_config_term(&tracking_evsel->config_terms);
 	}
 
 	/*
Signature · 1 line
2.9.4
#1 lore raw
Quoted 49 lines · On Wed, Jun 28, 2017 at 10:31:53AM -0400, [email protected] wrote:

From: Kan Liang <[email protected]>

An earlier kernel patch allowed enabling PT and LBR at the same time on Goldmont.
commit ccbebba4c6bf ("perf/x86/intel/pt: Bypass PT vs. LBR exclusivity if the core supports it")
However, users still cannot use Intel PT and LBRs simultaneously.

    $ sudo perf record -e cycles,intel_pt//u -b  -- sleep 1
    Error:
    PMU Hardware doesn't support sampling/overflow-interrupts.

PT implicitly adds dummy event in perf tool. dummy event is software event which doesn't support LBR.

Always setting branch_type=no for dummy event in Intel PT.

---
 tools/perf/arch/x86/util/intel-pt.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
tools/perf/arch/x86/util/intel-pt.c +16 -0
index f630de0..651ab9e 100644
@@ -544,6 +544,22 @@ static int intel_pt_validate_config(struct perf_pmu *intel_pt_pmu,
 					evsel->attr.config);
 }
 
+static int add_no_lbr_config_term(struct list_head *config_terms)
+{
+	struct perf_evsel_config_term *lbr_term;
+
+	lbr_term = zalloc(sizeof(*lbr_term));
+	if (!lbr_term)
+		return -ENOMEM;
+
+	INIT_LIST_HEAD(&lbr_term->list);
+	lbr_term->type = PERF_EVSEL__CONFIG_TERM_BRANCH;
+	lbr_term->val.branch = strdup("no");
+	list_add_tail(&lbr_term->list, config_terms);
+
+	return 0;
+}
+
 static int intel_pt_recording_options(struct auxtrace_record *itr,
 				      struct perf_evlist *evlist,
 				      struct record_opts *opts)

tools/perf/arch/x86/util/intel-pt.c static int intel_pt_recording_options(struct auxtrace_record *itr, · line 721

Quoted 5 lines
tools/perf/arch/x86/util/intel-pt.c +2 -0
@@ -701,6 +717,8 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
 				perf_evsel__set_sample_bit(switch_evsel, TIME);
 				perf_evsel__set_sample_bit(switch_evsel, CPU);
 
+				add_no_lbr_config_term(&switch_evsel->config_terms);
+

hum, why can't you change the sample bit directly? with:

			perf_evsel__reset_sample_bit(switch_evsel, BRANCH_STACK);

jirka

author
#2 lore raw
Quoted 59 lines · On Wed, Jun 28, 2017 at 10:31:53AM -0400, [email protected] wrote:

tools/perf/arch/x86/util/intel-pt.c static int intel_pt_validate_config(struct perf_pmu

Quoted 27 lines

From: Kan Liang <[email protected]>

An earlier kernel patch allowed enabling PT and LBR at the same time on Goldmont.
commit ccbebba4c6bf ("perf/x86/intel/pt: Bypass PT vs. LBR exclusivity if the core supports it") However, users still cannot use Intel PT and LBRs simultaneously.

    $ sudo perf record -e cycles,intel_pt//u -b  -- sleep 1
    Error:
    PMU Hardware doesn't support sampling/overflow-interrupts.

PT implicitly adds dummy event in perf tool. dummy event is software event which doesn't support LBR.

Always setting branch_type=no for dummy event in Intel PT.

---
 tools/perf/arch/x86/util/intel-pt.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
tools/perf/arch/x86/util/intel-pt.c +0 -0
index f630de0..651ab9e 100644
@@ -544,6 +544,22 @@ static int intel_pt_validate_config(struct perf_pmu

*intel_pt_pmu,

tools/perf/arch/x86/util/intel-pt.c static int intel_pt_recording_options(struct

Quoted 22 lines
tools/perf/arch/x86/util/intel-pt.c +15 -0
 					evsel->attr.config);
 }
 
+static int add_no_lbr_config_term(struct list_head *config_terms) {
+	struct perf_evsel_config_term *lbr_term;
+
+	lbr_term = zalloc(sizeof(*lbr_term));
+	if (!lbr_term)
+		return -ENOMEM;
+
+	INIT_LIST_HEAD(&lbr_term->list);
+	lbr_term->type = PERF_EVSEL__CONFIG_TERM_BRANCH;
+	lbr_term->val.branch = strdup("no");
+	list_add_tail(&lbr_term->list, config_terms);
+
+	return 0;
+}
+
 static int intel_pt_recording_options(struct auxtrace_record *itr,
 				      struct perf_evlist *evlist,
 				      struct record_opts *opts)
@@ -701,6 +717,8 @@ static int intel_pt_recording_options(struct

auxtrace_record *itr,

tools/perf/arch/x86/util/intel-pt.c static int intel_pt_recording_options(struct · line 717

Quoted 1 line
tools/perf/arch/x86/util/intel-pt.c +0 -0
 				perf_evsel__set_sample_bit(switch_evsel,

TIME);

tools/perf/arch/x86/util/intel-pt.c static int intel_pt_recording_options(struct · line 718

Quoted 1 line
tools/perf/arch/x86/util/intel-pt.c +0 -0
 				perf_evsel__set_sample_bit(switch_evsel,

CPU);

Quoted 1 line
Quoted 8 lines
Quoted 3 lines
tools/perf/arch/x86/util/intel-pt.c +1 -0
+				add_no_lbr_config_term(&switch_evsel-

config_terms);
+

hum, why can't you change the sample bit directly? with:

perf_evsel__reset_sample_bit(switch_evsel,
BRANCH_STACK);

It will be overwrite in perf_evsel__config.

Thanks,
Kan

#3 lore raw

On Thu, Jun 29, 2017 at 03:31:45PM +0000, Liang, Kan wrote:

SNIP

Quoted 16 lines
Quoted 16 lines

tools/perf/arch/x86/util/intel-pt.c static int intel_pt_recording_options(struct

Quoted 4 lines

static int intel_pt_recording_options(struct auxtrace_record *itr,

tools/perf/arch/x86/util/intel-pt.c +0 -0
 				      struct perf_evlist *evlist,
 				      struct record_opts *opts)
@@ -701,6 +717,8 @@ static int intel_pt_recording_options(struct

auxtrace_record *itr,

Review static int intel_pt_recording_options(struct · line 717

Quoted 1 line
(quoted diff) +0 -0
 				perf_evsel__set_sample_bit(switch_evsel,

TIME);

Review static int intel_pt_recording_options(struct · line 718

Quoted 1 line
(quoted diff) +0 -0
 				perf_evsel__set_sample_bit(switch_evsel,

CPU);

Review static int intel_pt_recording_options(struct · line 721

Quoted 4 lines
(quoted diff) +2 -0
+				add_no_lbr_config_term(&switch_evsel-
 config_terms);
+

hum, why can't you change the sample bit directly? with:

Quoted 5 lines
Quoted 2 lines

perf_evsel__reset_sample_bit(switch_evsel,
BRANCH_STACK);

It will be overwrite in perf_evsel__config.

where? you set the evsel->no_aux_samples

jirka

author
#4 lore raw
Quoted 24 lines · Kan

SNIP

Quoted 3 lines
Quoted 3 lines

Review

Quoted 3 lines

static int intel_pt_recording_options(struct auxtrace_record *itr,

(quoted diff) +0 -0
 				      struct perf_evlist *evlist,
 				      struct record_opts *opts) @@ -701,6

+717,8 @@ static

Quoted 13 lines
Quoted 13 lines
Quoted 1 line

int intel_pt_recording_options(struct

auxtrace_record *itr,

Quoted 1 line

perf_evsel__set_sample_bit(switch_evsel,

TIME);

Quoted 1 line

perf_evsel__set_sample_bit(switch_evsel,

CPU);

Quoted 4 lines
(quoted diff) +1 -0
+				add_no_lbr_config_term(&switch_evsel-

config_terms);
+

hum, why can't you change the sample bit directly? with:

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

perf_evsel__reset_sample_bit(switch_evsel,
BRANCH_STACK);

It will be overwrite in perf_evsel__config.

where? you set the evsel->no_aux_samples

Yes for switch_evsel, but no for tracking_evsel.

If it's only for switch_evsel, yes, we can change the sample bit directly. But I think we should use the same method for both of them.

Thanks,
Kan

#5 lore raw
Quoted 30 lines · Kan
Quoted 30 lines · Kan

SNIP

Quoted 3 lines
Quoted 3 lines

Review

Quoted 3 lines

static int intel_pt_recording_options(struct auxtrace_record *itr,

(quoted diff) +0 -0
 				      struct perf_evlist *evlist,
 				      struct record_opts *opts) @@ -701,6

+717,8 @@ static

Quoted 18 lines
Quoted 7 lines
Quoted 1 line

int intel_pt_recording_options(struct

auxtrace_record *itr,

Quoted 1 line

perf_evsel__set_sample_bit(switch_evsel,

TIME);

Quoted 1 line

perf_evsel__set_sample_bit(switch_evsel,

CPU);

Quoted 1 line
Quoted 8 lines
Quoted 3 lines
(quoted diff) +1 -0
+				add_no_lbr_config_term(&switch_evsel-

config_terms);
+

hum, why can't you change the sample bit directly? with:

perf_evsel__reset_sample_bit(switch_evsel,
BRANCH_STACK);

It will be overwrite in perf_evsel__config.

Quoted 6 lines
Quoted 1 line

where? you set the evsel->no_aux_samples

Yes for switch_evsel, but no for tracking_evsel.

If it's only for switch_evsel, yes, we can change the sample bit directly. But I think we should use the same method for both of them.

we could set the no_aux_samples for the tracking_evsel as well

jirka

author
#6 lore raw
Quoted 39 lines · Kan
Quoted 10 lines
Quoted 10 lines · Kan

SNIP

Quoted 3 lines
Quoted 3 lines

Review

Quoted 3 lines

static int intel_pt_recording_options(struct auxtrace_record *itr,

(quoted diff) +0 -0
 				      struct perf_evlist *evlist,
 				      struct record_opts *opts) @@ -

701,6

Quoted 4 lines
Quoted 4 lines

+717,8 @@ static

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

int intel_pt_recording_options(struct

auxtrace_record *itr,

Quoted 1 line

perf_evsel__set_sample_bit(switch_evsel,

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

TIME);

Quoted 1 line

perf_evsel__set_sample_bit(switch_evsel,

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

CPU);

Quoted 2 lines

+

add_no_lbr_config_term(&switch_evsel-

Quoted 13 lines
Quoted 12 lines
Quoted 10 lines
Quoted 7 lines
Quoted 2 lines

config_terms);
+

hum, why can't you change the sample bit directly? with:

perf_evsel__reset_sample_bit(switch_evsel,
BRANCH_STACK);

It will be overwrite in perf_evsel__config.

where? you set the evsel->no_aux_samples

Quoted 8 lines
Quoted 4 lines

Yes for switch_evsel, but no for tracking_evsel.

If it's only for switch_evsel, yes, we can change the sample bit directly. But I think we should use the same method for both of them.

we could set the no_aux_samples for the tracking_evsel as well

Yes, I will do it in next version.

Thanks,
Kan