The selftests: mincore: mincore_selftest fails only on qemu-armv7 running
Linux next, mainline and stable branches.
Reported-by: Linux Kernel Functional Testing <[email protected]>
# selftests: mincore: mincore_selftest
# TAP version 13
# 1..5
# # Starting 5 tests from 1 test cases.
# # RUN global.basic_interface ...
# # OK global.basic_interface
# ok 1 global.basic_interface
# # RUN global.check_anonymous_locked_pages ...
# # OK global.check_anonymous_locked_pages
# ok 2 global.check_anonymous_locked_pages
# # RUN global.check_huge_pages ...
# # mincore_selftest.c:156:check_huge_pages:mmap error: Invalid argument
# # mincore_selftest.c:159:check_huge_pages:Expected 0 (0) == retval (-1)
# # check_huge_pages: Test terminated by assertion
# # FAIL global.check_huge_pages
# not ok 3 global.check_huge_pages
# # RUN global.check_file_mmap ...
# # OK global.check_file_mmap
# ok 4 global.check_file_mmap
# # RUN global.check_tmpfs_mmap ...
# # OK global.check_tmpfs_mmap
# ok 5 global.check_tmpfs_mmap
# # FAILED: 4 / 5 tests passed.
# # Totals: pass:4 fail:1 xfail:0 xpass:0 skip:0 error:0
logs:
https://tuxapi.tuxsuite.com/v1/groups/linaro/projects/lkft/tests/2PnaQ12zfS0p4KS5pP37ZIHJR0U
History:
https://qa-reports.linaro.org/lkft/linux-mainline-master/build/v6.4-rc2/testrun/16947285/suite/kselftest-mincore/test/mincore_mincore_selftest/history/
Steps to reproduce:
----------------
# To install tuxrun on your system globally:
# sudo pip3 install -U tuxrun==0.42.0
#
# See https://tuxrun.org/ for complete documentation.
tuxrun \
--runtime podman \
--device qemu-armv7 \
--boot-args rw \
--kernel https://storage.tuxsuite.com/public/linaro/lkft/builds/2PnaP3qqppMDr51qUdKv971IZrE/zImage
\
--modules https://storage.tuxsuite.com/public/linaro/lkft/builds/2PnaP3qqppMDr51qUdKv971IZrE/modules.tar.xz
\
--rootfs https://storage.tuxboot.com/debian/bookworm/armhf/rootfs.ext4.xz \
--parameters SKIPFILE=skipfile-lkft.yaml \
--parameters KSELFTEST=https://storage.tuxsuite.com/public/linaro/lkft/builds/2PnaP3qqppMDr51qUdKv971IZrE/kselftest.tar.xz
\
--image docker.io/lavasoftware/lava-dispatcher:2023.01.0020.gc1598238f \
--tests kselftest-mincore \
--timeouts boot=30
--
Linaro LKFT
https://lkft.linaro.org
On Mon, May 15, 2023 at 03:29:02PM +0530, Naresh Kamboju wrote:
> The selftests: mincore: mincore_selftest fails only on qemu-armv7 running
> Linux next, mainline and stable branches.
>
> Reported-by: Linux Kernel Functional Testing <[email protected]>
>
> # selftests: mincore: mincore_selftest
> # TAP version 13
> # 1..5
> # # Starting 5 tests from 1 test cases.
> # # RUN global.basic_interface ...
> # # OK global.basic_interface
> # ok 1 global.basic_interface
> # # RUN global.check_anonymous_locked_pages ...
> # # OK global.check_anonymous_locked_pages
> # ok 2 global.check_anonymous_locked_pages
> # # RUN global.check_huge_pages ...
> # # mincore_selftest.c:156:check_huge_pages:mmap error: Invalid argument
> # # mincore_selftest.c:159:check_huge_pages:Expected 0 (0) == retval (-1)
The test is wrong. It doesn't accept -EINVAL as a valid failure.
tools/testing/selftests/mincore/mincore_selftest.c
139 TEST(check_huge_pages)
140 {
141 unsigned char vec[1];
142 char *addr;
143 int retval;
144 int page_size;
145
146 page_size = sysconf(_SC_PAGESIZE);
147
148 errno = 0;
149 addr = mmap(NULL, page_size, PROT_READ | PROT_WRITE,
150 MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB,
151 -1, 0);
152 if (addr == MAP_FAILED) {
153 if (errno == ENOMEM)
On Armv7 is a 32bit machine so HUGETLB isn't enabled and the errno can
be -EINVAL. It's has returned this for 10 years.
154 SKIP(return, "No huge pages available.");
155 else
156 TH_LOG("mmap error: %s", strerror(errno));
157 }
158 retval = mincore(addr, page_size, vec);
159 ASSERT_EQ(0, retval);
mm/mmap.c
1405 }
1406 } else if (flags & MAP_HUGETLB) {
1407 struct hstate *hs;
1408
1409 hs = hstate_sizelog((flags >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK);
1410 if (!hs)
1411 return -EINVAL;
^^^^^^^^^^^^^^^
hstate_sizelog() return NULL when CONFIG_HUGETLB_PAGE is disabled.
1412
1413 len = ALIGN(len, huge_page_size(hs));
regards,
dan carpenter
On Mon, May 15, 2023, at 13:51, Dan Carpenter wrote:
> On Mon, May 15, 2023 at 03:29:02PM +0530, Naresh Kamboju wrote:
>> The selftests: mincore: mincore_selftest fails only on qemu-armv7 running
>
> tools/testing/selftests/mincore/mincore_selftest.c
> 139 TEST(check_huge_pages)
> 140 {
> 141 unsigned char vec[1];
> 142 char *addr;
> 143 int retval;
> 144 int page_size;
> 145
> 146 page_size = sysconf(_SC_PAGESIZE);
> 147
> 148 errno = 0;
> 149 addr = mmap(NULL, page_size, PROT_READ | PROT_WRITE,
> 150 MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB,
> 151 -1, 0);
> 152 if (addr == MAP_FAILED) {
> 153 if (errno == ENOMEM)
>
> On Armv7 is a 32bit machine so HUGETLB isn't enabled and the errno can
> be -EINVAL. It's has returned this for 10 years.
I expected it to be enabled on 32-bit as well, but I see that
on normal ARMv7 without CONFIG_ARM_LPAE, it is indeed
always turned off, and the asm/pgtable-2level.h does not
define a way to use sections or supersections in user space:
arch/arm/Kconfig: select ARCH_SUPPORTS_HUGETLBFS if ARM_LPAE
Arnd
Hi all,
On 15/5/23 13:51, Dan Carpenter wrote:
> The test is wrong. It doesn't accept -EINVAL as a valid failure.
>
> tools/testing/selftests/mincore/mincore_selftest.c
> 139 TEST(check_huge_pages)
> 140 {
> 141 unsigned char vec[1];
> 142 char *addr;
> 143 int retval;
> 144 int page_size;
> 145
> 146 page_size = sysconf(_SC_PAGESIZE);
> 147
> 148 errno = 0;
> 149 addr = mmap(NULL, page_size, PROT_READ | PROT_WRITE,
> 150 MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB,
> 151 -1, 0);
> 152 if (addr == MAP_FAILED) {
> 153 if (errno == ENOMEM)
>
> On Armv7 is a 32bit machine so HUGETLB isn't enabled and the errno can
> be -EINVAL. It's has returned this for 10 years.
>
> 154 SKIP(return, "No huge pages available.");
> 155 else
> 156 TH_LOG("mmap error: %s", strerror(errno));
> 157 }
> 158 retval = mincore(addr, page_size, vec);
> 159 ASSERT_EQ(0, retval);
>
> mm/mmap.c
> 1405 }
> 1406 } else if (flags & MAP_HUGETLB) {
> 1407 struct hstate *hs;
> 1408
> 1409 hs = hstate_sizelog((flags >> MAP_HUGE_SHIFT) & MAP_HUGE_MASK);
> 1410 if (!hs)
> 1411 return -EINVAL;
> ^^^^^^^^^^^^^^^
> hstate_sizelog() return NULL when CONFIG_HUGETLB_PAGE is disabled.
>
> 1412
> 1413 len = ALIGN(len, huge_page_size(hs));
>
> regards,
> dan carpenter
>
Thanks for the tip, Dan. I'll send a patch for it asap.
Cheers,
Ricardo