11 #define PAGE_SIZE (1 << PAGE_SHIFT)
17 struct list_head list;
19 #define list_to_maps_list(list_head) \
20 container_of((list_head), struct maps_list, list)
22 #define BITRANGE(first, last) (((2ll << (last - first)) - 1) << first)
26 struct list_head ml; /* List of mappings which refer to this pfn */
28 unsigned long long pf; /* page frame entry from /proc/pid/pagemap */
29 unsigned long long kpageflags;
30 unsigned long long kpagecount;
35 #define tree_to_pageframe(tree_struct) \
36 container_of((tree_struct), struct pageframe, tree)
38 static inline void clear_pageframe(struct pageframe *pf)
40 memset(pf, 0, sizeof(*pf));
41 INIT_LIST_HEAD(&pf->ml);
44 static inline int page_present(struct pageframe *p)
46 return !!(BITRANGE(63, 63) & p->pf);
49 static inline int page_swapped(struct pageframe *p)
51 return !!(BITRANGE(62, 62) & p->pf);
54 static inline int page_shift(struct pageframe *p)
56 return (BITRANGE(55, 60) & p->pf) >> 55;
59 static inline long int pfn(struct pageframe *p)
61 return (BITRANGE(0, 54) & p->pf);
64 static inline int swap_type(struct pageframe *p)
66 return (BITRANGE(0, 4) & p->pf);
69 static inline int swap_offset(struct pageframe *p)
71 return (BITRANGE(5, 54) & p->pf) >> 5;
74 #define KPAGEFLAGS_NUM 22
101 struct kpageflag_str {
106 extern struct kpageflag_str kpageflag_str[];
108 static inline int kpageflag_is_set(struct pageframe *p, int flag)
110 return !!(BITRANGE(flag, flag) & p->kpageflags);
113 static inline char *kpageflag_to_str(int flag)
117 for (i = 0; i < KPAGEFLAGS_NUM; i++)
118 if (kpageflag_str[i].flag == flag)
119 return kpageflag_str[i].str;
125 struct list_head list;
127 /* Memory segment of a mapping */
132 long int pages_present;
133 long int pages_swapped;
135 /* Name of the mapping, such as library name or something else */
137 int pid; /* Process which address space the mapping belongs to */
138 int tid; /* thread id */
141 #define list_to_maps(list_head) \
142 container_of((list_head), struct maps, list)
146 struct list_head list;
151 long int pages_present;
152 long int pages_swapped;
153 long int pages_unique;
158 #define PARSE_PID 0x1
159 #define PARSE_MAP_NAME 0x2
160 #define PARSE_DUMP 0x8
161 #define PARSE_NOADD_TREE 0x10
162 #define PARSE_SHARED_MAPPING 0x20
165 struct list_head list;
171 struct list_head pidlist;
178 static inline void init_parse_opts(struct parse_opts *p)
180 memset(p, 0, sizeof(*p));
181 INIT_LIST_HEAD(&p->pidlist);
184 static inline struct pidlist *alloc_pidlist(void)
186 struct pidlist *p = malloc(sizeof(*p));
191 memset(p, 0, sizeof(*p));
192 INIT_LIST_HEAD(&p->list);
197 #define is_parse_option(parse_opts, flag) \
198 (!!((parse_opts)->parse_mask & (flag)))