All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: Andrea Arcangeli <aarcange@redhat.com>
Cc: linux-mm@kvack.org, akpm@linux-foundation.org
Subject: Re: [PATCH] mm/THP: Use pmd_populate to update the pmd with pgtable_t pointer
Date: Mon, 13 May 2013 20:14:55 +0530	[thread overview]
Message-ID: <87y5bj3pnc.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <20130513141357.GL27980@redhat.com>

Andrea Arcangeli <aarcange@redhat.com> writes:

> Hi Aneesh,
>
> On Mon, May 13, 2013 at 07:18:57PM +0530, Aneesh Kumar K.V wrote:
>> 
>> updated one fixing a compile warning.
>> 
>> From f721c77eb0d6aaf75758e8e93991a05207680ac8 Mon Sep 17 00:00:00 2001
>> From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
>> Date: Sun, 12 May 2013 01:59:00 +0530
>> Subject: [PATCH] mm/THP: Use pmd_populate to update the pmd with pgtable_t
>>  pointer
>> 
>> We should not use set_pmd_at to update pmd_t with pgtable_t pointer. set_pmd_at
>> is used to set pmd with huge pte entries and architectures like ppc64, clear
>> few flags from the pte when saving a new entry. Without this change we observe
>> bad pte errors like below on ppc64 with THP enabled.
>> 
>> BUG: Bad page map in process ld mm=0xc000001ee39f4780 pte:7fc3f37848000001 pmd:c000001ec0000000
>> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
>> ---
>>  mm/huge_memory.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>> index 03a89a2..f0bad1f 100644
>> --- a/mm/huge_memory.c
>> +++ b/mm/huge_memory.c
>> @@ -2325,7 +2325,7 @@ static void collapse_huge_page(struct mm_struct *mm,
>>  		pte_unmap(pte);
>>  		spin_lock(&mm->page_table_lock);
>>  		BUG_ON(!pmd_none(*pmd));
>> -		set_pmd_at(mm, address, pmd, _pmd);
>> +		pmd_populate(mm, pmd, (pgtable_t)_pmd);
>>  		spin_unlock(&mm->page_table_lock);
>>  		anon_vma_unlock_write(vma->anon_vma);
>>  		goto out;
>
> Great, looks like you found the ppc problem with gcc builds and that
> explains also why it cannot happen on x86.

yes. That was the reason for the failure. 

>
> But about the fix, did you test it? The above should be:
> pmd_populate(mm, pmd, pmd_pgtable(_pmd)) instead.
>

Yes and it worked in powerpc because we have for ppc64 

static inline pgtable_t pmd_pgtable(pmd_t pmd)
{
	return (pgtable_t)(pmd_val(pmd) & ~PMD_MASKED_BITS);
}

That is because we share the PTE page with multiple pmds

> _pmd is not a pointer to a page struct and the cast seems to be hiding
> a bug. _pmd if something is a physical address potentially with some
> high bit set not making it a good physical address either.
>
> So you can only use set_pmd_at when establishing hugepmds, and never
> for establishing regular pmds that points to regular pagetables. I
> guess a comment would be good to add too.
>

I will send an updated patch.


-aneesh

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2013-05-13 14:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-12  8:35 [PATCH] mm/THP: Use pmd_populate to update the pmd with pgtable_t pointer Aneesh Kumar K.V
2013-05-13 13:48 ` Aneesh Kumar K.V
2013-05-13 14:13   ` Andrea Arcangeli
2013-05-13 14:44     ` Aneesh Kumar K.V [this message]
2013-05-13 15:06       ` Aneesh Kumar K.V
2013-05-16 13:18         ` Andrea Arcangeli
2013-05-16 14:25           ` Aneesh Kumar K.V
2013-05-16 14:51             ` Andrea Arcangeli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y5bj3pnc.fsf@linux.vnet.ibm.com \
    --to=aneesh.kumar@linux.vnet.ibm.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.