]> www.infradead.org Git - users/hch/misc.git/commitdiff
mm: move mm flags to mm_types.h
authorNanyong Sun <sunnanyong@huawei.com>
Thu, 26 Sep 2024 07:49:22 +0000 (15:49 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 6 Nov 2024 00:56:26 +0000 (16:56 -0800)
The types of mm flags are now far beyond the core dump related features.
This patch moves mm flags from linux/sched/coredump.h to linux/mm_types.h.
The linux/sched/coredump.h has include the mm_types.h, so the C files
related to coredump does not need to change head file inclusion.  In
addition, the inclusion of sched/coredump.h now can be deleted from the C
files that irrelevant to core dump.

Link: https://lkml.kernel.org/r/20240926074922.2721274-1-sunnanyong@huawei.com
Signed-off-by: Nanyong Sun <sunnanyong@huawei.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
13 files changed:
include/linux/huge_mm.h
include/linux/khugepaged.h
include/linux/ksm.h
include/linux/mm_types.h
include/linux/oom.h
include/linux/sched/coredump.h
kernel/events/uprobes.c
kernel/fork.c
mm/huge_memory.c
mm/khugepaged.c
mm/ksm.c
mm/memory.c
mm/oom_kill.c

index ef5b80e48599c107a4fd92035f28d4c73c9c2600..8afe09a2cf03b0531da34eb67497cedf67276e6f 100644 (file)
@@ -2,7 +2,6 @@
 #ifndef _LINUX_HUGE_MM_H
 #define _LINUX_HUGE_MM_H
 
-#include <linux/sched/coredump.h>
 #include <linux/mm_types.h>
 
 #include <linux/fs.h> /* only for vma_is_dax() */
index 30baae91b2255f708665bc5fbbc9a7cd63ca3be1..1f46046080f515efb79098e17340db96a55223a9 100644 (file)
@@ -2,8 +2,6 @@
 #ifndef _LINUX_KHUGEPAGED_H
 #define _LINUX_KHUGEPAGED_H
 
-#include <linux/sched/coredump.h> /* MMF_VM_HUGEPAGE */
-
 extern unsigned int khugepaged_max_ptes_none __read_mostly;
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 extern struct attribute_group khugepaged_attr_group;
index ec9c05044d4fed068b39844a4141c71a339b0e39..29022e71a074a224d5f0b85b4e9cf2be5fcf789f 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/pagemap.h>
 #include <linux/rmap.h>
 #include <linux/sched.h>
-#include <linux/sched/coredump.h>
 
 #ifdef CONFIG_KSM
 int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
index 6e3bdf8e38bcaee66a71f5566ac7debb94c0ee78..ff8627acbaa709a721373c896154e3d178f73942 100644 (file)
@@ -1499,4 +1499,88 @@ enum {
        /* See also internal only FOLL flags in mm/internal.h */
 };
 
+/* mm flags */
+
+/*
+ * The first two bits represent core dump modes for set-user-ID,
+ * the modes are SUID_DUMP_* defined in linux/sched/coredump.h
+ */
+#define MMF_DUMPABLE_BITS 2
+#define MMF_DUMPABLE_MASK ((1 << MMF_DUMPABLE_BITS) - 1)
+/* coredump filter bits */
+#define MMF_DUMP_ANON_PRIVATE  2
+#define MMF_DUMP_ANON_SHARED   3
+#define MMF_DUMP_MAPPED_PRIVATE        4
+#define MMF_DUMP_MAPPED_SHARED 5
+#define MMF_DUMP_ELF_HEADERS   6
+#define MMF_DUMP_HUGETLB_PRIVATE 7
+#define MMF_DUMP_HUGETLB_SHARED  8
+#define MMF_DUMP_DAX_PRIVATE   9
+#define MMF_DUMP_DAX_SHARED    10
+
+#define MMF_DUMP_FILTER_SHIFT  MMF_DUMPABLE_BITS
+#define MMF_DUMP_FILTER_BITS   9
+#define MMF_DUMP_FILTER_MASK \
+       (((1 << MMF_DUMP_FILTER_BITS) - 1) << MMF_DUMP_FILTER_SHIFT)
+#define MMF_DUMP_FILTER_DEFAULT \
+       ((1 << MMF_DUMP_ANON_PRIVATE) | (1 << MMF_DUMP_ANON_SHARED) |\
+        (1 << MMF_DUMP_HUGETLB_PRIVATE) | MMF_DUMP_MASK_DEFAULT_ELF)
+
+#ifdef CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS
+# define MMF_DUMP_MASK_DEFAULT_ELF     (1 << MMF_DUMP_ELF_HEADERS)
+#else
+# define MMF_DUMP_MASK_DEFAULT_ELF     0
+#endif
+                                       /* leave room for more dump flags */
+#define MMF_VM_MERGEABLE       16      /* KSM may merge identical pages */
+#define MMF_VM_HUGEPAGE                17      /* set when mm is available for khugepaged */
+
+/*
+ * This one-shot flag is dropped due to necessity of changing exe once again
+ * on NFS restore
+ */
+//#define MMF_EXE_FILE_CHANGED 18      /* see prctl_set_mm_exe_file() */
+
+#define MMF_HAS_UPROBES                19      /* has uprobes */
+#define MMF_RECALC_UPROBES     20      /* MMF_HAS_UPROBES can be wrong */
+#define MMF_OOM_SKIP           21      /* mm is of no interest for the OOM killer */
+#define MMF_UNSTABLE           22      /* mm is unstable for copy_from_user */
+#define MMF_HUGE_ZERO_PAGE     23      /* mm has ever used the global huge zero page */
+#define MMF_DISABLE_THP                24      /* disable THP for all VMAs */
+#define MMF_DISABLE_THP_MASK   (1 << MMF_DISABLE_THP)
+#define MMF_OOM_REAP_QUEUED    25      /* mm was queued for oom_reaper */
+#define MMF_MULTIPROCESS       26      /* mm is shared between processes */
+/*
+ * MMF_HAS_PINNED: Whether this mm has pinned any pages.  This can be either
+ * replaced in the future by mm.pinned_vm when it becomes stable, or grow into
+ * a counter on its own. We're aggresive on this bit for now: even if the
+ * pinned pages were unpinned later on, we'll still keep this bit set for the
+ * lifecycle of this mm, just for simplicity.
+ */
+#define MMF_HAS_PINNED         27      /* FOLL_PIN has run, never cleared */
+
+#define MMF_HAS_MDWE           28
+#define MMF_HAS_MDWE_MASK      (1 << MMF_HAS_MDWE)
+
+
+#define MMF_HAS_MDWE_NO_INHERIT        29
+
+#define MMF_VM_MERGE_ANY       30
+#define MMF_VM_MERGE_ANY_MASK  (1 << MMF_VM_MERGE_ANY)
+
+#define MMF_TOPDOWN            31      /* mm searches top down by default */
+#define MMF_TOPDOWN_MASK       (1 << MMF_TOPDOWN)
+
+#define MMF_INIT_MASK          (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK |\
+                                MMF_DISABLE_THP_MASK | MMF_HAS_MDWE_MASK |\
+                                MMF_VM_MERGE_ANY_MASK | MMF_TOPDOWN_MASK)
+
+static inline unsigned long mmf_init_flags(unsigned long flags)
+{
+       if (flags & (1UL << MMF_HAS_MDWE_NO_INHERIT))
+               flags &= ~((1UL << MMF_HAS_MDWE) |
+                          (1UL << MMF_HAS_MDWE_NO_INHERIT));
+       return flags & MMF_INIT_MASK;
+}
+
 #endif /* _LINUX_MM_TYPES_H */
