summaryrefslogtreecommitdiffstats
path: root/include/linux/pagemap.h
diff options
context:
space:
mode:
authorJoonsoo Kim <iamjoonsoo.kim@lge.com>2016-03-17 17:19:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-03-17 18:09:34 -0400
commitfe896d1878949ea92ba547587bc3075cc688fb8f (patch)
tree582ae505611bafae117c0de8498916485699ac78 /include/linux/pagemap.h
parent444eb2a449ef36fe115431ed7b71467c4563c7f1 (diff)
mm: introduce page reference manipulation functions
The success of CMA allocation largely depends on the success of migration and key factor of it is page reference count. Until now, page reference is manipulated by direct calling atomic functions so we cannot follow up who and where manipulate it. Then, it is hard to find actual reason of CMA allocation failure. CMA allocation should be guaranteed to succeed so finding offending place is really important. In this patch, call sites where page reference is manipulated are converted to introduced wrapper function. This is preparation step to add tracepoint to each page reference manipulation function. With this facility, we can easily find reason of CMA allocation failure. There is no functional change in this patch. In addition, this patch also converts reference read sites. It will help a second step that renames page._count to something else and prevents later attempt to direct access to it (Suggested by Andrew). Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Acked-by: Vlastimil Babka <vbabka@suse.cz> Cc: Minchan Kim <minchan@kernel.org> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/pagemap.h')
-rw-r--r--include/linux/pagemap.h19
1 files changed, 3 insertions, 16 deletions
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index 183b15ea052b..1ebd65c91422 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -165,7 +165,7 @@ static inline int page_cache_get_speculative(struct page *page)
165 * SMP requires. 165 * SMP requires.
166 */ 166 */
167 VM_BUG_ON_PAGE(page_count(page) == 0, page); 167 VM_BUG_ON_PAGE(page_count(page) == 0, page);
168 atomic_inc(&page->_count); 168 page_ref_inc(page);
169 169
170#else 170#else
171 if (unlikely(!get_page_unless_zero(page))) { 171 if (unlikely(!get_page_unless_zero(page))) {
@@ -194,10 +194,10 @@ static inline int page_cache_add_speculative(struct page *page, int count)
194 VM_BUG_ON(!in_atomic()); 194 VM_BUG_ON(!in_atomic());
195# endif 195# endif
196 VM_BUG_ON_PAGE(page_count(page) == 0, page); 196 VM_BUG_ON_PAGE(page_count(page) == 0, page);
197 atomic_add(count, &page->_count); 197 page_ref_add(page, count);
198 198
199#else 199#else
200 if (unlikely(!atomic_add_unless(&page->_count, count, 0))) 200 if (unlikely(!page_ref_add_unless(page, count, 0)))
201 return 0; 201 return 0;
202#endif 202#endif
203 VM_BUG_ON_PAGE(PageCompound(page) && page != compound_head(page), page); 203 VM_BUG_ON_PAGE(PageCompound(page) && page != compound_head(page), page);
@@ -205,19 +205,6 @@ static inline int page_cache_add_speculative(struct page *page, int count)
205 return 1; 205 return 1;
206} 206}
207 207
208static inline int page_freeze_refs(struct page *page, int count)
209{
210 return likely(atomic_cmpxchg(&page->_count, count, 0) == count);
211}
212
213static inline void page_unfreeze_refs(struct page *page, int count)
214{
215 VM_BUG_ON_PAGE(page_count(page) != 0, page);
216 VM_BUG_ON(count == 0);
217
218 atomic_set(&page->_count, count);
219}
220
221#ifdef CONFIG_NUMA 208#ifdef CONFIG_NUMA
222extern struct page *__page_cache_alloc(gfp_t gfp); 209extern struct page *__page_cache_alloc(gfp_t gfp);
223#else 210#else