1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/docs/wiki/Paging Sun Jun 12 00:00:12 2022 +0200
1.3 @@ -0,0 +1,110 @@
1.4 += Paging =
1.5 +
1.6 +Within filesystem servers, a number of abstractions are combined to support
1.7 +[[FilesystemAccess|access to filesystem content]] through paging: the delivery
1.8 +of content to clients in mapped memory.
1.9 +
1.10 +The general paging mechanism used to support paging is depicted below.
1.11 +
1.12 +######## A graph showing the general paging mechanism
1.13 +
1.14 +{{{#!graphviz
1.15 +#format svg
1.16 +#transform notugly
1.17 +digraph paging {
1.18 + node [fontsize="12.0",fontname="sans-serif",shape=box];
1.19 + edge [fontsize="12.0",fontname="sans-serif"];
1.20 + rankdir=LR;
1.21 +
1.22 + subgraph {
1.23 + rank=same;
1.24 +
1.25 + Pager_note [shape=note,style=filled,fillcolor=gold,label="Provides\nfilesystem\ncontent"];
1.26 + Pager;
1.27 +
1.28 + Pager_note -> Pager [dir=none,style=dotted];
1.29 + }
1.30 +
1.31 + subgraph {
1.32 + rank=same;
1.33 +
1.34 + PageMapper_note [shape=note,style=filled,fillcolor=gold,label="Provides\npopulated\nfile pages"];
1.35 + PageMapper;
1.36 +
1.37 + PageMapper_note -> PageMapper [dir=none,style=dotted];
1.38 + }
1.39 +
1.40 + subgraph {
1.41 + rank=same;
1.42 +
1.43 + Accessor_note [shape=note,style=filled,fillcolor=gold,label="Populates\nfile pages"];
1.44 + Accessor;
1.45 +
1.46 + Accessor_note -> Accessor [dir=none,style=dotted];
1.47 + }
1.48 +
1.49 + AccessMap [shape=record,label="<head> AccessMap |
1.50 + { offset-0 |<fp0> flexpage-0 } | ... |
1.51 + { offset-n |<fpn> flexpage-n } | ..."];
1.52 +
1.53 + subgraph {
1.54 + rank=same;
1.55 +
1.56 + Pages_note [shape=note,style=filled,fillcolor=gold,label="Provides\nmemory\npages"];
1.57 + Pages;
1.58 +
1.59 + Pages_note -> Pages [dir=none,style=dotted];
1.60 + }
1.61 +
1.62 + PageQueue [shape=record,label="<head> PageQueue |
1.63 + { owner-0 |<fp0> flexpage-0 } | ... |
1.64 + { owner-N |<fpN> flexpage-N } | <end> ..."];
1.65 +
1.66 + Flexpage_offset_n [shape=record,label="<head> Flexpage |
1.67 + offset | size |<r> region"];
1.68 +
1.69 + subgraph {
1.70 + rank=same;
1.71 +
1.72 + Memory_note [shape=note,style=filled,fillcolor=gold,label="Allocates\nmemory\nregions"];
1.73 + Memory;
1.74 +
1.75 + Memory_note -> Memory [dir=none,style=dotted];
1.76 + }
1.77 +
1.78 + Region;
1.79 +
1.80 + /* Relationships. */
1.81 +
1.82 + PageMapper -> Accessor;
1.83 + PageMapper -> AccessMap:head;
1.84 + Pager -> PageMapper -> Pages;
1.85 + Pages -> Memory;
1.86 + Pages -> PageQueue:head;
1.87 + AccessMap:fpn -> Flexpage_offset_n:head;
1.88 + PageQueue:fpN -> Flexpage_offset_n:head;
1.89 + Flexpage_offset_n:r -> Region;
1.90 +}
1.91 +}}}
1.92 +
1.93 +########
1.94 +
1.95 +A [[FilesystemAccess#Pager|Pager]], being a resource that provides filesystem
1.96 +content to clients for a particular file, requests pages from the PageMapper,
1.97 +itself having the role of supplying populated pages of content from the given
1.98 +file. The PageMapper relies on the AccessMap to discover existing pages for
1.99 +any accessed region of a file, involving the Pages object (or page collection)
1.100 +to obtain new memory pages where existing pages are not available or are no
1.101 +longer valid, and requesting the population of such pages through use of the
1.102 +associated Accessor for the file concerned.
1.103 +
1.104 +The Pages object may either obtain new memory pages from a Memory object or
1.105 +reclaim (or recycle) existing pages from a PageQueue, this recording all pages
1.106 +that have been populated and supplied to clients. Since it may be desirable to
1.107 +limit the number of pages employed to satisfy file access operations, the
1.108 +PageQueue provides a kind of lending mechanism: pages are issued to clients
1.109 +and then added to the end of the queue; where no new page can be supplied by a
1.110 +Memory object, the issued page at the head of the queue is obtained for
1.111 +recycling; ultimately, an issued page will remain valid for its user (the
1.112 +client accessing its contents) until all pages in front of it in the queue are
1.113 +themselves recycled and it is then removed from the queue for recycling.