index 7d0c9c48a0c54e7265e2dc872d7f81c60463788a..1e0fc6931ce9675f61be4e49f65607b18a6fb43c 100644 (file)
@@ -7,7 +7,6 @@
 #include <linux/types.h>
 #include <linux/nodemask.h>
 #include <uapi/linux/oom.h>
-#include <linux/sched/coredump.h> /* MMF_* */
 #include <linux/mm.h> /* VM_FAULT* */
 
 struct zonelist;
index e62ff805cfc950fc3091f727b0517c70fdfd3bdc..6eb65ceed213e7163e1cd026c1575ba8f8ad406d 100644 (file)
@@ -8,12 +8,6 @@
 #define SUID_DUMP_USER         1       /* Dump as user of process */
 #define SUID_DUMP_ROOT         2       /* Dump as root */
 
-/* mm flags */
-
-/* for SUID_DUMP_* above */
-#define MMF_DUMPABLE_BITS 2
-#define MMF_DUMPABLE_MASK ((1 << MMF_DUMPABLE_BITS) - 1)
-
 extern void set_dumpable(struct mm_struct *mm, int value);
 /*
  * This returns the actual value of the suid_dumpable flag. For things
@@ -31,80 +25,4 @@ static inline int get_dumpable(struct mm_struct *mm)
        return __get_dumpable(mm->flags);
 }
 
-/* coredump filter bits */
-#define MMF_DUMP_ANON_PRIVATE  2
-#define MMF_DUMP_ANON_SHARED   3
-#define MMF_DUMP_MAPPED_PRIVATE        4
-#define MMF_DUMP_MAPPED_SHARED 5
-#define MMF_DUMP_ELF_HEADERS   6
-#define MMF_DUMP_HUGETLB_PRIVATE 7
-#define MMF_DUMP_HUGETLB_SHARED  8
-#define MMF_DUMP_DAX_PRIVATE   9
-#define MMF_DUMP_DAX_SHARED    10
-
-#define MMF_DUMP_FILTER_SHIFT  MMF_DUMPABLE_BITS
-#define MMF_DUMP_FILTER_BITS   9
-#define MMF_DUMP_FILTER_MASK \
-       (((1 << MMF_DUMP_FILTER_BITS) - 1) << MMF_DUMP_FILTER_SHIFT)
-#define MMF_DUMP_FILTER_DEFAULT \
-       ((1 << MMF_DUMP_ANON_PRIVATE) | (1 << MMF_DUMP_ANON_SHARED) |\
-        (1 << MMF_DUMP_HUGETLB_PRIVATE) | MMF_DUMP_MASK_DEFAULT_ELF)
-
-#ifdef CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS
-# define MMF_DUMP_MASK_DEFAULT_ELF     (1 << MMF_DUMP_ELF_HEADERS)
-#else
-# define MMF_DUMP_MASK_DEFAULT_ELF     0
-#endif
-                                       /* leave room for more dump flags */
-#define MMF_VM_MERGEABLE       16      /* KSM may merge identical pages */
-#define MMF_VM_HUGEPAGE                17      /* set when mm is available for
-                                          khugepaged */
-/*
- * This one-shot flag is dropped due to necessity of changing exe once again
- * on NFS restore
- */
-//#define MMF_EXE_FILE_CHANGED 18      /* see prctl_set_mm_exe_file() */
-
-#define MMF_HAS_UPROBES                19      /* has uprobes */
-#define MMF_RECALC_UPROBES     20      /* MMF_HAS_UPROBES can be wrong */
-#define MMF_OOM_SKIP           21      /* mm is of no interest for the OOM killer */
-#define MMF_UNSTABLE           22      /* mm is unstable for copy_from_user */
-#define MMF_HUGE_ZERO_PAGE     23      /* mm has ever used the global huge zero page */
-#define MMF_DISABLE_THP                24      /* disable THP for all VMAs */
-#define MMF_DISABLE_THP_MASK   (1 << MMF_DISABLE_THP)
-#define MMF_OOM_REAP_QUEUED    25      /* mm was queued for oom_reaper */
-#define MMF_MULTIPROCESS       26      /* mm is shared between processes */
-/*
- * MMF_HAS_PINNED: Whether this mm has pinned any pages.  This can be either
- * replaced in the future by mm.pinned_vm when it becomes stable, or grow into
- * a counter on its own. We're aggresive on this bit for now: even if the
- * pinned pages were unpinned later on, we'll still keep this bit set for the
- * lifecycle of this mm, just for simplicity.
- */
-#define MMF_HAS_PINNED         27      /* FOLL_PIN has run, never cleared */
-
-#define MMF_HAS_MDWE           28
-#define MMF_HAS_MDWE_MASK      (1 << MMF_HAS_MDWE)
-
-
-#define MMF_HAS_MDWE_NO_INHERIT        29
-
-#define MMF_VM_MERGE_ANY       30
-#define MMF_VM_MERGE_ANY_MASK  (1 << MMF_VM_MERGE_ANY)
-
-#define MMF_TOPDOWN            31      /* mm searches top down by default */
-#define MMF_TOPDOWN_MASK       (1 << MMF_TOPDOWN)
-
-#define MMF_INIT_MASK          (MMF_DUMPABLE_MASK | MMF_DUMP_FILTER_MASK |\
-                                MMF_DISABLE_THP_MASK | MMF_HAS_MDWE_MASK |\
-                                MMF_VM_MERGE_ANY_MASK | MMF_TOPDOWN_MASK)
-
-static inline unsigned long mmf_init_flags(unsigned long flags)
-{
-       if (flags & (1UL << MMF_HAS_MDWE_NO_INHERIT))
-               flags &= ~((1UL << MMF_HAS_MDWE) |
-                          (1UL << MMF_HAS_MDWE_NO_INHERIT));
-       return flags & MMF_INIT_MASK;
-}
-
 #endif /* _LINUX_SCHED_COREDUMP_H */
