1# SPDX-License-Identifier: GPL-2.0
2#
3# Makefile for the linux memory manager.
4#
5
6KASAN_SANITIZE_slab_common.o := n
7KASAN_SANITIZE_slab.o := n
8KASAN_SANITIZE_slub.o := n
9KCSAN_SANITIZE_kmemleak.o := n
10
11# These produce frequent data race reports: most of them are due to races on
12# the same word but accesses to different bits of that word. Re-enable KCSAN
13# for these when we have more consensus on what to do about them.
14KCSAN_SANITIZE_slab_common.o := n
15KCSAN_SANITIZE_slab.o := n
16KCSAN_SANITIZE_slub.o := n
17KCSAN_SANITIZE_page_alloc.o := n
18# But enable explicit instrumentation for memory barriers.
19KCSAN_INSTRUMENT_BARRIERS := y
20
21# These files are disabled because they produce non-interesting and/or
22# flaky coverage that is not a function of syscall inputs. E.g. slab is out of
23# free pages, or a task is migrated between nodes.
24KCOV_INSTRUMENT_slab_common.o := n
25KCOV_INSTRUMENT_slob.o := n
26KCOV_INSTRUMENT_slab.o := n
27KCOV_INSTRUMENT_slub.o := n
28KCOV_INSTRUMENT_page_alloc.o := n
29KCOV_INSTRUMENT_debug-pagealloc.o := n
30KCOV_INSTRUMENT_kmemleak.o := n
31KCOV_INSTRUMENT_memcontrol.o := n
32KCOV_INSTRUMENT_mmzone.o := n
33KCOV_INSTRUMENT_vmstat.o := n
34KCOV_INSTRUMENT_failslab.o := n
35
36CFLAGS_init-mm.o += $(call cc-disable-warning, override-init)
37CFLAGS_init-mm.o += $(call cc-disable-warning, initializer-overrides)
38
39mmu-y			:= nommu.o
40mmu-$(CONFIG_MMU)	:= highmem.o memory.o mincore.o \
41			   mlock.o mmap.o mmu_gather.o mprotect.o mremap.o \
42			   msync.o page_vma_mapped.o pagewalk.o \
43			   pgtable-generic.o rmap.o vmalloc.o
44
45
46ifdef CONFIG_CROSS_MEMORY_ATTACH
47mmu-$(CONFIG_MMU)	+= process_vm_access.o
48endif
49
50obj-y			:= filemap.o mempool.o oom_kill.o fadvise.o \
51			   maccess.o page-writeback.o folio-compat.o \
52			   readahead.o swap.o truncate.o vmscan.o shmem.o \
53			   util.o mmzone.o vmstat.o backing-dev.o \
54			   mm_init.o percpu.o slab_common.o \
55			   compaction.o \
56			   interval_tree.o list_lru.o workingset.o \
57			   debug.o gup.o mmap_lock.o $(mmu-y)
58
59# Give 'page_alloc' its own module-parameter namespace
60page-alloc-y := page_alloc.o
61page-alloc-$(CONFIG_SHUFFLE_PAGE_ALLOCATOR) += shuffle.o
62
63# Give 'memory_hotplug' its own module-parameter namespace
64memory-hotplug-$(CONFIG_MEMORY_HOTPLUG) += memory_hotplug.o
65
66obj-y += page-alloc.o
67obj-y += init-mm.o
68obj-y += memblock.o
69obj-y += $(memory-hotplug-y)
70
71ifdef CONFIG_MMU
72	obj-$(CONFIG_ADVISE_SYSCALLS)	+= madvise.o
73endif
74
75obj-$(CONFIG_SWAP)	+= page_io.o swap_state.o swapfile.o swap_slots.o
76obj-$(CONFIG_FRONTSWAP)	+= frontswap.o
77obj-$(CONFIG_ZSWAP)	+= zswap.o
78obj-$(CONFIG_HAS_DMA)	+= dmapool.o
79obj-$(CONFIG_HUGETLBFS)	+= hugetlb.o
80obj-$(CONFIG_HUGETLB_PAGE_OPTIMIZE_VMEMMAP)	+= hugetlb_vmemmap.o
81obj-$(CONFIG_NUMA) 	+= mempolicy.o
82obj-$(CONFIG_SPARSEMEM)	+= sparse.o
83obj-$(CONFIG_SPARSEMEM_VMEMMAP) += sparse-vmemmap.o
84obj-$(CONFIG_SLOB) += slob.o
85obj-$(CONFIG_MMU_NOTIFIER) += mmu_notifier.o
86obj-$(CONFIG_KSM) += ksm.o
87obj-$(CONFIG_PAGE_POISONING) += page_poison.o
88obj-$(CONFIG_SLAB) += slab.o
89obj-$(CONFIG_SLUB) += slub.o
90obj-$(CONFIG_KASAN)	+= kasan/
91obj-$(CONFIG_KFENCE) += kfence/
92obj-$(CONFIG_KMSAN)	+= kmsan/
93obj-$(CONFIG_FAILSLAB) += failslab.o
94obj-$(CONFIG_MEMTEST)		+= memtest.o
95obj-$(CONFIG_MIGRATION) += migrate.o
96obj-$(CONFIG_NUMA) += memory-tiers.o
97obj-$(CONFIG_DEVICE_MIGRATION) += migrate_device.o
98obj-$(CONFIG_TRANSPARENT_HUGEPAGE) += huge_memory.o khugepaged.o
99obj-$(CONFIG_PAGE_COUNTER) += page_counter.o
100obj-$(CONFIG_MEMCG) += memcontrol.o vmpressure.o
101ifdef CONFIG_SWAP
102obj-$(CONFIG_MEMCG) += swap_cgroup.o
103endif
104obj-$(CONFIG_CGROUP_HUGETLB) += hugetlb_cgroup.o
105obj-$(CONFIG_GUP_TEST) += gup_test.o
106obj-$(CONFIG_MEMORY_FAILURE) += memory-failure.o
107obj-$(CONFIG_HWPOISON_INJECT) += hwpoison-inject.o
108obj-$(CONFIG_DEBUG_KMEMLEAK) += kmemleak.o
109obj-$(CONFIG_DEBUG_RODATA_TEST) += rodata_test.o
110obj-$(CONFIG_DEBUG_VM_PGTABLE) += debug_vm_pgtable.o
111obj-$(CONFIG_PAGE_OWNER) += page_owner.o
112obj-$(CONFIG_MEMORY_ISOLATION) += page_isolation.o
113obj-$(CONFIG_ZPOOL)	+= zpool.o
114obj-$(CONFIG_ZBUD)	+= zbud.o
115obj-$(CONFIG_ZSMALLOC)	+= zsmalloc.o
116obj-$(CONFIG_Z3FOLD)	+= z3fold.o
117obj-$(CONFIG_GENERIC_EARLY_IOREMAP) += early_ioremap.o
118obj-$(CONFIG_CMA)	+= cma.o
119obj-$(CONFIG_MEMORY_BALLOON) += balloon_compaction.o
120obj-$(CONFIG_PAGE_EXTENSION) += page_ext.o
121obj-$(CONFIG_PAGE_TABLE_CHECK) += page_table_check.o
122obj-$(CONFIG_CMA_DEBUGFS) += cma_debug.o
123obj-$(CONFIG_SECRETMEM) += secretmem.o
124obj-$(CONFIG_CMA_SYSFS) += cma_sysfs.o
125obj-$(CONFIG_USERFAULTFD) += userfaultfd.o
126obj-$(CONFIG_IDLE_PAGE_TRACKING) += page_idle.o
127obj-$(CONFIG_DEBUG_PAGE_REF) += debug_page_ref.o
128obj-$(CONFIG_DAMON) += damon/
129obj-$(CONFIG_HARDENED_USERCOPY) += usercopy.o
130obj-$(CONFIG_PERCPU_STATS) += percpu-stats.o
131obj-$(CONFIG_ZONE_DEVICE) += memremap.o
132obj-$(CONFIG_HMM_MIRROR) += hmm.o
133obj-$(CONFIG_MEMFD_CREATE) += memfd.o
134obj-$(CONFIG_MAPPING_DIRTY_HELPERS) += mapping_dirty_helpers.o
135obj-$(CONFIG_PTDUMP_CORE) += ptdump.o
136obj-$(CONFIG_PAGE_REPORTING) += page_reporting.o
137obj-$(CONFIG_IO_MAPPING) += io-mapping.o
138obj-$(CONFIG_HAVE_BOOTMEM_INFO_NODE) += bootmem_info.o
139obj-$(CONFIG_GENERIC_IOREMAP) += ioremap.o
140obj-$(CONFIG_SHRINKER_DEBUG) += shrinker_debug.o
141