Lines Matching refs:page

7 #include <linux/page-flags.h>
29 extern void __page_ref_set(struct page *page, int v);
30 extern void __page_ref_mod(struct page *page, int v);
31 extern void __page_ref_mod_and_test(struct page *page, int v, int ret);
32 extern void __page_ref_mod_and_return(struct page *page, int v, int ret);
33 extern void __page_ref_mod_unless(struct page *page, int v, int u);
34 extern void __page_ref_freeze(struct page *page, int v, int ret);
35 extern void __page_ref_unfreeze(struct page *page, int v);
41 static inline void __page_ref_set(struct page *page, int v)
44 static inline void __page_ref_mod(struct page *page, int v)
47 static inline void __page_ref_mod_and_test(struct page *page, int v, int ret)
50 static inline void __page_ref_mod_and_return(struct page *page, int v, int ret)
53 static inline void __page_ref_mod_unless(struct page *page, int v, int u)
56 static inline void __page_ref_freeze(struct page *page, int v, int ret)
59 static inline void __page_ref_unfreeze(struct page *page, int v)
65 static inline int page_ref_count(const struct page *page)
67 return atomic_read(&page->_refcount);
78 * - Each reference from a page table
79 * - The page cache
83 * - Direct IO which references this page in the process address space
89 return page_ref_count(&folio->page);
92 static inline int page_count(const struct page *page)
94 return folio_ref_count(page_folio(page));
97 static inline void set_page_count(struct page *page, int v)
99 atomic_set(&page->_refcount, v);
101 __page_ref_set(page, v);
106 set_page_count(&folio->page, v);
110 * Setup the page count before being freed into the page allocator for
113 static inline void init_page_count(struct page *page)
115 set_page_count(page, 1);
118 static inline void page_ref_add(struct page *page, int nr)
120 atomic_add(nr, &page->_refcount);
122 __page_ref_mod(page, nr);
127 page_ref_add(&folio->page, nr);
130 static inline void page_ref_sub(struct page *page, int nr)
132 atomic_sub(nr, &page->_refcount);
134 __page_ref_mod(page, -nr);
139 page_ref_sub(&folio->page, nr);
142 static inline int page_ref_sub_return(struct page *page, int nr)
144 int ret = atomic_sub_return(nr, &page->_refcount);
147 __page_ref_mod_and_return(page, -nr, ret);
153 return page_ref_sub_return(&folio->page, nr);
156 static inline void page_ref_inc(struct page *page)
158 atomic_inc(&page->_refcount);
160 __page_ref_mod(page, 1);
165 page_ref_inc(&folio->page);
168 static inline void page_ref_dec(struct page *page)
170 atomic_dec(&page->_refcount);
172 __page_ref_mod(page, -1);
177 page_ref_dec(&folio->page);
180 static inline int page_ref_sub_and_test(struct page *page, int nr)
182 int ret = atomic_sub_and_test(nr, &page->_refcount);
185 __page_ref_mod_and_test(page, -nr, ret);
191 return page_ref_sub_and_test(&folio->page, nr);
194 static inline int page_ref_inc_return(struct page *page)
196 int ret = atomic_inc_return(&page->_refcount);
199 __page_ref_mod_and_return(page, 1, ret);
205 return page_ref_inc_return(&folio->page);
208 static inline int page_ref_dec_and_test(struct page *page)
210 int ret = atomic_dec_and_test(&page->_refcount);
213 __page_ref_mod_and_test(page, -1, ret);
219 return page_ref_dec_and_test(&folio->page);
222 static inline int page_ref_dec_return(struct page *page)
224 int ret = atomic_dec_return(&page->_refcount);
227 __page_ref_mod_and_return(page, -1, ret);
233 return page_ref_dec_return(&folio->page);
236 static inline bool page_ref_add_unless(struct page *page, int nr, int u)
238 bool ret = atomic_add_unless(&page->_refcount, nr, u);
241 __page_ref_mod_unless(page, nr, ret);
247 return page_ref_add_unless(&folio->page, nr, u);
294 * page and know that the page cannot have its refcount decreased to
298 * from interrupt context) and the page cache lookups (as pages are not
303 * pages being frozen & removed; eg the i_pages lock for the page cache
304 * or the mmap_lock or page table lock for page tables. In this case,
316 static inline int page_ref_freeze(struct page *page, int count)
318 int ret = likely(atomic_cmpxchg(&page->_refcount, count, 0) == count);
321 __page_ref_freeze(page, count, ret);
327 return page_ref_freeze(&folio->page, count);
330 static inline void page_ref_unfreeze(struct page *page, int count)
332 VM_BUG_ON_PAGE(page_count(page) != 0, page);
335 atomic_set_release(&page->_refcount, count);
337 __page_ref_unfreeze(page, count);
342 page_ref_unfreeze(&folio->page, count);