After this documentation was released in July 2003, I was approached by Prentice Hall and asked to write a book on the Linux VM under the Bruce Peren's Open Book Series.

The book is available and called simply "Understanding The Linux Virtual Memory Manager". There is a lot of additional material in the book that is not available here, including details on later 2.4 kernels, introductions to 2.6, a whole new chapter on the shared memory filesystem, coverage of TLB management, a lot more code commentary, countless other additions and clarifications and a CD with lots of cool stuff on it. This material (although now dated and lacking in comparison to the book) will remain available although I obviously encourge you to buy the book from your favourite book store :-) . As the book is under the Bruce Perens Open Book Series, it will be available 90 days after appearing on the book shelves which means it is not available right now. When it is available, it will be downloadable from http://www.phptr.com/perens so check there for more information.

To be fully clear, this webpage is not the actual book.
next up previous contents index
Next: 7.5 Avoiding Fragmentation Up: 7. Physical Page Allocation Previous: 7.3 Free Pages   Contents   Index

Subsections


7.4 Get Free Page (GFP) Flags

A persistent concept through the whole VM is the Get Free Page (GFP) flags. These flags determine how the allocator and kswapd will behave for the allocation and freeing of pages. For example, an interrupt handler may not sleep so it will not have the __GFP_WAIT flag set as this flag indicates the caller may sleep. There are three sets of GFP flags, all defined in $<$linux/mm.h$>$.

The first of the three is the set of zone modifiers listed in Table 7.3. These flags indicate that the caller must try to allocate from a particular zone. The reader will note there is not a zone modifier for ZONE_ NORMAL. This is because the zone modifier flag is used as an offset within an array and 0 implicitly means allocate from ZONE_ NORMAL.


Table 7.3: Low Level GFP Flags Affecting Zone Allocation
\begin{table}\ \begin{center}
\ \begin{tabularx}{10.85cm}{\vert l\vert l\vert}
\...
...r \texttt{\_\_GFP\_DMA} \\
\hline
\ \end{tabularx}
\end{center} \end{table}


The next flags are action modifiers listed in Table 7.4. They change the behavior of the VM and what the calling process may do. The low level flags on their own are too primitive to be easily used. It is difficult to know what the correct combinations are for each instance so a few high level combinations are defined and listed in Table 7.5. For clarity the __GFP_ is removed from the table combinations so, the __GFP_HIGH flag will read as HIGH below. The combinations to form the high level flags are listed in Table 7.6

To help understand this, take GFP_ATOMIC as an example. It has only the __GFP_HIGH flag set. This means it is high priority, will use emergency pools (if they exist) but will not sleep, perform IO or access the filesystem. This flag would be used by an interrupt handler for example.


Table 7.4: Low Level GFP Flags Affecting Allocator Behavior
\begin{table}\begin{center}
\begin{tabularx}{13.5cm}{\vert l\vert X\vert}
\hl...
...sively calling itself \\
\par\hline
\end{tabularx}
\end{center} \end{table}



Table 7.5: Low Level GFP Flag Combinations For High Level
\begin{table}\begin{center}
\begin{tabularx}{13.5cm}{\vert l\vert X\vert}
\hl...
...vert HIGHIO \vert FS \\
\hline
\par
\end{tabularx}
\end{center} \end{table}



Table 7.6: High Level GFP Flags Affecting Allocator Behavior
\begin{table}\begin{center}
\begin{tabularx}{13.5cm}{\vert l\vert X\vert}
\hl...
...\texttt{GFP\_KERNEL} \\
\par\hline
\end{tabularx}
\end{center} \end{table}



7.4.1 Process Flags

A process may also set flags in the task_struct which affects allocator behavior. The full list of process flags are defined in $<$linux/sched.h$>$ but only the ones affecting VM behavior are listed in Table 7.7.


Table 7.7: Process Flags Affecting Allocator Behavior
\begin{table}
% latex2html id marker 7292
\begin{center}
\begin{tabularx}{13.5...
...ng to the
free lists \\
\par\hline
\end{tabularx}
\end{center} \end{table}



next up previous contents index
Next: 7.5 Avoiding Fragmentation Up: 7. Physical Page Allocation Previous: 7.3 Free Pages   Contents   Index
Mel 2004-02-15