[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190517142648.GC2589@hirez.programming.kicks-ass.net>
Date: Fri, 17 May 2019 16:26:48 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Ingo Molnar <mingo@...nel.org>
Cc: yabinc@...gle.com, acme@...nel.org,
alexander.shishkin@...ux.intel.com, jolsa@...hat.com,
namhyung@...nel.org, mark.rutland@....com,
linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...hat.com>
Subject: Re: [PATCH 1/4] perf/ring_buffer: Fix exposing a temporarily
decreased data_head.
On Fri, May 17, 2019 at 03:05:09PM +0200, Ingo Molnar wrote:
>
> * Peter Zijlstra <peterz@...radead.org> wrote:
>
> > In perf_output_put_handle(), an IRQ/NMI can happen in below location and
> > write records to the same ring buffer:
> > ...
> > local_dec_and_test(&rb->nest)
> > ... <-- an IRQ/NMI can happen here
> > rb->user_page->data_head = head;
> > ...
> >
> > In this case, a value A is written to data_head in the IRQ, then a value
> > B is written to data_head after the IRQ. And A > B. As a result,
> > data_head is temporarily decreased from A to B. And a reader may see
> > data_head < data_tail if it read the buffer frequently enough, which
> > creates unexpected behaviors.
> >
> > This can be fixed by moving dec(&rb->nest) to after updating data_head,
> > which prevents the IRQ/NMI above from updating data_head.
> >
> > Cc: Arnaldo Carvalho de Melo <acme@...nel.org>
> > Cc: Ingo Molnar <mingo@...hat.com>
> > Cc: Jiri Olsa <jolsa@...hat.com>
> > Cc: Namhyung Kim <namhyung@...nel.org>
> > Cc: Alexander Shishkin <alexander.shishkin@...ux.intel.com>
> > Fixes: ef60777c9abd ("perf: Optimize the perf_output() path by removing IRQ-disables")
> > Signed-off-by: Yabin Cui <yabinc@...gle.com>
> > Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
> > Link: https://lkml.kernel.org/r/20190516184010.167903-1-yabinc@google.com
>
> So these are missing a bunch of:
>
> From: Yabin Cui <yabinc@...gle.com>
>
> lines, right?
>
The first. certainly, the rest, while inspired by his patch, is more
complete than what he did.
Powered by blists - more mailing lists