1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 2bb1f17b0SAlexey Dobriyan #include <linux/mm_types.h> 3bb1f17b0SAlexey Dobriyan #include <linux/rbtree.h> 4bb1f17b0SAlexey Dobriyan #include <linux/rwsem.h> 5bb1f17b0SAlexey Dobriyan #include <linux/spinlock.h> 6bb1f17b0SAlexey Dobriyan #include <linux/list.h> 7bb1f17b0SAlexey Dobriyan #include <linux/cpumask.h> 8bb1f17b0SAlexey Dobriyan 960063497SArun Sharma #include <linux/atomic.h> 10bfedb589SEric W. Biederman #include <linux/user_namespace.h> 11bb1f17b0SAlexey Dobriyan #include <asm/pgtable.h> 12a1b200e2SHeiko Carstens #include <asm/mmu.h> 13a1b200e2SHeiko Carstens 14a1b200e2SHeiko Carstens #ifndef INIT_MM_CONTEXT 15a1b200e2SHeiko Carstens #define INIT_MM_CONTEXT(name) 16a1b200e2SHeiko Carstens #endif 17bb1f17b0SAlexey Dobriyan 18*c1a2f7f0SRik van Riel /* 19*c1a2f7f0SRik van Riel * For dynamically allocated mm_structs, there is a dynamically sized cpumask 20*c1a2f7f0SRik van Riel * at the end of the structure, the size of which depends on the maximum CPU 21*c1a2f7f0SRik van Riel * number the system can see. That way we allocate only as much memory for 22*c1a2f7f0SRik van Riel * mm_cpumask() as needed for the hundreds, or thousands of processes that 23*c1a2f7f0SRik van Riel * a system typically runs. 24*c1a2f7f0SRik van Riel * 25*c1a2f7f0SRik van Riel * Since there is only one init_mm in the entire system, keep it simple 26*c1a2f7f0SRik van Riel * and size this cpu_bitmask to NR_CPUS. 27*c1a2f7f0SRik van Riel */ 28bb1f17b0SAlexey Dobriyan struct mm_struct init_mm = { 29bb1f17b0SAlexey Dobriyan .mm_rb = RB_ROOT, 30bb1f17b0SAlexey Dobriyan .pgd = swapper_pg_dir, 31bb1f17b0SAlexey Dobriyan .mm_users = ATOMIC_INIT(2), 32bb1f17b0SAlexey Dobriyan .mm_count = ATOMIC_INIT(1), 33bb1f17b0SAlexey Dobriyan .mmap_sem = __RWSEM_INITIALIZER(init_mm.mmap_sem), 34bb1f17b0SAlexey Dobriyan .page_table_lock = __SPIN_LOCK_UNLOCKED(init_mm.page_table_lock), 3588aa7cc6SYang Shi .arg_lock = __SPIN_LOCK_UNLOCKED(init_mm.arg_lock), 36bb1f17b0SAlexey Dobriyan .mmlist = LIST_HEAD_INIT(init_mm.mmlist), 37bfedb589SEric W. Biederman .user_ns = &init_user_ns, 38*c1a2f7f0SRik van Riel .cpu_bitmap = { [BITS_TO_LONGS(NR_CPUS)] = 0}, 39a1b200e2SHeiko Carstens INIT_MM_CONTEXT(init_mm) 40bb1f17b0SAlexey Dobriyan }; 41