Info

struct pagevec {

unsigned nr; int cold;

struct page *pages[PAGEVEC_SIZE];

This is simply an array with pointers to page instances that also allow the number of elements they contain to be queried using the nr element. The page array itself provides space for pagevec_size pointers to pages (the default value is 14).

The cold element is an addition that helps the kernel distinguish between hot and cold pages. Pages whose data are held in one of the CPU caches are described as hot because their data can be accessed very quickly. Pages not held in the cache are therefore cold. For the sake of simplicity, this property of memory pages is ignored in the following descriptions.

Page vectors enable operations to be performed on a whole list of page structures; this is sometimes quicker than performing operations on individual pages. Currently, the kernel provides functions that are primarily concerned with releasing pages:

□ pagevec_release decrements the usage counter of all pages in the vector batchwise. Pages whose usage counter value reaches 0 — these are therefore no longer in use — are automatically returned to the buddy system. If the page was on an LRU list of the system, it is removed from the list, regardless of the value of its usage counter.

□ pagevec_free returns the memory space occupied by a collection of pages to the buddy system. The caller is responsible for ensuring that the usage counter is 0 — which indicates that the pages are not in use anywhere else — and that they are not included on any LRU list.

□ pagevec_release_nonlru is a further function for releasing pages that decrements the usage counter of all pages of a given collection by 1. When the counter reaches 0, the memory occupied by the page is returned to the buddy system. In contrast to pagevec_release, this function assumes that all pages in the vector are not on any LRU list.

All these functions expect a pagevec structure containing the pages to be processed as parameter. If the vector is empty, all the functions return to the caller immediately.

There are also versions of the same functions with two preceding underscores (e.g.,__pagevec_release).

These do not test whether the vector passed contains pages or not.

What is still lacking is a function to add pages to a page vector:

Continue reading here: Mmswapc

Was this article helpful?

0 0