Skip to content

msync04, pipe2_04: Support kernel/userspace page size mismatch

Wake Liu via ltp ltp 2 versions In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 1 replyIn review
  2. v12 patches 1 replySuperseded

Changes in v2 from the cover letter

- pipe2_04: Drop the check that the minimum pipe size doesn't exceed getpagesize(), which fails with 16K kernel pages and a 4K page size reported to userspace (Kalesh).
- Rebased on current master.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2msync04: Check smaps when the page frame number is not exposedtestcases/kernel/syscalls/msync/msync04.c+44 -21 reply
2/2pipe2_04: Don't assume the minimum pipe size is getpagesize()testcases/kernel/syscalls/pipe2/pipe2_04.c+9 -60 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [LTP] [PATCH v2 0/2] msync04, pipe2_04: Support kernel/userspace page size mismatch

Hi,

This is the follow-up to the earlier series [1] for running LTP under the 16K page size emulation of the Android Common Kernels [2] (page_shift=14 on the kernel command line on x86_64), where the kernel reports a 16K page size to userspace while keeping 4K pages internally.

These two patches were kept separate from [1] because they adjust how msync04 and pipe2_04 verify the tested behavior:

- msync04: under the emulation, each /proc/self/pagemap entry covers four 4K kernel pages and therefore exposes no PFN (PFN == 0 even for root), so the test falls back to TCONF. When PM_PRESENT is set and PFN is 0, check Shared_Dirty and Private_Dirty of the mapping in /proc/self/smaps instead. Nothing changes on kernels that expose the PFN to root.
- pipe2_04: F_SETPIPE_SZ(0) rounds the capacity up to a single pipe buffer of one kernel page, which can be smaller or larger than getpagesize(). Only checking that F_GETPIPE_SZ on the other end matches the size returned by F_SETPIPE_SZ preserves the cross-fd check without assuming a pipe buffer is getpagesize() bytes.

Changes in v2:
- pipe2_04: Drop the check that the minimum pipe size doesn't exceed getpagesize(), which fails with 16K kernel pages and a 4K page size reported to userspace (Kalesh).
- Rebased on current master.

Tested on:
- x86_64 with a 4K page size (Debian, 7.1 kernel), where pipe2_04 passes and both tests compile without warnings with gcc and clang.
- An Android x86_64 emulator with a 4K page size (6.6 kernel), where both tests pass before and after.
- An Android x86_64 Cuttlefish device running 6.18.32-android17 with page_shift=14, where msync04 goes from 4x TCONF to 4x TPASS and pipe2_04 goes from TFAIL to TPASS.

For v2, pipe2_04 was also run on the same Cuttlefish device and on the 4K x86_64 host with getpagesize() and sysconf(_SC_PAGESIZE) wrapped to return 1K, to mimic kernel pages that are larger than the page size reported to userspace. v1 fails there with "Minimum pipe size (4096) exceeds page size (1024)", while v2 passes both as is and wrapped.

v1: https://lore.kernel.org/ltp/[email protected]/

[1] https://lore.kernel.org/ltp/[email protected]/
[2] https://source.android.com/docs/core/architecture/16kb-page-size/getting-started-cf-x86-64-pgagnostic

Wake Liu (2):
msync04: Check smaps when the page frame number is not exposed
pipe2_04: Don't assume the minimum pipe size is getpagesize()

 testcases/kernel/syscalls/msync/msync04.c  | 46 +++++++++++++++++++++-
 testcases/kernel/syscalls/pipe2/pipe2_04.c | 15 ++++---
 2 files changed, 53 insertions(+), 8 deletions(-)

base-commit: c4be3107083cd11e4732884c4c8c5e9c6665e729

Signature · 5 lines
2.56.0.611.g1030f0b940-goog


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