On 9 Jul 2025, at 8:32, wang lian wrote:

> Hi Zi Yan,
> Thanks for testing the patch and reporting this build failure.
> I don't have an arm64 environment readily available for testing, so I
> appreciate you catching this. I suspect this is caused by missing or
> older userspace headers in the cross-compilation toolchain.

Right. My /usr/include/sys does not have pidfd.h. IMHO selftests
should not rely on userspace headers, otherwise we cannot test
latest kernel changes.

> I will try to fix this in the next version. If the problem persists, a
> good solution would be to manually define the syscall wrapper to avoid
> the dependency on <sys/pidfd.h>.

Based on what I see in other mm tests, the following patch fixes my
compilation issue.

diff --git a/tools/testing/selftests/mm/process_madv.c 
b/tools/testing/selftests/mm/process_madv.c
index 3d26105b4781..8bf11433d6e6 100644
--- a/tools/testing/selftests/mm/process_madv.c
+++ b/tools/testing/selftests/mm/process_madv.c
@@ -10,13 +10,14 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/mman.h>
+#include <linux/mman.h>
 #include <sys/syscall.h>
 #include <unistd.h>
 #include <sched.h>
-#include <sys/pidfd.h>
+#include <linux/pidfd.h>
+#include <linux/uio.h>
 #include "vm_util.h"

-#include "../pidfd/pidfd.h"

 FIXTURE(process_madvise)
 {
@@ -240,7 +241,7 @@ TEST_F(process_madvise, remote_collapse)
        close(pipe_info[0]);
        child_pid = info.pid;

-       pidfd = pidfd_open(child_pid, 0);
+       pidfd = syscall(__NR_pidfd_open, child_pid, 0);
        ASSERT_GE(pidfd, 0);

        /* Baseline Check from Parent's perspective */
@@ -312,7 +313,7 @@ TEST_F(process_madvise, invalid_pidfd)
        if (child_pid == 0)
                exit(0);

-       pidfd = pidfd_open(child_pid, 0);
+       pidfd = syscall(__NR_pidfd_open, child_pid, 0);
        ASSERT_GE(pidfd, 0);

        /* Wait for the child to ensure it has terminated. */


Best Regards,
Yan, Zi

Reply via email to