Lines Matching refs:spool
98 static inline bool subpool_is_free(struct hugepage_subpool *spool) in subpool_is_free() argument
100 if (spool->count) in subpool_is_free()
102 if (spool->max_hpages != -1) in subpool_is_free()
103 return spool->used_hpages == 0; in subpool_is_free()
104 if (spool->min_hpages != -1) in subpool_is_free()
105 return spool->rsv_hpages == spool->min_hpages; in subpool_is_free()
110 static inline void unlock_or_release_subpool(struct hugepage_subpool *spool, in unlock_or_release_subpool() argument
113 spin_unlock_irqrestore(&spool->lock, irq_flags); in unlock_or_release_subpool()
118 if (subpool_is_free(spool)) { in unlock_or_release_subpool()
119 if (spool->min_hpages != -1) in unlock_or_release_subpool()
120 hugetlb_acct_memory(spool->hstate, in unlock_or_release_subpool()
121 -spool->min_hpages); in unlock_or_release_subpool()
122 kfree(spool); in unlock_or_release_subpool()
129 struct hugepage_subpool *spool; in hugepage_new_subpool() local
131 spool = kzalloc(sizeof(*spool), GFP_KERNEL); in hugepage_new_subpool()
132 if (!spool) in hugepage_new_subpool()
135 spin_lock_init(&spool->lock); in hugepage_new_subpool()
136 spool->count = 1; in hugepage_new_subpool()
137 spool->max_hpages = max_hpages; in hugepage_new_subpool()
138 spool->hstate = h; in hugepage_new_subpool()
139 spool->min_hpages = min_hpages; in hugepage_new_subpool()
142 kfree(spool); in hugepage_new_subpool()
145 spool->rsv_hpages = min_hpages; in hugepage_new_subpool()
147 return spool; in hugepage_new_subpool()
150 void hugepage_put_subpool(struct hugepage_subpool *spool) in hugepage_put_subpool() argument
154 spin_lock_irqsave(&spool->lock, flags); in hugepage_put_subpool()
155 BUG_ON(!spool->count); in hugepage_put_subpool()
156 spool->count--; in hugepage_put_subpool()
157 unlock_or_release_subpool(spool, flags); in hugepage_put_subpool()
168 static long hugepage_subpool_get_pages(struct hugepage_subpool *spool, in hugepage_subpool_get_pages() argument
173 if (!spool) in hugepage_subpool_get_pages()
176 spin_lock_irq(&spool->lock); in hugepage_subpool_get_pages()
178 if (spool->max_hpages != -1) { /* maximum size accounting */ in hugepage_subpool_get_pages()
179 if ((spool->used_hpages + delta) <= spool->max_hpages) in hugepage_subpool_get_pages()
180 spool->used_hpages += delta; in hugepage_subpool_get_pages()
188 if (spool->min_hpages != -1 && spool->rsv_hpages) { in hugepage_subpool_get_pages()
189 if (delta > spool->rsv_hpages) { in hugepage_subpool_get_pages()
194 ret = delta - spool->rsv_hpages; in hugepage_subpool_get_pages()
195 spool->rsv_hpages = 0; in hugepage_subpool_get_pages()
198 spool->rsv_hpages -= delta; in hugepage_subpool_get_pages()
203 spin_unlock_irq(&spool->lock); in hugepage_subpool_get_pages()
213 static long hugepage_subpool_put_pages(struct hugepage_subpool *spool, in hugepage_subpool_put_pages() argument
219 if (!spool) in hugepage_subpool_put_pages()
222 spin_lock_irqsave(&spool->lock, flags); in hugepage_subpool_put_pages()
224 if (spool->max_hpages != -1) /* maximum size accounting */ in hugepage_subpool_put_pages()
225 spool->used_hpages -= delta; in hugepage_subpool_put_pages()
228 if (spool->min_hpages != -1 && spool->used_hpages < spool->min_hpages) { in hugepage_subpool_put_pages()
229 if (spool->rsv_hpages + delta <= spool->min_hpages) in hugepage_subpool_put_pages()
232 ret = spool->rsv_hpages + delta - spool->min_hpages; in hugepage_subpool_put_pages()
234 spool->rsv_hpages += delta; in hugepage_subpool_put_pages()
235 if (spool->rsv_hpages > spool->min_hpages) in hugepage_subpool_put_pages()
236 spool->rsv_hpages = spool->min_hpages; in hugepage_subpool_put_pages()
243 unlock_or_release_subpool(spool, flags); in hugepage_subpool_put_pages()
250 return HUGETLBFS_SB(inode->i_sb)->spool; in subpool_inode()
758 struct hugepage_subpool *spool = subpool_inode(inode); in hugetlb_fix_reserve_counts() local
762 rsv_adjust = hugepage_subpool_get_pages(spool, 1); in hugetlb_fix_reserve_counts()
1664 struct hugepage_subpool *spool = hugetlb_page_subpool(page); in free_huge_page() local
1691 if (hugepage_subpool_put_pages(spool, 1) == 0) in free_huge_page()
2843 struct hugepage_subpool *spool = subpool_vma(vma); in alloc_huge_page() local
2870 gbl_chg = hugepage_subpool_get_pages(spool, 1); in alloc_huge_page()
2933 hugetlb_set_page_subpool(page, spool); in alloc_huge_page()
2948 rsv_adjust = hugepage_subpool_put_pages(spool, 1); in alloc_huge_page()
2964 hugepage_subpool_put_pages(spool, 1); in alloc_huge_page()
4563 struct hugepage_subpool *spool = subpool_vma(vma); in hugetlb_vm_op_close() local
4580 gbl_reserve = hugepage_subpool_put_pages(spool, reserve); in hugetlb_vm_op_close()
6213 struct hugepage_subpool *spool = subpool_inode(inode); in hugetlb_reserve_pages() local
6279 gbl_reserve = hugepage_subpool_get_pages(spool, chg); in hugetlb_reserve_pages()
6325 rsv_adjust = hugepage_subpool_put_pages(spool, in hugetlb_reserve_pages()
6342 (void)hugepage_subpool_put_pages(spool, chg); in hugetlb_reserve_pages()
6364 struct hugepage_subpool *spool = subpool_inode(inode); in hugetlb_unreserve_pages() local
6393 gbl_reserve = hugepage_subpool_put_pages(spool, (chg - freed)); in hugetlb_unreserve_pages()