Hi,
On 1/10/23 00:36, Andrew Morton wrote:
The patch titled
Subject: selftests/mm: define MADV_PAGEOUT to fix compilation issues
has been added to the -mm mm-unstable branch. Its filename is
selftests-mm-define-madv_pageout-to-fix-compilation-issues.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-mm-define-madv_pageout-to-fix-compilation-issues.patch
This patch will later appear in the mm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days
------------------------------------------------------
From: David Hildenbrand <david@xxxxxxxxxx>
Subject: selftests/mm: define MADV_PAGEOUT to fix compilation issues
Date: Mon, 9 Jan 2023 18:12:55 +0100
If MADV_PAGEOUT is not defined (e.g., on AlmaLinux 8), compilation will
fail. Let's fix that like khugepaged.c does by conditionally defining
MADV_PAGEOUT.
Link: https://lkml.kernel.org/r/20230109171255.488749-1-david@xxxxxxxxxx
Fixes: 69c66add5663 ("selftests/vm: anon_cow: test COW handling of anonymous memory")
Signed-off-by: David Hildenbrand <david@xxxxxxxxxx>
Reported-by: Mirsad Goran Todorovac <mirsad.todorovac@xxxxxxxxxxxx>
Cc: Shuah Khan <shuah@xxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---
tools/testing/selftests/mm/cow.c | 3 +++
1 file changed, 3 insertions(+)
--- a/tools/testing/selftests/mm/cow.c~selftests-mm-define-madv_pageout-to-fix-compilation-issues
+++ a/tools/testing/selftests/mm/cow.c
@@ -30,6 +30,9 @@
#include "../kselftest.h"
#include "vm_util.h"
+#ifndef MADV_PAGEOUT
+#define MADV_PAGEOUT 21
+#endif
#ifndef MADV_COLLAPSE
#define MADV_COLLAPSE 25
#endif
_
Patches currently in -mm which might be from david@xxxxxxxxxx are
mm-hugetlb-fix-pte-marker-handling-in-hugetlb_change_protection.patch
mm-hugetlb-fix-uffd-wp-handling-for-migration-entries-in-hugetlb_change_protection.patch
mm-userfaultfd-enable-writenotify-while-userfaultfd-wp-is-enabled-for-a-vma.patch
mm-userfaultfd-rely-on-vma-vm_page_prot-in-uffd_wp_range.patch
mm-userfaultfd-rely-on-vma-vm_page_prot-in-uffd_wp_range-fix.patch
mm-mprotect-drop-pgprot_t-parameter-from-change_protection.patch
mm-mprotect-drop-pgprot_t-parameter-from-change_protection-fix.patch
selftests-vm-cow-add-cow-tests-for-collapsing-of-pte-mapped-anon-thp.patch
mm-nommu-factor-out-check-for-nommu-shared-mappings-into-is_nommu_shared_mapping.patch
mm-nommu-dont-use-vm_mayshare-for-map_private-mappings.patch
drivers-misc-open-dice-dont-touch-vm_mayshare.patch
selftests-mm-define-madv_pageout-to-fix-compilation-issues.patch
Please consider alternative patch instead. I am submitting it for a
review.
It would give the referential integrity to the source of the selftest/vm
subtree.
#ifdef ... #endif encapsulation around `#define __USE_GNU` eliminates a
warning.
RATIONALE:
Though it is ulikely that the values of MADV_PAGEOUT,
MADV_POPULATE_READ and MADV_COLLAPSE will change, the source integrity
would benefit from having it changed in only one place,
.../usr/include/asm-generic/mman-common.h, included by
#include <linux/mman.h>
rather than in three places: mman-common.h, vm/cow.c and vm/khugepaged.c.
This can potentially lead to hard-to-find bugs, as three sources may
disagree about the value of MADV_PAGEOUT, MADV_POPULATE_READ and
MADV_COLLAPSE macro defines.
Thank you very much for your time and consideration.
Regards,
Mirsad
----------------------------------------------------------------------------------------------------------
tools/testing/selftests/vm/cow.c | 1 +
tools/testing/selftests/vm/hugetlb-madvise.c | 2 ++
tools/testing/selftests/vm/khugepaged.c | 11 +----------
3 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/tools/testing/selftests/vm/cow.c
b/tools/testing/selftests/vm/cow.c
index 26f6ea3079e2..7707b97e3ff4 100644
--- a/tools/testing/selftests/vm/cow.c
+++ b/tools/testing/selftests/vm/cow.c
@@ -20,6 +20,7 @@
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <linux/memfd.h>
+#include <linux/mman.h>
#include "local_config.h"
#ifdef LOCAL_CONFIG_HAVE_LIBURING
diff --git a/tools/testing/selftests/vm/hugetlb-madvise.c
b/tools/testing/selftests/vm/hugetlb-madvise.c
index a634f47d1e56..163dafe759d4 100644
--- a/tools/testing/selftests/vm/hugetlb-madvise.c
+++ b/tools/testing/selftests/vm/hugetlb-madvise.c
@@ -17,7 +17,9 @@
#include <stdio.h>
#include <unistd.h>
#include <sys/mman.h>
+#ifndef __USE_GNU
#define __USE_GNU
+#endif
#include <fcntl.h>
#define MIN_FREE_PAGES 20
diff --git a/tools/testing/selftests/vm/khugepaged.c
b/tools/testing/selftests/vm/khugepaged.c
index 64126c8cd561..6302de1ab0d0 100644
--- a/tools/testing/selftests/vm/khugepaged.c
+++ b/tools/testing/selftests/vm/khugepaged.c
@@ -19,19 +19,10 @@
#include <sys/vfs.h>
#include "linux/magic.h"
+#include "linux/mman.h"
#include "vm_util.h"
-#ifndef MADV_PAGEOUT
-#define MADV_PAGEOUT 21
-#endif
-#ifndef MADV_POPULATE_READ
-#define MADV_POPULATE_READ 22
-#endif
-#ifndef MADV_COLLAPSE
-#define MADV_COLLAPSE 25
-#endif
-
#define BASE_ADDR ((void *)(1UL << 30))
static unsigned long hpage_pmd_size;
static unsigned long page_size;
--
Mirsad Goran 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