]> git.itanic.dy.fi Git - scan-pagemap/blob - pagemap.h
pagemaps: Optimize memory usage
[scan-pagemap] / pagemap.h
1 #ifndef _PAGEMAP_H
2 #define _PAGEMAP_H
3
4 #include "utils.h"
5 #include "list.h"
6 #include "bintree.h"
7
8 #define PAGE_SHIFT      12
9 #define PAGE_SIZE       (2 << PAGE_SHIFT)
10
11 struct maps;
12
13 struct maps_list {
14         struct maps *map;
15         struct list_head list;
16 };
17
18 struct pageframe {
19         struct bintree tree;
20         struct maps_list *ml;   /* List to mappings which point to this pfn */
21         unsigned long pfn;      /* page frame number */
22         int swap_type;
23         int swap_offset;
24         int page_shift;
25         int page_swapped;
26         int page_present;
27         int refcount;
28 };
29
30 #define tree_to_pageframe(tree_struct)                          \
31         container_of((tree_struct), struct pageframe, tree)
32
33 struct maps {
34         struct list_head list;
35
36         /* Memory segment of a mapping */
37         unsigned long start;
38         unsigned long end;
39         unsigned long size;
40
41         /* Name of the mapping, such as library name or something else */
42         char name[128];
43         int pid; /* Process which address space the mapping belongs to */
44 };
45
46 #define list_to_maps(list_head)                         \
47         container_of((list_head), struct maps, list)
48
49 struct process {
50         struct pageframe *pageframes;
51         struct maps *maps;
52         char *name;
53 };
54
55 #endif