Skip to content

Commit

Permalink
mm/page_owner: introduce split_page_owner and replace manual handling
Browse files Browse the repository at this point in the history
split_page() calls set_page_owner() to set up page_owner to each pages.
But, it has a drawback that head page and the others have different
stacktrace because callsite of set_page_owner() is slightly differnt.
To avoid this problem, this patch copies head page's page_owner to the
others.  It needs to introduce new function, split_page_owner() but it
also remove the other function, get_page_owner_gfp() so looks good to
do.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Joonsoo Kim <[email protected]>
Acked-by: Vlastimil Babka <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: Minchan Kim <[email protected]>
Cc: Alexander Potapenko <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Michal Hocko <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
JoonsooKim authored and torvalds committed Jul 26, 2016
1 parent a8efe1c commit a9627bc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
12 changes: 5 additions & 7 deletions include/linux/page_owner.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern struct page_ext_operations page_owner_ops;
extern void __reset_page_owner(struct page *page, unsigned int order);
extern void __set_page_owner(struct page *page,
unsigned int order, gfp_t gfp_mask);
extern gfp_t __get_page_owner_gfp(struct page *page);
extern void __split_page_owner(struct page *page, unsigned int order);
extern void __copy_page_owner(struct page *oldpage, struct page *newpage);
extern void __set_page_owner_migrate_reason(struct page *page, int reason);
extern void __dump_page_owner(struct page *page);
Expand All @@ -28,12 +28,10 @@ static inline void set_page_owner(struct page *page,
__set_page_owner(page, order, gfp_mask);
}

static inline gfp_t get_page_owner_gfp(struct page *page)
static inline void split_page_owner(struct page *page, unsigned int order)
{
if (static_branch_unlikely(&page_owner_inited))
return __get_page_owner_gfp(page);
else
return 0;
__split_page_owner(page, order);
}
static inline void copy_page_owner(struct page *oldpage, struct page *newpage)
{
Expand All @@ -58,9 +56,9 @@ static inline void set_page_owner(struct page *page,
unsigned int order, gfp_t gfp_mask)
{
}
static inline gfp_t get_page_owner_gfp(struct page *page)
static inline void split_page_owner(struct page *page,
unsigned int order)
{
return 0;
}
static inline void copy_page_owner(struct page *oldpage, struct page *newpage)
{
Expand Down
8 changes: 2 additions & 6 deletions mm/page_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2461,7 +2461,6 @@ void free_hot_cold_page_list(struct list_head *list, bool cold)
void split_page(struct page *page, unsigned int order)
{
int i;
gfp_t gfp_mask;

VM_BUG_ON_PAGE(PageCompound(page), page);
VM_BUG_ON_PAGE(!page_count(page), page);
Expand All @@ -2475,12 +2474,9 @@ void split_page(struct page *page, unsigned int order)
split_page(virt_to_page(page[0].shadow), order);
#endif

gfp_mask = get_page_owner_gfp(page);
set_page_owner(page, 0, gfp_mask);
for (i = 1; i < (1 << order); i++) {
for (i = 1; i < (1 << order); i++)
set_page_refcounted(page + i);
set_page_owner(page + i, 0, gfp_mask);
}
split_page_owner(page, order);
}
EXPORT_SYMBOL_GPL(split_page);

Expand Down
14 changes: 7 additions & 7 deletions mm/page_owner.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,17 @@ void __set_page_owner_migrate_reason(struct page *page, int reason)
page_ext->last_migrate_reason = reason;
}

gfp_t __get_page_owner_gfp(struct page *page)
void __split_page_owner(struct page *page, unsigned int order)
{
int i;
struct page_ext *page_ext = lookup_page_ext(page);

if (unlikely(!page_ext))
/*
* The caller just returns 0 if no valid gfp
* So return 0 here too.
*/
return 0;
return;

return page_ext->gfp_mask;
page_ext->order = 0;
for (i = 1; i < (1 << order); i++)
__copy_page_owner(page, page + i);
}

void __copy_page_owner(struct page *oldpage, struct page *newpage)
Expand Down

0 comments on commit a9627bc

Please sign in to comment.