📄 xip.txt
字号:
Execute-in-place for file mappings----------------------------------Motivation----------File mappings are performed by mapping page cache pages to userspace. Inaddition, read&write type file operations also transfer data from/to the pagecache.For memory backed storage devices that use the block device interface, the pagecache pages are in fact copies of the original storage. Various approachesexist to work around the need for an extra copy. The ramdisk driver for exampledoes read the data into the page cache, keeps a reference, and discards theoriginal data behind later on.Execute-in-place solves this issue the other way around: instead of keepingdata in the page cache, the need to have a page cache copy is eliminatedcompletely. With execute-in-place, read&write type operations are performeddirectly from/to the memory backed storage device. For file mappings, thestorage device itself is mapped directly into userspace.This implementation was initially written for shared memory segments betweendifferent virtual machines on s390 hardware to allow multiple machines toshare the same binaries and libraries.Implementation--------------Execute-in-place is implemented in three steps: block device operation,address space operation, and file operations.A block device operation named direct_access is used to retrieve areference (pointer) to a block on-disk. The reference is supposed to becpu-addressable, physical address and remain valid until the release operationis performed. A struct block_device reference is used to address the device,and a sector_t argument is used to identify the individual block. As analternative, memory technology devices can be used for this.The block device operation is optional, these block devices support it as oftoday:- dcssblk: s390 dcss block device driverAn address space operation named get_xip_page is used to retrieve referenceto a struct page. To address the target page, a reference to an address_space,and a sector number is provided. A 3rd argument indicates whether thefunction should allocate blocks if needed.This address space operation is mutually exclusive with readpage&writepage thatdo page cache read/write operations.The following filesystems support it as of today:- ext2: the second extended filesystem, see Documentation/filesystems/ext2.txtA set of file operations that do utilize get_xip_page can be found inmm/filemap_xip.c . The following file operation implementations are provided:- aio_read/aio_write- readv/writev- sendfileThe generic file operations do_sync_read/do_sync_write can be used to implementclassic synchronous IO calls.Shortcomings------------This implementation is limited to storage devices that are cpu addressable atall times (no highmem or such). It works well on rom/ram, but enhancements areneeded to make it work with flash in read+write mode.Putting the Linux kernel and/or its modules on a xip filesystem does not meanthey are not copied.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -