Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Breno Leitao" <leitao@debian.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2] perf bench: add --write-size option to sched pipe
Date: Thu, 21 May 2026 16:39:50 +0000	[thread overview]
Message-ID: <20260521163951.2E2FB1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260521-perf_bench_pipe-v2-1-720b6ff7f0fa@debian.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] File descriptors allocated for pipes are leaked when returning early due to an fcntl() failure.
--

commit a15da46bb7bbcff2fe4b600fd4cd1fdf6d6d3ff0
Author: Breno Leitao <leitao@debian.org>

perf bench: add --write-size option to sched pipe

This commit adds a --write-size option to the sched pipe benchmark in perf to
allow testing the pipe page-allocation path. It updates the benchmark to
allocate a buffer per thread and resize the pipe capacity via fcntl() when a
larger write size is specified.

> diff --git a/tools/perf/bench/sched-pipe.c b/tools/perf/bench/sched-pipe.c
> index 70139036d68f0..216d3121d438d 100644
> --- a/tools/perf/bench/sched-pipe.c
> +++ b/tools/perf/bench/sched-pipe.c
[ ... ]
> @@ -233,12 +238,39 @@ int bench_sched_pipe(int argc, const char **argv)
[ ... ]
>  	BUG_ON(pipe2(pipe_1, flags));
>  	BUG_ON(pipe2(pipe_2, flags));
>  
> +	/*
> +	 * On a custom write_size, resize the pipes so a single payload fits.
> +	 */
> +	if (write_size > sizeof(int)) {
> +		int r1 = fcntl(pipe_1[1], F_SETPIPE_SZ, write_size);
> +		int r2 = fcntl(pipe_2[1], F_SETPIPE_SZ, write_size);
> +
> +		if (r1 < 0 || r2 < 0 ||
> +		    (unsigned int)r1 < write_size ||
> +		    (unsigned int)r2 < write_size) {
> +			fprintf(stderr,
> +				"--write-size %u exceeds /proc/sys/fs/pipe-max-size\n",
> +				write_size);
> +			return -1;

[Severity: Medium]
Are the file descriptors allocated for pipe_1 and pipe_2 leaked on this error
path?

The pipe2() calls just above this block allocate four file descriptors. If the
fcntl() operations fail and this path returns -1, those descriptors appear to
be left open.

> +		}
> +	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260521-perf_bench_pipe-v2-1-720b6ff7f0fa@debian.org?part=1

  reply	other threads:[~2026-05-21 16:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-21 16:15 [PATCH v2] perf bench: add --write-size option to sched pipe Breno Leitao
2026-05-21 16:39 ` sashiko-bot [this message]
2026-05-21 17:12   ` Breno Leitao
2026-05-26  2:17 ` Namhyung Kim

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=20260521163951.2E2FB1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=leitao@debian.org \
    --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