Skip to contentSkip to conversation

perf record: Reduce memory for recording lost samples event

PATCH Applied Ian Rogers 2 participants 3 messages Dec 7, 2023 – Jan 3, 2024 perf events

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

PATCH 1/1 perf record: Reduce memory for recording lost samples event

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

---
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(-)
tools/perf/builtin-record.c +4 -2
index eb5a398ddb1d..206110fc2799 100644
@@ -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;
Signature · 1 line
2.43.0.rc2.451.g8631bc7472-goog
author reviewer
#1 lore raw
Quoted 6 lines · Ian Rogers

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

Ping.

Thanks,
Ian

Quoted 34 lines

---
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(-)
tools/perf/builtin-record.c +4 -3
index eb5a398ddb1d..206110fc2799 100644
@@ -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

maintainer Applied
#2 lore raw
In reply to Ian Rogers

Em Wed, Dec 06, 2023 at 06:16:27PM -0800, Ian Rogers escreveu:

Quoted 4 lines

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

Thanks, applied to perf-tools-next.

- Arnaldo

Quoted 35 lines

---
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(-)
tools/perf/builtin-record.c +4 -2
index eb5a398ddb1d..206110fc2799 100644
@@ -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;
Signature · 1 line
2.43.0.rc2.451.g8631bc7472-goog
Signature · 1 line
- Arnaldo