/*
- * Copyright (C) 2010 Timo Kokkonen <kaapeli@itanic.dy.fi>
+ * Copyright (C) 2010 Timo Kokkonen <timo.t.kokkonen@iki.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#define _PAGEMAP_H
#include <stdlib.h>
+#include <string.h>
#include "utils.h"
#include "list.h"
-#include "bintree.h"
+#include "rbtree.h"
#define PAGE_SHIFT 12
#define PAGE_SIZE (1 << PAGE_SHIFT)
#define BITRANGE(first, last) (((2ll << (last - first)) - 1) << first)
struct pageframe {
- struct bintree tree;
+ struct rb_node tree;
struct list_head ml; /* List of mappings which refer to this pfn */
unsigned long long pf; /* page frame entry from /proc/pid/pagemap */
int refcount;
};
-#define tree_to_pageframe(tree_struct) \
+struct pageframe *pf_insert(struct rb_root *root, struct pageframe *pf);
+struct pageframe *pf_search(struct rb_root *root, struct pageframe *pf);
+
+#define rb_to_pageframe(tree_struct) \
container_of((tree_struct), struct pageframe, tree)
static inline void clear_pageframe(struct pageframe *pf)
return (BITRANGE(5, 54) & p->pf) >> 5;
}
-#define KPAGEFLAGS_NUM 22
-
enum kpageflags {
LOCKED,
ERROR,
HWPOISON,
NOPAGE,
KSM,
+ THP,
+ __PAGEFLAGS_LAST,
};
+#define KPAGEFLAGS_NUM __PAGEFLAGS_LAST
+
struct kpageflag_str {
int flag;
char *str;
static inline struct pidlist *alloc_pidlist(void)
{
- struct pidlist *p = malloc(sizeof(*p));
+ struct pidlist *p = calloc(sizeof(*p), 1);
if (p == NULL)
return p;
- memset(p, 0, sizeof(*p));
INIT_LIST_HEAD(&p->list);
return p;