Linux Test Project
 help / color / mirror / Atom feed
From: Wake Liu via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Cc: kaleshsingh@google.com
Subject: [LTP] [PATCH 2/2] pipe2_04: Don't assume the minimum pipe size is getpagesize()
Date: Mon, 16 Nov 2026 07:23:46 +0000	[thread overview]
Message-ID: <20261116072346.2462510-3-wakel@google.com> (raw)
In-Reply-To: <20261116072346.2462510-1-wakel@google.com>

F_SETPIPE_SZ rounds the requested size up to the minimum pipe capacity,
which is a single pipe buffer of one kernel page. The test expects that
to be equal to the page size reported to userspace.

That is not the case when the kernel reports a larger page size to
userspace than it uses internally, as with the 16K page size emulation
that Android uses on x86_64:

  TFAIL: Pipe size (4096) must be page size (16384)

Check that F_GETPIPE_SZ on the other end of the pipe returns the size
set by F_SETPIPE_SZ, which is what the test is about, and that the
minimum size does not exceed the page size. The rest of the test
already uses the actual pipe size.

Signed-off-by: Wake Liu <wakel@google.com>
---
 testcases/kernel/syscalls/pipe2/pipe2_04.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/testcases/kernel/syscalls/pipe2/pipe2_04.c b/testcases/kernel/syscalls/pipe2/pipe2_04.c
index 3911f95b4..7b071a420 100644
--- a/testcases/kernel/syscalls/pipe2/pipe2_04.c
+++ b/testcases/kernel/syscalls/pipe2/pipe2_04.c
@@ -57,7 +57,7 @@ static void test_pipe2(void)
 
 static void setup(void)
 {
-	int page_size, pipe_size;
+	int page_size, pipe_size, set_size;
 	char *write_buffer;
 
 	SAFE_PIPE2(fds, O_NONBLOCK);
@@ -70,17 +70,24 @@ static void setup(void)
 	 * A pipe has two file descriptors.
 	 * But in the kernel these two file descriptors point to the same pipe.
 	 * So setting size from first file handle set size for the pipe.
+	 *
+	 * The size is rounded up to the minimum pipe capacity, i.e. a single
+	 * pipe buffer of one kernel page, which is not necessarily the same
+	 * as the page size reported to userspace.
 	 */
-	SAFE_FCNTL(fds[0], F_SETPIPE_SZ, 0);
+	set_size = SAFE_FCNTL(fds[0], F_SETPIPE_SZ, 0);
+	if (set_size > page_size)
+		tst_res(TFAIL, "Minimum pipe size (%d) exceeds page size (%d)",
+				set_size, page_size);
 
 	/*
 	 * So getting size from the second file descriptor return the size of
 	 * the pipe which was changed before with first file descriptor.
 	 */
 	pipe_size = SAFE_FCNTL(fds[1], F_GETPIPE_SZ);
-	if (pipe_size != page_size)
-		tst_res(TFAIL, "Pipe size (%d) must be page size (%d)",
-				pipe_size, page_size);
+	if (pipe_size != set_size)
+		tst_res(TFAIL, "Pipe size (%d) must be the size set (%d)",
+				pipe_size, set_size);
 
 	write_buffer = SAFE_MALLOC(pipe_size);
 	memset(write_buffer, 'x', pipe_size);
-- 
2.56.0.611.g1030f0b940-goog


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2026-11-16  7:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  7:23 [LTP] [PATCH 0/2] msync04, pipe2_04: Support kernel/userspace page size mismatch Wake Liu via ltp
2026-11-16  7:23 ` [LTP] [PATCH 1/2] msync04: Check smaps when the page frame number is not exposed Wake Liu via ltp
2026-11-16 12:09   ` [LTP] " linuxtestproject.agent
2026-11-16  7:23 ` Wake Liu via ltp [this message]
2026-11-16 14:22 ` [LTP] [PATCH v2 0/2] msync04, pipe2_04: Support kernel/userspace page size mismatch Wake Liu via ltp
2026-11-16 14:22   ` [LTP] [PATCH v2 1/2] msync04: Check smaps when the page frame number is not exposed Wake Liu via ltp
2026-11-16 22:35     ` [LTP] " linuxtestproject.agent
2026-11-16 14:22   ` [LTP] [PATCH v2 2/2] pipe2_04: Don't assume the minimum pipe size is getpagesize() Wake Liu via ltp
2026-11-24  8:42   ` [LTP] [PATCH v2 0/2] msync04, pipe2_04: Support kernel/userspace page size mismatch Wake Liu via ltp

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=20261116072346.2462510-3-wakel@google.com \
    --to=ltp@lists.linux.it \
    --cc=kaleshsingh@google.com \
    --cc=wakel@google.com \
    /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