Skip to content

Commit 772c1d0

Browse files
committed
Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf updates from Ingo Molnar: "Kernel side changes: - Improved kbprobes robustness - Intel PEBS support for PT hardware tracing - Other Intel PT improvements: high order pages memory footprint reduction and various related cleanups - Misc cleanups The perf tooling side has been very busy in this cycle, with over 300 commits. This is an incomplete high-level summary of the many improvements done by over 30 developers: - Lots of updates to the following tools: 'perf c2c' 'perf config' 'perf record' 'perf report' 'perf script' 'perf test' 'perf top' 'perf trace' - Updates to libperf and libtraceevent, and a consolidation of the proliferation of x86 instruction decoder libraries. - Vendor event updates for Intel and PowerPC CPUs, - Updates to hardware tracing tooling for ARM and Intel CPUs, - ... and lots of other changes and cleanups - see the shortlog and Git log for details" * 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (322 commits) kprobes: Prohibit probing on BUG() and WARN() address perf/x86: Make more stuff static x86, perf: Fix the dependency of the x86 insn decoder selftest objtool: Ignore intentional differences for the x86 insn decoder objtool: Update sync-check.sh from perf's check-headers.sh perf build: Ignore intentional differences for the x86 insn decoder perf intel-pt: Use shared x86 insn decoder perf intel-pt: Remove inat.c from build dependency list perf: Update .gitignore file objtool: Move x86 insn decoder to a common location perf metricgroup: Support multiple events for metricgroup perf metricgroup: Scale the metric result perf pmu: Change convert_scale from static to global perf symbols: Move mem_info and branch_info out of symbol.h perf auxtrace: Uninline functions that touch perf_session perf tools: Remove needless evlist.h include directives perf tools: Remove needless evlist.h include directives perf tools: Remove needless thread_map.h include directives perf tools: Remove needless thread.h include directives perf tools: Remove needless map.h include directives ...
2 parents c7eba51 + e336b40 commit 772c1d0

File tree

441 files changed

+13375
-8857
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

441 files changed

+13375
-8857
lines changed

arch/x86/Kconfig.debug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ config HAVE_MMIOTRACE_SUPPORT
171171

172172
config X86_DECODER_SELFTEST
173173
bool "x86 instruction decoder selftest"
174-
depends on DEBUG_KERNEL && KPROBES
174+
depends on DEBUG_KERNEL && INSTRUCTION_DECODER
175175
depends on !COMPILE_TEST
176176
---help---
177177
Perform x86 instruction decoder selftests at build time.

arch/x86/events/core.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,27 @@ static int collect_events(struct cpu_hw_events *cpuc, struct perf_event *leader,
10051005

10061006
/* current number of events already accepted */
10071007
n = cpuc->n_events;
1008+
if (!cpuc->n_events)
1009+
cpuc->pebs_output = 0;
1010+
1011+
if (!cpuc->is_fake && leader->attr.precise_ip) {
1012+
/*
1013+
* For PEBS->PT, if !aux_event, the group leader (PT) went
1014+
* away, the group was broken down and this singleton event
1015+
* can't schedule any more.
1016+
*/
1017+
if (is_pebs_pt(leader) && !leader->aux_event)
1018+
return -EINVAL;
1019+
1020+
/*
1021+
* pebs_output: 0: no PEBS so far, 1: PT, 2: DS
1022+
*/
1023+
if (cpuc->pebs_output &&
1024+
cpuc->pebs_output != is_pebs_pt(leader) + 1)
1025+
return -EINVAL;
1026+
1027+
cpuc->pebs_output = is_pebs_pt(leader) + 1;
1028+
}
10081029

10091030
if (is_x86_event(leader)) {
10101031
if (n >= max_count)
@@ -2241,6 +2262,17 @@ static int x86_pmu_check_period(struct perf_event *event, u64 value)
22412262
return 0;
22422263
}
22432264

2265+
static int x86_pmu_aux_output_match(struct perf_event *event)
2266+
{
2267+
if (!(pmu.capabilities & PERF_PMU_CAP_AUX_OUTPUT))
2268+
return 0;
2269+
2270+
if (x86_pmu.aux_output_match)
2271+
return x86_pmu.aux_output_match(event);
2272+
2273+
return 0;
2274+
}
2275+
22442276
static struct pmu pmu = {
22452277
.pmu_enable = x86_pmu_enable,
22462278
.pmu_disable = x86_pmu_disable,
@@ -2266,6 +2298,8 @@ static struct pmu pmu = {
22662298
.sched_task = x86_pmu_sched_task,
22672299
.task_ctx_size = sizeof(struct x86_perf_task_context),
22682300
.check_period = x86_pmu_check_period,
2301+
2302+
.aux_output_match = x86_pmu_aux_output_match,
22692303
};
22702304

22712305
void arch_perf_update_userpage(struct perf_event *event,

arch/x86/events/intel/core.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <asm/cpufeature.h>
1919
#include <asm/hardirq.h>
2020
#include <asm/intel-family.h>
21+
#include <asm/intel_pt.h>
2122
#include <asm/apic.h>
2223
#include <asm/cpu_device_id.h>
2324

@@ -3298,6 +3299,13 @@ static int intel_pmu_hw_config(struct perf_event *event)
32983299
}
32993300
}
33003301

3302+
if (event->attr.aux_output) {
3303+
if (!event->attr.precise_ip)
3304+
return -EINVAL;
3305+
3306+
event->hw.flags |= PERF_X86_EVENT_PEBS_VIA_PT;
3307+
}
3308+
33013309
if (event->attr.type != PERF_TYPE_RAW)
33023310
return 0;
33033311

@@ -3816,6 +3824,14 @@ static int intel_pmu_check_period(struct perf_event *event, u64 value)
38163824
return intel_pmu_has_bts_period(event, value) ? -EINVAL : 0;
38173825
}
38183826

