linux-um archives
 help / color / mirror / Atom feed
From: Hajime Tazaki <thehajime@gmail.com>
To: pfalcato@suse.de
Cc: linux-mm@kvack.org, geert@linux-m68k.org, daniel@thingy.jp,
	shuah@kernel.org, akpm@linux-foundation.org, david@kernel.org,
	ljs@kernel.org, liam@infradead.org, vbabka@kernel.org,
	rppt@kernel.org, surenb@google.com, mhocko@suse.com,
	linux-kselftest@vger.kernel.org, linux-um@lists.infradead.org
Subject: Re: [RFC PATCH 4/6] selftests: fix build errors on alpine linux
Date: Fri, 14 Aug 2026 21:44:45 +0900	[thread overview]
Message-ID: <m24igwrhvm.wl-thehajime@gmail.com> (raw)
In-Reply-To: <an7eC0oBvfjB6g54@pedro-suse.lan>


Hello Pedro,

thank you for the review and looking at the patch.

On Fri, 14 Aug 2026 18:34:21 +0900,
Pedro Falcato wrote:
> 
> /me puts on his libc hat

thanks, this is really a good news to me.

> > diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h
> > index ae18c491ae53..ac21bf3d802e 100644
> > --- a/tools/testing/selftests/kselftest.h
> > +++ b/tools/testing/selftests/kselftest.h
> > @@ -58,6 +58,7 @@
> >  #include <string.h>
> >  #include <stdio.h>
> >  #include <sys/utsname.h>
> > +#include <stdint.h>
> >  #endif
> >  
> >  #ifndef ARRAY_SIZE
> > @@ -81,6 +82,48 @@
> >  #endif
> >  #endif /* end arch */
> >  
> > +#if !defined(NOLIBC) && !defined(__GLIBC__)
> > +#ifdef __LP64__
> > +typedef int64_t __fsword_t;
> > +#else
> > +typedef int32_t __fsword_t;
> > +#endif
> 
> The code should not be using __fsword_t. Per statfs(2):
> 
>        The __fsword_t type used for various fields in the statfs
>        structure definition is a glibc internal type, not intended for
>        public use.  This leaves the programmer in a bit of a conundrum
>        when trying to copy or compare these fields to local variables in
>        a program.  Using unsigned int for such variables suffices on most
>        systems.
> 
> and indeed if you look at musl's statvfs definition:
> struct statvfs {
> 	/* ... */
> 	unsigned int f_type;
> 	/* ... */
> };
> 
> so it should be perfectly cromulent to use unsigned int here. Or use an
> actual usable interface :)

thanks, I will drop this chunk and propose to update mm/gup_longterm.c
to address the issue with musl.

> > +
> > +/*
> > + * for a workaround to avoid struct conflict under
> > + * musl-libc (<sys/prctl.h> v.s. <linux/prctl.h>)
> > + */
> > +#include <sys/prctl.h>
> > +#ifndef _LINUX_PRCTL_H
> > +#define _LINUX_PRCTL_H
> > +#endif
> > +
> > +#ifndef PR_SET_MDWE
> > +#define PR_SET_MDWE 65
> > +#endif
> > +
> > +#ifndef PR_MDWE_REFUSE_EXEC_GAIN
> > +#define PR_MDWE_REFUSE_EXEC_GAIN (1UL << 0)
> > +#endif
> > +
> > +#ifndef PR_MDWE_NO_INHERIT
> > +#define PR_MDWE_NO_INHERIT (1UL << 1)
> > +#endif
> > +
> > +#ifndef PR_GET_MDWE
> > +#define PR_GET_MDWE 66
> > +#endif
> > +
> > +#ifndef PR_SET_MEMORY_MERGE
> > +#define PR_SET_MEMORY_MERGE 67
> > +#endif
> > +
> > +#ifndef PR_GET_MEMORY_MERGE
> > +#define PR_GET_MEMORY_MERGE 68
> > +#endif
> > +
> > +#endif
> 
> This looks fine. It's the same old problem with musl and kernel headers.

noted with thanks.

> >  /* define kselftest exit codes */
> >  #define KSFT_PASS  0
> >  #define KSFT_FAIL  1
> > diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> > index f02cc8a2e4ae..2cc819006424 100644
> > --- a/tools/testing/selftests/lib.mk
> > +++ b/tools/testing/selftests/lib.mk
> > @@ -197,7 +197,7 @@ clean: $(if $(TEST_GEN_MODS_DIR),clean_mods_dir)
> >  	$(CLEAN)
> >  
> >  # Build with _GNU_SOURCE by default
> > -CFLAGS += -D_GNU_SOURCE=
> > +CFLAGS += -D_GNU_SOURCE= -D_LARGEFILE64_SOURCE
> 
> What needs this?

this is a leftover chunk of patch not for TARGETS=mm, but
TARGETS=drivers/dma-buf, which generates the following errors.

udmabuf.c:137:9: error: unknown type name 'off64_t'; did you mean 'off_t'?
  137 |         off64_t size;

I will drop this chunk from this patch as the patch is only focusing
on TARGETS=mm.

> >  
> >  # Additional include paths needed by kselftest.h and local headers
> >  CFLAGS += -I${top_srcdir}/tools/testing/selftests
> > diff --git a/tools/testing/selftests/mm/hugetlb_dio.c b/tools/testing/selftests/mm/hugetlb_dio.c
> > index fb4600570e13..aee6be530ccb 100644
> > --- a/tools/testing/selftests/mm/hugetlb_dio.c
> > +++ b/tools/testing/selftests/mm/hugetlb_dio.c
> > @@ -22,12 +22,9 @@
> >  #include "kselftest.h"
> >  #include "hugepage_settings.h"
> >  
> > -#ifndef STATX_DIOALIGN
> > -#define STATX_DIOALIGN		0x00002000U
> > -#endif
> 
> Why doesn't this fallback work?

I thought that if this macro isn't defined, it's not available in the
underlying kernel, but that's very idiot modification given that the
libc headers is not up-to-date but the kernel is supporting this, this
ifndef should help.

I will look for another approach to address the situation of musl, and
revert this for the original purpose.

> > -
> >  static int get_dio_alignment(int fd)
> >  {
> > +#ifdef STATX_DIOALIGN
> >  	struct statx stx;
> >  	int ret;
> >  
> > @@ -43,6 +40,9 @@ static int get_dio_alignment(int fd)
> >  		return 1;
> >  
> >  	return stx.stx_dio_offset_align;
> > +#else
> > +	return -1;
> > +#endif
> >  }
> >  
> >  static bool check_dio_alignment(unsigned int start_off,
> > diff --git a/tools/testing/selftests/mm/mdwe_test.c b/tools/testing/selftests/mm/mdwe_test.c
> > index 647779653da0..031c79ed067e 100644
> > --- a/tools/testing/selftests/mm/mdwe_test.c
> > +++ b/tools/testing/selftests/mm/mdwe_test.c
> > @@ -1,5 +1,7 @@
> >  // SPDX-License-Identifier: GPL-2.0
> >  
> > +#include "kselftest_harness.h"
> > +
> >  #ifdef __aarch64__
> >  #include <asm/hwcap.h>
> >  #endif
> > @@ -14,8 +16,6 @@
> >  #include <sys/wait.h>
> >  #include <unistd.h>
> >  
> > -#include "kselftest_harness.h"
> > -
> >  #ifndef __aarch64__
> >  # define PROT_BTI	0
> >  #endif
> > -- 
> > 2.43.0
> > 
> > 
> 
> Honestly, I'm surprised you needed so few hacks for this! But if I am to
> guess, there are certainly much more problematic selftests out there.

Currently I only tested with `TARGETS=mm` and didn't look carefully to
other tests.  I will look more into running other tests on alpine
(with CONFIG_MMU enabled) first, then will see !MMU environment with
investigating if those are meaningful to test on nommu.

anyway, (again) thanks for the review.

-- Hajime


  reply	other threads:[~2026-08-14 12:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260813063401.1786548-1-thehajime@gmail.com>
2026-08-13  6:33 ` [RFC PATCH 4/6] selftests: fix build errors on alpine linux Hajime Tazaki
2026-08-14  9:34   ` Pedro Falcato
2026-08-14 12:44     ` Hajime Tazaki [this message]
2026-08-14 12:39   ` Lorenzo Stoakes (ARM)
2026-08-13  6:34 ` [RFC PATCH 5/6] selftests: run tests on nommu architecture Hajime Tazaki
2026-08-14 12:50   ` Lorenzo Stoakes (ARM)
2026-08-14 14:34     ` Mark Brown
2026-08-13  6:34 ` [RFC PATCH 6/6] selftests/mm: add nommu mmap and mremap behavior tests Hajime Tazaki
2026-08-14 13:28   ` Lorenzo Stoakes (ARM)

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=m24igwrhvm.wl-thehajime@gmail.com \
    --to=thehajime@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=daniel@thingy.jp \
    --cc=david@kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=liam@infradead.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-um@lists.infradead.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=pfalcato@suse.de \
    --cc=rppt@kernel.org \
    --cc=shuah@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    /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