All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/3] Fix unsuitable behavior for poisoned tail pages of THP.
@ 2011-01-25  5:46 Jin Dongming
  2011-01-25 22:46 ` Andrea Arcangeli
  0 siblings, 1 reply; 3+ messages in thread
From: Jin Dongming @ 2011-01-25  5:46 UTC (permalink / raw)
  To: Andi Kleen, Andrea Arcangeli
  Cc: AKPM , Hidetoshi Seto, Huang Ying, LKLM

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.

Signed-off-by: Jin Dongming <jin.dongming@np.css.fujitsu.com>
Reviewed-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
---
 mm/memory-failure.c |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 5396603..44a1bdf 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -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;
 	}
 
 	/*
-- 
1.7.2.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 3/3] Fix unsuitable behavior for poisoned tail pages of THP.
  2011-01-25  5:46 [PATCH 3/3] Fix unsuitable behavior for poisoned tail pages of THP Jin Dongming
@ 2011-01-25 22:46 ` Andrea Arcangeli
  2011-01-27  0:13   ` Jin Dongming
  0 siblings, 1 reply; 3+ messages in thread
From: Andrea Arcangeli @ 2011-01-25 22:46 UTC (permalink / raw)
  To: Jin Dongming; +Cc: Andi Kleen, AKPM , Hidetoshi Seto, Huang Ying, LKLM

On Tue, Jan 25, 2011 at 02:46:32PM +0900, Jin Dongming wrote:
> 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.
> 
> Signed-off-by: Jin Dongming <jin.dongming@np.css.fujitsu.com>
> Reviewed-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
> ---
>  mm/memory-failure.c |   27 +++++++++++++++------------
>  1 files changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index 5396603..44a1bdf 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -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)) {

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).


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 3/3] Fix unsuitable behavior for poisoned tail pages of THP.
  2011-01-25 22:46 ` Andrea Arcangeli
@ 2011-01-27  0:13   ` Jin Dongming
  0 siblings, 0 replies; 3+ messages in thread
From: Jin Dongming @ 2011-01-27  0:13 UTC (permalink / raw)
  To: Andrea Arcangeli
  Cc: Andi Kleen, AKPM , Hidetoshi Seto, Huang Ying, LKLM

Hi, Andrea
(2011/01/26 7:46), Andrea Arcangeli wrote:
> On Tue, Jan 25, 2011 at 02:46:32PM +0900, Jin Dongming wrote:
>> 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.
>>
>> Signed-off-by: Jin Dongming <jin.dongming@np.css.fujitsu.com>
>> Reviewed-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
>> ---
>>  mm/memory-failure.c |   27 +++++++++++++++------------
>>  1 files changed, 15 insertions(+), 12 deletions(-)
>>
>> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
>> index 5396603..44a1bdf 100644
>> --- a/mm/memory-failure.c
>> +++ b/mm/memory-failure.c
>> @@ -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)) {
> 
> Here the check could become a:
> 
>         if (!PageHuge(p) && !PageTransCompound(p))
> 
I will modify it.

Thanks.

Best Regards,
Jin Dongming

> 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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 
> 



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-27  0:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-25  5:46 [PATCH 3/3] Fix unsuitable behavior for poisoned tail pages of THP Jin Dongming
2011-01-25 22:46 ` Andrea Arcangeli
2011-01-27  0:13   ` Jin Dongming

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.