blob: 3cc4010521a019562e68eb070aa83ad78b0e8c4b [file] [log] [blame]
Carsten Otted763b7a2005-06-23 22:05:31 -07001Execute-in-place for file mappings
2----------------------------------
3
4Motivation
5----------
6File mappings are performed by mapping page cache pages to userspace. In
7addition, read&write type file operations also transfer data from/to the page
8cache.
9
10For memory backed storage devices that use the block device interface, the page
11cache pages are in fact copies of the original storage. Various approaches
12exist to work around the need for an extra copy. The ramdisk driver for example
13does read the data into the page cache, keeps a reference, and discards the
14original data behind later on.
15
16Execute-in-place solves this issue the other way around: instead of keeping
17data in the page cache, the need to have a page cache copy is eliminated
18completely. With execute-in-place, read&write type operations are performed
19directly from/to the memory backed storage device. For file mappings, the
20storage device itself is mapped directly into userspace.
21
Matt LaPlantea982ac02007-05-09 07:35:06 +020022This implementation was initially written for shared memory segments between
Carsten Otted763b7a2005-06-23 22:05:31 -070023different virtual machines on s390 hardware to allow multiple machines to
24share the same binaries and libraries.
25
26Implementation
27--------------
28Execute-in-place is implemented in three steps: block device operation,
29address space operation, and file operations.
30
31A block device operation named direct_access is used to retrieve a
32reference (pointer) to a block on-disk. The reference is supposed to be
33cpu-addressable, physical address and remain valid until the release operation
34is performed. A struct block_device reference is used to address the device,
35and a sector_t argument is used to identify the individual block. As an
36alternative, memory technology devices can be used for this.
37
38The block device operation is optional, these block devices support it as of
39today:
40- dcssblk: s390 dcss block device driver
41
42An address space operation named get_xip_page is used to retrieve reference
43to a struct page. To address the target page, a reference to an address_space,
44and a sector number is provided. A 3rd argument indicates whether the
45function should allocate blocks if needed.
46
47This address space operation is mutually exclusive with readpage&writepage that
48do page cache read/write operations.
49The following filesystems support it as of today:
50- ext2: the second extended filesystem, see Documentation/filesystems/ext2.txt
51
52A set of file operations that do utilize get_xip_page can be found in
53mm/filemap_xip.c . The following file operation implementations are provided:
54- aio_read/aio_write
55- readv/writev
56- sendfile
57
58The generic file operations do_sync_read/do_sync_write can be used to implement
59classic synchronous IO calls.
60
61Shortcomings
62------------
63This implementation is limited to storage devices that are cpu addressable at
64all times (no highmem or such). It works well on rom/ram, but enhancements are
65needed to make it work with flash in read+write mode.
66Putting the Linux kernel and/or its modules on a xip filesystem does not mean
67they are not copied.