lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 8 Oct 2019 21:18:13 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Song Liu <songliubraving@...com>
Cc:     linux-kernel@...r.kernel.org, kernel-team@...com,
        stable@...r.kernel.org, Arnaldo Carvalho de Melo <acme@...nel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Sasha Levin <sashal@...nel.org>
Subject: Re: [PATCH v2] perf/core: fix corner case in perf_rotate_context()

On Tue, Oct 08, 2019 at 09:59:49AM -0700, Song Liu wrote:
> In perf_rotate_context(), when the first cpu flexible event fail to
> schedule, cpu_rotate is 1, while cpu_event is NULL. Since cpu_event is
> NULL, perf_rotate_context will _NOT_ call cpu_ctx_sched_out(), thus
> cpuctx->ctx.is_active will have EVENT_FLEXIBLE set. Then, the next
> perf_event_sched_in() will skip all cpu flexible events because of the
> EVENT_FLEXIBLE bit.
> 
> In the next call of perf_rotate_context(), cpu_rotate stays 1, and
> cpu_event stays NULL, so this process repeats. The end result is, flexible
> events on this cpu will not be scheduled (until another event being added
> to the cpuctx).
> 
> Here is an easy repro of this issue. On Intel CPUs, where ref-cycles
> could only use one counter, run one pinned event for ref-cycles, one
> flexible event for ref-cycles, and one flexible event for cycles. The
> flexible ref-cycles is never scheduled, which is expected. However,
> because of this issue, the cycles event is never scheduled either.
> 
> perf stat -e ref-cycles:D,ref-cycles,cycles -C 5 -I 1000
>            time             counts unit events
>     1.000152973         15,412,480      ref-cycles:D
>     1.000152973      <not counted>      ref-cycles     (0.00%)
>     1.000152973      <not counted>      cycles         (0.00%)
>     2.000486957         18,263,120      ref-cycles:D
>     2.000486957      <not counted>      ref-cycles     (0.00%)
>     2.000486957      <not counted>      cycles         (0.00%)
> 
> To fix this, when the flexible_active list is empty, try rotate the
> first event in the flexible_groups. Also, rename ctx_first_active() to
> ctx_event_to_rotate(), which is more accurate.
> 
> Fixes: 8d5bce0c37fa ("perf/core: Optimize perf_rotate_context() event scheduling")
> Cc: stable@...r.kernel.org # v4.17+
> Cc: Peter Zijlstra <peterz@...radead.org>
> Cc: Arnaldo Carvalho de Melo <acme@...nel.org>
> Cc: Thomas Gleixner <tglx@...utronix.de>
> Cc: Sasha Levin <sashal@...nel.org>
> Signed-off-by: Song Liu <songliubraving@...com>

Thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