From: Greg KH <greg@kroah.com>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: stable@vger.kernel.org
Subject: Re: [PATCH 4.19] perf/x86/intel/pt: Fix buffer full but size is 0 case
Date: Fri, 6 Dec 2024 10:29:40 +0100 [thread overview]
Message-ID: <2024120630-retinal-drizzle-009a@gregkh> (raw)
In-Reply-To: <20241204181126.61934-1-adrian.hunter@intel.com>
On Wed, Dec 04, 2024 at 08:11:26PM +0200, Adrian Hunter wrote:
> commit 5b590160d2cf776b304eb054afafea2bd55e3620 upstream.
>
> If the trace data buffer becomes full, a truncated flag [T] is reported
> in PERF_RECORD_AUX. In some cases, the size reported is 0, even though
> data must have been added to make the buffer full.
>
> That happens when the buffer fills up from empty to full before the
> Intel PT driver has updated the buffer position. Then the driver
> calculates the new buffer position before calculating the data size.
> If the old and new positions are the same, the data size is reported
> as 0, even though it is really the whole buffer size.
>
> Fix by detecting when the buffer position is wrapped, and adjust the
> data size calculation accordingly.
>
> Example
>
> Use a very small buffer size (8K) and observe the size of truncated [T]
> data. Before the fix, it is possible to see records of 0 size.
>
> Before:
>
> $ perf record -m,8K -e intel_pt// uname
> Linux
> [ perf record: Woken up 2 times to write data ]
> [ perf record: Captured and wrote 0.105 MB perf.data ]
> $ perf script -D --no-itrace | grep AUX | grep -F '[T]'
> Warning:
> AUX data lost 2 times out of 3!
>
> 5 19462712368111 0x19710 [0x40]: PERF_RECORD_AUX offset: 0 size: 0 flags: 0x1 [T]
> 5 19462712700046 0x19ba8 [0x40]: PERF_RECORD_AUX offset: 0x170 size: 0xe90 flags: 0x1 [T]
>
> After:
>
> $ perf record -m,8K -e intel_pt// uname
> Linux
> [ perf record: Woken up 3 times to write data ]
> [ perf record: Captured and wrote 0.040 MB perf.data ]
> $ perf script -D --no-itrace | grep AUX | grep -F '[T]'
> Warning:
> AUX data lost 2 times out of 3!
>
> 1 113720802995 0x4948 [0x40]: PERF_RECORD_AUX offset: 0 size: 0x2000 flags: 0x1 [T]
> 1 113720979812 0x6b10 [0x40]: PERF_RECORD_AUX offset: 0x2000 size: 0x2000 flags: 0x1 [T]
>
> Fixes: 52ca9ced3f70 ("perf/x86/intel/pt: Add Intel PT PMU driver")
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Cc: stable@vger.kernel.org
> Link: https://lkml.kernel.org/r/20241022155920.17511-2-adrian.hunter@intel.com
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
> arch/x86/events/intel/pt.c | 11 ++++++++---
> arch/x86/events/intel/pt.h | 2 ++
> 2 files changed, 10 insertions(+), 3 deletions(-)
Sorry, but 4.19.y is now end-of-life.
prev parent reply other threads:[~2024-12-06 9:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-02 15:03 FAILED: patch "[PATCH] perf/x86/intel/pt: Fix buffer full but size is 0 case" failed to apply to 4.19-stable tree gregkh
2024-12-04 18:11 ` [PATCH 4.19] perf/x86/intel/pt: Fix buffer full but size is 0 case Adrian Hunter
2024-12-04 22:11 ` Sasha Levin
2024-12-06 9:29 ` Greg KH [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2024120630-retinal-drizzle-009a@gregkh \
--to=greg@kroah.com \
--cc=adrian.hunter@intel.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.