3827+
static int intel_pmu_aux_output_match(struct perf_event *event)
3828+
{
3829+
if (!x86_pmu.intel_cap.pebs_output_pt_available)
3830+
return 0;
3831+
3832+
return is_intel_pt_event(event);
3833+
}
3834+
38193835
PMU_FORMAT_ATTR(offcore_rsp, "config1:0-63");
38203836

38213837
PMU_FORMAT_ATTR(ldlat, "config1:0-15");
@@ -3940,6 +3956,8 @@ static __initconst const struct x86_pmu intel_pmu = {
39403956
.sched_task = intel_pmu_sched_task,
39413957

39423958
.check_period = intel_pmu_check_period,
3959+
3960+
.aux_output_match = intel_pmu_aux_output_match,
39433961
};
39443962

39453963
static __init void intel_clovertown_quirk(void)

arch/x86/events/intel/cstate.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,15 +446,15 @@ static int cstate_cpu_init(unsigned int cpu)
446446
return 0;
447447
}
448448

449-
const struct attribute_group *core_attr_update[] = {
449+
static const struct attribute_group *core_attr_update[] = {
450450
&group_cstate_core_c1,
451451
&group_cstate_core_c3,
452452
&group_cstate_core_c6,
453453
&group_cstate_core_c7,
454454
NULL,
455455
};
456456

457-
const struct attribute_group *pkg_attr_update[] = {
457+
static const struct attribute_group *pkg_attr_update[] = {
458458
&group_cstate_pkg_c2,
459459
&group_cstate_pkg_c3,
460460
&group_cstate_pkg_c6,

arch/x86/events/intel/ds.c

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,9 @@ struct event_constraint *intel_pebs_constraints(struct perf_event *event)
902902
*/
903903
static inline bool pebs_needs_sched_cb(struct cpu_hw_events *cpuc)
904904
{
905+
if (cpuc->n_pebs == cpuc->n_pebs_via_pt)
906+
return false;
907+
905908
return cpuc->n_pebs && (cpuc->n_pebs == cpuc->n_large_pebs);
906909
}
907910

@@ -919,6 +922,9 @@ static inline void pebs_update_threshold(struct cpu_hw_events *cpuc)
919922
u64 threshold;
920923
int reserved;
921924

925+
if (cpuc->n_pebs_via_pt)
926+
return;
927+
922928
if (x86_pmu.flags & PMU_FL_PEBS_ALL)
923929
reserved = x86_pmu.max_pebs_events + x86_pmu.num_counters_fixed;
924930
else
@@ -1059,10 +1065,40 @@ void intel_pmu_pebs_add(struct perf_event *event)
10591065
cpuc->n_pebs++;
10601066
if (hwc->flags & PERF_X86_EVENT_LARGE_PEBS)
10611067
cpuc->n_large_pebs++;
1068+
if (hwc->flags & PERF_X86_EVENT_PEBS_VIA_PT)
1069+
cpuc->n_pebs_via_pt++;
10621070

10631071
pebs_update_state(needed_cb, cpuc, event, true);
10641072
}
10651073

1074+
static void intel_pmu_pebs_via_pt_disable(struct perf_event *event)
1075+
{
1076+
struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
1077+
1078+
if (!is_pebs_pt(event))
1079+
return;
1080+
1081+
if (!(cpuc->pebs_enabled & ~PEBS_VIA_PT_MASK))
1082+
cpuc->pebs_enabled &= ~PEBS_VIA_PT_MASK;
1083+
}
1084+
1085+
static void intel_pmu_pebs_via_pt_enable(struct perf_event *event)
1086+
{
1087+
struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
1088+
struct hw_perf_event *hwc = &event->hw;
1089+
struct debug_store *ds = cpuc->ds;
1090+
1091+
if (!is_pebs_pt(event))
1092+
return;
1093+
1094+
if (!(event->hw.flags & PERF_X86_EVENT_LARGE_PEBS))
1095+
cpuc->pebs_enabled |= PEBS_PMI_AFTER_EACH_RECORD;
1096+
1097+
cpuc->pebs_enabled |= PEBS_OUTPUT_PT;
1098+
1099+
wrmsrl(MSR_RELOAD_PMC0 + hwc->idx, ds->pebs_event_reset[hwc->idx]);
1100+
}
1101+
10661102
void intel_pmu_pebs_enable(struct perf_event *event)
10671103
{
10681104
struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
@@ -1100,6 +1136,8 @@ void intel_pmu_pebs_enable(struct perf_event *event)
11001136
} else {
11011137
ds->pebs_event_reset[hwc->idx] = 0;
11021138
}
1139+
1140+
intel_pmu_pebs_via_pt_enable(event);
11031141
}
11041142

11051143
void intel_pmu_pebs_del(struct perf_event *event)
@@ -1111,6 +1149,8 @@ void intel_pmu_pebs_del(struct perf_event *event)
11111149
cpuc->n_pebs--;
11121150
if (hwc->flags & PERF_X86_EVENT_LARGE_PEBS)
11131151
cpuc->n_large_pebs--;
1152+
if (hwc->flags & PERF_X86_EVENT_PEBS_VIA_PT)
1153+
cpuc->n_pebs_via_pt--;
11141154

11151155
pebs_update_state(needed_cb, cpuc, event, false);
11161156
}
@@ -1120,7 +1160,8 @@ void intel_pmu_pebs_disable(struct perf_event *event)
11201160
struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
11211161
struct hw_perf_event *hwc = &event->hw;
11221162

1123-
if (cpuc->n_pebs == cpuc->n_large_pebs)
1163+
if (cpuc->n_pebs == cpuc->n_large_pebs &&
1164+
cpuc->n_pebs != cpuc->n_pebs_via_pt)
11241165
intel_pmu_drain_pebs_buffer();
11251166

11261167
cpuc->pebs_enabled &= ~(1ULL << hwc->idx);
@@ -1131,6 +1172,8 @@ void intel_pmu_pebs_disable(struct perf_event *event)
11311172
else if (event->hw.flags & PERF_X86_EVENT_PEBS_ST)
11321173
cpuc->pebs_enabled &= ~(1ULL << 63);
11331174

1175+
intel_pmu_pebs_via_pt_disable(event);
1176+
11341177
if (cpuc->enabled)
11351178
wrmsrl(MSR_IA32_PEBS_ENABLE, cpuc->pebs_enabled);
11361179

@@ -2031,6 +2074,12 @@ void __init intel_ds_init(void)
20312074
PERF_SAMPLE_REGS_INTR);
20322075
}
20332076
pr_cont("PEBS fmt4%c%s, ", pebs_type, pebs_qual);
2077+
2078+
if (x86_pmu.intel_cap.pebs_output_pt_available) {
2079+
pr_cont("PEBS-via-PT, ");
2080+
x86_get_pmu()->capabilities |= PERF_PMU_CAP_AUX_OUTPUT;
2081+
}
2082+
20342083
break;
20352084

20362085
default:

arch/x86/events/intel/lbr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ static inline bool lbr_from_signext_quirk_needed(void)
273273
return !tsx_support && (lbr_desc[lbr_format] & LBR_TSX);
274274
}
275275

276-
DEFINE_STATIC_KEY_FALSE(lbr_from_quirk_key);
276+
static DEFINE_STATIC_KEY_FALSE(lbr_from_quirk_key);
277277

278278
/* If quirk is enabled, ensure sign extension is 63 bits: */
279279
inline u64 lbr_from_signext_quirk_wr(u64 val)

0 commit comments

Comments
 (0)