162306a36Sopenharmony_ci============================== 262306a36Sopenharmony_ciremap_file_pages() system call 362306a36Sopenharmony_ci============================== 462306a36Sopenharmony_ci 562306a36Sopenharmony_ciThe remap_file_pages() system call is used to create a nonlinear mapping, 662306a36Sopenharmony_cithat is, a mapping in which the pages of the file are mapped into a 762306a36Sopenharmony_cinonsequential order in memory. The advantage of using remap_file_pages() 862306a36Sopenharmony_ciover using repeated calls to mmap(2) is that the former approach does not 962306a36Sopenharmony_cirequire the kernel to create additional VMA (Virtual Memory Area) data 1062306a36Sopenharmony_cistructures. 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ciSupporting of nonlinear mapping requires significant amount of non-trivial 1362306a36Sopenharmony_cicode in kernel virtual memory subsystem including hot paths. Also to get 1462306a36Sopenharmony_cinonlinear mapping work kernel need a way to distinguish normal page table 1562306a36Sopenharmony_cientries from entries with file offset (pte_file). Kernel reserves flag in 1662306a36Sopenharmony_ciPTE for this purpose. PTE flags are scarce resource especially on some CPU 1762306a36Sopenharmony_ciarchitectures. It would be nice to free up the flag for other usage. 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ciFortunately, there are not many users of remap_file_pages() in the wild. 2062306a36Sopenharmony_ciIt's only known that one enterprise RDBMS implementation uses the syscall 2162306a36Sopenharmony_cion 32-bit systems to map files bigger than can linearly fit into 32-bit 2262306a36Sopenharmony_civirtual address space. This use-case is not critical anymore since 64-bit 2362306a36Sopenharmony_cisystems are widely available. 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ciThe syscall is deprecated and replaced it with an emulation now. The 2662306a36Sopenharmony_ciemulation creates new VMAs instead of nonlinear mappings. It's going to 2762306a36Sopenharmony_ciwork slower for rare users of remap_file_pages() but ABI is preserved. 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ciOne side effect of emulation (apart from performance) is that user can hit 3062306a36Sopenharmony_civm.max_map_count limit more easily due to additional VMAs. See comment for 3162306a36Sopenharmony_ciDEFAULT_MAX_MAP_COUNT for more details on the limit. 32