Re: PROBLEM: selftest/vm/cow.c failed to compile (‘MADV_PAGEOUT’ undeclared)

From: Mirsad Goran Todorovac
Date: Mon Jan 09 2023 - 16:42:41 EST


On 1/9/2023 5:42 PM, David Hildenbrand wrote:

Hi, thank you for your reply.

I hope this is enough information for you to debug the issue.

I am standing by for any additional diagnostics needed.

Won't userfaultfd.c fail in a similar way?

Anyhow, khugepaged.c jas

#ifndef MADV_PAGEOUT
#define MADV_PAGEOUT 21
#endif

So most probably we should do the same.

Actually, David, it turned out that userfaultfd.c compiled out-of-the-box, and side-by-side comparison showed that it also included "/home/marvin/linux/kernel/linux_torvalds/usr/include/asm-generic/mman-common.h"

The only remaining difference was including <linux/mman.h>, which fixed the issue w/o #ifdef ... #endif

Hope this helps.

Please find the following diff.

Regards,
Mirsad

------------------------------------------------------------------------------
diff --git a/tools/testing/selftests/vm/cow.c b/tools/testing/selftests/vm/cow.c
index 26f6ea3079e2..dd8cf12c6776 100644
--- a/tools/testing/selftests/vm/cow.c
+++ b/tools/testing/selftests/vm/cow.c
@@ -16,6 +16,7 @@
#include <fcntl.h>
#include <dirent.h>
#include <assert.h>
+#include <linux/mman.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/wait.h>




--
Mirsad Todorovac
Sistem inženjer
Grafički fakultet | Akademija likovnih umjetnosti
Sveučilište u Zagrebu
--
System engineer
Faculty of Graphic Arts | Academy of Fine Arts
University of Zagreb, Republic of Croatia
tel. +385 (0)1 3711 451
mob. +385 91 57 88 355