From: sashiko-bot@kernel.org
To: "Qiliang Yuan" <qiliang.yuan@linux.dev>
Cc: dri-devel@lists.freedesktop.org, media-ci@linuxtv.org
Subject: Re: [PATCH v4 3/3] selftests/udmabuf: test mapping a huge page backed udmabuf
Date: Sat, 05 Dec 2026 15:35:03 +0000 [thread overview]
Message-ID: <sashiko-outbox-251702@kernel.org> (raw)
In-Reply-To: <20261205-feat-udmabuf-huge-pfnmap-v4-3-c1e1a1d22e27@linux.dev>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Low] selftests/udmabuf: test_huge_mapping() fails instead of skipping
on ENOMEM
- [Low] selftests/udmabuf: missing skip reasons and broad madvise() skip
- [Low] selftests/udmabuf: 32-bit size overflow in test_huge_mapping()
and read_size()
--
commit 7bf6e5af4a4c3adbec3f31e720d6121b01f5b50e
Author: Qiliang Yuan <qiliang.yuan@linux.dev>
selftests/udmabuf: test mapping a huge page backed udmabuf
This commit adds four selftest cases in test_huge_mapping() to verify
mapping a huge-page-backed udmabuf across PMD-aligned, unaligned, forked,
PTE-only, and MADV_NOHUGEPAGE mappings.
> diff --git a/tools/testing/selftests/drivers/dma-buf/udmabuf.c b/tools/testing/selftests/drivers/dma-buf/udmabuf.c
> index d78aec662586b..1f4b7dd1f610e 100644
> --- a/tools/testing/selftests/drivers/dma-buf/udmabuf.c
> +++ b/tools/testing/selftests/drivers/dma-buf/udmabuf.c
[ ... ]
> +static void test_huge_mapping(int devfd)
> +{
> + size_t pmd = read_size("/sys/kernel/mm/transparent_hugepage/hpage_pmd_size",
> + NULL);
> + size_t hpage = read_size("/proc/meminfo", "Hugepagesize");
> + struct udmabuf_create create = {};
> + int memfd, buf, sub, status, test;
> + size_t unit, size;
> + char *mem, *addr;
> + pid_t pid;
> + bool ok;
> +
> + if (!hpage) {
> + for (test = 8; test <= 11; test++)
> + ksft_test_result_skip("%s: [SKIP,test-%d]\n",
> + TEST_PREFIX, test);
> + return;
> + }
> + unit = hpage > pmd ? hpage : pmd;
> + size = 8 * unit;
[Severity: Low]
Can 8 * unit overflow size_t on a 32-bit build?
test_huge_mapping() explicitly handles 32-bit tasks via the
sizeof(long) != 8 check below, but when unit is 512 MiB or 1 GiB (for
example on a 64-bit kernel with default_hugepagesz=1G), 8 * unit wraps to
0. mmap_fd(memfd, 0) then fails with EINVAL and aborts with KSFT_FAIL
instead of skipping tests 8 through 11.
Similarly, read_size() shifts a 32-bit unsigned long left by 10, which
overflows silently if Hugepagesize is 4 GiB or larger.
> +
> + memfd = create_memfd_with_seals(size, true);
> + mem = mmap_fd(memfd, size);
[Severity: Low]
Will mmap_fd() abort the test instead of skipping when fewer than 8 huge
pages are free?
/proc/meminfo reports a non-zero Hugepagesize whenever hugetlb is
supported, even if the pool has fewer than 8 free huge pages (for instance
with default_hugepagesz=1G and 2 to 7 free pages, where earlier tests
pass). mmap_fd() calls exit(KSFT_FAIL) on ENOMEM, which fails the run
and truncates output before tests 8 through 11 are reported.
[ ... ]
> + /* Map a PMD, disable THP for the mapping, then fault next to the PMD */
> + addr = mmap(NULL, size, PROT_READ, MAP_SHARED, buf, 0);
> + ok = addr != MAP_FAILED && addr[0] == mem[0];
> + if (ok && madvise(addr, size, MADV_NOHUGEPAGE)) {
> + munmap(addr, size);
> + ksft_test_result_skip("%s: [SKIP,test-11]\n", TEST_PREFIX);
> + } else {
[Severity: Low]
Should this skip test-11 only when madvise() fails with EINVAL, and include
a skip reason?
madvise(MADV_NOHUGEPAGE) returns EINVAL when transparent huge pages are
disabled, but madvise_vma_behavior() can also return EAGAIN on ENOMEM,
which would be masked as a skip instead of a failure here. Both this skip
and the !hpage skip above also omit the missing-prerequisite reason string
expected by kselftest.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261205-feat-udmabuf-huge-pfnmap-v4-0-c1e1a1d22e27@linux.dev?part=3
prev parent reply other threads:[~2026-12-05 15:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 15:16 [PATCH v4 0/3] udmabuf: speed up mmap() of huge page backed buffers Qiliang Yuan
2026-12-05 15:16 ` [PATCH v4 1/3] dma-buf: align large mappings to PMD boundaries Qiliang Yuan
2026-12-05 15:16 ` [PATCH v4 2/3] udmabuf: map huge page backed ranges with PMDs Qiliang Yuan
2026-12-05 15:37 ` sashiko-bot
2026-12-05 15:16 ` [PATCH v4 3/3] selftests/udmabuf: test mapping a huge page backed udmabuf Qiliang Yuan
2026-12-05 15:35 ` sashiko-bot [this message]
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=sashiko-outbox-251702@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=media-ci@linuxtv.org \
--cc=qiliang.yuan@linux.dev \
--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