-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]> Acked-by: Michal Nazarewicz <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Mel Gorman <[email protected]> Cc: "Kirill A. Shutemov" <[email protected]> Cc: Sergey Senozhatsky <[email protected]> Cc: Steven Rostedt <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
- Loading branch information
1 parent
444eb2a
commit fe896d1
Showing
25 changed files
with
134 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#ifndef _LINUX_PAGE_REF_H | ||
#define _LINUX_PAGE_REF_H | ||
|
||
#include <linux/atomic.h> | ||
#include <linux/mm_types.h> | ||
#include <linux/page-flags.h> | ||
|
||
static inline int page_ref_count(struct page *page) | ||
{ | ||
return atomic_read(&page->_count); | ||
} | ||
|
||
static inline int page_count(struct page *page) | ||
{ | ||
return atomic_read(&compound_head(page)->_count); | ||
} | ||
|
||
static inline void set_page_count(struct page *page, int v) | ||
{ | ||
atomic_set(&page->_count, v); | ||
} | ||
|
||
/* | ||
* Setup the page count before being freed into the page allocator for | ||
* the first time (boot or memory hotplug) | ||
*/ | ||
static inline void init_page_count(struct page *page) | ||
{ | ||
set_page_count(page, 1); | ||
} | ||
|
||
static inline void page_ref_add(struct page *page, int nr) | ||
{ | ||
atomic_add(nr, &page->_count); | ||
} | ||
|
||
static inline void page_ref_sub(struct page *page, int nr) | ||
{ | ||
atomic_sub(nr, &page->_count); | ||
} | ||
|
||
static inline void page_ref_inc(struct page *page) | ||
{ | ||
atomic_inc(&page->_count); | ||
} | ||
|
||
static inline void page_ref_dec(struct page *page) | ||
{ | ||
atomic_dec(&page->_count); | ||
} | ||
|
||
static inline int page_ref_sub_and_test(struct page *page, int nr) | ||
{ | ||
return atomic_sub_and_test(nr, &page->_count); | ||
} | ||
|
||
static inline int page_ref_dec_and_test(struct page *page) | ||
{ | ||
return atomic_dec_and_test(&page->_count); | ||
} | ||
|
||
static inline int page_ref_dec_return(struct page *page) | ||
{ | ||
return atomic_dec_return(&page->_count); | ||
} | ||
|
||
static inline int page_ref_add_unless(struct page *page, int nr, int u) | ||
{ | ||
return atomic_add_unless(&page->_count, nr, u); | ||
} | ||
|
||
static inline int page_ref_freeze(struct page *page, int count) | ||
{ | ||
return likely(atomic_cmpxchg(&page->_count, count, 0) == count); | ||
} | ||
|
||
static inline void page_ref_unfreeze(struct page *page, int count) | ||
{ | ||
VM_BUG_ON_PAGE(page_count(page) != 0, page); | ||
VM_BUG_ON(count == 0); | ||
|
||
atomic_set(&page->_count, count); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.