linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] perf record: Reduce memory for recording lost samples event
@ 2023-12-07  2:16 Ian Rogers
  2024-01-03  2:59 ` Ian Rogers
  2024-01-03 16:45 ` Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 3+ messages in thread
From: Ian Rogers @ 2023-12-07  2:16 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Ian Rogers, Adrian Hunter, linux-perf-users, linux-kernel

Reduce from PERF_SAMPLE_MAX_SIZE to "sizeof(*lost) +
session->machines.host.id_hdr_size".

Suggested-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Ian Rogers <irogers@google.com>
---
Suggested in:
https://lore.kernel.org/lkml/CAM9d7cjpYHN_Q63sW70vTCisdW=-SzjsrryUUJjgtZ3+9jdxfA@mail.gmail.com/
---
 tools/perf/builtin-record.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index eb5a398ddb1d..206110fc2799 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -1954,7 +1954,8 @@ static void record__read_lost_samples(struct record *rec)
 
 				if (count.lost) {
 					if (!lost) {
-						lost = zalloc(PERF_SAMPLE_MAX_SIZE);
+						lost = zalloc(sizeof(*lost) +
+							      session->machines.host.id_hdr_size);
 						if (!lost) {
 							pr_debug("Memory allocation failed\n");
 							return;
@@ -1970,7 +1971,8 @@ static void record__read_lost_samples(struct record *rec)
 		lost_count = perf_bpf_filter__lost_count(evsel);
 		if (lost_count) {
 			if (!lost) {
-				lost = zalloc(PERF_SAMPLE_MAX_SIZE);
+				lost = zalloc(sizeof(*lost) +
+					      session->machines.host.id_hdr_size);
 				if (!lost) {
 					pr_debug("Memory allocation failed\n");
 					return;
-- 
2.43.0.rc2.451.g8631bc7472-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-01-03 16:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-07  2:16 [PATCH v1] perf record: Reduce memory for recording lost samples event Ian Rogers
2024-01-03  2:59 ` Ian Rogers
2024-01-03 16:45 ` Arnaldo Carvalho de Melo

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).