Fix unsuitable behavior for poisoned tail pages of THP.
Subsystems (2)
PATCH 3/3 Fix unsuitable behavior for poisoned tail pages of THP.
When a tail page of THP is poisoned, memory-failure will do nothing except setting poison flag, while the expected behavior is that the process, who is using the poisoned tail page, should be killed.
The above problem is caused by lru checking of the poisoned tail page of THP. Because PG_lru flag is only set on the head page of THP, the check always consider the poisoned tail page as NON lru page.
So avoid checking NON lru for THP, as like as hugetlb.
--- mm/memory-failure.c | 27 +++++++++++++++------------ 1 files changed, 15 insertions(+), 12 deletions(-)
mm/memory-failure.c +15 -12
@@ -1046,19 +1046,22 @@ 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 (!PageLRU (p) && !PageHuge (p)) -shake_page (p,0 ); -if (!PageLRU (p) && !PageHuge (p)) { -/* -* shake_page could have turned it free. -*/ -if (is_free_buddy_page (p)) { -action_result (pfn,"free buddy, 2nd try" ,DELAYED ); -return 0 ; +if (!PageCompound (p)) { +if (!PageLRU (p)) +shake_page (p,0 ); +if (!PageLRU (p)) { +/* +* shake_page could have turned it free. +*/ +if (is_free_buddy_page (p)) { +action_result (pfn,"free buddy, 2nd try" , +DELAYED ); +return 0 ; + } +action_result (pfn,"non LRU" ,IGNORED ); +put_page (p); +return -EBUSY ; } -action_result (pfn,"non LRU" ,IGNORED ); -put_page (p); -return -EBUSY ; }/*
Signature · 1 line
1.7.2.2
Quoted 26 lines · Jin Dongming
When a tail page of THP is poisoned, memory-failure will do nothing except setting poison flag, while the expected behavior is that the process, who is using the poisoned tail page, should be killed.
The above problem is caused by lru checking of the poisoned tail page of THP. Because
PG_lruflag is only set on the head page of THP, the check always consider the poisoned tail page as NON lru page.So avoid checking NON lru for THP, as like as hugetlb.
Signed-off-by Jin Dongming <[email protected]>Reviewed-by Hidetoshi Seto <[email protected]>--- mm/memory-failure.c | 27 +++++++++++++++------------ 1 files changed, 15 insertions(+), 12 deletions(-)mm/memory-failure.c +0
-0@@ -1046,19 +1046,22 @@ 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. */
mm/memory-failure.c int __memory_failure(unsigned long pfn, int trapno, int flags) · line 1049
Quoted 10 lines
mm/memory-failure.c +1
-9-if (!PageLRU (p) && !PageHuge (p)) -shake_page (p,0 ); -if (!PageLRU (p) && !PageHuge (p)) { -/* -* shake_page could have turned it free. -*/ -if (is_free_buddy_page (p)) { -action_result (pfn,"free buddy, 2nd try" ,DELAYED ); -return 0 ; +if (!PageCompound (p)) {
Here the check could become a:
if (!PageHuge(p) && !PageTransCompound(p))
so the whole branch is optimized away at build time when both hugetlbfs and THP are set =n (or in archs not supporting either of those).
Hi, Andrea
Quoted 40 lines · Andrea Arcangeli
Quoted 26 lines · Jin Dongming
When a tail page of THP is poisoned, memory-failure will do nothing except setting poison flag, while the expected behavior is that the process, who is using the poisoned tail page, should be killed.
The above problem is caused by lru checking of the poisoned tail page of THP. Because
PG_lruflag is only set on the head page of THP, the check always consider the poisoned tail page as NON lru page.So avoid checking NON lru for THP, as like as hugetlb.
Signed-off-by Jin Dongming <[email protected]>Reviewed-by Hidetoshi Seto <[email protected]>--- mm/memory-failure.c | 27 +++++++++++++++------------ 1 files changed, 15 insertions(+), 12 deletions(-)mm/memory-failure.c +0
-0@@ -1046,19 +1046,22 @@ 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. */ mm/memory-failure.c int __memory_failure(unsigned long pfn, int trapno, int flags) · line 1049
Quoted 10 lines
mm/memory-failure.c +1
-9-if (!PageLRU (p) && !PageHuge (p)) -shake_page (p,0 ); -if (!PageLRU (p) && !PageHuge (p)) { -/* -* shake_page could have turned it free. -*/ -if (is_free_buddy_page (p)) { -action_result (pfn,"free buddy, 2nd try" ,DELAYED ); -return 0 ; +if (!PageCompound (p)) {Here the check could become a:
Quoted 2 lines
if (!PageHuge(p) && !PageTransCompound(p))
I will modify it.
Thanks.
Best Regards,
Jin Dongming
Quoted 11 lines
so the whole branch is optimized away at build time when both hugetlbfs and THP are set =n (or in archs not supporting either of those).
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/