From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yu Zhao Subject: Re: [PATCH v2 1/3] arm64: mm: use appropriate ctors for page tables Date: Fri, 8 Mar 2019 21:01:53 -0700 Message-ID: <20190309040153.GB214016@google.com> References: <20190214211642.2200-1-yuzhao@google.com> <20190218231319.178224-1-yuzhao@google.com> <20190226151230.GA20230@lakrids.cambridge.arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <20190226151230.GA20230@lakrids.cambridge.arm.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: Mark Rutland Cc: linux-arch@vger.kernel.org, Ard Biesheuvel , Peter Zijlstra , Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, Nick Piggin , Jun Yao , linux-mm@kvack.org, "Aneesh Kumar K . V" , Chintan Pandya , Joel Fernandes , "Kirill A . Shutemov" , Andrew Morton , Laura Abbott , linux-arm-kernel@lists.infradead.org List-Id: linux-arch.vger.kernel.org On Tue, Feb 26, 2019 at 03:12:31PM +0000, Mark Rutland wrote: > Hi, > > On Mon, Feb 18, 2019 at 04:13:17PM -0700, Yu Zhao wrote: > > For pte page, use pgtable_page_ctor(); for pmd page, use > > pgtable_pmd_page_ctor() if not folded; and for the rest (pud, > > p4d and pgd), don't use any. > > > > Signed-off-by: Yu Zhao > > --- > > arch/arm64/mm/mmu.c | 33 +++++++++++++++++++++------------ > > 1 file changed, 21 insertions(+), 12 deletions(-) > > [...] > > > -static phys_addr_t pgd_pgtable_alloc(void) > > +static phys_addr_t pgd_pgtable_alloc(int shift) > > { > > void *ptr = (void *)__get_free_page(PGALLOC_GFP); > > - if (!ptr || !pgtable_page_ctor(virt_to_page(ptr))) > > - BUG(); > > + BUG_ON(!ptr); > > + > > + /* > > + * Initialize page table locks in case later we need to > > + * call core mm functions like apply_to_page_range() on > > + * this pre-allocated page table. > > + */ > > + if (shift == PAGE_SHIFT) > > + BUG_ON(!pgtable_page_ctor(virt_to_page(ptr))); > > + else if (shift == PMD_SHIFT && PMD_SHIFT != PUD_SHIFT) > > + BUG_ON(!pgtable_pmd_page_ctor(virt_to_page(ptr))); > > IIUC, this is for nopmd kernels, where we only have real PGD and PTE > levels of table. From my PoV, that would be clearer if we did: > > else if (shift == PMD_SHIFT && !is_defined(__PAGETABLE_PMD_FOLDED)) > > ... though IMO it would be a bit nicer if the generic > pgtable_pmd_page_ctor() were nop'd out for __PAGETABLE_PMD_FOLDED > builds, so that callers don't have to be aware of folding. Agreed. Will make pgtable_pmd_page_ctor() nop when pmd is folded. > I couldn't think of a nicer way of distinguishing levels of table, and > having separate function pointers for each level seems over-the-top, so > otehr than that this looks good to me. > > Assuming you're happy with the above change: > > Acked-by: Mark Rutland > > Thanks, > Mark. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-it1-f195.google.com ([209.85.166.195]:34087 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbfCIEB6 (ORCPT ); Fri, 8 Mar 2019 23:01:58 -0500 Received: by mail-it1-f195.google.com with SMTP id d125so12034270ith.1 for ; Fri, 08 Mar 2019 20:01:58 -0800 (PST) Date: Fri, 8 Mar 2019 21:01:53 -0700 From: Yu Zhao Subject: Re: [PATCH v2 1/3] arm64: mm: use appropriate ctors for page tables Message-ID: <20190309040153.GB214016@google.com> References: <20190214211642.2200-1-yuzhao@google.com> <20190218231319.178224-1-yuzhao@google.com> <20190226151230.GA20230@lakrids.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190226151230.GA20230@lakrids.cambridge.arm.com> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Mark Rutland Cc: Catalin Marinas , Will Deacon , "Aneesh Kumar K . V" , Andrew Morton , Nick Piggin , Peter Zijlstra , Joel Fernandes , "Kirill A . Shutemov" , Ard Biesheuvel , Chintan Pandya , Jun Yao , Laura Abbott , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org Message-ID: <20190309040153.oHp2ui-uEsOcJcLk6eUJJfsDRYCj_xUqmLhcEkUnL-k@z> On Tue, Feb 26, 2019 at 03:12:31PM +0000, Mark Rutland wrote: > Hi, > > On Mon, Feb 18, 2019 at 04:13:17PM -0700, Yu Zhao wrote: > > For pte page, use pgtable_page_ctor(); for pmd page, use > > pgtable_pmd_page_ctor() if not folded; and for the rest (pud, > > p4d and pgd), don't use any. > > > > Signed-off-by: Yu Zhao > > --- > > arch/arm64/mm/mmu.c | 33 +++++++++++++++++++++------------ > > 1 file changed, 21 insertions(+), 12 deletions(-) > > [...] > > > -static phys_addr_t pgd_pgtable_alloc(void) > > +static phys_addr_t pgd_pgtable_alloc(int shift) > > { > > void *ptr = (void *)__get_free_page(PGALLOC_GFP); > > - if (!ptr || !pgtable_page_ctor(virt_to_page(ptr))) > > - BUG(); > > + BUG_ON(!ptr); > > + > > + /* > > + * Initialize page table locks in case later we need to > > + * call core mm functions like apply_to_page_range() on > > + * this pre-allocated page table. > > + */ > > + if (shift == PAGE_SHIFT) > > + BUG_ON(!pgtable_page_ctor(virt_to_page(ptr))); > > + else if (shift == PMD_SHIFT && PMD_SHIFT != PUD_SHIFT) > > + BUG_ON(!pgtable_pmd_page_ctor(virt_to_page(ptr))); > > IIUC, this is for nopmd kernels, where we only have real PGD and PTE > levels of table. From my PoV, that would be clearer if we did: > > else if (shift == PMD_SHIFT && !is_defined(__PAGETABLE_PMD_FOLDED)) > > ... though IMO it would be a bit nicer if the generic > pgtable_pmd_page_ctor() were nop'd out for __PAGETABLE_PMD_FOLDED > builds, so that callers don't have to be aware of folding. Agreed. Will make pgtable_pmd_page_ctor() nop when pmd is folded. > I couldn't think of a nicer way of distinguishing levels of table, and > having separate function pointers for each level seems over-the-top, so > otehr than that this looks good to me. > > Assuming you're happy with the above change: > > Acked-by: Mark Rutland > > Thanks, > Mark. 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=-1.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS, URIBL_BLOCKED,USER_AGENT_MUTT 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 58457C43381 for ; Sat, 9 Mar 2019 04:02:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 27EB720866 for ; Sat, 9 Mar 2019 04:02:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KeP4jiQh"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="enB8NIwm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 27EB720866 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WKcsspTVUWfTN7NztipVINGEuzJV+H8WIT6WNG9d4oo=; b=KeP4jiQhO77D00 0VLXqIV9piWxGIVxG1aoMVRYh8qO02utg8N/XhmYJgx5gGXTt9RIqXV+s92XkGMXhBN2BK9CIyXAC 0KCM/bm95NuaFmnB0ko4jpsNegLTU2YrNNeNOL6I5ff5SFHp4RWSWRnVjUGwZcHNP2wBM3wHnrL/5 KLvd5KH2pJkV6wx6wxPV8iKtIhmHbgl3kbT0PDekfVYQPJeN+iI5V/I2AnQ7IiTgIYuHMGhzP86E7 ppoumd7iev+xpdewe/qABeBGcammQOfEOj/CcOJ6Do8l3bUy95/TmFTtDhoyr1ahEIgJOsQsyBIMg DL1+igi5g5fjjlKsZcvQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h2TBS-0006BW-Nr; Sat, 09 Mar 2019 04:02:02 +0000 Received: from mail-it1-x144.google.com ([2607:f8b0:4864:20::144]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h2TBP-0006Aj-1p for linux-arm-kernel@lists.infradead.org; Sat, 09 Mar 2019 04:02:00 +0000 Received: by mail-it1-x144.google.com with SMTP id f186so7947780ita.0 for ; Fri, 08 Mar 2019 20:01:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=pH8sAGGnXCkPUbMJRChks7/3dKNz3dpZwqyj91moOWQ=; b=enB8NIwmaJi4OQIxi6Q/xvZ0q+BraSiTqy2d+wEIOPrVqPSROmqMNQgomRAX4Fy7FD aU78a/tdjiDj1/km2nvCbgYpYF9620eRVkuVKCsDdfCUQUAsyg8tR2d/2/z+p9F8ciy0 jp8jVPyYgGRg0vxFP2Z+iW/sp6FGoTiBKNf3gWO8vlKBn/8fLJo4Sp37mSN0IIgTQajl PtSqL/rRPvsI6d3mF0YCccXv69WCZWvqLWFV2M3Wz4F+VaUtRs2GXmeDFv9jOuWXSSb1 cRPA6JKp79uuMAhwfOnwo60sTRoe1HWGlcGwVh4jlOA2wSZsKXqv3SbwFfbJrR5OvO7i 6Jgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=pH8sAGGnXCkPUbMJRChks7/3dKNz3dpZwqyj91moOWQ=; b=W3OwEV4jCzXlsqZaGLzhs3L31QI8s0pxX42IJaiWOHgp5IZwCFXrt2A8VIKhZM8b8g uLG3PEfDKcDtV6BoHSI9avF/w6LIbL5K6027kBNC7Jf2jjpTnSBuiDNg9eMeNxV52grh o5aP6GExEff6lc6TrAd0rpa6VfpDRIf+M/sm6EbvUJs+wAMNo/hLgrjPXhEBUI7i1S3h nUUXBiKHFJIDd1Puj2YK2/IzDdiFRiNy01+OCKtkUonSPIZmJYr7zqab+cMO1fNsTRkg UnLL+zYvuX3xuKfUaZYu0XturOCW7ljAAQij45VoMvfs95ZW+uv912dWVSk4ozSPxNOn IN6A== X-Gm-Message-State: APjAAAWMXDnP0iVsWY7b6U79HT8fcDCxOLpkQjxpYM96C1Jb17TXXRPa hFq5MiS2KKu/Lqo0LPYdolPfmQ== X-Google-Smtp-Source: APXvYqxw7MTdz7bi6mEtWop3jiCjYq5/KwPLeoWLGPADNTbYqSyrAqSKBzbVkN9Z2kxcgJUuJ4Uj3g== X-Received: by 2002:a24:7690:: with SMTP id z138mr10329033itb.119.1552104117606; Fri, 08 Mar 2019 20:01:57 -0800 (PST) Received: from google.com ([2620:15c:183:0:a0c3:519e:9276:fc96]) by smtp.gmail.com with ESMTPSA id u82sm4882605itb.18.2019.03.08.20.01.56 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 08 Mar 2019 20:01:57 -0800 (PST) Date: Fri, 8 Mar 2019 21:01:53 -0700 From: Yu Zhao To: Mark Rutland Subject: Re: [PATCH v2 1/3] arm64: mm: use appropriate ctors for page tables Message-ID: <20190309040153.GB214016@google.com> References: <20190214211642.2200-1-yuzhao@google.com> <20190218231319.178224-1-yuzhao@google.com> <20190226151230.GA20230@lakrids.cambridge.arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190226151230.GA20230@lakrids.cambridge.arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190308_200159_119761_6B196C9C X-CRM114-Status: GOOD ( 20.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Ard Biesheuvel , Peter Zijlstra , Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, Nick Piggin , Jun Yao , linux-mm@kvack.org, "Aneesh Kumar K . V" , Chintan Pandya , Joel Fernandes , "Kirill A . Shutemov" , Andrew Morton , Laura Abbott , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Feb 26, 2019 at 03:12:31PM +0000, Mark Rutland wrote: > Hi, > > On Mon, Feb 18, 2019 at 04:13:17PM -0700, Yu Zhao wrote: > > For pte page, use pgtable_page_ctor(); for pmd page, use > > pgtable_pmd_page_ctor() if not folded; and for the rest (pud, > > p4d and pgd), don't use any. > > > > Signed-off-by: Yu Zhao > > --- > > arch/arm64/mm/mmu.c | 33 +++++++++++++++++++++------------ > > 1 file changed, 21 insertions(+), 12 deletions(-) > > [...] > > > -static phys_addr_t pgd_pgtable_alloc(void) > > +static phys_addr_t pgd_pgtable_alloc(int shift) > > { > > void *ptr = (void *)__get_free_page(PGALLOC_GFP); > > - if (!ptr || !pgtable_page_ctor(virt_to_page(ptr))) > > - BUG(); > > + BUG_ON(!ptr); > > + > > + /* > > + * Initialize page table locks in case later we need to > > + * call core mm functions like apply_to_page_range() on > > + * this pre-allocated page table. > > + */ > > + if (shift == PAGE_SHIFT) > > + BUG_ON(!pgtable_page_ctor(virt_to_page(ptr))); > > + else if (shift == PMD_SHIFT && PMD_SHIFT != PUD_SHIFT) > > + BUG_ON(!pgtable_pmd_page_ctor(virt_to_page(ptr))); > > IIUC, this is for nopmd kernels, where we only have real PGD and PTE > levels of table. From my PoV, that would be clearer if we did: > > else if (shift == PMD_SHIFT && !is_defined(__PAGETABLE_PMD_FOLDED)) > > ... though IMO it would be a bit nicer if the generic > pgtable_pmd_page_ctor() were nop'd out for __PAGETABLE_PMD_FOLDED > builds, so that callers don't have to be aware of folding. Agreed. Will make pgtable_pmd_page_ctor() nop when pmd is folded. > I couldn't think of a nicer way of distinguishing levels of table, and > having separate function pointers for each level seems over-the-top, so > otehr than that this looks good to me. > > Assuming you're happy with the above change: > > Acked-by: Mark Rutland > > Thanks, > Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel