History

perf, powerpc: Fix power_pmu_event_init to not use event->ctx

Commit c3f00c70 ("perf: Separate find_get_context() from event initialization") changed the generic perf_event code to call perf_event_alloc, which calls the arch-specific event_init code, before looking up the context for the new event. Unfortunately, power_pmu_event_init uses event->ctx->task to see whether the new event is a per-task event or a system-wide event, and thus crashes since event->ctx is NULL at the point where power_pmu_event_init gets called. (The reason it needs to know whether it is a per-task event is because there are some hardware events on Power systems which only count when the processor is not idle, and there are some fixed-function counters which count such events. For example, the "run cycles" event counts cycles when the processor is not idle. If the user asks to count cycles, we can use "run cycles" if this is a per-task event, since the processor is running when the task is running, by definition. We can't use "run cycles" if the user asks for "cycles" on a system-wide counter.) Fortunately the information we need is in the event->attach_state field, so we just use that instead.

Paul Mackerras committed 16 years ago

Commit 57fa7211 parent 1fa41261 file · +1 −1Browse files

Unified · Split

arch/powerpc/kernel/perf_event.c+1−1
@@ -1092,7 +1092,7 @@ static int power_pmu_event_init(struct perf_event *event) · 1091 unmodified lines
10921092 * XXX we should check if the task is an idle task.
10931093 */
10941094 flags = 0;
1095− if (event->ctx->task)
1095+ if (event->attach_state & PERF_ATTACH_TASK)
10961096 flags |= PPMU_ONLY_COUNT_RUN;
10971097
10981098 /*

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t