linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ravi Bangoria <ravi.bangoria@amd.com>
To: <acme@kernel.org>
Cc: <ravi.bangoria@amd.com>, <jolsa@kernel.org>,
	<namhyung@kernel.org>, <irogers@google.com>,
	<peterz@infradead.org>, <adrian.hunter@intel.com>,
	<kan.liang@intel.com>, <eranian@google.com>, <ak@linux.intel.com>,
	<linux-perf-users@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <sandipan.das@amd.com>,
	<ananth.narayan@amd.com>, <santosh.shukla@amd.com>
Subject: [RFC] perf record: Use PERF_RECORD_LOST for synthesizing samples from read_format->lost
Date: Fri, 23 Jun 2023 13:50:31 +0530	[thread overview]
Message-ID: <20230623082031.1402-1-ravi.bangoria@amd.com> (raw)

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.

Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
---
Notes:
 - Posting this as RFC to get feedback. I haven't tested it well.
 - There is one more minor issue: Aggregated Stats shows count of LOST/
   LOST_SAMPLES records instead of actual number of lost events/samples:
     ```
     $ sudo ./perf report -D | tail -20
     Warning:
     Processed 78923 events and lost 1153 chunks!
     Warning:
     Processed 47427 samples and lost 28.30%!
     ...
     Aggregated stats:
               LOST events:       1153  ( 1.5%)
       LOST_SAMPLES events:        132  ( 0.2%)
     ```
   Not sure if this is intentional.

 tools/perf/builtin-record.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index efa03e4ac2c9..5baed42437b2 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1858,7 +1858,7 @@ record__switch_output(struct record *rec, bool at_exit)
 }
 
 static void __record__save_lost_samples(struct record *rec, struct evsel *evsel,
-					struct perf_record_lost_samples *lost,
+					struct perf_record_lost *lost,
 					int cpu_idx, int thread_idx, u64 lost_count,
 					u16 misc_flag)
 {
@@ -1871,6 +1871,7 @@ static void __record__save_lost_samples(struct record *rec, struct evsel *evsel,
 		sid = xyarray__entry(evsel->core.sample_id, cpu_idx, thread_idx);
 		sample.id = sid->id;
 	}
+	lost->id = sid->id;
 
 	id_hdr_size = perf_event__synthesize_id_sample((void *)(lost + 1),
 						       evsel->core.attr.sample_type, &sample);
@@ -1882,7 +1883,7 @@ static void __record__save_lost_samples(struct record *rec, struct evsel *evsel,
 static void record__read_lost_samples(struct record *rec)
 {
 	struct perf_session *session = rec->session;
-	struct perf_record_lost_samples *lost;
+	struct perf_record_lost *lost;
 	struct evsel *evsel;
 
 	/* there was an error during record__open */
@@ -1895,7 +1896,7 @@ static void record__read_lost_samples(struct record *rec)
 		return;
 	}
 
-	lost->header.type = PERF_RECORD_LOST_SAMPLES;
+	lost->header.type = PERF_RECORD_LOST;
 
 	evlist__for_each_entry(session->evlist, evsel) {
 		struct xyarray *xy = evsel->core.sample_id;
-- 
2.41.0


             reply	other threads:[~2023-06-23  8:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-23  8:20 Ravi Bangoria [this message]
2023-06-24  5:55 ` [RFC] perf record: Use PERF_RECORD_LOST for synthesizing samples from read_format->lost Namhyung Kim
2023-06-26  6:06   ` Ravi Bangoria

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=20230623082031.1402-1-ravi.bangoria@amd.com \
    --to=ravi.bangoria@amd.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=ananth.narayan@amd.com \
    --cc=eranian@google.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=sandipan.das@amd.com \
    --cc=santosh.shukla@amd.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).