Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964814AbbESNzU (ORCPT ); Tue, 19 May 2015 09:55:20 -0400 Received: from cantor2.suse.de ([195.135.220.15]:52440 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964790AbbESNzO (ORCPT ); Tue, 19 May 2015 09:55:14 -0400 Message-ID: <555B40C0.3050703@suse.cz> Date: Tue, 19 May 2015 15:55:12 +0200 From: Vlastimil Babka User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: "Kirill A. Shutemov" , Andrew Morton , Andrea Arcangeli , Hugh Dickins CC: Dave Hansen , Mel Gorman , Rik van Riel , Christoph Lameter , Naoya Horiguchi , Steve Capper , "Aneesh Kumar K.V" , Johannes Weiner , Michal Hocko , Jerome Marchand , Sasha Levin , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCHv5 23/28] thp: add option to setup migration entiries during PMD split References: <1429823043-157133-1-git-send-email-kirill.shutemov@linux.intel.com> <1429823043-157133-24-git-send-email-kirill.shutemov@linux.intel.com> In-Reply-To: <1429823043-157133-24-git-send-email-kirill.shutemov@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2825 Lines: 77 On 04/23/2015 11:03 PM, Kirill A. Shutemov wrote: > We are going to use migration PTE entires to stabilize page counts. > If the page is mapped with PMDs we need to split the PMD and setup > migration enties. It's reasonable to combine these operations to avoid > double-scanning over the page table. > > Signed-off-by: Kirill A. Shutemov > Tested-by: Sasha Levin Acked-by: Vlastimil Babka > --- > mm/huge_memory.c | 23 +++++++++++++++-------- > 1 file changed, 15 insertions(+), 8 deletions(-) > > diff --git a/mm/huge_memory.c b/mm/huge_memory.c > index 5885ef8f0fad..2f9e2e882bab 100644 > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -23,6 +23,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -2551,7 +2552,7 @@ static void __split_huge_zero_page_pmd(struct vm_area_struct *vma, > } > > static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, > - unsigned long haddr) > + unsigned long haddr, bool freeze) > { > struct mm_struct *mm = vma->vm_mm; > struct page *page; > @@ -2593,12 +2594,18 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, > * transferred to avoid any possibility of altering > * permissions across VMAs. > */ > - entry = mk_pte(page + i, vma->vm_page_prot); > - entry = maybe_mkwrite(pte_mkdirty(entry), vma); > - if (!write) > - entry = pte_wrprotect(entry); > - if (!young) > - entry = pte_mkold(entry); > + if (freeze) { > + swp_entry_t swp_entry; > + swp_entry = make_migration_entry(page + i, write); > + entry = swp_entry_to_pte(swp_entry); > + } else { > + entry = mk_pte(page + i, vma->vm_page_prot); > + entry = maybe_mkwrite(pte_mkdirty(entry), vma); > + if (!write) > + entry = pte_wrprotect(entry); > + if (!young) > + entry = pte_mkold(entry); > + } > pte = pte_offset_map(&_pmd, haddr); > BUG_ON(!pte_none(*pte)); > set_pte_at(mm, haddr, pte, entry); > @@ -2625,7 +2632,7 @@ void __split_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd, > mmu_notifier_invalidate_range_start(mm, haddr, haddr + HPAGE_PMD_SIZE); > ptl = pmd_lock(mm, pmd); > if (likely(pmd_trans_huge(*pmd))) > - __split_huge_pmd_locked(vma, pmd, haddr); > + __split_huge_pmd_locked(vma, pmd, haddr, false); > spin_unlock(ptl); > mmu_notifier_invalidate_range_end(mm, haddr, haddr + HPAGE_PMD_SIZE); > } > -- 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/