index 4b52cb2ae6d620b2526de7e86291bdc137aa4f49..75ac18a3ac0ff8365f44ef9a6372e40d191f9f11 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/slab.h>
 #include <linux/sched.h>
 #include <linux/sched/mm.h>
-#include <linux/sched/coredump.h>
 #include <linux/export.h>
 #include <linux/rmap.h>                /* anon_vma_prepare */
 #include <linux/mmu_notifier.h>
index b2ab422f62309a477ab1128b032b61f7f8530202..61a4abd628f35aaa9eb0926fe2181c91ef852a75 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/slab.h>
 #include <linux/sched/autogroup.h>
 #include <linux/sched/mm.h>
-#include <linux/sched/coredump.h>
 #include <linux/sched/user.h>
 #include <linux/sched/numa_balancing.h>
 #include <linux/sched/stat.h>
index 03fd4bc39ea156f268f3cea88fc549e2927c1fef..e71b58d84cba230e5ba2d609631f04096e39c410 100644 (file)
@@ -8,7 +8,6 @@
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/sched/mm.h>
-#include <linux/sched/coredump.h>
 #include <linux/sched/numa_balancing.h>
 #include <linux/highmem.h>
 #include <linux/hugetlb.h>
index 0bd80e134010f87ca8da1193897588771e1df15b..ed1a225dd198e9824ec6520964d6ddf094e1e1d1 100644 (file)
@@ -4,7 +4,6 @@
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/sched/mm.h>
-#include <linux/sched/coredump.h>
 #include <linux/mmu_notifier.h>
 #include <linux/rmap.h>
 #include <linux/swap.h>
