Re: [PATCH] perf: correct ctx_event_type in ctx_resched()
From: Peter Zijlstra
Date: Tue Mar 06 2018 - 03:54:50 EST
On Mon, Mar 05, 2018 at 09:55:04PM -0800, Song Liu wrote:
> In ctx_resched(), EVENT_FLEXIBLE should be sched_out when EVENT_PINNED is
> added. However, ctx_resched() calculates ctx_event_type before checking
> this condition. As a result, pinned events will NOT get higher priority
> than flexible events.
>
> The following shows this issue on an Intel CPU (where ref-cycles can
> only use one hardware counter).
>
> 1. First start:
> perf stat -C 0 -e ref-cycles -I 1000
> 2. Then, in the second console, run:
> perf stat -C 0 -e ref-cycles:D -I 1000
>
> The second perf uses pinned events, which is expected to have higher
> priority. However, because it failed in ctx_resched(). It is never
> run.
>
> This patch fixes this by calculating ctx_event_type after re-evaluating
> event_type.
>
> Fixes: 487f05e18aa4 ("perf/core: Optimize event rescheduling on active contexts")
> Signed-off-by: Song Liu <songliubraving@xxxxxx>
> Reported-by: Ephraim Park <ephiepark@xxxxxx>
Thanks!