Info

typedef struct {

unsigned long val; } swp_entry_t;

Only one variable is used, although two different information items must be stored. The components of the variable can be filtered out by selecting different areas, as illustrated in Figure 18-6.

0 59 64

Offset

Swap Identifier

0 27 32

Figure 18-6: Components of an architecture-independent swap identifier.

Why is just a single unsigned long variable used to formally store both items of information? First, all systems supported so far are happily able to make do with the information provided in this way. And second, the value held in the variable is also used as a search key for the radix tree that lists all swap cache pages. Since the swap cache is merely a page cache that uses longs as a key, a swapped-out page can be uniquely identified in this way.

As this situation may change in the future, the unsigned long value is not used directly but is hidden in a structure. As the contents of a swap_entry_t value may only be accessed by special functions, the internal representation may be modified in future versions without having to rewrite significant parts of the swap implementation.

To ensure access to both information items in swap_entry_t, the kernel defines two constants for the bit arrangement shown in Figure 18-6:

Continue reading here: Info

Was this article helpful?

0 0