index a2e2a521df0aec24873f622033085da0aa83c45e..dec536d6d91ad18ea55f673f36a04a2eddd771ae 100644 (file)
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -20,7 +20,6 @@
 #include <linux/mman.h>
 #include <linux/sched.h>
 #include <linux/sched/mm.h>
-#include <linux/sched/coredump.h>
 #include <linux/sched/cputime.h>
 #include <linux/rwsem.h>
 #include <linux/pagemap.h>
index bdf77a3ec47bc26a8560c41a7ab0d485a9f99367..c8d5d040d6ab113e896be7ebade6a0557090eda1 100644 (file)
@@ -44,7 +44,6 @@
 #include <linux/mm.h>
 #include <linux/mm_inline.h>
 #include <linux/sched/mm.h>
-#include <linux/sched/coredump.h>
 #include <linux/sched/numa_balancing.h>
 #include <linux/sched/task.h>
 #include <linux/hugetlb.h>
index 4d7a0004df2cac7f0eb8b892e24cdb66e3143479..1c485beb0b934b00c031504d1d1c234abaf60854 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/gfp.h>
 #include <linux/sched.h>
 #include <linux/sched/mm.h>
-#include <linux/sched/coredump.h>
 #include <linux/sched/task.h>
 #include <linux/sched/debug.h>
 #include <linux/swap.h>