linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* selftests: mincore: mincore_selftest fails only on qemu-armv7
@ 2023-05-15  9:59 Naresh Kamboju
  2023-05-15 11:51 ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Naresh Kamboju @ 2023-05-15  9:59 UTC (permalink / raw)
  To: open list, open list:KERNEL SELFTEST FRAMEWORK, lkft-triage
  Cc: Ricardo Cañuelo, Andrew Morton, Linus Torvalds,
	Arnd Bergmann, Ard Biesheuvel, Shuah Khan, Dan Carpenter,
	Anders Roxell

The selftests: mincore: mincore_selftest fails only on qemu-armv7 running
Linux next, mainline and stable branches.

Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>

# 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: selftests: mincore: mincore_selftest fails only on qemu-armv7
  2023-05-15  9:59 selftests: mincore: mincore_selftest fails only on qemu-armv7 Naresh Kamboju
@ 2023-05-15 11:51 ` Dan Carpenter
  2023-05-15 12:13   ` Arnd Bergmann
  2023-05-15 12:32   ` Ricardo Cañuelo
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2023-05-15 11:51 UTC (permalink / raw)
  To: Naresh Kamboju, Ricardo Cañuelo
  Cc: open list, open list:KERNEL SELFTEST FRAMEWORK, lkft-triage,
	Andrew Morton, Linus Torvalds, Arnd Bergmann, Ard Biesheuvel,
	Shuah Khan, Anders Roxell

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 <lkft@linaro.org>
> 
> # 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: selftests: mincore: mincore_selftest fails only on qemu-armv7
  2023-05-15 11:51 ` Dan Carpenter
@ 2023-05-15 12:13   ` Arnd Bergmann
  2023-05-15 12:32   ` Ricardo Cañuelo
  1 sibling, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2023-05-15 12:13 UTC (permalink / raw)
  To: Dan Carpenter, Naresh Kamboju, Ricardo Cañuelo
  Cc: open list, open list:KERNEL SELFTEST FRAMEWORK, lkft-triage,
	Andrew Morton, Linus Torvalds, Ard Biesheuvel, shuah,
	Anders Roxell

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: selftests: mincore: mincore_selftest fails only on qemu-armv7
  2023-05-15 11:51 ` Dan Carpenter
  2023-05-15 12:13   ` Arnd Bergmann
@ 2023-05-15 12:32   ` Ricardo Cañuelo
  1 sibling, 0 replies; 4+ messages in thread
From: Ricardo Cañuelo @ 2023-05-15 12:32 UTC (permalink / raw)
  To: Dan Carpenter, Naresh Kamboju
  Cc: open list, open list:KERNEL SELFTEST FRAMEWORK, lkft-triage,
	Andrew Morton, Linus Torvalds, Arnd Bergmann, Ard Biesheuvel,
	Shuah Khan, Anders Roxell

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-15 12:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-15  9:59 selftests: mincore: mincore_selftest fails only on qemu-armv7 Naresh Kamboju
2023-05-15 11:51 ` Dan Carpenter
2023-05-15 12:13   ` Arnd Bergmann
2023-05-15 12:32   ` Ricardo Cañuelo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).