9 #define PAGE_SIZE (1 << PAGE_SHIFT)
15 struct list_head list;
17 #define list_to_maps_list(list_head) \
18 container_of((list_head), struct maps_list, list)
20 #define BITRANGE(first, last) (((2ll << (last - first)) - 1) << first)
24 struct list_head ml; /* List of mappings which refer to this pfn */
26 unsigned long long pf; /* page frame entry from /proc/pid/pagemap */
31 #define tree_to_pageframe(tree_struct) \
32 container_of((tree_struct), struct pageframe, tree)
34 static inline void clear_pageframe(struct pageframe *pf)
36 memset(pf, 0, sizeof(*pf));
37 INIT_LIST_HEAD(&pf->ml);
40 static inline int page_present(struct pageframe *p)
42 return !!(BITRANGE(63, 63) & p->pf);
45 static inline int page_swapped(struct pageframe *p)
47 return !!(BITRANGE(62, 62) & p->pf);
50 static inline int page_shift(struct pageframe *p)
52 return (BITRANGE(55, 60) & p->pf) >> 55;
55 static inline long int pfn(struct pageframe *p)
57 return (BITRANGE(0, 54) & p->pf);
60 static inline int swap_type(struct pageframe *p)
62 return (BITRANGE(0, 4) & p->pf);
65 static inline int swap_offset(struct pageframe *p)
67 return (BITRANGE(5, 54) & p->pf) >> 5;
71 struct list_head list;
73 /* Memory segment of a mapping */
78 long int pages_present;
79 long int pages_swapped;
81 /* Name of the mapping, such as library name or something else */
83 int pid; /* Process which address space the mapping belongs to */
84 int tid; /* thread id */
87 #define list_to_maps(list_head) \
88 container_of((list_head), struct maps, list)
92 struct list_head list;
97 long int pages_present;
98 long int pages_swapped;
103 #define PARSE_PID 0x1
104 #define PARSE_MAP_NAME 0x2
105 #define PARSE_PROCESS_NAME 0x4
106 #define PARSE_DUMP 0x8
107 #define PARSE_NOADD_TREE 0x10
110 struct list_head list;
116 struct list_head pidlist;
123 static inline void init_parse_opts(struct parse_opts *p)
125 memset(p, 0, sizeof(*p));
126 INIT_LIST_HEAD(&p->pidlist);
129 static inline struct pidlist *alloc_pidlist(void)
131 struct pidlist *p = malloc(sizeof(*p));
136 memset(p, 0, sizeof(*p));
137 INIT_LIST_HEAD(&p->list);
142 #define is_parse_option(parse_opts, flag) \
143 (!!((parse_opts)->parse_mask & (flag)))