Lines Matching defs:rmap_item

124 	struct rmap_item *rmap_list;
140 struct rmap_item **rmap_list;
153 * @rmap_hlist_len: number of rmap_item entries in hlist or STABLE_NODE_CHAIN
185 * struct rmap_item - reverse mapping item for virtual addresses
186 * @rmap_list: next rmap_item in mm_slot's singly-linked rmap_list
189 * @mm: the memory structure this rmap_item is pointing into
190 * @address: the virtual address this rmap_item tracks (+ flags in low bits)
192 * @node: rb node of this rmap_item in the unstable tree
196 struct rmap_item {
197 struct rmap_item *rmap_list;
309 rmap_item_cache = KSM_KMEM_CACHE(rmap_item, 0);
378 static inline struct rmap_item *alloc_rmap_item(void)
380 struct rmap_item *rmap_item;
382 rmap_item = kmem_cache_zalloc(rmap_item_cache, GFP_KERNEL |
384 if (rmap_item)
386 return rmap_item;
389 static inline void free_rmap_item(struct rmap_item *rmap_item)
392 rmap_item->mm = NULL; /* debug safety */
393 kmem_cache_free(rmap_item_cache, rmap_item);
535 static void break_cow(struct rmap_item *rmap_item)
537 struct mm_struct *mm = rmap_item->mm;
538 unsigned long addr = rmap_item->address;
545 put_anon_vma(rmap_item->anon_vma);
554 static struct page *get_mergeable_page(struct rmap_item *rmap_item)
556 struct mm_struct *mm = rmap_item->mm;
557 unsigned long addr = rmap_item->address;
635 struct rmap_item *rmap_item;
640 hlist_for_each_entry(rmap_item, &stable_node->hlist, hlist) {
641 if (rmap_item->hlist.next)
647 put_anon_vma(rmap_item->anon_vma);
648 rmap_item->address &= PAGE_MASK;
772 * Removing rmap_item from stable or unstable tree.
775 static void remove_rmap_item_from_tree(struct rmap_item *rmap_item)
777 if (rmap_item->address & STABLE_FLAG) {
781 stable_node = rmap_item->head;
786 hlist_del(&rmap_item->hlist);
797 put_anon_vma(rmap_item->anon_vma);
798 rmap_item->head = NULL;
799 rmap_item->address &= PAGE_MASK;
801 } else if (rmap_item->address & UNSTABLE_FLAG) {
807 * if this rmap_item was inserted by this scan, rather
810 age = (unsigned char)(ksm_scan.seqnr - rmap_item->address);
813 rb_erase(&rmap_item->node,
814 root_unstable_tree + NUMA(rmap_item->nid));
816 rmap_item->address &= PAGE_MASK;
823 struct rmap_item **rmap_list)
826 struct rmap_item *rmap_item = *rmap_list;
827 *rmap_list = rmap_item->rmap_list;
828 remove_rmap_item_from_tree(rmap_item);
829 free_rmap_item(rmap_item);
836 * that - an rmap_item is assigned to the stable tree after inserting ksm
1282 static int try_to_merge_with_ksm_page(struct rmap_item *rmap_item,
1285 struct mm_struct *mm = rmap_item->mm;
1290 vma = find_mergeable_vma(mm, rmap_item->address);
1299 remove_rmap_item_from_tree(rmap_item);
1302 rmap_item->anon_vma = vma->anon_vma;
1319 static struct page *try_to_merge_two_pages(struct rmap_item *rmap_item,
1321 struct rmap_item *tree_rmap_item,
1326 err = try_to_merge_with_ksm_page(rmap_item, page, NULL);
1335 break_cow(rmap_item);
1916 * else insert rmap_item into the unstable tree.
1920 * tree, we insert rmap_item as a new object into the unstable tree.
1922 * This function returns pointer to rmap_item found to be identical
1929 struct rmap_item *unstable_tree_search_insert(struct rmap_item *rmap_item,
1943 struct rmap_item *tree_rmap_item;
1948 tree_rmap_item = rb_entry(*new, struct rmap_item, node);
1985 rmap_item->address |= UNSTABLE_FLAG;
1986 rmap_item->address |= (ksm_scan.seqnr & SEQNR_MASK);
1987 DO_NUMA(rmap_item->nid = nid);
1988 rb_link_node(&rmap_item->node, parent, new);
1989 rb_insert_color(&rmap_item->node, root);
1996 * stable_tree_append - add another rmap_item to the linked list of
2000 static void stable_tree_append(struct rmap_item *rmap_item,
2006 * rmap_item in the right stable_node
2022 rmap_item->head = stable_node;
2023 rmap_item->address |= STABLE_FLAG;
2024 hlist_add_head(&rmap_item->hlist, &stable_node->hlist);
2026 if (rmap_item->hlist.next)
2039 * @rmap_item: the reverse mapping into the virtual address of this page
2041 static void cmp_and_merge_page(struct page *page, struct rmap_item *rmap_item)
2043 struct mm_struct *mm = rmap_item->mm;
2044 struct rmap_item *tree_rmap_item;
2062 rmap_item->head == stable_node)
2074 if (kpage == page && rmap_item->head == stable_node) {
2079 remove_rmap_item_from_tree(rmap_item);
2085 err = try_to_merge_with_ksm_page(rmap_item, page, kpage);
2089 * add its rmap_item to the stable tree.
2092 stable_tree_append(rmap_item, page_stable_node(kpage),
2107 if (rmap_item->oldchecksum != checksum) {
2108 rmap_item->oldchecksum = checksum;
2120 vma = find_mergeable_vma(mm, rmap_item->address);
2123 ZERO_PAGE(rmap_item->address));
2140 unstable_tree_search_insert(rmap_item, page, &tree_page);
2144 kpage = try_to_merge_two_pages(rmap_item, page,
2169 stable_tree_append(rmap_item, stable_node,
2182 break_cow(rmap_item);
2202 static struct rmap_item *get_next_rmap_item(struct mm_slot *mm_slot,
2203 struct rmap_item **rmap_list,
2206 struct rmap_item *rmap_item;
2209 rmap_item = *rmap_list;
2210 if ((rmap_item->address & PAGE_MASK) == addr)
2211 return rmap_item;
2212 if (rmap_item->address > addr)
2214 *rmap_list = rmap_item->rmap_list;
2215 remove_rmap_item_from_tree(rmap_item);
2216 free_rmap_item(rmap_item);
2219 rmap_item = alloc_rmap_item();
2220 if (rmap_item) {
2222 rmap_item->mm = mm_slot->mm;
2223 rmap_item->address = addr;
2224 rmap_item->rmap_list = *rmap_list;
2225 *rmap_list = rmap_item;
2227 return rmap_item;
2230 static struct rmap_item *scan_get_next_rmap_item(struct page **page)
2235 struct rmap_item *rmap_item;
2320 rmap_item = get_next_rmap_item(slot,
2322 if (rmap_item) {
2324 &rmap_item->rmap_list;
2329 return rmap_item;
2395 struct rmap_item *rmap_item;
2400 rmap_item = scan_get_next_rmap_item(&page);
2401 if (!rmap_item)
2403 cmp_and_merge_page(page, rmap_item);
2612 struct rmap_item *rmap_item;
2627 hlist_for_each_entry(rmap_item, &stable_node->hlist, hlist) {
2628 struct anon_vma *anon_vma = rmap_item->anon_vma;
2642 addr = rmap_item->address & ~KSM_FLAG_MASK;
2648 * rmap_item; but later, if there is still work to do,
2652 if ((rmap_item->mm == vma->vm_mm) == search_new_forks)