Lines Matching refs:resv
404 get_file_region_entry_from_cache(struct resv_map *resv, long from, long to) in get_file_region_entry_from_cache() argument
408 VM_BUG_ON(resv->region_cache_count <= 0); in get_file_region_entry_from_cache()
410 resv->region_cache_count--; in get_file_region_entry_from_cache()
411 nrg = list_first_entry(&resv->region_cache, struct file_region, link); in get_file_region_entry_from_cache()
434 struct resv_map *resv, in record_hugetlb_cgroup_uncharge_info() argument
453 if (!resv->pages_per_hpage) in record_hugetlb_cgroup_uncharge_info()
454 resv->pages_per_hpage = pages_per_huge_page(h); in record_hugetlb_cgroup_uncharge_info()
458 VM_BUG_ON(resv->pages_per_hpage != pages_per_huge_page(h)); in record_hugetlb_cgroup_uncharge_info()
486 static void coalesce_file_region(struct resv_map *resv, struct file_region *rg) in coalesce_file_region() argument
491 if (&prg->link != &resv->regions && prg->to == rg->from && in coalesce_file_region()
503 if (&nrg->link != &resv->regions && nrg->from == rg->to && in coalesce_file_region()
539 static long add_reservation_in_range(struct resv_map *resv, long f, long t, in add_reservation_in_range() argument
544 struct list_head *head = &resv->regions; in add_reservation_in_range()
579 add += hugetlb_resv_map_add(resv, iter->link.prev, in add_reservation_in_range()
593 add += hugetlb_resv_map_add(resv, rg, last_accounted_offset, in add_reservation_in_range()
601 static int allocate_file_region_entries(struct resv_map *resv, in allocate_file_region_entries() argument
603 __must_hold(&resv->lock) in allocate_file_region_entries()
620 while (resv->region_cache_count < in allocate_file_region_entries()
621 (resv->adds_in_progress + regions_needed)) { in allocate_file_region_entries()
622 to_allocate = resv->adds_in_progress + regions_needed - in allocate_file_region_entries()
623 resv->region_cache_count; in allocate_file_region_entries()
629 VM_BUG_ON(resv->region_cache_count < resv->adds_in_progress); in allocate_file_region_entries()
631 spin_unlock(&resv->lock); in allocate_file_region_entries()
639 spin_lock(&resv->lock); in allocate_file_region_entries()
641 list_splice(&allocated_regions, &resv->region_cache); in allocate_file_region_entries()
642 resv->region_cache_count += to_allocate; in allocate_file_region_entries()
672 static long region_add(struct resv_map *resv, long f, long t, in region_add() argument
678 spin_lock(&resv->lock); in region_add()
682 add_reservation_in_range(resv, f, t, NULL, NULL, in region_add()
695 resv->region_cache_count < in region_add()
696 resv->adds_in_progress + in region_add()
704 resv, actual_regions_needed - in_regions_needed)) { in region_add()
711 add = add_reservation_in_range(resv, f, t, h_cg, h, NULL); in region_add()
713 resv->adds_in_progress -= in_regions_needed; in region_add()
715 spin_unlock(&resv->lock); in region_add()
739 static long region_chg(struct resv_map *resv, long f, long t, in region_chg() argument
744 spin_lock(&resv->lock); in region_chg()
747 chg = add_reservation_in_range(resv, f, t, NULL, NULL, in region_chg()
753 if (allocate_file_region_entries(resv, *out_regions_needed)) in region_chg()
756 resv->adds_in_progress += *out_regions_needed; in region_chg()
758 spin_unlock(&resv->lock); in region_chg()
775 static void region_abort(struct resv_map *resv, long f, long t, in region_abort() argument
778 spin_lock(&resv->lock); in region_abort()
779 VM_BUG_ON(!resv->region_cache_count); in region_abort()
780 resv->adds_in_progress -= regions_needed; in region_abort()
781 spin_unlock(&resv->lock); in region_abort()
798 static long region_del(struct resv_map *resv, long f, long t) in region_del() argument
800 struct list_head *head = &resv->regions; in region_del()
806 spin_lock(&resv->lock); in region_del()
827 resv->region_cache_count > resv->adds_in_progress) { in region_del()
828 nrg = list_first_entry(&resv->region_cache, in region_del()
832 resv->region_cache_count--; in region_del()
836 spin_unlock(&resv->lock); in region_del()
845 resv, rg, t - f, false); in region_del()
865 hugetlb_cgroup_uncharge_file_region(resv, rg, in region_del()
873 hugetlb_cgroup_uncharge_file_region(resv, rg, in region_del()
879 hugetlb_cgroup_uncharge_file_region(resv, rg, in region_del()
887 spin_unlock(&resv->lock); in region_del()
925 static long region_count(struct resv_map *resv, long f, long t) in region_count() argument
927 struct list_head *head = &resv->regions; in region_count()
931 spin_lock(&resv->lock); in region_count()
947 spin_unlock(&resv->lock); in region_count()
2693 struct resv_map *resv; in __vma_reservation_common() local
2698 resv = vma_resv_map(vma); in __vma_reservation_common()
2699 if (!resv) in __vma_reservation_common()
2705 ret = region_chg(resv, idx, idx + 1, &dummy_out_regions_needed); in __vma_reservation_common()
2713 ret = region_add(resv, idx, idx + 1, 1, NULL, NULL); in __vma_reservation_common()
2718 region_abort(resv, idx, idx + 1, 1); in __vma_reservation_common()
2723 ret = region_add(resv, idx, idx + 1, 1, NULL, NULL); in __vma_reservation_common()
2727 region_abort(resv, idx, idx + 1, 1); in __vma_reservation_common()
2728 ret = region_del(resv, idx, idx + 1); in __vma_reservation_common()
2733 region_abort(resv, idx, idx + 1, 1); in __vma_reservation_common()
2734 ret = region_del(resv, idx, idx + 1); in __vma_reservation_common()
2736 ret = region_add(resv, idx, idx + 1, 1, NULL, NULL); in __vma_reservation_common()
4770 struct resv_map *resv = vma_resv_map(vma); in hugetlb_vm_op_open() local
4781 if (resv && is_vma_resv_set(vma, HPAGE_RESV_OWNER)) { in hugetlb_vm_op_open()
4782 resv_map_dup_hugetlb_cgroup_uncharge_info(resv); in hugetlb_vm_op_open()
4783 kref_get(&resv->refs); in hugetlb_vm_op_open()
4809 struct resv_map *resv; in hugetlb_vm_op_close() local
4816 resv = vma_resv_map(vma); in hugetlb_vm_op_close()
4817 if (!resv || !is_vma_resv_set(vma, HPAGE_RESV_OWNER)) in hugetlb_vm_op_close()
4823 reserve = (end - start) - region_count(resv, start, end); in hugetlb_vm_op_close()
4824 hugetlb_cgroup_uncharge_counter(resv, start, end); in hugetlb_vm_op_close()
4834 kref_put(&resv->refs, resv_map_release); in hugetlb_vm_op_close()