Re: [RFC] perf record: Use PERF_RECORD_LOST for synthesizing samples from read_format->lost

From: Ravi Bangoria
Date: Mon Jun 26 2023 - 02:07:04 EST


On 24-Jun-23 11:25 AM, Namhyung Kim wrote:
> Hi Ravi,
>
> On Fri, Jun 23, 2023 at 1:21 AM Ravi Bangoria <ravi.bangoria@xxxxxxx> wrote:
>>
>> Currently perf synthesizes PERF_RECORD_LOST_SAMPLES samples for values
>> returned by read_format->lost. IIUC, PERF_RECORD_LOST_SAMPLES is used
>> only when hw provides corrupted samples and thus kernel has to drop
>> those. OTOH, PERF_RECORD_LOST is used when kernel has valid samples but
>> it fails to push them to ring-buffer because ring-buffer is already full.
>>
>> So I feel PERF_RECORD_LOST is more appropriate for synthesizing samples
>> from read_format->lost.
>
> The problem of PERF_RECORD_LOST is that it counts non-sample
> records too. It just counts every lost records and put the number
> when it can find a space in the ring buffer later. We don't know
> which one is lost and how many of it.
>
> Some users want to get the accurate number of samples even if it's
> not recorded in the ring buffer. Using PERF_RECORD_LOST can be
> confusing since the kernel will return inaccurate data in terms of the
> number of lost samples. So I chose PERF_RECORD_LOST_SAMPLES
> to return the accurate number for each event.

Ok. Thanks for the clarification.

Ravi