From: "Huang\, Ying" <ying.huang@intel.com>
To: Zi Yan <zi.yan@cs.rutgers.edu>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Michal Hocko <mhocko@suse.com>, Minchan Kim <minchan@kernel.org>,
Shaohua Li <shli@kernel.org>,
jglisse@redhat.com,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: Re: [PATCH -mm] mm, madvise, THP: Use THP aligned address in madvise_free_huge_pmd()
Date: Thu, 15 Mar 2018 09:47:44 +0800 [thread overview]
Message-ID: <873712az3z.fsf@yhuang-dev.intel.com> (raw)
In-Reply-To: <869F4AAA-5BBA-40D6-916F-6919E515D271@cs.rutgers.edu> (Zi Yan's message of "Wed, 14 Mar 2018 21:39:54 -0400")
Zi Yan <zi.yan@cs.rutgers.edu> writes:
> This cannot happen.
>
> Two address parameters are passed: addr and next.
> If a??addra?? is not aligned and a??nexta?? is aligned or the end of madvise range, which might not be aligned,
> either way next - addr < HPAGE_PMD_SIZE.
>
> This means the code in a??if (next - addr != HPAGE_PMD_SIZE)a??, which is above your second hunk,
> will split the THP between a??addra?? and a??nexta?? and get out as long as a??addra?? is not aligned.
> Thus, the code in your second hunk should always get aligned a??addra??.
>
> Let me know if I miss anything.
Yes, you are right! Thanks for pointing this out.
Sorry for bothering, please ignore this patch.
Best Regards,
Huang, Ying
> a??
> Best Regards,
> Yan Zi
>
> On 14 Mar 2018, at 21:18, Huang, Ying wrote:
>
>> From: Huang Ying <ying.huang@intel.com>
>>
>> The address argument passed in madvise_free_huge_pmd() may be not THP
>> aligned. But some THP operations like pmdp_invalidate(),
>> set_pmd_at(), and tlb_remove_pmd_tlb_entry() need the address to be
>> THP aligned. Fix this via using THP aligned address for these
>> functions in madvise_free_huge_pmd().
>>
>> Signed-off-by: "Huang, Ying" <ying.huang@intel.com>
>> Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
>> Cc: Michal Hocko <mhocko@suse.com>
>> Cc: Minchan Kim <minchan@kernel.org>
>> Cc: Shaohua Li <shli@kernel.org>
>> Cc: Zi Yan <zi.yan@cs.rutgers.edu>
>> Cc: jglisse@redhat.com
>> Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
>> ---
>> mm/huge_memory.c | 7 ++++---
>> 1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
>> index 0cc62405de9c..c5e1bfb08bd7 100644
>> --- a/mm/huge_memory.c
>> +++ b/mm/huge_memory.c
>> @@ -1617,6 +1617,7 @@ bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
>> struct page *page;
>> struct mm_struct *mm = tlb->mm;
>> bool ret = false;
>> + unsigned long haddr = addr & HPAGE_PMD_MASK;
>>
>> tlb_remove_check_page_size_change(tlb, HPAGE_PMD_SIZE);
>>
>> @@ -1663,12 +1664,12 @@ bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
>> unlock_page(page);
>>
>> if (pmd_young(orig_pmd) || pmd_dirty(orig_pmd)) {
>> - pmdp_invalidate(vma, addr, pmd);
>> + pmdp_invalidate(vma, haddr, pmd);
>> orig_pmd = pmd_mkold(orig_pmd);
>> orig_pmd = pmd_mkclean(orig_pmd);
>>
>> - set_pmd_at(mm, addr, pmd, orig_pmd);
>> - tlb_remove_pmd_tlb_entry(tlb, pmd, addr);
>> + set_pmd_at(mm, haddr, pmd, orig_pmd);
>> + tlb_remove_pmd_tlb_entry(tlb, pmd, haddr);
>> }
>>
>> mark_page_lazyfree(page);
>> --
>> 2.16.1
next prev parent reply other threads:[~2018-03-15 1:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-15 1:18 Huang, Ying
2018-03-15 1:39 ` Zi Yan
2018-03-15 1:47 ` Huang, Ying [this message]
2018-03-15 12:29 ` Michal Hocko
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=873712az3z.fsf@yhuang-dev.intel.com \
--to=ying.huang@intel.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=jglisse@redhat.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=minchan@kernel.org \
--cc=shli@kernel.org \
--cc=zi.yan@cs.rutgers.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox