Skip to content

Commit ce2814f

Browse files
committed
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf: Fix double start/stop in x86_pmu_start() perf evsel: Fix an issue where perf report fails to show the proper percentage perf tools: Fix prefix matching for kernel maps perf tools: Fix perf stack to non executable on x86_64 perf: Remove deprecated WARN_ON_ONCE()
2 parents 1282ab3 + f39d47f commit ce2814f

File tree

6 files changed

+22
-9
lines changed

6 files changed

+22
-9
lines changed

arch/x86/kernel/cpu/perf_event_intel_ds.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,6 @@ void intel_pmu_pebs_enable(struct perf_event *event)
439439
hwc->config &= ~ARCH_PERFMON_EVENTSEL_INT;
440440

441441
cpuc->pebs_enabled |= 1ULL << hwc->idx;
442-
WARN_ON_ONCE(cpuc->enabled);
443442

444443
if (x86_pmu.intel_cap.pebs_trap && event->attr.precise_ip > 1)
445444
intel_pmu_lbr_enable(event);

arch/x86/kernel/cpu/perf_event_intel_lbr.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ void intel_pmu_lbr_enable(struct perf_event *event)
7272
if (!x86_pmu.lbr_nr)
7373
return;
7474

75-
WARN_ON_ONCE(cpuc->enabled);
76-
7775
/*
7876
* Reset the LBR stack if we changed task context to
7977
* avoid data leaks.

kernel/events/core.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2303,7 +2303,7 @@ do { \
23032303
static DEFINE_PER_CPU(int, perf_throttled_count);
23042304
static DEFINE_PER_CPU(u64, perf_throttled_seq);
23052305

2306-
static void perf_adjust_period(struct perf_event *event, u64 nsec, u64 count)
2306+
static void perf_adjust_period(struct perf_event *event, u64 nsec, u64 count, bool disable)
23072307
{
23082308
struct hw_perf_event *hwc = &event->hw;
23092309
s64 period, sample_period;
@@ -2322,9 +2322,13 @@ static void perf_adjust_period(struct perf_event *event, u64 nsec, u64 count)
23222322
hwc->sample_period = sample_period;
23232323

23242324
if (local64_read(&hwc->period_left) > 8*sample_period) {
2325-
event->pmu->stop(event, PERF_EF_UPDATE);
2325+
if (disable)
2326+
event->pmu->stop(event, PERF_EF_UPDATE);
2327+
23262328
local64_set(&hwc->period_left, 0);
2327-
event->pmu->start(event, PERF_EF_RELOAD);
2329+
2330+
if (disable)
2331+
event->pmu->start(event, PERF_EF_RELOAD);
23282332
}
23292333
}
23302334

@@ -2350,6 +2354,7 @@ static void perf_adjust_freq_unthr_context(struct perf_event_context *ctx,
23502354
return;
23512355

23522356
raw_spin_lock(&ctx->lock);
2357+
perf_pmu_disable(ctx->pmu);
23532358

23542359
list_for_each_entry_rcu(event, &ctx->event_list, event_entry) {
23552360
if (event->state != PERF_EVENT_STATE_ACTIVE)
@@ -2381,13 +2386,17 @@ static void perf_adjust_freq_unthr_context(struct perf_event_context *ctx,
23812386
/*
23822387
* restart the event
23832388
* reload only if value has changed
2389+
* we have stopped the event so tell that
2390+
* to perf_adjust_period() to avoid stopping it
2391+
* twice.
23842392
*/
23852393
if (delta > 0)
2386-
perf_adjust_period(event, period, delta);
2394+
perf_adjust_period(event, period, delta, false);
23872395

23882396
event->pmu->start(event, delta > 0 ? PERF_EF_RELOAD : 0);
23892397
}
23902398

2399+
perf_pmu_enable(ctx->pmu);
23912400
raw_spin_unlock(&ctx->lock);
23922401
}
23932402

@@ -4562,7 +4571,7 @@ static int __perf_event_overflow(struct perf_event *event,
45624571
hwc->freq_time_stamp = now;
45634572

45644573
if (delta > 0 && delta < 2*TICK_NSEC)
4565-
perf_adjust_period(event, delta, hwc->last_period);
4574+
perf_adjust_period(event, delta, hwc->last_period, true);
45664575
}
45674576

45684577
/*
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11

22
#include "../../../arch/x86/lib/memcpy_64.S"
3+
/*
4+
* We need to provide note.GNU-stack section, saying that we want
5+
* NOT executable stack. Otherwise the final linking will assume that
6+
* the ELF stack should not be restricted at all and set it RWX.
7+
*/
8+
.section .note.GNU-stack,"",@progbits

tools/perf/util/event.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ static int perf_event__process_kernel_mmap(struct perf_tool *tool __used,
554554

555555
is_kernel_mmap = memcmp(event->mmap.filename,
556556
kmmap_prefix,
557-
strlen(kmmap_prefix)) == 0;
557+
strlen(kmmap_prefix) - 1) == 0;
558558
if (event->mmap.filename[0] == '/' ||
559559
(!is_kernel_mmap && event->mmap.filename[0] == '[')) {
560560

tools/perf/util/evsel.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ int perf_event__parse_sample(const union perf_event *event, u64 type,
463463
memset(data, 0, sizeof(*data));
464464
data->cpu = data->pid = data->tid = -1;
465465
data->stream_id = data->id = data->time = -1ULL;
466+
data->period = 1;
466467

467468
if (event->header.type != PERF_RECORD_SAMPLE) {
468469
if (!sample_id_all)

0 commit comments

Comments
 (0)