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.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, 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 68E54C2D0C8 for ; Thu, 12 Dec 2019 11:33:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 143A221556 for ; Thu, 12 Dec 2019 11:33:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=shipmail.org header.i=@shipmail.org header.b="KNdoCX78" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 143A221556 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shipmail.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AD1FF8E0006; Thu, 12 Dec 2019 06:33:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A81A68E0001; Thu, 12 Dec 2019 06:33:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 971858E0006; Thu, 12 Dec 2019 06:33:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0082.hostedemail.com [216.40.44.82]) by kanga.kvack.org (Postfix) with ESMTP id 7DBF58E0001 for ; Thu, 12 Dec 2019 06:33:51 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 2C0DF180AD822 for ; Thu, 12 Dec 2019 11:33:51 +0000 (UTC) X-FDA: 76256279862.13.pump05_3e7451b324440 X-HE-Tag: pump05_3e7451b324440 X-Filterd-Recvd-Size: 9300 Received: from pio-pvt-msa2.bahnhof.se (pio-pvt-msa2.bahnhof.se [79.136.2.41]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Thu, 12 Dec 2019 11:33:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTP id 1F5F43F26D; Thu, 12 Dec 2019 12:33:47 +0100 (CET) Authentication-Results: pio-pvt-msa2.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=KNdoCX78; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at bahnhof.se Received: from pio-pvt-msa2.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa2.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lVmIvZW3qp8P; Thu, 12 Dec 2019 12:33:46 +0100 (CET) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by pio-pvt-msa2.bahnhof.se (Postfix) with ESMTPA id BBCC13F260; Thu, 12 Dec 2019 12:33:42 +0100 (CET) Received: from localhost.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id E08613621B7; Thu, 12 Dec 2019 12:33:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1576150422; bh=j+eZpqHQB3Fw6vN5gPAYjZGzDln9/TW6yi+1c53Ud3s=; h=Subject:From:To:Cc:References:Date:In-Reply-To:From; b=KNdoCX78D1HbeR+xToPzg2mJbPz6wjJPjDEQEQ52UZaJwdyDy3+Z0KvmHWDn3zLgX wQL2+nf0yms8GAk3wQ9STIOAjhr2665XcT+S6WoGFE+vpqB/qUYM4zJtemeV6M9mG1 UoMNK4wLqkbbpG8BBjfClh+E+jwqtrhyQt3/BKrM= Subject: Re: [PATCH v16 11/25] mm: pagewalk: Add p4d_entry() and pgd_entry() From: =?UTF-8?Q?Thomas_Hellstr=c3=b6m_=28VMware=29?= To: Steven Price Cc: Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Dave Hansen , Ingo Molnar , James Morse , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Peter Zijlstra , Thomas Gleixner , Will Deacon , x86@kernel.org, "H. Peter Anvin" , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Rutland , "Liang, Kan" , Zong Li , Andrew Morton , "linux-mm@kvack.org" References: <20191206135316.47703-1-steven.price@arm.com> <20191206135316.47703-12-steven.price@arm.com> <13280f9e-6f03-e1fd-659a-31462ba185b0@shipmail.org> Organization: VMware Inc. Message-ID: <7fd20e9f-822a-897d-218e-bddf135fd33d@shipmail.org> Date: Thu, 12 Dec 2019 12:33:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <13280f9e-6f03-e1fd-659a-31462ba185b0@shipmail.org> Content-Type: text/plain; charset=utf-8; format=flowed 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 12/12/19 12:23 PM, Thomas Hellstr=C3=B6m (VMware) wrote: > On 12/6/19 2:53 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. Since there have never >> been upstream users of this, revert the semantics back to match the >> other callbacks. This means pud_entry() is called for all entries, not >> just transparent huge pages. > > Actually, there are two users of pud_entry(), in hmm.c and since=20 > 5.5rc1 also mapping_dirty_helpers.c. The latter one is unproblematic=20 > and requires no attention but the one in hmm.c is probably largely=20 > untested, and seems to assume it was called outside of the spinlock. > > The problem with the current patch is that the hmm pud_entry will=20 > traverse also pmds, so that will be done twice now. > > In another thread we were discussing a means of rerunning the level=20 > (in case of a race), or continuing after a level, based on the return=20 > value after the callback. The change was fairly invasive, > Hmm. Forgot to remove the above text that appears twice. :(. The correct=20 one is inline below. > >> Tested-by: Zong Li >> Signed-off-by: Steven Price >> --- >> =C2=A0 include/linux/pagewalk.h | 19 +++++++++++++------ >> =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 | 27 ++++++++++++++++----------- >> =C2=A0 2 files changed, 29 insertions(+), 17 deletions(-) >> >> diff --git a/include/linux/pagewalk.h b/include/linux/pagewalk.h >> index 6ec82e92c87f..06790f23957f 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=20 >> (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=20 >> (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=20 >> (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=20 >> (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=20 >> (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=20 >> 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=20 >> 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=20 >> 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, >> diff --git a/mm/pagewalk.c b/mm/pagewalk.c >> index ea0b9e606ad1..c089786e7a7f 100644 >> --- a/mm/pagewalk.c >> +++ b/mm/pagewalk.c >> @@ -94,15 +94,9 @@ static int walk_pud_range(p4d_t *p4d, unsigned=20 >> 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=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=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 er= r =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 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 break; > > Actually, there are two current users of pud_entry(), in hmm.c and=20 > since 5.5rc1 also mapping_dirty_helpers.c. The latter one is=20 > unproblematic and requires no attention but the one in hmm.c is=20 > probably largely untested, and seems to assume it was called outside=20 > of the spinlock. > > The problem with the current patch is that the hmm pud_entry will=20 > traverse also pmds, so that will now be done twice. > > /Thomas >