Skip to content

Commit

Permalink
MIPS, Perf-events: Fix event check in validate_event()
Browse files Browse the repository at this point in the history
Ignore events that are in off/error state or belong to a different PMU.

This patch originates from the following commit for ARM by Will Deacon:

- 65b4711
    ARM: 6352/1: perf: fix event validation

    The validate_event function in the ARM perf events backend has the
    following problems:

    1.) Events that are disabled count towards the cost.
    2.) Events associated with other PMUs [for example, software events or
        breakpoints] do not count towards the cost, but do fail validation,
        causing the group to fail.

    This patch changes validate_event so that it ignores events in the
    PERF_EVENT_STATE_OFF state or that are scheduled for other PMUs.

Acked-by: Will Deacon <[email protected]>
Acked-by: David Daney <[email protected]>
Signed-off-by: Deng-Cheng Zhu <[email protected]>
To: [email protected]
To: [email protected]
To: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Patchwork: http://patchwork.linux-mips.org/patch/2013/
Signed-off-by: Ralf Baechle <[email protected]>
  • Loading branch information
dczhu authored and ralfbaechle committed Mar 14, 2011
1 parent 404ff63 commit c049b6a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions arch/mips/kernel/perf_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,9 @@ static int validate_event(struct cpu_hw_events *cpuc,
{
struct hw_perf_event fake_hwc = event->hw;

if (event->pmu && event->pmu != &pmu)
return 0;
/* Allow mixed event group. So return 1 to pass validation. */
if (event->pmu != &pmu || event->state <= PERF_EVENT_STATE_OFF)
return 1;

return mipspmu->alloc_counter(cpuc, &fake_hwc) >= 0;
}
Expand Down

0 comments on commit c049b6a

Please sign in to comment.