]> git.itanic.dy.fi Git - scan-pagemap/blobdiff - pagemap.h
Compact pageframe structure
[scan-pagemap] / pagemap.h
index b06afb69f142755c0e5f2c7239b2fa2b72f6d13f..d7dacdf151b908d6f5e5b0557ebe53d591d6ba48 100644 (file)
--- a/pagemap.h
+++ b/pagemap.h
@@ -17,21 +17,50 @@ struct maps_list {
 #define list_to_maps_list(list_head)                           \
        container_of((list_head), struct maps_list, list)
 
+#define BITRANGE(first, last) (((2ll << (last - first)) - 1) << first)
+
 struct pageframe {
        struct bintree tree;
        struct maps_list ml;    /* List to mappings which point to this pfn */
-       unsigned long pfn;      /* page frame number */
-       int swap_type;
-       int swap_offset;
-       int page_shift;
-       int page_swapped;
-       int page_present;
+
+       unsigned long long pf;  /* page frame entry from /proc/pid/pagemap */
+
        int refcount;
 };
 
 #define tree_to_pageframe(tree_struct)                         \
        container_of((tree_struct), struct pageframe, tree)
 
+static inline int page_present(struct pageframe *p)
+{
+       return !!(BITRANGE(63, 63) & p->pf);
+}
+
+static inline int page_swapped(struct pageframe *p)
+{
+       return !!(BITRANGE(62, 62) & p->pf);
+}
+
+static inline int page_shift(struct pageframe *p)
+{
+       return (BITRANGE(55, 60) & p->pf) >> 55;
+}
+
+static inline long int pfn(struct pageframe *p)
+{
+       return (BITRANGE(0, 54) & p->pf);
+}
+
+static inline int swap_type(struct pageframe *p)
+{
+       return (BITRANGE(0, 4) & p->pf);
+}
+
+static inline int swap_offset(struct pageframe *p)
+{
+       return (BITRANGE(5, 54) & p->pf) >> 5;
+}
+
 struct maps {
        struct list_head list;