aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/mm.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 541d99b86aea..7000ddd807e0 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -980,6 +980,15 @@ static inline void get_page(struct page *page)
980 page_ref_inc(page); 980 page_ref_inc(page);
981} 981}
982 982
983static inline __must_check bool try_get_page(struct page *page)
984{
985 page = compound_head(page);
986 if (WARN_ON_ONCE(page_ref_count(page) <= 0))
987 return false;
988 page_ref_inc(page);
989 return true;
990}
991
983static inline void put_page(struct page *page) 992static inline void put_page(struct page *page)
984{ 993{
985 page = compound_head(page); 994 page = compound_head(page);