Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dmitry Ilvokhin" <d@ilvokhin.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 1/3] perf record: Fix multiple PERF_RECORD_COMPRESSED2 records per push
Date: Tue, 30 Jun 2026 07:32:36 +0000	[thread overview]
Message-ID: <20260630073237.450281F000E9@smtp.kernel.org> (raw)
In-Reply-To: <079503c01a3e28d3775947f3449cadacfa1f4117.1782743187.git.d@ilvokhin.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Missing explicit `#include <string.h>` for `memset` in `builtin-record.c`.
--

commit cb8ac7d313a36a42601f85ffc5fb9a9061002bc0
Author: Dmitry Ilvokhin <d@ilvokhin.com>

perf record: Fix multiple PERF_RECORD_COMPRESSED2 records per push

This commit frames compressed records individually when produced rather
than rewriting a single header for an entire blob. This prevents truncation
of the header.size field when a compressed blob exceeds 64KB.

> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index 4a5eba498c025..2562c3177eae1 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c

[ ... ]

> @@ -1590,18 +1577,29 @@ static void record__adjust_affinity(struct record *rec, struct mmap *map)
>  	}
>  }
>  
> -static size_t process_comp_header(void *record, size_t increment)
> +/*
> + * Called once with data_size == 0 to start a record, then once with
> + * data_size == compressed payload size to finalize and 8-byte-pad it
> + * (unaligned records trip ASan in the reader).
> + */
> +static size_t process_comp_header(void *record, size_t data_size)
>  {
>  	struct perf_record_compressed2 *event = record;
>  	size_t size = sizeof(*event);
>  
> -	if (increment) {
> -		event->header.size += increment;
> -		return increment;
> +	if (data_size) {
> +		size_t padding;
> +
> +		event->data_size = data_size;
> +		event->header.size = PERF_ALIGN(size + data_size, sizeof(u64));
> +		padding = event->header.size - size - data_size;
> +		memset(record + size + data_size, 0, padding);

[Severity: Low]
Does this file need an explicit include for <string.h>?

Relying on implicit header inclusion for POSIX libc functions like memset can
cause build failures on systems using musl libc, where implicit header graphs
differ from glibc.

> +		return data_size + padding;
>  	}
>  
>  	event->header.type = PERF_RECORD_COMPRESSED2;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1782743187.git.d@ilvokhin.com?part=1

  reply	other threads:[~2026-06-30  7:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-30  7:16 [PATCH v2 0/3] perf record: fix multi-record Zstd compression Dmitry Ilvokhin
2026-06-30  7:17 ` [PATCH v2 1/3] perf record: Fix multiple PERF_RECORD_COMPRESSED2 records per push Dmitry Ilvokhin
2026-06-30  7:32   ` sashiko-bot [this message]
2026-06-30  7:17 ` [PATCH v2 2/3] perf record: Avoid overrunning the zstd output buffer Dmitry Ilvokhin
2026-06-30  7:17 ` [PATCH v2 3/3] perf record: Don't store raw data on zstd compression failure Dmitry Ilvokhin

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=20260630073237.450281F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=d@ilvokhin.com \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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