From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0629C2D0D2 for ; Fri, 20 Dec 2019 15:35:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2991B222C2 for ; Fri, 20 Dec 2019 15:35:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2991B222C2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 88B1C8E019E; Fri, 20 Dec 2019 10:35:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 83C758E019D; Fri, 20 Dec 2019 10:35:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 72B538E019E; Fri, 20 Dec 2019 10:35:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 567638E019D for ; Fri, 20 Dec 2019 10:35:50 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id E59424DD4 for ; Fri, 20 Dec 2019 15:35:49 +0000 (UTC) X-FDA: 76285920018.23.mom07_15ae075eeb445 X-HE-Tag: mom07_15ae075eeb445 X-Filterd-Recvd-Size: 15780 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Fri, 20 Dec 2019 15:35:48 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DD9CA30E; Fri, 20 Dec 2019 07:35:47 -0800 (PST) Received: from [10.1.194.52] (e112269-lin.cambridge.arm.com [10.1.194.52]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5A7EB3F6CF; Fri, 20 Dec 2019 07:35:45 -0800 (PST) Subject: Re: [PATCH v17 11/23] mm: pagewalk: Add p4d_entry() and pgd_entry() To: =?UTF-8?Q?Thomas_Hellstr=c3=b6m_=28VMware=29?= , Andrew Morton , linux-mm@kvack.org Cc: Mark Rutland , x86@kernel.org, Arnd Bergmann , Ard Biesheuvel , Peter Zijlstra , Catalin Marinas , Dave Hansen , linux-kernel@vger.kernel.org, =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Ingo Molnar , Borislav Petkov , Andy Lutomirski , "H. Peter Anvin" , James Morse , Thomas Gleixner , Will Deacon , linux-arm-kernel@lists.infradead.org, "Liang, Kan" References: <20191218162402.45610-1-steven.price@arm.com> <20191218162402.45610-12-steven.price@arm.com> <9ea2f1a2-5ec0-c21c-e725-334b6bf2886d@shipmail.org> From: Steven Price Message-ID: Date: Fri, 20 Dec 2019 15:35:44 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: <9ea2f1a2-5ec0-c21c-e725-334b6bf2886d@shipmail.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 19/12/2019 14:25, Thomas Hellstr=C3=B6m (VMware) wrote: > Hi, Steven, >=20 >=20 > On 12/18/19 5:23 PM, Steven Price wrote: >> pgd_entry() and pud_entry() were removed by commit 0b1fbfe50006c410 >> ("mm/pagewalk: remove pgd_entry() and pud_entry()") because there were >> no users. We're about to add users so reintroduce them, along with >> p4d_entry() as we now have 5 levels of tables. >> >> Note that commit a00cc7d9dd93d66a ("mm, x86: add support for >> PUD-sized transparent hugepages") already re-added pud_entry() but wit= h >> different semantics to the other callbacks. This commit reverts the >> semantics back to match the other callbacks. >> >> To support hmm.c which now uses the new semantics of pud_entry() a new >> member ('action') of struct mm_walk is added which allows the callback= s >> to either descend (ACTION_SUBTREE, the default), skip (ACTION_CONTINUE= ) >> or repeat the callback (ACTION_AGAIN). hmm.c is then updated to call >> pud_trans_huge_lock() itself and make use of the splitting/retry logic >> of the core code. >> >> After this change pud_entry() is called for all entries, not just >> transparent huge pages. >> >> Signed-off-by: Steven Price >=20 > I have a couple of comments that are actually mostly related to > pre-existing bugs, but that affect code that are touched by this patch. >=20 > Perhaps this is most cleanly addressed by a follow-up patch. Up to you > to decide. >=20 > Since these problems are pre-existing, >=20 > Reviewed-by: Thomas Hellstrom Thanks, I'll send out an extra patch with these changes. Steve > Thanks, >=20 > Thomas >=20 >=20 >> --- >> =C2=A0 include/linux/pagewalk.h | 34 ++++++++++++++++++++----- >> =C2=A0 mm/hmm.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | 55 ++++++++++++++++++++++------= ------------ >> =C2=A0 mm/pagewalk.c=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 | 50 +++++++++++++++++++++++++----------- >> =C2=A0 3 files changed, 94 insertions(+), 45 deletions(-) >> >> diff --git a/include/linux/pagewalk.h b/include/linux/pagewalk.h >> index 6ec82e92c87f..aa6a0b63964e 100644 >> --- a/include/linux/pagewalk.h >> +++ b/include/linux/pagewalk.h >> @@ -8,15 +8,15 @@ struct mm_walk; >> =C2=A0 =C2=A0 /** >> =C2=A0=C2=A0 * mm_walk_ops - callbacks for walk_page_range >> - * @pud_entry:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if set, call= ed for each non-empty PUD >> (2nd-level) entry >> - *=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = this handler should only handle pud_trans_huge() puds. >> - *=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = the pmd_entry or pte_entry callbacks will be used for >> - *=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = regular PUDs. >> - * @pmd_entry:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if set, call= ed for each non-empty PMD >> (3rd-level) entry >> + * @pgd_entry:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if set, call= ed for each non-empty PGD >> (top-level) entry >> + * @p4d_entry:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if set, call= ed for each non-empty P4D entry >> + * @pud_entry:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if set, call= ed for each non-empty PUD entry >> + * @pmd_entry:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if set, call= ed for each non-empty PMD entry >> =C2=A0=C2=A0 *=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 this handler is required to be able to handle >> =C2=A0=C2=A0 *=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 pmd_trans_huge() pmds.=C2=A0 They may simply choose to >> =C2=A0=C2=A0 *=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 split_huge_page() instead of handling it explicitly. >> - * @pte_entry:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if set, call= ed for each non-empty PTE >> (4th-level) entry >> + * @pte_entry:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if set, call= ed for each non-empty PTE >> (lowest-level) >> + *=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = entry >> =C2=A0=C2=A0 * @pte_hole:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if= set, called for each hole at all levels >> =C2=A0=C2=A0 * @hugetlb_entry:=C2=A0=C2=A0=C2=A0 if set, called for ea= ch hugetlb entry >> =C2=A0=C2=A0 * @test_walk:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 c= aller specific callback function to determine >> whether >> @@ -27,8 +27,15 @@ struct mm_walk; >> =C2=A0=C2=A0 * @pre_vma:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 if set, called before starting walk on a >> non-null vma. >> =C2=A0=C2=A0 * @post_vma:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 if set, called after a walk on a non-null >> vma, provided >> =C2=A0=C2=A0 *=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 tha= t @pre_vma and the vma walk succeeded. >> + * >> + * p?d_entry callbacks are called even if those levels are folded on = a >> + * particular architecture/configuration. >> =C2=A0=C2=A0 */ >> =C2=A0 struct mm_walk_ops { >> +=C2=A0=C2=A0=C2=A0 int (*pgd_entry)(pgd_t *pgd, unsigned long addr, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 unsigned long next, struct mm_walk *walk); >> +=C2=A0=C2=A0=C2=A0 int (*p4d_entry)(p4d_t *p4d, unsigned long addr, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 unsigned long next, struct mm_walk *walk); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int (*pud_entry)(pud_t *pud, unsigned l= ong addr, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 unsigned long next, struct mm_walk *walk); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int (*pmd_entry)(pmd_t *pmd, unsigned l= ong addr, >> @@ -47,11 +54,25 @@ struct mm_walk_ops { >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 void (*post_vma)(struct mm_walk *walk); >> =C2=A0 }; >> =C2=A0 +/* >> + * Action for pud_entry / pmd_entry callbacks. >> + * ACTION_SUBTREE is the default >> + */ >> +enum page_walk_action { >> +=C2=A0=C2=A0=C2=A0 /* Descend to next level, splitting huge pages if = needed and >> possible */ >> +=C2=A0=C2=A0=C2=A0 ACTION_SUBTREE =3D 0, >> +=C2=A0=C2=A0=C2=A0 /* Continue to next entry at this level (ignoring = any subtree) */ >> +=C2=A0=C2=A0=C2=A0 ACTION_CONTINUE =3D 1, >> +=C2=A0=C2=A0=C2=A0 /* Call again for this entry */ >> +=C2=A0=C2=A0=C2=A0 ACTION_AGAIN =3D 2 >> +}; >> + >> =C2=A0 /** >> =C2=A0=C2=A0 * mm_walk - walk_page_range data >> =C2=A0=C2=A0 * @ops:=C2=A0=C2=A0=C2=A0 operation to call during the wa= lk >> =C2=A0=C2=A0 * @mm:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 mm_struc= t representing the target process of page >> table walk >> =C2=A0=C2=A0 * @vma:=C2=A0=C2=A0=C2=A0 vma currently walked (NULL if w= alking outside vmas) >> + * @action:=C2=A0=C2=A0=C2=A0 next action to perform (see enum page_w= alk_action) >> =C2=A0=C2=A0 * @private:=C2=A0=C2=A0=C2=A0 private data for callbacks'= usage >> =C2=A0=C2=A0 * >> =C2=A0=C2=A0 * (see the comment on walk_page_range() for more details) >> @@ -60,6 +81,7 @@ struct mm_walk { >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 const struct mm_walk_ops *ops; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct mm_struct *mm; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct vm_area_struct *vma; >> +=C2=A0=C2=A0=C2=A0 enum page_walk_action action; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 void *private; >> =C2=A0 }; >> =C2=A0 diff --git a/mm/hmm.c b/mm/hmm.c >> index d379cb6496ae..05241c82e05c 100644 >> --- a/mm/hmm.c >> +++ b/mm/hmm.c >> @@ -477,20 +477,30 @@ static int hmm_vma_walk_pud(pud_t *pudp, >> unsigned long start, unsigned long end, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned long addr =3D start, next; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pmd_t *pmdp; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pud_t pud; >> -=C2=A0=C2=A0=C2=A0 int ret; >> +=C2=A0=C2=A0=C2=A0 int ret =3D 0; >> +=C2=A0=C2=A0=C2=A0 spinlock_t *ptl =3D pud_trans_huge_lock(pudp, walk= ->vma); >> + >> +=C2=A0=C2=A0=C2=A0 if (!ptl) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 0; >=20 > Since if we didn't get the PTL here, the pud might be unstable in which > case we want to retry: >=20 > if (!ptl) { > =C2=A0=C2=A0=C2=A0=C2=A0if (pud_trans_unstable(pudp)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 walk->action =3D ACTION_AGAI= N; > =C2=A0=C2=A0=C2=A0=C2=A0return 0; > } >=20 >=20 >> + >> +=C2=A0=C2=A0=C2=A0 /* Normally we don't want to split the huge page *= / >> +=C2=A0=C2=A0=C2=A0 walk->action =3D ACTION_CONTINUE; >> =C2=A0 -again: >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pud =3D READ_ONCE(*pudp); >=20 > We have the lock now, so READ_ONCE could probably be a simple dereferen= ce. >=20 >> -=C2=A0=C2=A0=C2=A0 if (pud_none(pud)) >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return hmm_vma_walk_hole(s= tart, end, walk); >> +=C2=A0=C2=A0=C2=A0 if (pud_none(pud)) { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ret =3D hmm_vma_walk_hole(= start, end, walk); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto out_unlock; >> +=C2=A0=C2=A0=C2=A0 } >=20 > pud_trans_huge_lock() successful return means pud_none() is always fals= e. >=20 >=20 >> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (pud_huge(pud) && pud_devmap(= pud)) { >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned long i= , npages, pfn; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 uint64_t *pfns,= cpu_flags; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 bool fault, wri= te_fault; >> =C2=A0 -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!pud_present(pu= d)) >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 re= turn hmm_vma_walk_hole(start, end, walk); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!pud_present(pud)) { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 re= t =3D hmm_vma_walk_hole(start, end, walk); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 go= to out_unlock; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >=20 > Can't see !pud_present happening either after a succesful > pud_trans_huge_lock(). >=20 >> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 i =3D (a= ddr - range->start) >> PAGE_SHIFT; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 npages =3D (end= - addr) >> PAGE_SHIFT; >> @@ -499,16 +509,20 @@ static int hmm_vma_walk_pud(pud_t *pudp, >> unsigned long start, unsigned long end, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 cpu_flags =3D p= ud_to_hmm_pfn_flags(range, pud); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 hmm_range_need_= fault(hmm_vma_walk, pfns, npages, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 cpu_flags, &= fault, &write_fault); >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (fault || write_fault) >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 re= turn hmm_vma_walk_hole_(addr, end, fault, >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 wri= te_fault, walk); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (fault || write_fault) = { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 re= t =3D hmm_vma_walk_hole_(addr, end, fault, >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= write_fault, walk); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 go= to out_unlock; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pfn =3D = pud_pfn(pud) + ((addr & ~PUD_MASK) >> PAGE_SHIFT); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 for (i =3D 0; i= < npages; ++i, ++pfn) { >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 hmm_vma_walk->pgmap =3D get_dev_pagemap(pfn, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 hmm_vma_walk->pgmap); >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if= (unlikely(!hmm_vma_walk->pgmap)) >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 return -EBUSY; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if= (unlikely(!hmm_vma_walk->pgmap)) { >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 ret =3D -EBUSY; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 goto out_unlock; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 pfns[i] =3D hmm_device_entry_from_pfn(range, pfn) | >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 cpu_flags; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> @@ -517,22 +531,15 @@ static int hmm_vma_walk_pud(pud_t *pudp, >> unsigned long start, unsigned long end, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 hmm_vma_walk->pgmap =3D NULL; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 hmm_vma_walk->l= ast =3D end; >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 0; >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto out_unlock; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> =C2=A0 -=C2=A0=C2=A0=C2=A0 split_huge_pud(walk->vma, pudp, addr); >> -=C2=A0=C2=A0=C2=A0 if (pud_none(*pudp)) >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto again; >> +=C2=A0=C2=A0=C2=A0 /* Ask for the PUD to be split */ >> +=C2=A0=C2=A0=C2=A0 walk->action =3D ACTION_SUBTREE; >> =C2=A0 -=C2=A0=C2=A0=C2=A0 pmdp =3D pmd_offset(pudp, addr); >> -=C2=A0=C2=A0=C2=A0 do { >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 next =3D pmd_addr_end(addr= , end); >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ret =3D hmm_vma_walk_pmd(p= mdp, addr, next, walk); >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (ret) >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 re= turn ret; >> -=C2=A0=C2=A0=C2=A0 } while (pmdp++, addr =3D next, addr !=3D end); >> - >> -=C2=A0=C2=A0=C2=A0 return 0; >> +out_unlock: >> +=C2=A0=C2=A0=C2=A0 spin_unlock(ptl); >> +=C2=A0=C2=A0=C2=A0 return ret; >> =C2=A0 } >> =C2=A0 #else >> =C2=A0 #define hmm_vma_walk_pud=C2=A0=C2=A0=C2=A0 NULL >> diff --git a/mm/pagewalk.c b/mm/pagewalk.c >> index ea0b9e606ad1..690af44609e2 100644 >> --- a/mm/pagewalk.c >> +++ b/mm/pagewalk.c >> @@ -46,6 +46,9 @@ static int walk_pmd_range(pud_t *pud, unsigned long >> addr, unsigned long end, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 continue; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> + >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 walk->action =3D ACTION_SU= BTREE; >> + >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * This im= plies that each ->pmd_entry() handler >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * needs t= o know about pmd_trans_huge() pmds >> @@ -55,16 +58,21 @@ static int walk_pmd_range(pud_t *pud, unsigned >> long addr, unsigned long end, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (err) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 break; >> =C2=A0 +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (walk->action =3D= =3D ACTION_AGAIN) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 go= to again; >> + >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * Check t= his here so we only break down trans_huge >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 * pages w= hen we _need_ to >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 */ >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!ops->pte_entry) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (walk->action =3D=3D AC= TION_CONTINUE || >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 !(= ops->pte_entry)) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 continue; >> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 split_hu= ge_pmd(walk->vma, pmd, addr); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (pmd_trans_u= nstable(pmd)) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 goto again; >> + >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 err =3D walk_pt= e_range(pmd, addr, next, walk); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (err) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 break; >> @@ -93,24 +101,25 @@ static int walk_pud_range(p4d_t *p4d, unsigned >> long addr, unsigned long end, >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0 continue; >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> =C2=A0 -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (ops->pud_entry)= { >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sp= inlock_t *ptl =3D pud_trans_huge_lock(pud, walk->vma); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 walk->action =3D ACTION_SU= BTREE; >> =C2=A0 -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 if (ptl) { >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 err =3D ops->pud_entry(pud, addr, next, walk); >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 spin_unlock(ptl); >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 if (err) >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 break; >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 continue; >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (ops->pud_entry) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 er= r =3D ops->pud_entry(pud, addr, next, walk); >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (err) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 br= eak; >> + >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (walk->action =3D=3D AC= TION_AGAIN) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 go= to again; >> + >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (walk->action =3D=3D AC= TION_CONTINUE || >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 !(= ops->pmd_entry || ops->pte_entry)) >> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 co= ntinue; >> =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 split_hu= ge_pud(walk->vma, pud, addr); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (pud_none(*p= ud)) >=20 > Here we should really have >=20 > if (pud_trans_unstable(pud)) >=20 > Thanks, >=20 > Thomas >=20 >=20 >=20 > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel