€•uߌsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ-/translations/zh_CN/admin-guide/mm/nommu-mmap”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ-/translations/zh_TW/admin-guide/mm/nommu-mmap”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ-/translations/it_IT/admin-guide/mm/nommu-mmap”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ-/translations/ja_JP/admin-guide/mm/nommu-mmap”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ-/translations/ko_KR/admin-guide/mm/nommu-mmap”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒPortuguese (Brazilian)”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ-/translations/pt_BR/admin-guide/mm/nommu-mmap”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ-/translations/sp_SP/admin-guide/mm/nommu-mmap”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒNo-MMU memory mapping support”h]”hŒNo-MMU memory mapping support”…””}”(hh¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhh·h²hh³ŒG/var/lib/git/docbuild/linux/Documentation/admin-guide/mm/nommu-mmap.rst”h´KubhŒ paragraph”“”)”}”(hX®The kernel has limited support for memory mapping under no-MMU conditions, such as are used in uClinux environments. From the userspace point of view, memory mapping is made use of in conjunction with the mmap() system call, the shmat() call and the execve() system call. From the kernel's point of view, execve() mapping is actually performed by the binfmt drivers, which call back into the mmap() routines to do the actual work.”h]”hX°The kernel has limited support for memory mapping under no-MMU conditions, such as are used in uClinux environments. From the userspace point of view, memory mapping is made use of in conjunction with the mmap() system call, the shmat() call and the execve() system call. From the kernel’s point of view, execve() mapping is actually performed by the binfmt drivers, which call back into the mmap() routines to do the actual work.”…””}”(hhÍh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khh·h²hubhÌ)”}”(hŒ¬Memory mapping behaviour also involves the way fork(), vfork(), clone() and ptrace() work. Under uClinux there is no fork(), and clone() must be supplied the CLONE_VM flag.”h]”hŒ¬Memory mapping behaviour also involves the way fork(), vfork(), clone() and ptrace() work. Under uClinux there is no fork(), and clone() must be supplied the CLONE_VM flag.”…””}”(hhÛh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K hh·h²hubhÌ)”}”(hŒ„The behaviour is similar between the MMU and no-MMU cases, but not identical; and it's also much more restricted in the latter case:”h]”hŒ†The behaviour is similar between the MMU and no-MMU cases, but not identical; and it’s also much more restricted in the latter case:”…””}”(hhéh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khh·h²hubhŒ block_quote”“”)”}”(hX¥(#) Anonymous mapping, MAP_PRIVATE In the MMU case: VM regions backed by arbitrary pages; copy-on-write across fork. In the no-MMU case: VM regions backed by arbitrary contiguous runs of pages. (#) Anonymous mapping, MAP_SHARED These behave very much like private mappings, except that they're shared across fork() or clone() without CLONE_VM in the MMU case. Since the no-MMU case doesn't support these, behaviour is identical to MAP_PRIVATE there. (#) File, MAP_PRIVATE, PROT_READ / PROT_EXEC, !PROT_WRITE In the MMU case: VM regions backed by pages read from file; changes to the underlying file are reflected in the mapping; copied across fork. In the no-MMU case: - If one exists, the kernel will reuse an existing mapping to the same segment of the same file if that has compatible permissions, even if this was created by another process. - If possible, the file mapping will be directly on the backing device if the backing device has the NOMMU_MAP_DIRECT capability and appropriate mapping protection capabilities. Ramfs, romfs, cramfs and mtd might all permit this. - If the backing device can't or won't permit direct sharing, but does have the NOMMU_MAP_COPY capability, then a copy of the appropriate bit of the file will be read into a contiguous bit of memory and any extraneous space beyond the EOF will be cleared - Writes to the file do not affect the mapping; writes to the mapping are visible in other processes (no MMU protection), but should not happen. (#) File, MAP_PRIVATE, PROT_READ / PROT_EXEC, PROT_WRITE In the MMU case: like the non-PROT_WRITE case, except that the pages in question get copied before the write actually happens. From that point on writes to the file underneath that page no longer get reflected into the mapping's backing pages. The page is then backed by swap instead. In the no-MMU case: works much like the non-PROT_WRITE case, except that a copy is always taken and never shared. (#) Regular file / blockdev, MAP_SHARED, PROT_READ / PROT_EXEC / PROT_WRITE In the MMU case: VM regions backed by pages read from file; changes to pages written back to file; writes to file reflected into pages backing mapping; shared across fork. In the no-MMU case: not supported. (#) Memory backed regular file, MAP_SHARED, PROT_READ / PROT_EXEC / PROT_WRITE In the MMU case: As for ordinary regular files. In the no-MMU case: The filesystem providing the memory-backed file (such as ramfs or tmpfs) may choose to honour an open, truncate, mmap sequence by providing a contiguous sequence of pages to map. In that case, a shared-writable memory mapping will be possible. It will work as for the MMU case. If the filesystem does not provide any such support, then the mapping request will be denied. (#) Memory backed blockdev, MAP_SHARED, PROT_READ / PROT_EXEC / PROT_WRITE In the MMU case: As for ordinary regular files. In the no-MMU case: As for memory backed regular files, but the blockdev must be able to provide a contiguous run of pages without truncate being called. The ramdisk driver could do this if it allocated all its memory as a contiguous array upfront. (#) Memory backed chardev, MAP_SHARED, PROT_READ / PROT_EXEC / PROT_WRITE In the MMU case: As for ordinary regular files. In the no-MMU case: The character device driver may choose to honour the mmap() by providing direct access to the underlying device if it provides memory or quasi-memory that can be accessed directly. Examples of such are frame buffers and flash devices. If the driver does not provide any such support, then the mapping request will be denied. ”h]”hŒenumerated_list”“”)”}”(hhh]”(hŒ list_item”“”)”}”(hŒÌAnonymous mapping, MAP_PRIVATE In the MMU case: VM regions backed by arbitrary pages; copy-on-write across fork. In the no-MMU case: VM regions backed by arbitrary contiguous runs of pages. ”h]”(hÌ)”}”(hŒAnonymous mapping, MAP_PRIVATE”h]”hŒAnonymous mapping, MAP_PRIVATE”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khjubhø)”}”(hŒ In the MMU case: VM regions backed by arbitrary pages; copy-on-write across fork. In the no-MMU case: VM regions backed by arbitrary contiguous runs of pages. ”h]”(hÌ)”}”(hŒQIn the MMU case: VM regions backed by arbitrary pages; copy-on-write across fork.”h]”hŒQIn the MMU case: VM regions backed by arbitrary pages; copy-on-write across fork.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KhjubhÌ)”}”(hŒLIn the no-MMU case: VM regions backed by arbitrary contiguous runs of pages.”h]”hŒLIn the no-MMU case: VM regions backed by arbitrary contiguous runs of pages.”…””}”(hj(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khjubeh}”(h]”h ]”h"]”h$]”h&]”uh1h÷h³hÊh´Khjubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhhÿubj)”}”(hX Anonymous mapping, MAP_SHARED These behave very much like private mappings, except that they're shared across fork() or clone() without CLONE_VM in the MMU case. Since the no-MMU case doesn't support these, behaviour is identical to MAP_PRIVATE there. ”h]”(hÌ)”}”(hŒAnonymous mapping, MAP_SHARED”h]”hŒAnonymous mapping, MAP_SHARED”…””}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KhjBubhø)”}”(hŒÞThese behave very much like private mappings, except that they're shared across fork() or clone() without CLONE_VM in the MMU case. Since the no-MMU case doesn't support these, behaviour is identical to MAP_PRIVATE there. ”h]”hÌ)”}”(hŒÝThese behave very much like private mappings, except that they're shared across fork() or clone() without CLONE_VM in the MMU case. Since the no-MMU case doesn't support these, behaviour is identical to MAP_PRIVATE there.”h]”hŒáThese behave very much like private mappings, except that they’re shared across fork() or clone() without CLONE_VM in the MMU case. Since the no-MMU case doesn’t support these, behaviour is identical to MAP_PRIVATE there.”…””}”(hjXh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KhjTubah}”(h]”h ]”h"]”h$]”h&]”uh1h÷h³hÊh´KhjBubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhhÿubj)”}”(hXYFile, MAP_PRIVATE, PROT_READ / PROT_EXEC, !PROT_WRITE In the MMU case: VM regions backed by pages read from file; changes to the underlying file are reflected in the mapping; copied across fork. In the no-MMU case: - If one exists, the kernel will reuse an existing mapping to the same segment of the same file if that has compatible permissions, even if this was created by another process. - If possible, the file mapping will be directly on the backing device if the backing device has the NOMMU_MAP_DIRECT capability and appropriate mapping protection capabilities. Ramfs, romfs, cramfs and mtd might all permit this. - If the backing device can't or won't permit direct sharing, but does have the NOMMU_MAP_COPY capability, then a copy of the appropriate bit of the file will be read into a contiguous bit of memory and any extraneous space beyond the EOF will be cleared - Writes to the file do not affect the mapping; writes to the mapping are visible in other processes (no MMU protection), but should not happen. ”h]”(hÌ)”}”(hŒ5File, MAP_PRIVATE, PROT_READ / PROT_EXEC, !PROT_WRITE”h]”hŒ5File, MAP_PRIVATE, PROT_READ / PROT_EXEC, !PROT_WRITE”…””}”(hjvh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K"hjrubhø)”}”(hXïIn the MMU case: VM regions backed by pages read from file; changes to the underlying file are reflected in the mapping; copied across fork. In the no-MMU case: - If one exists, the kernel will reuse an existing mapping to the same segment of the same file if that has compatible permissions, even if this was created by another process. - If possible, the file mapping will be directly on the backing device if the backing device has the NOMMU_MAP_DIRECT capability and appropriate mapping protection capabilities. Ramfs, romfs, cramfs and mtd might all permit this. - If the backing device can't or won't permit direct sharing, but does have the NOMMU_MAP_COPY capability, then a copy of the appropriate bit of the file will be read into a contiguous bit of memory and any extraneous space beyond the EOF will be cleared - Writes to the file do not affect the mapping; writes to the mapping are visible in other processes (no MMU protection), but should not happen. ”h]”(hÌ)”}”(hŒŒIn the MMU case: VM regions backed by pages read from file; changes to the underlying file are reflected in the mapping; copied across fork.”h]”hŒŒIn the MMU case: VM regions backed by pages read from file; changes to the underlying file are reflected in the mapping; copied across fork.”…””}”(hjˆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K$hj„ubhÌ)”}”(hŒIn the no-MMU case:”h]”hŒIn the no-MMU case:”…””}”(hj–h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K'hj„ubhø)”}”(hX>- If one exists, the kernel will reuse an existing mapping to the same segment of the same file if that has compatible permissions, even if this was created by another process. - If possible, the file mapping will be directly on the backing device if the backing device has the NOMMU_MAP_DIRECT capability and appropriate mapping protection capabilities. Ramfs, romfs, cramfs and mtd might all permit this. - If the backing device can't or won't permit direct sharing, but does have the NOMMU_MAP_COPY capability, then a copy of the appropriate bit of the file will be read into a contiguous bit of memory and any extraneous space beyond the EOF will be cleared - Writes to the file do not affect the mapping; writes to the mapping are visible in other processes (no MMU protection), but should not happen. ”h]”hŒ bullet_list”“”)”}”(hhh]”(j)”}”(hŒ¯If one exists, the kernel will reuse an existing mapping to the same segment of the same file if that has compatible permissions, even if this was created by another process. ”h]”hÌ)”}”(hŒ®If one exists, the kernel will reuse an existing mapping to the same segment of the same file if that has compatible permissions, even if this was created by another process.”h]”hŒ®If one exists, the kernel will reuse an existing mapping to the same segment of the same file if that has compatible permissions, even if this was created by another process.”…””}”(hj±h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K)hj­ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjªubj)”}”(hŒäIf possible, the file mapping will be directly on the backing device if the backing device has the NOMMU_MAP_DIRECT capability and appropriate mapping protection capabilities. Ramfs, romfs, cramfs and mtd might all permit this. ”h]”hÌ)”}”(hŒãIf possible, the file mapping will be directly on the backing device if the backing device has the NOMMU_MAP_DIRECT capability and appropriate mapping protection capabilities. Ramfs, romfs, cramfs and mtd might all permit this.”h]”hŒãIf possible, the file mapping will be directly on the backing device if the backing device has the NOMMU_MAP_DIRECT capability and appropriate mapping protection capabilities. Ramfs, romfs, cramfs and mtd might all permit this.”…””}”(hjÉh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K-hjÅubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjªubj)”}”(hŒýIf the backing device can't or won't permit direct sharing, but does have the NOMMU_MAP_COPY capability, then a copy of the appropriate bit of the file will be read into a contiguous bit of memory and any extraneous space beyond the EOF will be cleared ”h]”hÌ)”}”(hŒüIf the backing device can't or won't permit direct sharing, but does have the NOMMU_MAP_COPY capability, then a copy of the appropriate bit of the file will be read into a contiguous bit of memory and any extraneous space beyond the EOF will be cleared”h]”hXIf the backing device can’t or won’t permit direct sharing, but does have the NOMMU_MAP_COPY capability, then a copy of the appropriate bit of the file will be read into a contiguous bit of memory and any extraneous space beyond the EOF will be cleared”…””}”(hjáh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K2hjÝubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjªubj)”}”(hŒWrites to the file do not affect the mapping; writes to the mapping are visible in other processes (no MMU protection), but should not happen. ”h]”hÌ)”}”(hŒŽWrites to the file do not affect the mapping; writes to the mapping are visible in other processes (no MMU protection), but should not happen.”h]”hŒŽWrites to the file do not affect the mapping; writes to the mapping are visible in other processes (no MMU protection), but should not happen.”…””}”(hjùh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K7hjõubah}”(h]”h ]”h"]”h$]”h&]”uh1jhjªubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1j¨h³hÊh´K)hj¤ubah}”(h]”h ]”h"]”h$]”h&]”uh1h÷h³hÊh´K)hj„ubeh}”(h]”h ]”h"]”h$]”h&]”uh1h÷h³hÊh´K$hjrubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhhÿubj)”}”(hXØFile, MAP_PRIVATE, PROT_READ / PROT_EXEC, PROT_WRITE In the MMU case: like the non-PROT_WRITE case, except that the pages in question get copied before the write actually happens. From that point on writes to the file underneath that page no longer get reflected into the mapping's backing pages. The page is then backed by swap instead. In the no-MMU case: works much like the non-PROT_WRITE case, except that a copy is always taken and never shared. ”h]”(hÌ)”}”(hŒ4File, MAP_PRIVATE, PROT_READ / PROT_EXEC, PROT_WRITE”h]”hŒ4File, MAP_PRIVATE, PROT_READ / PROT_EXEC, PROT_WRITE”…””}”(hj+h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K;hj'ubhø)”}”(hXIn the MMU case: like the non-PROT_WRITE case, except that the pages in question get copied before the write actually happens. From that point on writes to the file underneath that page no longer get reflected into the mapping's backing pages. The page is then backed by swap instead. In the no-MMU case: works much like the non-PROT_WRITE case, except that a copy is always taken and never shared. ”h]”(hÌ)”}”(hXIn the MMU case: like the non-PROT_WRITE case, except that the pages in question get copied before the write actually happens. From that point on writes to the file underneath that page no longer get reflected into the mapping's backing pages. The page is then backed by swap instead.”h]”hXIn the MMU case: like the non-PROT_WRITE case, except that the pages in question get copied before the write actually happens. From that point on writes to the file underneath that page no longer get reflected into the mapping’s backing pages. The page is then backed by swap instead.”…””}”(hj=h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K=hj9ubhÌ)”}”(hŒqIn the no-MMU case: works much like the non-PROT_WRITE case, except that a copy is always taken and never shared.”h]”hŒqIn the no-MMU case: works much like the non-PROT_WRITE case, except that a copy is always taken and never shared.”…””}”(hjKh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KBhj9ubeh}”(h]”h ]”h"]”h$]”h&]”uh1h÷h³hÊh´K=hj'ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhhÿubj)”}”(hX%Regular file / blockdev, MAP_SHARED, PROT_READ / PROT_EXEC / PROT_WRITE In the MMU case: VM regions backed by pages read from file; changes to pages written back to file; writes to file reflected into pages backing mapping; shared across fork. In the no-MMU case: not supported. ”h]”(hÌ)”}”(hŒGRegular file / blockdev, MAP_SHARED, PROT_READ / PROT_EXEC / PROT_WRITE”h]”hŒGRegular file / blockdev, MAP_SHARED, PROT_READ / PROT_EXEC / PROT_WRITE”…””}”(hjih²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KEhjeubhø)”}”(hŒÐIn the MMU case: VM regions backed by pages read from file; changes to pages written back to file; writes to file reflected into pages backing mapping; shared across fork. In the no-MMU case: not supported. ”h]”(hÌ)”}”(hŒ«In the MMU case: VM regions backed by pages read from file; changes to pages written back to file; writes to file reflected into pages backing mapping; shared across fork.”h]”hŒ«In the MMU case: VM regions backed by pages read from file; changes to pages written back to file; writes to file reflected into pages backing mapping; shared across fork.”…””}”(hj{h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KGhjwubhÌ)”}”(hŒ"In the no-MMU case: not supported.”h]”hŒ"In the no-MMU case: not supported.”…””}”(hj‰h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KKhjwubeh}”(h]”h ]”h"]”h$]”h&]”uh1h÷h³hÊh´KGhjeubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhhÿubj)”}”(hXMemory backed regular file, MAP_SHARED, PROT_READ / PROT_EXEC / PROT_WRITE In the MMU case: As for ordinary regular files. In the no-MMU case: The filesystem providing the memory-backed file (such as ramfs or tmpfs) may choose to honour an open, truncate, mmap sequence by providing a contiguous sequence of pages to map. In that case, a shared-writable memory mapping will be possible. It will work as for the MMU case. If the filesystem does not provide any such support, then the mapping request will be denied. ”h]”(hÌ)”}”(hŒJMemory backed regular file, MAP_SHARED, PROT_READ / PROT_EXEC / PROT_WRITE”h]”hŒJMemory backed regular file, MAP_SHARED, PROT_READ / PROT_EXEC / PROT_WRITE”…””}”(hj§h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KMhj£ubhø)”}”(hX¹In the MMU case: As for ordinary regular files. In the no-MMU case: The filesystem providing the memory-backed file (such as ramfs or tmpfs) may choose to honour an open, truncate, mmap sequence by providing a contiguous sequence of pages to map. In that case, a shared-writable memory mapping will be possible. It will work as for the MMU case. If the filesystem does not provide any such support, then the mapping request will be denied. ”h]”(hÌ)”}”(hŒ/In the MMU case: As for ordinary regular files.”h]”hŒ/In the MMU case: As for ordinary regular files.”…””}”(hj¹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KOhjµubhÌ)”}”(hX‡In the no-MMU case: The filesystem providing the memory-backed file (such as ramfs or tmpfs) may choose to honour an open, truncate, mmap sequence by providing a contiguous sequence of pages to map. In that case, a shared-writable memory mapping will be possible. It will work as for the MMU case. If the filesystem does not provide any such support, then the mapping request will be denied.”h]”hX‡In the no-MMU case: The filesystem providing the memory-backed file (such as ramfs or tmpfs) may choose to honour an open, truncate, mmap sequence by providing a contiguous sequence of pages to map. In that case, a shared-writable memory mapping will be possible. It will work as for the MMU case. If the filesystem does not provide any such support, then the mapping request will be denied.”…””}”(hjÇh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KQhjµubeh}”(h]”h ]”h"]”h$]”h&]”uh1h÷h³hÊh´KOhj£ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhhÿubj)”}”(hXMemory backed blockdev, MAP_SHARED, PROT_READ / PROT_EXEC / PROT_WRITE In the MMU case: As for ordinary regular files. In the no-MMU case: As for memory backed regular files, but the blockdev must be able to provide a contiguous run of pages without truncate being called. The ramdisk driver could do this if it allocated all its memory as a contiguous array upfront. ”h]”(hÌ)”}”(hŒFMemory backed blockdev, MAP_SHARED, PROT_READ / PROT_EXEC / PROT_WRITE”h]”hŒFMemory backed blockdev, MAP_SHARED, PROT_READ / PROT_EXEC / PROT_WRITE”…””}”(hjåh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KXhjáubhø)”}”(hX*In the MMU case: As for ordinary regular files. In the no-MMU case: As for memory backed regular files, but the blockdev must be able to provide a contiguous run of pages without truncate being called. The ramdisk driver could do this if it allocated all its memory as a contiguous array upfront. ”h]”(hÌ)”}”(hŒ/In the MMU case: As for ordinary regular files.”h]”hŒ/In the MMU case: As for ordinary regular files.”…””}”(hj÷h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KZhjóubhÌ)”}”(hŒøIn the no-MMU case: As for memory backed regular files, but the blockdev must be able to provide a contiguous run of pages without truncate being called. The ramdisk driver could do this if it allocated all its memory as a contiguous array upfront.”h]”hŒøIn the no-MMU case: As for memory backed regular files, but the blockdev must be able to provide a contiguous run of pages without truncate being called. The ramdisk driver could do this if it allocated all its memory as a contiguous array upfront.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K\hjóubeh}”(h]”h ]”h"]”h$]”h&]”uh1h÷h³hÊh´KZhjáubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhhÿubj)”}”(hXäMemory backed chardev, MAP_SHARED, PROT_READ / PROT_EXEC / PROT_WRITE In the MMU case: As for ordinary regular files. In the no-MMU case: The character device driver may choose to honour the mmap() by providing direct access to the underlying device if it provides memory or quasi-memory that can be accessed directly. Examples of such are frame buffers and flash devices. If the driver does not provide any such support, then the mapping request will be denied. ”h]”(hÌ)”}”(hŒEMemory backed chardev, MAP_SHARED, PROT_READ / PROT_EXEC / PROT_WRITE”h]”hŒEMemory backed chardev, MAP_SHARED, PROT_READ / PROT_EXEC / PROT_WRITE”…””}”(hj#h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kahjubhø)”}”(hX‹In the MMU case: As for ordinary regular files. In the no-MMU case: The character device driver may choose to honour the mmap() by providing direct access to the underlying device if it provides memory or quasi-memory that can be accessed directly. Examples of such are frame buffers and flash devices. If the driver does not provide any such support, then the mapping request will be denied. ”h]”(hÌ)”}”(hŒ/In the MMU case: As for ordinary regular files.”h]”hŒ/In the MMU case: As for ordinary regular files.”…””}”(hj5h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kchj1ubhÌ)”}”(hXXIn the no-MMU case: The character device driver may choose to honour the mmap() by providing direct access to the underlying device if it provides memory or quasi-memory that can be accessed directly. Examples of such are frame buffers and flash devices. If the driver does not provide any such support, then the mapping request will be denied.”h]”hXXIn the no-MMU case: The character device driver may choose to honour the mmap() by providing direct access to the underlying device if it provides memory or quasi-memory that can be accessed directly. Examples of such are frame buffers and flash devices. If the driver does not provide any such support, then the mapping request will be denied.”…””}”(hjCh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kehj1ubeh}”(h]”h ]”h"]”h$]”h&]”uh1h÷h³hÊh´Kchjubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhhÿubeh}”(h]”h ]”h"]”h$]”h&]”Œenumtype”Œarabic”Œprefix”Œ(”Œsuffix”Œ)”uh1hýhhùubah}”(h]”h ]”h"]”h$]”h&]”uh1h÷h³hÊh´Khh·h²hubh¶)”}”(hhh]”(h»)”}”(hŒFurther notes on no-MMU MMAP”h]”hŒFurther notes on no-MMU MMAP”…””}”(hjrh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjoh²hh³hÊh´Kmubhø)”}”(hXs (#) A request for a private mapping of a file may return a buffer that is not page-aligned. This is because XIP may take place, and the data may not be paged aligned in the backing store. (#) A request for an anonymous mapping will always be page aligned. If possible the size of the request should be a power of two otherwise some of the space may be wasted as the kernel must allocate a power-of-2 granule but will only discard the excess if appropriately configured as this has an effect on fragmentation. (#) The memory allocated by a request for an anonymous mapping will normally be cleared by the kernel before being returned in accordance with the Linux man pages (ver 2.22 or later). In the MMU case this can be achieved with reasonable performance as regions are backed by virtual pages, with the contents only being mapped to cleared physical pages when a write happens on that specific page (prior to which, the pages are effectively mapped to the global zero page from which reads can take place). This spreads out the time it takes to initialize the contents of a page - depending on the write-usage of the mapping. In the no-MMU case, however, anonymous mappings are backed by physical pages, and the entire map is cleared at allocation time. This can cause significant delays during a userspace malloc() as the C library does an anonymous mapping and the kernel then does a memset for the entire map. However, for memory that isn't required to be precleared - such as that returned by malloc() - mmap() can take a MAP_UNINITIALIZED flag to indicate to the kernel that it shouldn't bother clearing the memory before returning it. Note that CONFIG_MMAP_ALLOW_UNINITIALIZED must be enabled to permit this, otherwise the flag will be ignored. uClibc uses this to speed up malloc(), and the ELF-FDPIC binfmt uses this to allocate the brk and stack region. (#) A list of all the private copy and anonymous mappings on the system is visible through /proc/maps in no-MMU mode. (#) A list of all the mappings in use by a process is visible through /proc//maps in no-MMU mode. (#) Supplying MAP_FIXED or a requesting a particular mapping address will result in an error. (#) Files mapped privately usually have to have a read method provided by the driver or filesystem so that the contents can be read into the memory allocated if mmap() chooses not to map the backing device directly. An error will result if they don't. This is most likely to be encountered with character device files, pipes, fifos and sockets. ”h]”hþ)”}”(hhh]”(j)”}”(hŒ¹A request for a private mapping of a file may return a buffer that is not page-aligned. This is because XIP may take place, and the data may not be paged aligned in the backing store. ”h]”hÌ)”}”(hŒ¸A request for a private mapping of a file may return a buffer that is not page-aligned. This is because XIP may take place, and the data may not be paged aligned in the backing store.”h]”hŒ¸A request for a private mapping of a file may return a buffer that is not page-aligned. This is because XIP may take place, and the data may not be paged aligned in the backing store.”…””}”(hj‹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kohj‡ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj„ubj)”}”(hX>A request for an anonymous mapping will always be page aligned. If possible the size of the request should be a power of two otherwise some of the space may be wasted as the kernel must allocate a power-of-2 granule but will only discard the excess if appropriately configured as this has an effect on fragmentation. ”h]”hÌ)”}”(hX=A request for an anonymous mapping will always be page aligned. If possible the size of the request should be a power of two otherwise some of the space may be wasted as the kernel must allocate a power-of-2 granule but will only discard the excess if appropriately configured as this has an effect on fragmentation.”h]”hX=A request for an anonymous mapping will always be page aligned. If possible the size of the request should be a power of two otherwise some of the space may be wasted as the kernel must allocate a power-of-2 granule but will only discard the excess if appropriately configured as this has an effect on fragmentation.”…””}”(hj£h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KshjŸubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj„ubj)”}”(hXQThe memory allocated by a request for an anonymous mapping will normally be cleared by the kernel before being returned in accordance with the Linux man pages (ver 2.22 or later). In the MMU case this can be achieved with reasonable performance as regions are backed by virtual pages, with the contents only being mapped to cleared physical pages when a write happens on that specific page (prior to which, the pages are effectively mapped to the global zero page from which reads can take place). This spreads out the time it takes to initialize the contents of a page - depending on the write-usage of the mapping. In the no-MMU case, however, anonymous mappings are backed by physical pages, and the entire map is cleared at allocation time. This can cause significant delays during a userspace malloc() as the C library does an anonymous mapping and the kernel then does a memset for the entire map. However, for memory that isn't required to be precleared - such as that returned by malloc() - mmap() can take a MAP_UNINITIALIZED flag to indicate to the kernel that it shouldn't bother clearing the memory before returning it. Note that CONFIG_MMAP_ALLOW_UNINITIALIZED must be enabled to permit this, otherwise the flag will be ignored. uClibc uses this to speed up malloc(), and the ELF-FDPIC binfmt uses this to allocate the brk and stack region. ”h]”(hÌ)”}”(hŒ³The memory allocated by a request for an anonymous mapping will normally be cleared by the kernel before being returned in accordance with the Linux man pages (ver 2.22 or later).”h]”hŒ³The memory allocated by a request for an anonymous mapping will normally be cleared by the kernel before being returned in accordance with the Linux man pages (ver 2.22 or later).”…””}”(hj»h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kyhj·ubhÌ)”}”(hXµIn the MMU case this can be achieved with reasonable performance as regions are backed by virtual pages, with the contents only being mapped to cleared physical pages when a write happens on that specific page (prior to which, the pages are effectively mapped to the global zero page from which reads can take place). This spreads out the time it takes to initialize the contents of a page - depending on the write-usage of the mapping.”h]”hXµIn the MMU case this can be achieved with reasonable performance as regions are backed by virtual pages, with the contents only being mapped to cleared physical pages when a write happens on that specific page (prior to which, the pages are effectively mapped to the global zero page from which reads can take place). This spreads out the time it takes to initialize the contents of a page - depending on the write-usage of the mapping.”…””}”(hjÉh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K}hj·ubhÌ)”}”(hXIn the no-MMU case, however, anonymous mappings are backed by physical pages, and the entire map is cleared at allocation time. This can cause significant delays during a userspace malloc() as the C library does an anonymous mapping and the kernel then does a memset for the entire map.”h]”hXIn the no-MMU case, however, anonymous mappings are backed by physical pages, and the entire map is cleared at allocation time. This can cause significant delays during a userspace malloc() as the C library does an anonymous mapping and the kernel then does a memset for the entire map.”…””}”(hj×h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K…hj·ubhÌ)”}”(hXRHowever, for memory that isn't required to be precleared - such as that returned by malloc() - mmap() can take a MAP_UNINITIALIZED flag to indicate to the kernel that it shouldn't bother clearing the memory before returning it. Note that CONFIG_MMAP_ALLOW_UNINITIALIZED must be enabled to permit this, otherwise the flag will be ignored.”h]”hXVHowever, for memory that isn’t required to be precleared - such as that returned by malloc() - mmap() can take a MAP_UNINITIALIZED flag to indicate to the kernel that it shouldn’t bother clearing the memory before returning it. Note that CONFIG_MMAP_ALLOW_UNINITIALIZED must be enabled to permit this, otherwise the flag will be ignored.”…””}”(hjåh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KŠhj·ubhÌ)”}”(hŒouClibc uses this to speed up malloc(), and the ELF-FDPIC binfmt uses this to allocate the brk and stack region.”h]”hŒouClibc uses this to speed up malloc(), and the ELF-FDPIC binfmt uses this to allocate the brk and stack region.”…””}”(hjóh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Khj·ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhj„ubj)”}”(hŒrA list of all the private copy and anonymous mappings on the system is visible through /proc/maps in no-MMU mode. ”h]”hÌ)”}”(hŒqA list of all the private copy and anonymous mappings on the system is visible through /proc/maps in no-MMU mode.”h]”hŒqA list of all the private copy and anonymous mappings on the system is visible through /proc/maps in no-MMU mode.”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K“hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj„ubj)”}”(hŒcA list of all the mappings in use by a process is visible through /proc//maps in no-MMU mode. ”h]”hÌ)”}”(hŒbA list of all the mappings in use by a process is visible through /proc//maps in no-MMU mode.”h]”hŒbA list of all the mappings in use by a process is visible through /proc//maps in no-MMU mode.”…””}”(hj#h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K–hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj„ubj)”}”(hŒZSupplying MAP_FIXED or a requesting a particular mapping address will result in an error. ”h]”hÌ)”}”(hŒYSupplying MAP_FIXED or a requesting a particular mapping address will result in an error.”h]”hŒYSupplying MAP_FIXED or a requesting a particular mapping address will result in an error.”…””}”(hj;h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K™hj7ubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj„ubj)”}”(hXVFiles mapped privately usually have to have a read method provided by the driver or filesystem so that the contents can be read into the memory allocated if mmap() chooses not to map the backing device directly. An error will result if they don't. This is most likely to be encountered with character device files, pipes, fifos and sockets. ”h]”hÌ)”}”(hXTFiles mapped privately usually have to have a read method provided by the driver or filesystem so that the contents can be read into the memory allocated if mmap() chooses not to map the backing device directly. An error will result if they don't. This is most likely to be encountered with character device files, pipes, fifos and sockets.”h]”hXVFiles mapped privately usually have to have a read method provided by the driver or filesystem so that the contents can be read into the memory allocated if mmap() chooses not to map the backing device directly. An error will result if they don’t. This is most likely to be encountered with character device files, pipes, fifos and sockets.”…””}”(hjSh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KœhjOubah}”(h]”h ]”h"]”h$]”h&]”uh1jhj„ubeh}”(h]”h ]”h"]”h$]”h&]”jcjdjejfjgjhuh1hýhj€ubah}”(h]”h ]”h"]”h$]”h&]”uh1h÷h³hÊh´Kohjoh²hubeh}”(h]”Œfurther-notes-on-no-mmu-mmap”ah ]”h"]”Œfurther notes on no-mmu mmap”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kmubh¶)”}”(hhh]”(h»)”}”(hŒInterprocess shared memory”h]”hŒInterprocess shared memory”…””}”(hj~h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj{h²hh³hÊh´K¤ubhÌ)”}”(hŒ·Both SYSV IPC SHM shared memory and POSIX shared memory is supported in NOMMU mode. The former through the usual mechanism, the latter through files created on ramfs or tmpfs mounts.”h]”hŒ·Both SYSV IPC SHM shared memory and POSIX shared memory is supported in NOMMU mode. The former through the usual mechanism, the latter through files created on ramfs or tmpfs mounts.”…””}”(hjŒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K¦hj{h²hubeh}”(h]”Œinterprocess-shared-memory”ah ]”h"]”Œinterprocess shared memory”ah$]”h&]”uh1hµhh·h²hh³hÊh´K¤ubh¶)”}”(hhh]”(h»)”}”(hŒFutexes”h]”hŒFutexes”…””}”(hj¥h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj¢h²hh³hÊh´K¬ubhÌ)”}”(hXFutexes are supported in NOMMU mode if the arch supports them. An error will be given if an address passed to the futex system call lies outside the mappings made by a process or if the mapping in which the address lies does not support futexes (such as an I/O chardev mapping).”h]”hXFutexes are supported in NOMMU mode if the arch supports them. An error will be given if an address passed to the futex system call lies outside the mappings made by a process or if the mapping in which the address lies does not support futexes (such as an I/O chardev mapping).”…””}”(hj³h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K®hj¢h²hubeh}”(h]”Œfutexes”ah ]”h"]”Œfutexes”ah$]”h&]”uh1hµhh·h²hh³hÊh´K¬ubh¶)”}”(hhh]”(h»)”}”(hŒ No-MMU mremap”h]”hŒ No-MMU mremap”…””}”(hjÌh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjÉh²hh³hÊh´KµubhÌ)”}”(hX7The mremap() function is partially supported. It may change the size of a mapping, and may move it [#]_ if MREMAP_MAYMOVE is specified and if the new size of the mapping exceeds the size of the slab object currently occupied by the memory to which the mapping refers, or if a smaller slab object could be used.”h]”(hŒdThe mremap() function is partially supported. It may change the size of a mapping, and may move it ”…””}”(hjÚh²hh³Nh´NubhŒfootnote_reference”“”)”}”(hŒ[#]_”h]”hŒ1”…””}”(hjäh²hh³Nh´Nubah}”(h]”Œid1”ah ]”h"]”h$]”h&]”Œauto”KŒrefid”Œid2”Œdocname”Œadmin-guide/mm/nommu-mmap”uh1jâhjÚŒresolved”KubhŒÏ if MREMAP_MAYMOVE is specified and if the new size of the mapping exceeds the size of the slab object currently occupied by the memory to which the mapping refers, or if a smaller slab object could be used.”…””}”(hjÚh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K·hjÉh²hubhÌ)”}”(hŒ}MREMAP_FIXED is not supported, though it is ignored if there's no change of address and the object does not need to be moved.”h]”hŒMREMAP_FIXED is not supported, though it is ignored if there’s no change of address and the object does not need to be moved.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K¼hjÉh²hubhÌ)”}”(hŒuShared mappings may not be moved. Shareable mappings may not be moved either, even if they are not currently shared.”h]”hŒuShared mappings may not be moved. Shareable mappings may not be moved either, even if they are not currently shared.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K¿hjÉh²hubhÌ)”}”(hXThe mremap() function must be given an exact match for base address and size of a previously mapped object. It may not be used to create holes in existing mappings, move parts of existing mappings or resize parts of mappings. It must act on a complete mapping.”h]”hXThe mremap() function must be given an exact match for base address and size of a previously mapped object. It may not be used to create holes in existing mappings, move parts of existing mappings or resize parts of mappings. It must act on a complete mapping.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÂhjÉh²hubhŒfootnote”“”)”}”(hŒNot currently supported. ”h]”(hŒlabel”“”)”}”(hhh]”hŒ1”…””}”(hj5h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j3hj/h²hh³Nh´NubhÌ)”}”(hŒNot currently supported.”h]”hŒNot currently supported.”…””}”(hjBh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÇhj/ubeh}”(h]”jõah ]”h"]”Œ1”ah$]”h&]”jîajóKjöj÷uh1j-h³hÊh´KÇhjÉh²hubeh}”(h]”Œ no-mmu-mremap”ah ]”h"]”Œ no-mmu mremap”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kµubh¶)”}”(hhh]”(h»)”}”(hŒ,Providing shareable character device support”h]”hŒ,Providing shareable character device support”…””}”(hjbh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj_h²hh³hÊh´KËubhÌ)”}”(hXdTo provide shareable character device support, a driver must provide a file->f_op->get_unmapped_area() operation. The mmap() routines will call this to get a proposed address for the mapping. This may return an error if it doesn't wish to honour the mapping because it's too long, at a weird offset, under some unsupported combination of flags or whatever.”h]”hXhTo provide shareable character device support, a driver must provide a file->f_op->get_unmapped_area() operation. The mmap() routines will call this to get a proposed address for the mapping. This may return an error if it doesn’t wish to honour the mapping because it’s too long, at a weird offset, under some unsupported combination of flags or whatever.”…””}”(hjph²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÍhj_h²hubhÌ)”}”(hŒþThe driver should also provide backing device information with capabilities set to indicate the permitted types of mapping on such devices. The default is assumed to be readable and writable, not executable, and only shareable directly (can't be copied).”h]”hXThe driver should also provide backing device information with capabilities set to indicate the permitted types of mapping on such devices. The default is assumed to be readable and writable, not executable, and only shareable directly (can’t be copied).”…””}”(hj~h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÓhj_h²hubhÌ)”}”(hŒÜThe file->f_op->mmap() operation will be called to actually inaugurate the mapping. It can be rejected at that point. Returning the ENOSYS error will cause the mapping to be copied instead if NOMMU_MAP_COPY is specified.”h]”hŒÜThe file->f_op->mmap() operation will be called to actually inaugurate the mapping. It can be rejected at that point. Returning the ENOSYS error will cause the mapping to be copied instead if NOMMU_MAP_COPY is specified.”…””}”(hjŒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KØhj_h²hubhÌ)”}”(hŒºThe vm_ops->close() routine will be invoked when the last mapping on a chardev is removed. An existing mapping will be shared, partially or not, if possible without notifying the driver.”h]”hŒºThe vm_ops->close() routine will be invoked when the last mapping on a chardev is removed. An existing mapping will be shared, partially or not, if possible without notifying the driver.”…””}”(hjšh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÜhj_h²hubhÌ)”}”(hX&It is permitted also for the file->f_op->get_unmapped_area() operation to return -ENOSYS. This will be taken to mean that this operation just doesn't want to handle it, despite the fact it's got an operation. For instance, it might try directing the call to a secondary driver which turns out not to implement it. Such is the case for the framebuffer driver which attempts to direct the call to the device-specific driver. Under such circumstances, the mapping request will be rejected if NOMMU_MAP_COPY is not specified, and a copy mapped otherwise.”h]”hX*It is permitted also for the file->f_op->get_unmapped_area() operation to return -ENOSYS. This will be taken to mean that this operation just doesn’t want to handle it, despite the fact it’s got an operation. For instance, it might try directing the call to a secondary driver which turns out not to implement it. Such is the case for the framebuffer driver which attempts to direct the call to the device-specific driver. Under such circumstances, the mapping request will be rejected if NOMMU_MAP_COPY is not specified, and a copy mapped otherwise.”…””}”(hj¨h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kàhj_h²hubhŒ important”“”)”}”(hXSome types of device may present a different appearance to anyone looking at them in certain modes. Flash chips can be like this; for instance if they're in programming or erase mode, you might see the status reflected in the mapping, instead of the data. In such a case, care must be taken lest userspace see a shared or a private mapping showing such information when the driver is busy controlling the device. Remember especially: private executable mappings may still be mapped directly off the device under some circumstances!”h]”(hÌ)”}”(hŒÿSome types of device may present a different appearance to anyone looking at them in certain modes. Flash chips can be like this; for instance if they're in programming or erase mode, you might see the status reflected in the mapping, instead of the data.”h]”hXSome types of device may present a different appearance to anyone looking at them in certain modes. Flash chips can be like this; for instance if they’re in programming or erase mode, you might see the status reflected in the mapping, instead of the data.”…””}”(hj¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Këhj¸ubhÌ)”}”(hXIn such a case, care must be taken lest userspace see a shared or a private mapping showing such information when the driver is busy controlling the device. Remember especially: private executable mappings may still be mapped directly off the device under some circumstances!”h]”hXIn such a case, care must be taken lest userspace see a shared or a private mapping showing such information when the driver is busy controlling the device. Remember especially: private executable mappings may still be mapped directly off the device under some circumstances!”…””}”(hjÊh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kðhj¸ubeh}”(h]”h ]”h"]”h$]”h&]”uh1j¶hj_h²hh³hÊh´Nubeh}”(h]”Œ,providing-shareable-character-device-support”ah ]”h"]”Œ,providing shareable character device support”ah$]”h&]”uh1hµhh·h²hh³hÊh´KËubh¶)”}”(hhh]”(h»)”}”(hŒ.Providing shareable memory-backed file support”h]”hŒ.Providing shareable memory-backed file support”…””}”(hjéh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjæh²hh³hÊh´KøubhÌ)”}”(hX Provision of shared mappings on memory backed files is similar to the provision of support for shared mapped character devices. The main difference is that the filesystem providing the service will probably allocate a contiguous collection of pages and permit mappings to be made on that.”h]”hX Provision of shared mappings on memory backed files is similar to the provision of support for shared mapped character devices. The main difference is that the filesystem providing the service will probably allocate a contiguous collection of pages and permit mappings to be made on that.”…””}”(hj÷h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kúhjæh²hubhÌ)”}”(hŒêIt is recommended that a truncate operation applied to such a file that increases the file size, if that file is empty, be taken as a request to gather enough pages to honour a mapping. This is required to support POSIX shared memory.”h]”hŒêIt is recommended that a truncate operation applied to such a file that increases the file size, if that file is empty, be taken as a request to gather enough pages to honour a mapping. This is required to support POSIX shared memory.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kÿhjæh²hubhÌ)”}”(hŒkMemory backed devices are indicated by the mapping's backing device info having the memory_backed flag set.”h]”hŒmMemory backed devices are indicated by the mapping’s backing device info having the memory_backed flag set.”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhjæh²hubeh}”(h]”Œ.providing-shareable-memory-backed-file-support”ah ]”h"]”Œ.providing shareable memory-backed file support”ah$]”h&]”uh1hµhh·h²hh³hÊh´Køubh¶)”}”(hhh]”(h»)”}”(hŒ(Providing shareable block device support”h]”hŒ(Providing shareable block device support”…””}”(hj,h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj)h²hh³hÊh´M ubhÌ)”}”(hŒçProvision of shared mappings on block device files is exactly the same as for character devices. If there isn't a real device underneath, then the driver should allocate sufficient contiguous memory to honour any supported mapping.”h]”hŒéProvision of shared mappings on block device files is exactly the same as for character devices. If there isn’t a real device underneath, then the driver should allocate sufficient contiguous memory to honour any supported mapping.”…””}”(hj:h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M hj)h²hubeh}”(h]”Œ(providing-shareable-block-device-support”ah ]”h"]”Œ(providing shareable block device support”ah$]”h&]”uh1hµhh·h²hh³hÊh´M ubh¶)”}”(hhh]”(h»)”}”(hŒ!Adjusting page trimming behaviour”h]”hŒ!Adjusting page trimming behaviour”…””}”(hjSh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjPh²hh³hÊh´MubhÌ)”}”(hXìNOMMU mmap automatically rounds up to the nearest power-of-2 number of pages when performing an allocation. This can have adverse effects on memory fragmentation, and as such, is left configurable. The default behaviour is to aggressively trim allocations and discard any excess pages back in to the page allocator. In order to retain finer-grained control over fragmentation, this behaviour can either be disabled completely, or bumped up to a higher page watermark where trimming begins.”h]”hXìNOMMU mmap automatically rounds up to the nearest power-of-2 number of pages when performing an allocation. This can have adverse effects on memory fragmentation, and as such, is left configurable. The default behaviour is to aggressively trim allocations and discard any excess pages back in to the page allocator. In order to retain finer-grained control over fragmentation, this behaviour can either be disabled completely, or bumped up to a higher page watermark where trimming begins.”…””}”(hjah²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MhjPh²hubhÌ)”}”(hŒLPage trimming behaviour is configurable via the sysctl ``vm.nr_trim_pages``.”h]”(hŒ7Page trimming behaviour is configurable via the sysctl ”…””}”(hjoh²hh³Nh´NubhŒliteral”“”)”}”(hŒ``vm.nr_trim_pages``”h]”hŒvm.nr_trim_pages”…””}”(hjyh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jwhjoubhŒ.”…””}”(hjoh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MhjPh²hubeh}”(h]”Œ!adjusting-page-trimming-behaviour”ah ]”h"]”Œ!adjusting page trimming behaviour”ah$]”h&]”uh1hµhh·h²hh³hÊh´Mubeh}”(h]”Œno-mmu-memory-mapping-support”ah ]”h"]”Œno-mmu memory mapping support”ah$]”h&]”uh1hµhhh²hh³hÊh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÊuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(hºNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jÄŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÊŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”jõ]”jäasŒnameids”}”(jžj›jxjujŸjœjÆjÃj\jYjãjàj&j#jMjJj–j“jTjõuŒ nametypes”}”(jž‰jx‰jŸ‰jƉj\‰jã‰j&‰jM‰j–‰jTˆuh}”(j›h·jujojœj{jÃj¢jYjÉjîjäjõj/jàj_j#jæjJj)j“jPuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”j/aŒautofootnote_refs”]”jäaŒsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”jÒKs…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.