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 v2 2/2] pipe2_04: Don't assume the minimum pipe size is getpagesize()
Date: Mon, 16 Nov 2026 14:22:40 +0000	[thread overview]
Message-ID: <20261116142240.3153725-3-wakel@google.com> (raw)
In-Reply-To: <20261116142240.3153725-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 page size reported to userspace differs
from the one the kernel uses internally. With the 16K page size
emulation that Android uses on x86_64 the test fails with:

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

Conversely, with 16K kernel pages and a 4K page size reported to
userspace, the minimum pipe size is 16384 instead of the expected 4096.

As the minimum pipe size can't be derived from getpagesize(), only
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. The rest of the
test already uses the actual pipe size.

Suggested-by: Kalesh Singh <kaleshsingh@google.com>
Signed-off-by: Wake Liu <wakel@google.com>
---

Notes:
    Changes in v2:
    - Drop the check that the minimum pipe size doesn't exceed
      getpagesize(), which fails when the kernel uses larger pages than
      reported to userspace (Kalesh)

 testcases/kernel/syscalls/pipe2/pipe2_04.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/testcases/kernel/syscalls/pipe2/pipe2_04.c b/testcases/kernel/syscalls/pipe2/pipe2_04.c
index 3911f95b4..91aacab79 100644
--- a/testcases/kernel/syscalls/pipe2/pipe2_04.c
+++ b/testcases/kernel/syscalls/pipe2/pipe2_04.c
@@ -57,11 +57,10 @@ static void test_pipe2(void)
 
 static void setup(void)
 {
-	int page_size, pipe_size;
+	int pipe_size, set_size;
 	char *write_buffer;
 
 	SAFE_PIPE2(fds, O_NONBLOCK);
-	page_size = SAFE_SYSCONF(_SC_PAGESIZE);
 
 	flags = SAFE_FCNTL(fds[1], F_GETFL);
 	if (!(flags & O_NONBLOCK))
@@ -70,17 +69,21 @@ 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 can be smaller or larger than
+	 * the page size reported to userspace.
 	 */
-	SAFE_FCNTL(fds[0], F_SETPIPE_SZ, 0);
+	set_size = SAFE_FCNTL(fds[0], F_SETPIPE_SZ, 0);
 
 	/*
 	 * 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 14: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 ` [LTP] [PATCH 2/2] pipe2_04: Don't assume the minimum pipe size is getpagesize() Wake Liu via ltp
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   ` Wake Liu via ltp [this message]
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=20261116142240.3153725-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