Lines Matching refs:spool
88 static inline bool subpool_is_free(struct hugepage_subpool *spool) in subpool_is_free() argument
90 if (spool->count) in subpool_is_free()
92 if (spool->max_hpages != -1) in subpool_is_free()
93 return spool->used_hpages == 0; in subpool_is_free()
94 if (spool->min_hpages != -1) in subpool_is_free()
95 return spool->rsv_hpages == spool->min_hpages; in subpool_is_free()
100 static inline void unlock_or_release_subpool(struct hugepage_subpool *spool, in unlock_or_release_subpool() argument
103 spin_unlock_irqrestore(&spool->lock, irq_flags); in unlock_or_release_subpool()
108 if (subpool_is_free(spool)) { in unlock_or_release_subpool()
109 if (spool->min_hpages != -1) in unlock_or_release_subpool()
110 hugetlb_acct_memory(spool->hstate, in unlock_or_release_subpool()
111 -spool->min_hpages); in unlock_or_release_subpool()
112 kfree(spool); in unlock_or_release_subpool()
119 struct hugepage_subpool *spool; in hugepage_new_subpool() local
121 spool = kzalloc(sizeof(*spool), GFP_KERNEL); in hugepage_new_subpool()
122 if (!spool) in hugepage_new_subpool()
125 spin_lock_init(&spool->lock); in hugepage_new_subpool()
126 spool->count = 1; in hugepage_new_subpool()
127 spool->max_hpages = max_hpages; in hugepage_new_subpool()
128 spool->hstate = h; in hugepage_new_subpool()
129 spool->min_hpages = min_hpages; in hugepage_new_subpool()
132 kfree(spool); in hugepage_new_subpool()
135 spool->rsv_hpages = min_hpages; in hugepage_new_subpool()
137 return spool; in hugepage_new_subpool()
140 void hugepage_put_subpool(struct hugepage_subpool *spool) in hugepage_put_subpool() argument
144 spin_lock_irqsave(&spool->lock, flags); in hugepage_put_subpool()
145 BUG_ON(!spool->count); in hugepage_put_subpool()
146 spool->count--; in hugepage_put_subpool()
147 unlock_or_release_subpool(spool, flags); in hugepage_put_subpool()
158 static long hugepage_subpool_get_pages(struct hugepage_subpool *spool, in hugepage_subpool_get_pages() argument
163 if (!spool) in hugepage_subpool_get_pages()
166 spin_lock_irq(&spool->lock); in hugepage_subpool_get_pages()
168 if (spool->max_hpages != -1) { /* maximum size accounting */ in hugepage_subpool_get_pages()
169 if ((spool->used_hpages + delta) <= spool->max_hpages) in hugepage_subpool_get_pages()
170 spool->used_hpages += delta; in hugepage_subpool_get_pages()
178 if (spool->min_hpages != -1 && spool->rsv_hpages) { in hugepage_subpool_get_pages()
179 if (delta > spool->rsv_hpages) { in hugepage_subpool_get_pages()
184 ret = delta - spool->rsv_hpages; in hugepage_subpool_get_pages()
185 spool->rsv_hpages = 0; in hugepage_subpool_get_pages()
188 spool->rsv_hpages -= delta; in hugepage_subpool_get_pages()
193 spin_unlock_irq(&spool->lock); in hugepage_subpool_get_pages()
203 static long hugepage_subpool_put_pages(struct hugepage_subpool *spool, in hugepage_subpool_put_pages() argument
209 if (!spool) in hugepage_subpool_put_pages()
212 spin_lock_irqsave(&spool->lock, flags); in hugepage_subpool_put_pages()
214 if (spool->max_hpages != -1) /* maximum size accounting */ in hugepage_subpool_put_pages()
215 spool->used_hpages -= delta; in hugepage_subpool_put_pages()
218 if (spool->min_hpages != -1 && spool->used_hpages < spool->min_hpages) { in hugepage_subpool_put_pages()
219 if (spool->rsv_hpages + delta <= spool->min_hpages) in hugepage_subpool_put_pages()
222 ret = spool->rsv_hpages + delta - spool->min_hpages; in hugepage_subpool_put_pages()
224 spool->rsv_hpages += delta; in hugepage_subpool_put_pages()
225 if (spool->rsv_hpages > spool->min_hpages) in hugepage_subpool_put_pages()
226 spool->rsv_hpages = spool->min_hpages; in hugepage_subpool_put_pages()
233 unlock_or_release_subpool(spool, flags); in hugepage_subpool_put_pages()
240 return HUGETLBFS_SB(inode->i_sb)->spool; in subpool_inode()
750 struct hugepage_subpool *spool = subpool_inode(inode); in hugetlb_fix_reserve_counts() local
754 rsv_adjust = hugepage_subpool_get_pages(spool, 1); in hugetlb_fix_reserve_counts()
1585 struct hugepage_subpool *spool = hugetlb_page_subpool(page); in free_huge_page() local
1612 if (hugepage_subpool_put_pages(spool, 1) == 0) in free_huge_page()
2746 struct hugepage_subpool *spool = subpool_vma(vma); in alloc_huge_page() local
2773 gbl_chg = hugepage_subpool_get_pages(spool, 1); in alloc_huge_page()
2836 hugetlb_set_page_subpool(page, spool); in alloc_huge_page()
2851 rsv_adjust = hugepage_subpool_put_pages(spool, 1); in alloc_huge_page()
2867 hugepage_subpool_put_pages(spool, 1); in alloc_huge_page()
4140 struct hugepage_subpool *spool = subpool_vma(vma); in hugetlb_vm_op_close() local
4157 gbl_reserve = hugepage_subpool_put_pages(spool, reserve); in hugetlb_vm_op_close()
5735 struct hugepage_subpool *spool = subpool_inode(inode); in hugetlb_reserve_pages() local
5801 gbl_reserve = hugepage_subpool_get_pages(spool, chg); in hugetlb_reserve_pages()
5847 rsv_adjust = hugepage_subpool_put_pages(spool, in hugetlb_reserve_pages()
5864 (void)hugepage_subpool_put_pages(spool, chg); in hugetlb_reserve_pages()
5886 struct hugepage_subpool *spool = subpool_inode(inode); in hugetlb_unreserve_pages() local
5915 gbl_reserve = hugepage_subpool_put_pages(spool, (chg - freed)); in hugetlb_unreserve_pages()