Skip to content

Commit

Permalink
thp: allow a hwpoisoned head page to be put back to LRU
Browse files Browse the repository at this point in the history
Andrea Arcangeli pointed out to me that a check in __memory_failure()
which was intended to prevent THP tail pages from being checked for the
absence of the PG_lru flag (something that is always the case), was also
preventing THP head pages from being checked.

A THP head page could actually benefit from the call to shake_page() by
ending up being put back to a LRU, provided it had been waiting in a
pagevec array.

Andrea suggested that the "!PageTransCompound(p)" in the if-statement
should be replaced by a "!PageTransTail(p)", thus allowing THP head pages
to be checked and possibly shaken.

Signed-off-by: Dean Nelson <[email protected]>
Cc: Jin Dongming <[email protected]>
Reviewed-by: Andrea Arcangeli <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Hidetoshi Seto <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
dnlsn authored and torvalds committed Mar 22, 2012
1 parent 6d9d88d commit 385de35
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions include/linux/page-flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,26 @@ static inline int PageTransHuge(struct page *page)
return PageHead(page);
}

/*
* PageTransCompound returns true for both transparent huge pages
* and hugetlbfs pages, so it should only be called when it's known
* that hugetlbfs pages aren't involved.
*/
static inline int PageTransCompound(struct page *page)
{
return PageCompound(page);
}

/*
* PageTransTail returns true for both transparent huge pages
* and hugetlbfs pages, so it should only be called when it's known
* that hugetlbfs pages aren't involved.
*/
static inline int PageTransTail(struct page *page)
{
return PageTail(page);
}

#else

static inline int PageTransHuge(struct page *page)
Expand All @@ -430,6 +445,11 @@ static inline int PageTransCompound(struct page *page)
{
return 0;
}

static inline int PageTransTail(struct page *page)
{
return 0;
}
#endif

#ifdef CONFIG_MMU
Expand Down
2 changes: 1 addition & 1 deletion mm/memory-failure.c
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ int __memory_failure(unsigned long pfn, int trapno, int flags)
* The check (unnecessarily) ignores LRU pages being isolated and
* walked by the page reclaim code, however that's not a big loss.
*/
if (!PageHuge(p) && !PageTransCompound(p)) {
if (!PageHuge(p) && !PageTransTail(p)) {
if (!PageLRU(p))
shake_page(p, 0);
if (!PageLRU(p)) {
Expand Down

0 comments on commit 385de35

Please sign in to comment.