xref: /linux/mm/Kconfig (revision e323b52cf00ffc3f5ac79420af7ab340b4576a5c)
1# SPDX-License-Identifier: GPL-2.0-only
2
3menu "Memory Management options"
4
5#
6# For some reason microblaze and nios2 hard code SWAP=n.  Hopefully we can
7# add proper SWAP support to them, in which case this can be remove.
8#
9config ARCH_NO_SWAP
10	bool
11
12menuconfig SWAP
13	bool "Support for paging of anonymous memory (swap)"
14	depends on MMU && BLOCK && !ARCH_NO_SWAP
15	default y
16	help
17	  This option allows you to choose whether you want to have support
18	  for so called swap devices or swap files in your kernel that are
19	  used to provide more virtual memory than the actual RAM present
20	  in your computer.  If unsure say Y.
21
22config ZSWAP
23	bool "Compressed cache for swap pages"
24	depends on SWAP
25	select CRYPTO
26	select ZSMALLOC
27	help
28	  A lightweight compressed cache for swap pages.  It takes
29	  pages that are in the process of being swapped out and attempts to
30	  compress them into a dynamically allocated RAM-based memory pool.
31	  This can result in a significant I/O reduction on swap device and,
32	  in the case where decompressing from RAM is faster than swap device
33	  reads, can also improve workload performance.
34
35config ZSWAP_DEFAULT_ON
36	bool "Enable the compressed cache for swap pages by default"
37	depends on ZSWAP
38	help
39	  If selected, the compressed cache for swap pages will be enabled
40	  at boot, otherwise it will be disabled.
41
42	  The selection made here can be overridden by using the kernel
43	  command line 'zswap.enabled=' option.
44
45config ZSWAP_SHRINKER_DEFAULT_ON
46	bool "Shrink the zswap pool on memory pressure"
47	depends on ZSWAP
48	default n
49	help
50	  If selected, the zswap shrinker will be enabled, and the pages
51	  stored in the zswap pool will become available for reclaim (i.e
52	  written back to the backing swap device) on memory pressure.
53
54	  This means that zswap writeback could happen even if the pool is
55	  not yet full, or the cgroup zswap limit has not been reached,
56	  reducing the chance that cold pages will reside in the zswap pool
57	  and consume memory indefinitely.
58
59choice
60	prompt "Default compressor"
61	depends on ZSWAP
62	default ZSWAP_COMPRESSOR_DEFAULT_LZO
63	help
64	  Selects the default compression algorithm for the compressed cache
65	  for swap pages.
66
67	  For an overview what kind of performance can be expected from
68	  a particular compression algorithm please refer to the benchmarks
69	  available at the following LWN page:
70	  https://lwn.net/Articles/751795/
71
72	  If in doubt, select 'LZO'.
73
74	  The selection made here can be overridden by using the kernel
75	  command line 'zswap.compressor=' option.
76
77config ZSWAP_COMPRESSOR_DEFAULT_DEFLATE
78	bool "Deflate"
79	select CRYPTO_DEFLATE
80	help
81	  Use the Deflate algorithm as the default compression algorithm.
82
83config ZSWAP_COMPRESSOR_DEFAULT_LZO
84	bool "LZO"
85	select CRYPTO_LZO
86	help
87	  Use the LZO algorithm as the default compression algorithm.
88
89config ZSWAP_COMPRESSOR_DEFAULT_842
90	bool "842"
91	select CRYPTO_842
92	help
93	  Use the 842 algorithm as the default compression algorithm.
94
95config ZSWAP_COMPRESSOR_DEFAULT_LZ4
96	bool "LZ4"
97	select CRYPTO_LZ4
98	help
99	  Use the LZ4 algorithm as the default compression algorithm.
100
101config ZSWAP_COMPRESSOR_DEFAULT_LZ4HC
102	bool "LZ4HC"
103	select CRYPTO_LZ4HC
104	help
105	  Use the LZ4HC algorithm as the default compression algorithm.
106
107config ZSWAP_COMPRESSOR_DEFAULT_ZSTD
108	bool "zstd"
109	select CRYPTO_ZSTD
110	help
111	  Use the zstd algorithm as the default compression algorithm.
112endchoice
113
114config ZSWAP_COMPRESSOR_DEFAULT
115       string
116       depends on ZSWAP
117       default "deflate" if ZSWAP_COMPRESSOR_DEFAULT_DEFLATE
118       default "lzo" if ZSWAP_COMPRESSOR_DEFAULT_LZO
119       default "842" if ZSWAP_COMPRESSOR_DEFAULT_842
120       default "lz4" if ZSWAP_COMPRESSOR_DEFAULT_LZ4
121       default "lz4hc" if ZSWAP_COMPRESSOR_DEFAULT_LZ4HC
122       default "zstd" if ZSWAP_COMPRESSOR_DEFAULT_ZSTD
123       default ""
124
125config ZSMALLOC
126	tristate
127
128if ZSMALLOC
129
130menu "Zsmalloc allocator options"
131	depends on ZSMALLOC
132
133comment "Zsmalloc is a common backend allocator for zswap & zram"
134
135config ZSMALLOC_STAT
136	bool "Export zsmalloc statistics"
137	select DEBUG_FS
138	help
139	  This option enables code in the zsmalloc to collect various
140	  statistics about what's happening in zsmalloc and exports that
141	  information to userspace via debugfs.
142	  If unsure, say N.
143
144config ZSMALLOC_CHAIN_SIZE
145	int "Maximum number of physical pages per-zspage"
146	default 8
147	range 4 16
148	help
149	  This option sets the upper limit on the number of physical pages
150	  that a zmalloc page (zspage) can consist of. The optimal zspage
151	  chain size is calculated for each size class during the
152	  initialization of the pool.
153
154	  Changing this option can alter the characteristics of size classes,
155	  such as the number of pages per zspage and the number of objects
156	  per zspage. This can also result in different configurations of
157	  the pool, as zsmalloc merges size classes with similar
158	  characteristics.
159
160	  For more information, see zsmalloc documentation.
161
162endmenu
163
164endif
165
166menu "Slab allocator options"
167
168config SLUB
169	def_bool y
170	select IRQ_WORK
171
172config KVFREE_RCU_BATCHED
173	def_bool y
174	depends on !SLUB_TINY && !TINY_RCU
175
176config SLUB_TINY
177	bool "Configure for minimal memory footprint"
178	depends on EXPERT && !COMPILE_TEST
179	select SLAB_MERGE_DEFAULT
180	help
181	   Configures the slab allocator in a way to achieve minimal memory
182	   footprint, sacrificing scalability, debugging and other features.
183	   This is intended only for the smallest system that had used the
184	   SLOB allocator and is not recommended for systems with more than
185	   16MB RAM.
186
187	   If unsure, say N.
188
189config SLAB_MERGE_DEFAULT
190	bool "Allow slab caches to be merged"
191	default y
192	help
193	  For reduced kernel memory fragmentation, slab caches can be
194	  merged when they share the same size and other characteristics.
195	  This carries a risk of kernel heap overflows being able to
196	  overwrite objects from merged caches (and more easily control
197	  cache layout), which makes such heap attacks easier to exploit
198	  by attackers. By keeping caches unmerged, these kinds of exploits
199	  can usually only damage objects in the same cache. To disable
200	  merging at runtime, "slab_nomerge" can be passed on the kernel
201	  command line.
202
203config SLAB_FREELIST_RANDOM
204	bool "Randomize slab freelist"
205	depends on !SLUB_TINY
206	help
207	  Randomizes the freelist order used on creating new pages. This
208	  security feature reduces the predictability of the kernel slab
209	  allocator against heap overflows.
210
211config SLAB_FREELIST_HARDENED
212	bool "Harden slab freelist metadata"
213	depends on !SLUB_TINY
214	help
215	  Many kernel heap attacks try to target slab cache metadata and
216	  other infrastructure. This options makes minor performance
217	  sacrifices to harden the kernel slab allocator against common
218	  freelist exploit methods.
219
220config SLAB_BUCKETS
221	bool "Support allocation from separate kmalloc buckets"
222	depends on !SLUB_TINY
223	default SLAB_FREELIST_HARDENED
224	help
225	  Kernel heap attacks frequently depend on being able to create
226	  specifically-sized allocations with user-controlled contents
227	  that will be allocated into the same kmalloc bucket as a
228	  target object. To avoid sharing these allocation buckets,
229	  provide an explicitly separated set of buckets to be used for
230	  user-controlled allocations. This may very slightly increase
231	  memory fragmentation, though in practice it's only a handful
232	  of extra pages since the bulk of user-controlled allocations
233	  are relatively long-lived.
234
235	  If unsure, say Y.
236
237config SLUB_STATS
238	default n
239	bool "Enable performance statistics"
240	depends on SYSFS && !SLUB_TINY
241	help
242	  The statistics are useful to debug slab allocation behavior in
243	  order find ways to optimize the allocator. This should never be
244	  enabled for production use since keeping statistics slows down
245	  the allocator by a few percentage points. The slabinfo command
246	  supports the determination of the most active slabs to figure
247	  out which slabs are relevant to a particular load.
248	  Try running: slabinfo -DA
249
250config RANDOM_KMALLOC_CACHES
251	default n
252	depends on !SLUB_TINY
253	bool "Randomize slab caches for normal kmalloc"
254	help
255	  A hardening feature that creates multiple copies of slab caches for
256	  normal kmalloc allocation and makes kmalloc randomly pick one based
257	  on code address, which makes the attackers more difficult to spray
258	  vulnerable memory objects on the heap for the purpose of exploiting
259	  memory vulnerabilities.
260
261	  Currently the number of copies is set to 16, a reasonably large value
262	  that effectively diverges the memory objects allocated for different
263	  subsystems or modules into different caches, at the expense of a
264	  limited degree of memory and CPU overhead that relates to hardware and
265	  system workload.
266
267endmenu # Slab allocator options
268
269config SHUFFLE_PAGE_ALLOCATOR
270	bool "Page allocator randomization"
271	default SLAB_FREELIST_RANDOM && ACPI_NUMA
272	help
273	  Randomization of the page allocator improves the average
274	  utilization of a direct-mapped memory-side-cache. See section
275	  5.2.27 Heterogeneous Memory Attribute Table (HMAT) in the ACPI
276	  6.2a specification for an example of how a platform advertises
277	  the presence of a memory-side-cache. There are also incidental
278	  security benefits as it reduces the predictability of page
279	  allocations to compliment SLAB_FREELIST_RANDOM, but the
280	  default granularity of shuffling on the MAX_PAGE_ORDER i.e, 10th
281	  order of pages is selected based on cache utilization benefits
282	  on x86.
283
284	  While the randomization improves cache utilization it may
285	  negatively impact workloads on platforms without a cache. For
286	  this reason, by default, the randomization is not enabled even
287	  if SHUFFLE_PAGE_ALLOCATOR=y. The randomization may be force enabled
288	  with the 'page_alloc.shuffle' kernel command line parameter.
289
290	  Say Y if unsure.
291
292config COMPAT_BRK
293	bool "Disable heap randomization"
294	default y
295	help
296	  Randomizing heap placement makes heap exploits harder, but it
297	  also breaks ancient binaries (including anything libc5 based).
298	  This option changes the bootup default to heap randomization
299	  disabled, and can be overridden at runtime by setting
300	  /proc/sys/kernel/randomize_va_space to 2.
301
302	  On non-ancient distros (post-2000 ones) N is usually a safe choice.
303
304config MMAP_ALLOW_UNINITIALIZED
305	bool "Allow mmapped anonymous memory to be uninitialized"
306	depends on EXPERT && !MMU
307	default n
308	help
309	  Normally, and according to the Linux spec, anonymous memory obtained
310	  from mmap() has its contents cleared before it is passed to
311	  userspace.  Enabling this config option allows you to request that
312	  mmap() skip that if it is given an MAP_UNINITIALIZED flag, thus
313	  providing a huge performance boost.  If this option is not enabled,
314	  then the flag will be ignored.
315
316	  This is taken advantage of by uClibc's malloc(), and also by
317	  ELF-FDPIC binfmt's brk and stack allocator.
318
319	  Because of the obvious security issues, this option should only be
320	  enabled on embedded devices where you control what is run in
321	  userspace.  Since that isn't generally a problem on no-MMU systems,
322	  it is normally safe to say Y here.
323
324	  See Documentation/admin-guide/mm/nommu-mmap.rst for more information.
325
326config SELECT_MEMORY_MODEL
327	def_bool y
328	depends on ARCH_SELECT_MEMORY_MODEL
329
330choice
331	prompt "Memory model"
332	depends on SELECT_MEMORY_MODEL
333	default SPARSEMEM_MANUAL if ARCH_SPARSEMEM_DEFAULT
334	default FLATMEM_MANUAL
335	help
336	  This option allows you to change some of the ways that
337	  Linux manages its memory internally. Most users will
338	  only have one option here selected by the architecture
339	  configuration. This is normal.
340
341config FLATMEM_MANUAL
342	bool "Flat Memory"
343	depends on !ARCH_SPARSEMEM_ENABLE || ARCH_FLATMEM_ENABLE
344	help
345	  This option is best suited for non-NUMA systems with
346	  flat address space. The FLATMEM is the most efficient
347	  system in terms of performance and resource consumption
348	  and it is the best option for smaller systems.
349
350	  For systems that have holes in their physical address
351	  spaces and for features like NUMA and memory hotplug,
352	  choose "Sparse Memory".
353
354	  If unsure, choose this option (Flat Memory) over any other.
355
356config SPARSEMEM_MANUAL
357	bool "Sparse Memory"
358	depends on ARCH_SPARSEMEM_ENABLE
359	help
360	  This will be the only option for some systems, including
361	  memory hot-plug systems.  This is normal.
362
363	  This option provides efficient support for systems with
364	  holes is their physical address space and allows memory
365	  hot-plug and hot-remove.
366
367	  If unsure, choose "Flat Memory" over this option.
368
369endchoice
370
371config SPARSEMEM
372	def_bool y
373	depends on (!SELECT_MEMORY_MODEL && ARCH_SPARSEMEM_ENABLE) || SPARSEMEM_MANUAL
374
375config FLATMEM
376	def_bool y
377	depends on !SPARSEMEM || FLATMEM_MANUAL
378
379#
380# SPARSEMEM_EXTREME (which is the default) does some bootmem
381# allocations when sparse_init() is called.  If this cannot
382# be done on your architecture, select this option.  However,
383# statically allocating the mem_section[] array can potentially
384# consume vast quantities of .bss, so be careful.
385#
386# This option will also potentially produce smaller runtime code
387# with gcc 3.4 and later.
388#
389config SPARSEMEM_STATIC
390	bool
391
392#
393# Architecture platforms which require a two level mem_section in SPARSEMEM
394# must select this option. This is usually for architecture platforms with
395# an extremely sparse physical address space.
396#
397config SPARSEMEM_EXTREME
398	def_bool y
399	depends on SPARSEMEM && !SPARSEMEM_STATIC
400
401config SPARSEMEM_VMEMMAP_ENABLE
402	bool
403
404config SPARSEMEM_VMEMMAP
405	def_bool y
406	depends on SPARSEMEM && SPARSEMEM_VMEMMAP_ENABLE
407	help
408	  SPARSEMEM_VMEMMAP uses a virtually mapped memmap to optimise
409	  pfn_to_page and page_to_pfn operations.  This is the most
410	  efficient option when sufficient kernel resources are available.
411
412config SPARSEMEM_VMEMMAP_PREINIT
413	bool
414#
415# Select this config option from the architecture Kconfig, if it is preferred
416# to enable the feature of HugeTLB/dev_dax vmemmap optimization.
417#
418config ARCH_WANT_OPTIMIZE_DAX_VMEMMAP
419	bool
420
421config ARCH_WANT_OPTIMIZE_HUGETLB_VMEMMAP
422	bool
423
424config ARCH_WANT_HUGETLB_VMEMMAP_PREINIT
425	bool
426
427config HAVE_MEMBLOCK_PHYS_MAP
428	bool
429
430config HAVE_GUP_FAST
431	depends on MMU
432	bool
433
434# Enable memblock support for scratch memory which is needed for kexec handover
435config MEMBLOCK_KHO_SCRATCH
436	bool
437
438# Don't discard allocated memory used to track "memory" and "reserved" memblocks
439# after early boot, so it can still be used to test for validity of memory.
440# Also, memblocks are updated with memory hot(un)plug.
441config ARCH_KEEP_MEMBLOCK
442	bool
443
444# Keep arch NUMA mapping infrastructure post-init.
445config NUMA_KEEP_MEMINFO
446	bool
447
448config MEMORY_ISOLATION
449	bool
450
451# IORESOURCE_SYSTEM_RAM regions in the kernel resource tree that are marked
452# IORESOURCE_EXCLUSIVE cannot be mapped to user space, for example, via
453# /dev/mem.
454config EXCLUSIVE_SYSTEM_RAM
455	def_bool y
456	depends on !DEVMEM || STRICT_DEVMEM
457
458#
459# Only be set on architectures that have completely implemented memory hotplug
460# feature. If you are not sure, don't touch it.
461#
462config HAVE_BOOTMEM_INFO_NODE
463	def_bool n
464
465config ARCH_ENABLE_MEMORY_HOTPLUG
466	bool
467
468config ARCH_ENABLE_MEMORY_HOTREMOVE
469	bool
470
471# eventually, we can have this option just 'select SPARSEMEM'
472menuconfig MEMORY_HOTPLUG
473	bool "Memory hotplug"
474	select MEMORY_ISOLATION
475	depends on SPARSEMEM
476	depends on ARCH_ENABLE_MEMORY_HOTPLUG
477	depends on 64BIT
478	select NUMA_KEEP_MEMINFO if NUMA
479
480if MEMORY_HOTPLUG
481
482choice
483	prompt "Memory Hotplug Default Online Type"
484	default MHP_DEFAULT_ONLINE_TYPE_OFFLINE
485	help
486	  Default memory type for hotplugged memory.
487
488	  This option sets the default policy setting for memory hotplug
489	  onlining policy (/sys/devices/system/memory/auto_online_blocks) which
490	  determines what happens to newly added memory regions. Policy setting
491	  can always be changed at runtime.
492
493	  The default is 'offline'.
494
495	  Select offline to defer onlining to drivers and user policy.
496	  Select auto to let the kernel choose what zones to utilize.
497	  Select online_kernel to generally allow kernel usage of this memory.
498	  Select online_movable to generally disallow kernel usage of this memory.
499
500	  Example kernel usage would be page structs and page tables.
501
502	  See Documentation/admin-guide/mm/memory-hotplug.rst for more information.
503
504config MHP_DEFAULT_ONLINE_TYPE_OFFLINE
505	bool "offline"
506	help
507	  Hotplugged memory will not be onlined by default.
508	  Choose this for systems with drivers and user policy that
509	  handle onlining of hotplug memory policy.
510
511config MHP_DEFAULT_ONLINE_TYPE_ONLINE_AUTO
512	bool "auto"
513	help
514	  Select this if you want the kernel to automatically online
515	  hotplugged memory into the zone it thinks is reasonable.
516	  This memory may be utilized for kernel data.
517
518config MHP_DEFAULT_ONLINE_TYPE_ONLINE_KERNEL
519	bool "kernel"
520	help
521	  Select this if you want the kernel to automatically online
522	  hotplugged memory into a zone capable of being used for kernel
523	  data. This typically means ZONE_NORMAL.
524
525config MHP_DEFAULT_ONLINE_TYPE_ONLINE_MOVABLE
526	bool "movable"
527	help
528	  Select this if you want the kernel to automatically online
529	  hotplug memory into ZONE_MOVABLE. This memory will generally
530	  not be utilized for kernel data.
531
532	  This should only be used when the admin knows sufficient
533	  ZONE_NORMAL memory is available to describe hotplug memory,
534	  otherwise hotplug memory may fail to online. For example,
535	  sufficient kernel-capable memory (ZONE_NORMAL) must be
536	  available to allocate page structs to describe ZONE_MOVABLE.
537
538endchoice
539
540config MEMORY_HOTREMOVE
541	bool "Allow for memory hot remove"
542	select HAVE_BOOTMEM_INFO_NODE if (X86_64 || PPC64)
543	depends on MEMORY_HOTPLUG && ARCH_ENABLE_MEMORY_HOTREMOVE
544	depends on MIGRATION
545
546config MHP_MEMMAP_ON_MEMORY
547	def_bool y
548	depends on MEMORY_HOTPLUG && SPARSEMEM_VMEMMAP
549	depends on ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE
550
551endif # MEMORY_HOTPLUG
552
553config ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE
554       bool
555
556# Heavily threaded applications may benefit from splitting the mm-wide
557# page_table_lock, so that faults on different parts of the user address
558# space can be handled with less contention: split it at this NR_CPUS.
559# Default to 4 for wider testing, though 8 might be more appropriate.
560# ARM's adjust_pte (unused if VIPT) depends on mm-wide page_table_lock.
561# PA-RISC 7xxx's spinlock_t would enlarge struct page from 32 to 44 bytes.
562# SPARC32 allocates multiple pte tables within a single page, and therefore
563# a per-page lock leads to problems when multiple tables need to be locked
564# at the same time (e.g. copy_page_range()).
565# DEBUG_SPINLOCK and DEBUG_LOCK_ALLOC spinlock_t also enlarge struct page.
566#
567config SPLIT_PTE_PTLOCKS
568	def_bool y
569	depends on MMU
570	depends on SMP
571	depends on NR_CPUS >= 4
572	depends on !ARM || CPU_CACHE_VIPT
573	depends on !PARISC || PA20
574	depends on !SPARC32
575
576config ARCH_ENABLE_SPLIT_PMD_PTLOCK
577	bool
578
579config SPLIT_PMD_PTLOCKS
580	def_bool y
581	depends on SPLIT_PTE_PTLOCKS && ARCH_ENABLE_SPLIT_PMD_PTLOCK
582
583#
584# support for memory balloon
585config MEMORY_BALLOON
586	bool
587
588#
589# support for memory balloon compaction
590config BALLOON_COMPACTION
591	bool "Allow for balloon memory compaction/migration"
592	default y
593	depends on COMPACTION && MEMORY_BALLOON
594	help
595	  Memory fragmentation introduced by ballooning might reduce
596	  significantly the number of 2MB contiguous memory blocks that can be
597	  used within a guest, thus imposing performance penalties associated
598	  with the reduced number of transparent huge pages that could be used
599	  by the guest workload. Allowing the compaction & migration for memory
600	  pages enlisted as being part of memory balloon devices avoids the
601	  scenario aforementioned and helps improving memory defragmentation.
602
603#
604# support for memory compaction
605config COMPACTION
606	bool "Allow for memory compaction"
607	default y
608	select MIGRATION
609	depends on MMU
610	help
611	  Compaction is the only memory management component to form
612	  high order (larger physically contiguous) memory blocks
613	  reliably. The page allocator relies on compaction heavily and
614	  the lack of the feature can lead to unexpected OOM killer
615	  invocations for high order memory requests. You shouldn't
616	  disable this option unless there really is a strong reason for
617	  it and then we would be really interested to hear about that at
618	  linux-mm@kvack.org.
619
620config COMPACT_UNEVICTABLE_DEFAULT
621	int
622	depends on COMPACTION
623	default 0 if PREEMPT_RT
624	default 1
625
626#
627# support for free page reporting
628config PAGE_REPORTING
629	bool "Free page reporting"
630	help
631	  Free page reporting allows for the incremental acquisition of
632	  free pages from the buddy allocator for the purpose of reporting
633	  those pages to another entity, such as a hypervisor, so that the
634	  memory can be freed within the host for other uses.
635
636#
637# support for page migration
638#
639config MIGRATION
640	bool "Page migration"
641	default y
642	depends on (NUMA || ARCH_ENABLE_MEMORY_HOTREMOVE || COMPACTION || CMA) && MMU
643	help
644	  Allows the migration of the physical location of pages of processes
645	  while the virtual addresses are not changed. This is useful in
646	  two situations. The first is on NUMA systems to put pages nearer
647	  to the processors accessing. The second is when allocating huge
648	  pages as migration can relocate pages to satisfy a huge page
649	  allocation instead of reclaiming.
650
651config DEVICE_MIGRATION
652	def_bool MIGRATION && ZONE_DEVICE
653
654config ARCH_ENABLE_HUGEPAGE_MIGRATION
655	bool
656
657config ARCH_ENABLE_THP_MIGRATION
658	bool
659
660config HUGETLB_PAGE_SIZE_VARIABLE
661	def_bool n
662	help
663	  Allows the pageblock_order value to be dynamic instead of just standard
664	  HUGETLB_PAGE_ORDER when there are multiple HugeTLB page sizes available
665	  on a platform.
666
667	  Note that the pageblock_order cannot exceed MAX_PAGE_ORDER and will be
668	  clamped down to MAX_PAGE_ORDER.
669
670config CONTIG_ALLOC
671	def_bool (MEMORY_ISOLATION && COMPACTION) || CMA
672
673config PCP_BATCH_SCALE_MAX
674	int "Maximum scale factor of PCP (Per-CPU pageset) batch allocate/free"
675	default 5
676	range 0 6
677	help
678	  In page allocator, PCP (Per-CPU pageset) is refilled and drained in
679	  batches.  The batch number is scaled automatically to improve page
680	  allocation/free throughput.  But too large scale factor may hurt
681	  latency.  This option sets the upper limit of scale factor to limit
682	  the maximum latency.
683
684config PHYS_ADDR_T_64BIT
685	def_bool 64BIT
686
687config MMU_NOTIFIER
688	bool
689	select INTERVAL_TREE
690
691config KSM
692	bool "Enable KSM for page merging"
693	depends on MMU
694	select XXHASH
695	help
696	  Enable Kernel Samepage Merging: KSM periodically scans those areas
697	  of an application's address space that an app has advised may be
698	  mergeable.  When it finds pages of identical content, it replaces
699	  the many instances by a single page with that content, so
700	  saving memory until one or another app needs to modify the content.
701	  Recommended for use with KVM, or with other duplicative applications.
702	  See Documentation/mm/ksm.rst for more information: KSM is inactive
703	  until a program has madvised that an area is MADV_MERGEABLE, and
704	  root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
705
706config DEFAULT_MMAP_MIN_ADDR
707	int "Low address space to protect from user allocation"
708	depends on MMU
709	default 4096
710	help
711	  This is the portion of low virtual memory which should be protected
712	  from userspace allocation.  Keeping a user from writing to low pages
713	  can help reduce the impact of kernel NULL pointer bugs.
714
715	  For most arm64, ppc64 and x86 users with lots of address space
716	  a value of 65536 is reasonable and should cause no problems.
717	  On arm and other archs it should not be higher than 32768.
718	  Programs which use vm86 functionality or have some need to map
719	  this low address space will need CAP_SYS_RAWIO or disable this
720	  protection by setting the value to 0.
721
722	  This value can be changed after boot using the
723	  /proc/sys/vm/mmap_min_addr tunable.
724
725config ARCH_SUPPORTS_MEMORY_FAILURE
726	bool
727
728config MEMORY_FAILURE
729	depends on MMU
730	depends on ARCH_SUPPORTS_MEMORY_FAILURE
731	bool "Enable recovery from hardware memory errors"
732	select INTERVAL_TREE
733	help
734	  Enables code to recover from some memory failures on systems
735	  with MCA recovery. This allows a system to continue running
736	  even when some of its memory has uncorrected errors. This requires
737	  special hardware support and typically ECC memory.
738
739config HWPOISON_INJECT
740	tristate "HWPoison pages injector"
741	depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
742	select PROC_PAGE_MONITOR
743
744config NOMMU_INITIAL_TRIM_EXCESS
745	int "Turn on mmap() excess space trimming before booting"
746	depends on !MMU
747	default 1
748	help
749	  The NOMMU mmap() frequently needs to allocate large contiguous chunks
750	  of memory on which to store mappings, but it can only ask the system
751	  allocator for chunks in 2^N*PAGE_SIZE amounts - which is frequently
752	  more than it requires.  To deal with this, mmap() is able to trim off
753	  the excess and return it to the allocator.
754
755	  If trimming is enabled, the excess is trimmed off and returned to the
756	  system allocator, which can cause extra fragmentation, particularly
757	  if there are a lot of transient processes.
758
759	  If trimming is disabled, the excess is kept, but not used, which for
760	  long-term mappings means that the space is wasted.
761
762	  Trimming can be dynamically controlled through a sysctl option
763	  (/proc/sys/vm/nr_trim_pages) which specifies the minimum number of
764	  excess pages there must be before trimming should occur, or zero if
765	  no trimming is to occur.
766
767	  This option specifies the initial value of this option.  The default
768	  of 1 says that all excess pages should be trimmed.
769
770	  See Documentation/admin-guide/mm/nommu-mmap.rst for more information.
771
772config ARCH_WANT_GENERAL_HUGETLB
773	bool
774
775config ARCH_WANTS_THP_SWAP
776	def_bool n
777
778config PERSISTENT_HUGE_ZERO_FOLIO
779	bool "Allocate a PMD sized folio for zeroing"
780	depends on TRANSPARENT_HUGEPAGE
781	help
782	  Enable this option to reduce the runtime refcounting overhead
783	  of the huge zero folio and expand the places in the kernel
784	  that can use huge zero folios. For instance, block I/O benefits
785	  from access to large folios for zeroing memory.
786
787	  With this option enabled, the huge zero folio is allocated
788	  once and never freed. One full huge page's worth of memory shall
789	  be used.
790
791	  Say Y if your system has lots of memory. Say N if you are
792	  memory constrained.
793
794config MM_ID
795	def_bool n
796
797menuconfig TRANSPARENT_HUGEPAGE
798	bool "Transparent Hugepage Support"
799	depends on HAVE_ARCH_TRANSPARENT_HUGEPAGE && !PREEMPT_RT
800	select COMPACTION
801	select XARRAY_MULTI
802	select MM_ID
803	help
804	  Transparent Hugepages allows the kernel to use huge pages and
805	  huge tlb transparently to the applications whenever possible.
806	  This feature can improve computing performance to certain
807	  applications by speeding up page faults during memory
808	  allocation, by reducing the number of tlb misses and by speeding
809	  up the pagetable walking.
810
811	  If memory constrained on embedded, you may want to say N.
812
813if TRANSPARENT_HUGEPAGE
814
815choice
816	prompt "Transparent Hugepage Support sysfs defaults"
817	depends on TRANSPARENT_HUGEPAGE
818	default TRANSPARENT_HUGEPAGE_ALWAYS
819	help
820	  Selects the sysfs defaults for Transparent Hugepage Support.
821
822	config TRANSPARENT_HUGEPAGE_ALWAYS
823		bool "always"
824	help
825	  Enabling Transparent Hugepage always, can increase the
826	  memory footprint of applications without a guaranteed
827	  benefit but it will work automatically for all applications.
828
829	config TRANSPARENT_HUGEPAGE_MADVISE
830		bool "madvise"
831	help
832	  Enabling Transparent Hugepage madvise, will only provide a
833	  performance improvement benefit to the applications using
834	  madvise(MADV_HUGEPAGE) but it won't risk to increase the
835	  memory footprint of applications without a guaranteed
836	  benefit.
837
838	config TRANSPARENT_HUGEPAGE_NEVER
839		bool "never"
840	help
841	  Disable Transparent Hugepage by default. It can still be
842	  enabled at runtime via sysfs.
843endchoice
844
845choice
846	prompt "Shmem hugepage allocation defaults"
847	depends on TRANSPARENT_HUGEPAGE
848	default TRANSPARENT_HUGEPAGE_SHMEM_HUGE_NEVER
849	help
850	  Selects the hugepage allocation policy defaults for
851	  the internal shmem mount.
852
853	  The selection made here can be overridden by using the kernel
854	  command line 'transparent_hugepage_shmem=' option.
855
856	config TRANSPARENT_HUGEPAGE_SHMEM_HUGE_NEVER
857		bool "never"
858	help
859	  Disable hugepage allocation for shmem mount by default. It can
860	  still be enabled with the kernel command line
861	  'transparent_hugepage_shmem=' option or at runtime via sysfs
862	  knob. Note that madvise(MADV_COLLAPSE) can still cause
863	  transparent huge pages to be obtained even if this mode is
864	  specified.
865
866	config TRANSPARENT_HUGEPAGE_SHMEM_HUGE_ALWAYS
867		bool "always"
868	help
869	  Always attempt to allocate hugepage for shmem mount, can
870	  increase the memory footprint of applications without a
871	  guaranteed benefit but it will work automatically for all
872	  applications.
873
874	config TRANSPARENT_HUGEPAGE_SHMEM_HUGE_WITHIN_SIZE
875		bool "within_size"
876	help
877	  Enable hugepage allocation for shmem mount if the allocation
878	  will be fully within the i_size. This configuration also takes
879	  into account any madvise(MADV_HUGEPAGE) hints that may be
880	  provided by the applications.
881
882	config TRANSPARENT_HUGEPAGE_SHMEM_HUGE_ADVISE
883		bool "advise"
884	help
885	  Enable hugepage allocation for the shmem mount exclusively when
886	  applications supply the madvise(MADV_HUGEPAGE) hint.
887	  This ensures that hugepages are used only in response to explicit
888	  requests from applications.
889endchoice
890
891choice
892	prompt "Tmpfs hugepage allocation defaults"
893	depends on TRANSPARENT_HUGEPAGE
894	default TRANSPARENT_HUGEPAGE_TMPFS_HUGE_NEVER
895	help
896	  Selects the hugepage allocation policy defaults for
897	  the tmpfs mount.
898
899	  The selection made here can be overridden by using the kernel
900	  command line 'transparent_hugepage_tmpfs=' option.
901
902	config TRANSPARENT_HUGEPAGE_TMPFS_HUGE_NEVER
903		bool "never"
904	help
905	  Disable hugepage allocation for tmpfs mount by default. It can
906	  still be enabled with the kernel command line
907	  'transparent_hugepage_tmpfs=' option. Note that
908	  madvise(MADV_COLLAPSE) can still cause transparent huge pages
909	  to be obtained even if this mode is specified.
910
911	config TRANSPARENT_HUGEPAGE_TMPFS_HUGE_ALWAYS
912		bool "always"
913	help
914	  Always attempt to allocate hugepage for tmpfs mount, can
915	  increase the memory footprint of applications without a
916	  guaranteed benefit but it will work automatically for all
917	  applications.
918
919	config TRANSPARENT_HUGEPAGE_TMPFS_HUGE_WITHIN_SIZE
920		bool "within_size"
921	help
922	  Enable hugepage allocation for tmpfs mount if the allocation
923	  will be fully within the i_size. This configuration also takes
924	  into account any madvise(MADV_HUGEPAGE) hints that may be
925	  provided by the applications.
926
927	config TRANSPARENT_HUGEPAGE_TMPFS_HUGE_ADVISE
928		bool "advise"
929	help
930	  Enable hugepage allocation for the tmpfs mount exclusively when
931	  applications supply the madvise(MADV_HUGEPAGE) hint.
932	  This ensures that hugepages are used only in response to explicit
933	  requests from applications.
934endchoice
935
936config THP_SWAP
937	def_bool y
938	depends on TRANSPARENT_HUGEPAGE && ARCH_WANTS_THP_SWAP && SWAP && 64BIT
939	help
940	  Swap transparent huge pages in one piece, without splitting.
941	  XXX: For now, swap cluster backing transparent huge page
942	  will be split after swapout.
943
944	  For selection by architectures with reasonable THP sizes.
945
946config READ_ONLY_THP_FOR_FS
947	bool "Read-only THP for filesystems (EXPERIMENTAL)"
948	depends on TRANSPARENT_HUGEPAGE
949
950	help
951	  Allow khugepaged to put read-only file-backed pages in THP.
952
953	  This is marked experimental because it is a new feature. Write
954	  support of file THPs will be developed in the next few release
955	  cycles.
956
957config NO_PAGE_MAPCOUNT
958	bool "No per-page mapcount (EXPERIMENTAL)"
959	help
960	  Do not maintain per-page mapcounts for pages part of larger
961	  allocations, such as transparent huge pages.
962
963	  When this config option is enabled, some interfaces that relied on
964	  this information will rely on less-precise per-allocation information
965	  instead: for example, using the average per-page mapcount in such
966	  a large allocation instead of the per-page mapcount.
967
968	  EXPERIMENTAL because the impact of some changes is still unclear.
969
970endif # TRANSPARENT_HUGEPAGE
971
972# simple helper to make the code a bit easier to read
973config PAGE_MAPCOUNT
974	def_bool !NO_PAGE_MAPCOUNT
975
976#
977# The architecture supports pgtable leaves that is larger than PAGE_SIZE
978#
979config PGTABLE_HAS_HUGE_LEAVES
980	def_bool TRANSPARENT_HUGEPAGE || HUGETLB_PAGE
981
982#
983# We can end up creating gigantic folio.
984#
985config HAVE_GIGANTIC_FOLIOS
986	def_bool (HUGETLB_PAGE && ARCH_HAS_GIGANTIC_PAGE) || \
987		 (ZONE_DEVICE && HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD)
988
989config ASYNC_KERNEL_PGTABLE_FREE
990	def_bool n
991
992# TODO: Allow to be enabled without THP
993config ARCH_SUPPORTS_HUGE_PFNMAP
994	def_bool n
995	depends on TRANSPARENT_HUGEPAGE
996
997config ARCH_SUPPORTS_PMD_PFNMAP
998	def_bool y
999	depends on ARCH_SUPPORTS_HUGE_PFNMAP && HAVE_ARCH_TRANSPARENT_HUGEPAGE
1000
1001config ARCH_SUPPORTS_PUD_PFNMAP
1002	def_bool y
1003	depends on ARCH_SUPPORTS_HUGE_PFNMAP && HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD
1004
1005#
1006# Architectures that always use weak definitions for percpu
1007# variables in modules should set this.
1008#
1009config ARCH_MODULE_NEEDS_WEAK_PER_CPU
1010       bool
1011
1012#
1013# UP and nommu archs use km based percpu allocator
1014#
1015config NEED_PER_CPU_KM
1016	depends on !SMP || !MMU
1017	bool
1018	default y
1019
1020config NEED_PER_CPU_EMBED_FIRST_CHUNK
1021	bool
1022
1023config NEED_PER_CPU_PAGE_FIRST_CHUNK
1024	bool
1025
1026config USE_PERCPU_NUMA_NODE_ID
1027	bool
1028
1029config HAVE_SETUP_PER_CPU_AREA
1030	bool
1031
1032config CMA
1033	bool "Contiguous Memory Allocator"
1034	depends on MMU
1035	select MIGRATION
1036	select MEMORY_ISOLATION
1037	help
1038	  This enables the Contiguous Memory Allocator which allows other
1039	  subsystems to allocate big physically-contiguous blocks of memory.
1040	  CMA reserves a region of memory and allows only movable pages to
1041	  be allocated from it. This way, the kernel can use the memory for
1042	  pagecache and when a subsystem requests for contiguous area, the
1043	  allocated pages are migrated away to serve the contiguous request.
1044
1045	  If unsure, say "n".
1046
1047config CMA_DEBUGFS
1048	bool "CMA debugfs interface"
1049	depends on CMA && DEBUG_FS
1050	help
1051	  Turns on the DebugFS interface for CMA.
1052
1053config CMA_SYSFS
1054	bool "CMA information through sysfs interface"
1055	depends on CMA && SYSFS
1056	help
1057	  This option exposes some sysfs attributes to get information
1058	  from CMA.
1059
1060config CMA_AREAS
1061	int "Maximum count of the CMA areas"
1062	depends on CMA
1063	default 20 if NUMA
1064	default 8
1065	help
1066	  CMA allows to create CMA areas for particular purpose, mainly,
1067	  used as device private area. This parameter sets the maximum
1068	  number of CMA area in the system.
1069
1070	  If unsure, leave the default value "8" in UMA and "20" in NUMA.
1071
1072#
1073# Select this config option from the architecture Kconfig, if available, to set
1074# the max page order for physically contiguous allocations.
1075#
1076config ARCH_FORCE_MAX_ORDER
1077	int
1078
1079#
1080# When ARCH_FORCE_MAX_ORDER is not defined,
1081# the default page block order is MAX_PAGE_ORDER (10) as per
1082# include/linux/mmzone.h.
1083#
1084config PAGE_BLOCK_MAX_ORDER
1085	int "Page Block Order Upper Limit"
1086	range 1 10 if ARCH_FORCE_MAX_ORDER = 0
1087	default 10 if ARCH_FORCE_MAX_ORDER = 0
1088	range 1 ARCH_FORCE_MAX_ORDER if ARCH_FORCE_MAX_ORDER != 0
1089	default ARCH_FORCE_MAX_ORDER if ARCH_FORCE_MAX_ORDER != 0
1090	help
1091	  The page block order refers to the power of two number of pages that
1092	  are physically contiguous and can have a migrate type associated to
1093	  them. The maximum size of the page block order is at least limited by
1094	  ARCH_FORCE_MAX_ORDER/MAX_PAGE_ORDER.
1095
1096	  This config adds a new upper limit of default page block
1097	  order when the page block order is required to be smaller than
1098	  ARCH_FORCE_MAX_ORDER/MAX_PAGE_ORDER or other limits
1099	  (see include/linux/pageblock-flags.h for details).
1100
1101	  Reducing pageblock order can negatively impact THP generation
1102	  success rate. If your workloads use THP heavily, please use this
1103	  option with caution.
1104
1105	  Don't change if unsure.
1106
1107config MEM_SOFT_DIRTY
1108	bool "Track memory changes"
1109	depends on CHECKPOINT_RESTORE && HAVE_ARCH_SOFT_DIRTY && PROC_FS
1110	select PROC_PAGE_MONITOR
1111	help
1112	  This option enables memory changes tracking by introducing a
1113	  soft-dirty bit on pte-s. This bit it set when someone writes
1114	  into a page just as regular dirty bit, but unlike the latter
1115	  it can be cleared by hands.
1116
1117	  See Documentation/admin-guide/mm/soft-dirty.rst for more details.
1118
1119config GENERIC_EARLY_IOREMAP
1120	bool
1121
1122config STACK_MAX_DEFAULT_SIZE_MB
1123	int "Default maximum user stack size for 32-bit processes (MB)"
1124	default 100
1125	range 8 2048
1126	depends on STACK_GROWSUP && (!64BIT || COMPAT)
1127	help
1128	  This is the maximum stack size in Megabytes in the VM layout of 32-bit
1129	  user processes when the stack grows upwards (currently only on parisc
1130	  arch) when the RLIMIT_STACK hard limit is unlimited.
1131
1132	  A sane initial value is 100 MB.
1133
1134config DEFERRED_STRUCT_PAGE_INIT
1135	bool "Defer initialisation of struct pages to kthreads"
1136	depends on SPARSEMEM
1137	depends on !NEED_PER_CPU_KM
1138	depends on 64BIT
1139	depends on !KMSAN
1140	select PADATA
1141	help
1142	  Ordinarily all struct pages are initialised during early boot in a
1143	  single thread. On very large machines this can take a considerable
1144	  amount of time. If this option is set, large machines will bring up
1145	  a subset of memmap at boot and then initialise the rest in parallel.
1146	  This has a potential performance impact on tasks running early in the
1147	  lifetime of the system until these kthreads finish the
1148	  initialisation.
1149
1150config PAGE_IDLE_FLAG
1151	bool
1152	select PAGE_EXTENSION if !64BIT
1153	help
1154	  This adds PG_idle and PG_young flags to 'struct page'.  PTE Accessed
1155	  bit writers can set the state of the bit in the flags so that PTE
1156	  Accessed bit readers may avoid disturbance.
1157
1158config IDLE_PAGE_TRACKING
1159	bool "Enable idle page tracking"
1160	depends on SYSFS && MMU
1161	select PAGE_IDLE_FLAG
1162	help
1163	  This feature allows to estimate the amount of user pages that have
1164	  not been touched during a given period of time. This information can
1165	  be useful to tune memory cgroup limits and/or for job placement
1166	  within a compute cluster.
1167
1168	  See Documentation/admin-guide/mm/idle_page_tracking.rst for
1169	  more details.
1170
1171# Architectures which implement cpu_dcache_is_aliasing() to query
1172# whether the data caches are aliased (VIVT or VIPT with dcache
1173# aliasing) need to select this.
1174config ARCH_HAS_CPU_CACHE_ALIASING
1175	bool
1176
1177config ARCH_HAS_CACHE_LINE_SIZE
1178	bool
1179
1180config ARCH_HAS_CURRENT_STACK_POINTER
1181	bool
1182	help
1183	  In support of HARDENED_USERCOPY performing stack variable lifetime
1184	  checking, an architecture-agnostic way to find the stack pointer
1185	  is needed. Once an architecture defines an unsigned long global
1186	  register alias named "current_stack_pointer", this config can be
1187	  selected.
1188
1189config ARCH_HAS_ZONE_DMA_SET
1190	bool
1191
1192config ZONE_DMA
1193	bool "Support DMA zone" if ARCH_HAS_ZONE_DMA_SET
1194	default y if ARM64 || X86
1195
1196config ZONE_DMA32
1197	bool "Support DMA32 zone" if ARCH_HAS_ZONE_DMA_SET
1198	depends on !X86_32
1199	default y if ARM64
1200
1201config ZONE_DEVICE
1202	bool "Device memory (pmem, HMM, etc...) hotplug support"
1203	depends on MEMORY_HOTPLUG
1204	depends on MEMORY_HOTREMOVE
1205	depends on SPARSEMEM_VMEMMAP
1206	select XARRAY_MULTI
1207
1208	help
1209	  Device memory hotplug support allows for establishing pmem,
1210	  or other device driver discovered memory regions, in the
1211	  memmap. This allows pfn_to_page() lookups of otherwise
1212	  "device-physical" addresses which is needed for using a DAX
1213	  mapping in an O_DIRECT operation, among other things.
1214
1215	  If FS_DAX is enabled, then say Y.
1216
1217#
1218# Helpers to mirror range of the CPU page tables of a process into device page
1219# tables.
1220#
1221config HMM_MIRROR
1222	bool
1223	depends on MMU
1224
1225config GET_FREE_REGION
1226	bool
1227
1228config DEVICE_PRIVATE
1229	bool "Unaddressable device memory (GPU memory, ...)"
1230	depends on ZONE_DEVICE
1231	select GET_FREE_REGION
1232
1233	help
1234	  Allows creation of struct pages to represent unaddressable device
1235	  memory; i.e., memory that is only accessible from the device (or
1236	  group of devices). You likely also want to select HMM_MIRROR.
1237
1238config VMAP_PFN
1239	bool
1240
1241config ARCH_USES_HIGH_VMA_FLAGS
1242	bool
1243config ARCH_HAS_PKEYS
1244	bool
1245
1246config ARCH_USES_PG_ARCH_2
1247	bool
1248config ARCH_USES_PG_ARCH_3
1249	bool
1250
1251config VM_EVENT_COUNTERS
1252	default y
1253	bool "Enable VM event counters for /proc/vmstat" if EXPERT
1254	help
1255	  VM event counters are needed for event counts to be shown.
1256	  This option allows the disabling of the VM event counters
1257	  on EXPERT systems.  /proc/vmstat will only show page counts
1258	  if VM event counters are disabled.
1259
1260config PERCPU_STATS
1261	bool "Collect percpu memory statistics"
1262	help
1263	  This feature collects and exposes statistics via debugfs. The
1264	  information includes global and per chunk statistics, which can
1265	  be used to help understand percpu memory usage.
1266
1267config GUP_TEST
1268	bool "Enable infrastructure for get_user_pages()-related unit tests"
1269	depends on DEBUG_FS
1270	help
1271	  Provides /sys/kernel/debug/gup_test, which in turn provides a way
1272	  to make ioctl calls that can launch kernel-based unit tests for
1273	  the get_user_pages*() and pin_user_pages*() family of API calls.
1274
1275	  These tests include benchmark testing of the _fast variants of
1276	  get_user_pages*() and pin_user_pages*(), as well as smoke tests of
1277	  the non-_fast variants.
1278
1279	  There is also a sub-test that allows running dump_page() on any
1280	  of up to eight pages (selected by command line args) within the
1281	  range of user-space addresses. These pages are either pinned via
1282	  pin_user_pages*(), or pinned via get_user_pages*(), as specified
1283	  by other command line arguments.
1284
1285	  See tools/testing/selftests/mm/gup_test.c
1286
1287comment "GUP_TEST needs to have DEBUG_FS enabled"
1288	depends on !GUP_TEST && !DEBUG_FS
1289
1290config GUP_GET_PXX_LOW_HIGH
1291	bool
1292
1293config DMAPOOL_TEST
1294	tristate "Enable a module to run time tests on dma_pool"
1295	depends on HAS_DMA
1296	help
1297	  Provides a test module that will allocate and free many blocks of
1298	  various sizes and report how long it takes. This is intended to
1299	  provide a consistent way to measure how changes to the
1300	  dma_pool_alloc/free routines affect performance.
1301
1302config ARCH_HAS_PTE_SPECIAL
1303	bool
1304
1305config MAPPING_DIRTY_HELPERS
1306        bool
1307
1308config KMAP_LOCAL
1309	bool
1310
1311config KMAP_LOCAL_NON_LINEAR_PTE_ARRAY
1312	bool
1313
1314config MEMFD_CREATE
1315	bool "Enable memfd_create() system call" if EXPERT
1316
1317config SECRETMEM
1318	default y
1319	bool "Enable memfd_secret() system call" if EXPERT
1320	depends on ARCH_HAS_SET_DIRECT_MAP
1321	help
1322	  Enable the memfd_secret() system call with the ability to create
1323	  memory areas visible only in the context of the owning process and
1324	  not mapped to other processes and other kernel page tables.
1325
1326config ANON_VMA_NAME
1327	bool "Anonymous VMA name support"
1328	depends on PROC_FS && ADVISE_SYSCALLS && MMU
1329
1330	help
1331	  Allow naming anonymous virtual memory areas.
1332
1333	  This feature allows assigning names to virtual memory areas. Assigned
1334	  names can be later retrieved from /proc/pid/maps and /proc/pid/smaps
1335	  and help identifying individual anonymous memory areas.
1336	  Assigning a name to anonymous virtual memory area might prevent that
1337	  area from being merged with adjacent virtual memory areas due to the
1338	  difference in their name.
1339
1340config HAVE_ARCH_USERFAULTFD_WP
1341	bool
1342	help
1343	  Arch has userfaultfd write protection support
1344
1345config HAVE_ARCH_USERFAULTFD_MINOR
1346	bool
1347	help
1348	  Arch has userfaultfd minor fault support
1349
1350menuconfig USERFAULTFD
1351	bool "Enable userfaultfd() system call"
1352	depends on MMU
1353	help
1354	  Enable the userfaultfd() system call that allows to intercept and
1355	  handle page faults in userland.
1356
1357if USERFAULTFD
1358config PTE_MARKER_UFFD_WP
1359	bool "Userfaultfd write protection support for shmem/hugetlbfs"
1360	default y
1361	depends on HAVE_ARCH_USERFAULTFD_WP
1362
1363	help
1364	  Allows to create marker PTEs for userfaultfd write protection
1365	  purposes.  It is required to enable userfaultfd write protection on
1366	  file-backed memory types like shmem and hugetlbfs.
1367endif # USERFAULTFD
1368
1369# multi-gen LRU {
1370config LRU_GEN
1371	bool "Multi-Gen LRU"
1372	depends on MMU
1373	# make sure folio->flags has enough spare bits
1374	depends on 64BIT || !SPARSEMEM || SPARSEMEM_VMEMMAP
1375	help
1376	  A high performance LRU implementation to overcommit memory. See
1377	  Documentation/admin-guide/mm/multigen_lru.rst for details.
1378
1379config LRU_GEN_ENABLED
1380	bool "Enable by default"
1381	depends on LRU_GEN
1382	help
1383	  This option enables the multi-gen LRU by default.
1384
1385config LRU_GEN_STATS
1386	bool "Full stats for debugging"
1387	depends on LRU_GEN
1388	help
1389	  Do not enable this option unless you plan to look at historical stats
1390	  from evicted generations for debugging purpose.
1391
1392	  This option has a per-memcg and per-node memory overhead.
1393
1394config LRU_GEN_WALKS_MMU
1395	def_bool y
1396	depends on LRU_GEN && ARCH_HAS_HW_PTE_YOUNG
1397# }
1398
1399config ARCH_SUPPORTS_PER_VMA_LOCK
1400       def_bool n
1401
1402config PER_VMA_LOCK
1403	def_bool y
1404	depends on ARCH_SUPPORTS_PER_VMA_LOCK && MMU && SMP
1405	help
1406	  Allow per-vma locking during page fault handling.
1407
1408	  This feature allows locking each virtual memory area separately when
1409	  handling page faults instead of taking mmap_lock.
1410
1411config LOCK_MM_AND_FIND_VMA
1412	bool
1413	depends on !STACK_GROWSUP
1414
1415config IOMMU_MM_DATA
1416	bool
1417
1418config EXECMEM
1419	bool
1420
1421config NUMA_MEMBLKS
1422	bool
1423
1424config NUMA_EMU
1425	bool "NUMA emulation"
1426	depends on NUMA_MEMBLKS
1427	depends on X86 || GENERIC_ARCH_NUMA
1428	help
1429	  Enable NUMA emulation. A flat machine will be split
1430	  into virtual nodes when booted with "numa=fake=N", where N is the
1431	  number of nodes. This is only useful for debugging.
1432
1433config ARCH_HAS_USER_SHADOW_STACK
1434	bool
1435	help
1436	  The architecture has hardware support for userspace shadow call
1437          stacks (eg, x86 CET, arm64 GCS or RISC-V Zicfiss).
1438
1439config ARCH_SUPPORTS_PT_RECLAIM
1440	def_bool n
1441
1442config PT_RECLAIM
1443	bool "reclaim empty user page table pages"
1444	default y
1445	depends on ARCH_SUPPORTS_PT_RECLAIM && MMU && SMP
1446	select MMU_GATHER_RCU_TABLE_FREE
1447	help
1448	  Try to reclaim empty user page table pages in paths other than munmap
1449	  and exit_mmap path.
1450
1451	  Note: now only empty user PTE page table pages will be reclaimed.
1452
1453config FIND_NORMAL_PAGE
1454	def_bool n
1455
1456source "mm/damon/Kconfig"
1457
1458endmenu
1459