Lines Matching full:bm

588 static void memory_bm_position_reset(struct memory_bitmap *bm)
590 bm->cur.zone = list_entry(bm->zones.next, struct mem_zone_bm_rtree,
592 bm->cur.node = list_entry(bm->cur.zone->leaves.next,
594 bm->cur.node_pfn = 0;
595 bm->cur.cur_pfn = BM_END_OF_MAP;
596 bm->cur.node_bit = 0;
599 static void memory_bm_free(struct memory_bitmap *bm, int clear_nosave_free);
684 static int memory_bm_create(struct memory_bitmap *bm, gfp_t gfp_mask,
693 INIT_LIST_HEAD(&bm->zones);
708 list_add_tail(&zone->list, &bm->zones);
711 bm->p_list = ca.chain;
712 memory_bm_position_reset(bm);
718 bm->p_list = ca.chain;
719 memory_bm_free(bm, PG_UNSAFE_CLEAR);
725 * @bm: Memory bitmap.
727 static void memory_bm_free(struct memory_bitmap *bm, int clear_nosave_free)
731 list_for_each_entry(zone, &bm->zones, list)
734 free_list_of_pages(bm->p_list, clear_nosave_free);
736 INIT_LIST_HEAD(&bm->zones);
742 * Find the bit in memory bitmap @bm that corresponds to the given PFN.
743 * The cur.zone, cur.block and cur.node_pfn members of @bm are updated.
748 static int memory_bm_find_bit(struct memory_bitmap *bm, unsigned long pfn,
755 zone = bm->cur.zone;
763 list_for_each_entry(curr, &bm->zones, list) {
784 node = bm->cur.node;
785 if (zone == bm->cur.zone &&
786 ((pfn - zone->start_pfn) & ~BM_BLOCK_MASK) == bm->cur.node_pfn)
803 bm->cur.zone = zone;
804 bm->cur.node = node;
805 bm->cur.node_pfn = (pfn - zone->start_pfn) & ~BM_BLOCK_MASK;
806 bm->cur.cur_pfn = pfn;
815 static void memory_bm_set_bit(struct memory_bitmap *bm, unsigned long pfn)
821 error = memory_bm_find_bit(bm, pfn, &addr, &bit);
826 static int mem_bm_set_bit_check(struct memory_bitmap *bm, unsigned long pfn)
832 error = memory_bm_find_bit(bm, pfn, &addr, &bit);
839 static void memory_bm_clear_bit(struct memory_bitmap *bm, unsigned long pfn)
845 error = memory_bm_find_bit(bm, pfn, &addr, &bit);
850 static void memory_bm_clear_current(struct memory_bitmap *bm)
854 bit = max(bm->cur.node_bit - 1, 0);
855 clear_bit(bit, bm->cur.node->data);
858 static unsigned long memory_bm_get_current(struct memory_bitmap *bm)
860 return bm->cur.cur_pfn;
863 static int memory_bm_test_bit(struct memory_bitmap *bm, unsigned long pfn)
869 error = memory_bm_find_bit(bm, pfn, &addr, &bit);
874 static bool memory_bm_pfn_present(struct memory_bitmap *bm, unsigned long pfn)
879 return !memory_bm_find_bit(bm, pfn, &addr, &bit);
892 static bool rtree_next_node(struct memory_bitmap *bm)
894 if (!list_is_last(&bm->cur.node->list, &bm->cur.zone->leaves)) {
895 bm->cur.node = list_entry(bm->cur.node->list.next,
897 bm->cur.node_pfn += BM_BITS_PER_BLOCK;
898 bm->cur.node_bit = 0;
904 if (!list_is_last(&bm->cur.zone->list, &bm->zones)) {
905 bm->cur.zone = list_entry(bm->cur.zone->list.next,
907 bm->cur.node = list_entry(bm->cur.zone->leaves.next,
909 bm->cur.node_pfn = 0;
910 bm->cur.node_bit = 0;
920 * @bm: Memory bitmap.
923 * set bit in @bm and returns the PFN represented by it. If no more bits are
929 static unsigned long memory_bm_next_pfn(struct memory_bitmap *bm)
935 pages = bm->cur.zone->end_pfn - bm->cur.zone->start_pfn;
936 bits = min(pages - bm->cur.node_pfn, BM_BITS_PER_BLOCK);
937 bit = find_next_bit(bm->cur.node->data, bits,
938 bm->cur.node_bit);
940 pfn = bm->cur.zone->start_pfn + bm->cur.node_pfn + bit;
941 bm->cur.node_bit = bit + 1;
942 bm->cur.cur_pfn = pfn;
945 } while (rtree_next_node(bm));
947 bm->cur.cur_pfn = BM_END_OF_MAP;
974 static void memory_bm_recycle(struct memory_bitmap *bm)
979 list_for_each_entry(zone, &bm->zones, list)
982 p_list = bm->p_list;
1077 * @bm: Memory bitmap.
1079 * Set the bits in @bm that correspond to the page frames the contents of which
1082 static void mark_nosave_pages(struct memory_bitmap *bm)
1105 mem_bm_set_bit_check(bm, pfn);
1197 struct memory_bitmap *bm = free_pages_map;
1204 memory_bm_position_reset(bm);
1205 pfn = memory_bm_next_pfn(bm);
1210 pfn = memory_bm_next_pfn(bm);
1212 memory_bm_position_reset(bm);
2046 static inline unsigned int alloc_highmem_pages(struct memory_bitmap *bm,
2059 memory_bm_set_bit(bm, page_to_pfn(page));
2066 static inline unsigned int alloc_highmem_pages(struct memory_bitmap *bm,
2199 * @bm: Memory bitmap.
2203 * PFNs corresponding to set bits in @bm are stored in the area of memory
2208 static inline void pack_pfns(unsigned long *buf, struct memory_bitmap *bm,
2214 buf[j] = memory_bm_next_pfn(bm);
2304 static void mark_unsafe_pages(struct memory_bitmap *bm)
2317 duplicate_memory_bitmap(free_pages_map, bm);
2354 * @bm: Memory bitmap.
2359 * corresponding bit in @bm. If the page was originally populated with only
2362 static int unpack_orig_pfns(unsigned long *buf, struct memory_bitmap *bm,
2375 if (pfn_valid(decoded_pfn) && memory_bm_pfn_present(bm, decoded_pfn)) {
2376 memory_bm_set_bit(bm, decoded_pfn);
2414 * @bm: Memory bitmap.
2416 * The bits in @bm that correspond to image pages are assumed to be set.
2418 static unsigned int count_highmem_image_pages(struct memory_bitmap *bm)
2423 memory_bm_position_reset(bm);
2424 pfn = memory_bm_next_pfn(bm);
2429 pfn = memory_bm_next_pfn(bm);
2440 * @bm: Pointer to an uninitialized memory bitmap structure.
2447 * @bm (it must be uninitialized).
2451 static int prepare_highmem_image(struct memory_bitmap *bm,
2456 if (memory_bm_create(bm, GFP_ATOMIC, PG_SAFE))
2475 memory_bm_set_bit(bm, page_to_pfn(page));
2482 memory_bm_position_reset(bm);
2483 safe_highmem_bm = bm;
2585 static unsigned int count_highmem_image_pages(struct memory_bitmap *bm) { return 0; }
2587 static inline int prepare_highmem_image(struct memory_bitmap *bm,
2606 * @bm: Memory bitmap with unsafe pages marked.
2609 * Use @bm to mark the pages that will be overwritten in the process of
2622 static int prepare_image(struct memory_bitmap *new_bm, struct memory_bitmap *bm,
2634 nr_highmem = count_highmem_image_pages(bm);
2635 mark_unsafe_pages(bm);
2641 duplicate_memory_bitmap(new_bm, bm);
2642 memory_bm_free(bm, PG_UNSAFE_KEEP);
2662 error = prepare_highmem_image(bm, &nr_highmem);
2718 static void *get_buffer(struct memory_bitmap *bm, struct chain_allocator *ca)
2722 unsigned long pfn = memory_bm_next_pfn(bm);