Skip to contentSkip to conversation

perf session: Fix handling when buffer exceeds 2 GiB

PATCH Applied Leo Yan 3 participants 3 messages Aug 8, 2025 – Sep 17, 2025 perf events

lore
Share & tools
lore

Leo Yan

author
#0 lore raw

PATCH 1/1 perf session: Fix handling when buffer exceeds 2 GiB

If a user specifies an AUX buffer larger than 2 GiB, the returned size may exceed 0x80000000. Since the err variable is defined as a signed 32-bit integer, such a value overflows and becomes negative.

As a result, the perf record command reports an error:

0x146e8 [0x30]: failed to process type: 71 [Unknown error 183711232]

Change the type of the err variable to a signed 64-bit integer to accommodate large buffer sizes correctly.

Fixes d5652d865ea7 ("perf session: Add ability to skip 4GiB or more")
---
 tools/perf/util/session.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/session.c +1 -1
index 26ae078278cd67fc5894c01cbb44c4b8fa81321a..09af486c83e4ff82e74f17f3da08d3bc3989768b 100644
@@ -1402,7 +1402,7 @@ static s64 perf_session__process_user_event(struct perf_session *session,
 	const struct perf_tool *tool = session->tool;
 	struct perf_sample sample;
 	int fd = perf_data__fd(session->data);
-	int err;
+	s64 err;
 
 	perf_sample__init(&sample, /*all=*/true);
 	if ((event->header.type != PERF_RECORD_COMPRESSED &&

---
base-commit: 6235ce77749f45cac27f630337e2fdf04e8a6c73
change-id: 20250808-perf_fix_big_buffer_size-e28f618df61c

Best regards,

Signature · 1 line
Leo Yan <[email protected]>
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Leo Yan

If a user specifies an AUX buffer larger than 2 GiB, the returned size may exceed 0x80000000. Since the err variable is defined as a signed 32-bit integer, such a value overflows and becomes negative.

As a result, the perf record command reports an error:

Quoted 8 lines

0x146e8 [0x30]: failed to process type: 71 [Unknown error 183711232]

Change the type of the err variable to a signed 64-bit integer to accommodate large buffer sizes correctly.

Fixes d5652d865ea7 ("perf session: Add ability to skip 4GiB or more")

Thanks,
Namhyung

Quoted 26 lines
---
 tools/perf/util/session.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/session.c +1 -2
index 26ae078278cd67fc5894c01cbb44c4b8fa81321a..09af486c83e4ff82e74f17f3da08d3bc3989768b 100644
@@ -1402,7 +1402,7 @@ static s64 perf_session__process_user_event(struct perf_session *session,
 	const struct perf_tool *tool = session->tool;
 	struct perf_sample sample;
 	int fd = perf_data__fd(session->data);
-	int err;
+	s64 err;
 
 	perf_sample__init(&sample, /*all=*/true);
 	if ((event->header.type != PERF_RECORD_COMPRESSED &&
 
---

base-commit: 6235ce77749f45cac27f630337e2fdf04e8a6c73
change-id: 20250808-perf_fix_big_buffer_size-e28f618df61c

Best regards,

Signature · 1 line
Leo Yan <[email protected]>
maintainer Applied
#2 lore raw
Quoted 9 lines · Namhyung Kim
Quoted 8 lines · Leo Yan

If a user specifies an AUX buffer larger than 2 GiB, the returned size may exceed 0x80000000. Since the err variable is defined as a signed 32-bit integer, such a value overflows and becomes negative.

As a result, the perf record command reports an error:

0x146e8 [0x30]: failed to process type: 71 [Unknown error 183711232]

Quoted 8 lines
Quoted 6 lines

Change the type of the err variable to a signed 64-bit integer to accommodate large buffer sizes correctly.

Fixes d5652d865ea7 ("perf session: Add ability to skip 4GiB or more")

Thanks, applied to perf-tools-next,

- Arnaldo