Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp396416pxb; Wed, 24 Feb 2021 05:18:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwVivbGvEanX4SK9qEVTBztL0vgbikR70AZT05Rlh5cX7XPRwPFOENBlvLqmPphnDr3xdXC X-Received: by 2002:a17:906:7fc4:: with SMTP id r4mr30466112ejs.81.1614172715152; Wed, 24 Feb 2021 05:18:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614172715; cv=none; d=google.com; s=arc-20160816; b=mq5W4xgF7y+cLpfk+nhXBnUGUDzxkBnUlpJUOAK2xNNCUk9vTPeQAXmdiEtYZInABm FlUly6YIMUUX5un3rQlC/ytwXgkVkl5FSc3oifGnmJtJiKJraXi2iYQ2W/fzKBtzcZ9i 0eLNxLeFliXB/mbvnrWrEI8xL86i73LznWIUdFfJh7SymZnXI9hW5+++zY25kmv9v1Gh L1/IHxnUv4b0D56gOmTv4tSujPdVclXhHbVcju8BTPgNNzpfLrCjFRvLSPA4bSqzw7CQ m6qdq1Inz+Zq6nPRSQRw3cYiigvUd3miKf4YPL4qrn/G+7AWlYpMJ0QK5jXQCFvWJsas xMsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=9f8ZRgLxfCHzhWNbx6a3owR9mKe4+uMt6tzmND++sTg=; b=X23MCbVIwWB8RURBJyfZczXjl8wy3NZKOJ5YO7Yvg6VO5JX5fC5rdI8cr43YeWjql9 AXn9yeEdwAt3wiF2oxeJJgWpoFzBZjTmNeCLhsAE56942v40hnVAJaOjsXTChmYdEeSO NA/ZhSaavEUtfhYe1daCCl/KXm6JLr0F0pajtweLmPvlGOR2gBVOYAVqPtMTELSLN4yL KJi/l/o1V9z1BmgO7zX0o7/yFWW0z7WccH3YpkjQ0OGw9h2oTNK0imU4KA1f339KlQgL JSzPTvIoanYPCcp57PHLNpeNnLN6faV9qTWTfMRr3YzHDdN9nvCx8YAnyAlpOgSdGS0P rQxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r18si1229075edo.400.2021.02.24.05.17.23; Wed, 24 Feb 2021 05:18:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233360AbhBXMft (ORCPT + 99 others); Wed, 24 Feb 2021 07:35:49 -0500 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:51981 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232326AbhBXMfr (ORCPT ); Wed, 24 Feb 2021 07:35:47 -0500 X-Originating-IP: 81.185.165.217 Received: from [192.168.43.237] (217.165.185.81.rev.sfr.net [81.185.165.217]) (Authenticated sender: alex@ghiti.fr) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id DFE59240005; Wed, 24 Feb 2021 12:34:56 +0000 (UTC) Subject: Re: [PATCH] riscv: mm: Remove the copy operation of pmd To: Chuanhua Han , paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu Cc: sfr@canb.auug.org.au, schwab@suse.de, Anup.Patel@wdc.com, linux-kernel@vger.kernel.org, peterx@redhat.com, linux-riscv@lists.infradead.org, ebiederm@xmission.com, akpm@linux-foundation.org, shihpo.hung@sifive.com, tglx@linutronix.de References: <20200330115319.1507-1-hanchuanhua@fishsemi.com> From: Alex Ghiti Message-ID: Date: Wed, 24 Feb 2021 07:34:55 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20200330115319.1507-1-hanchuanhua@fishsemi.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 3/30/20 ? 7:53 AM, Chuanhua Han a ?crit?: > Since all processes share the kernel address space, > we only need to copy pgd in case of a vmalloc page > fault exception, the other levels of page tables are > shared, so the operation of copying pmd is unnecessary. > > Signed-off-by: Chuanhua Han > --- > arch/riscv/mm/fault.c | 10 +++------- > 1 file changed, 3 insertions(+), 7 deletions(-) > > diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c > index be84e32adc4c..24f4ebfd2df8 100644 > --- a/arch/riscv/mm/fault.c > +++ b/arch/riscv/mm/fault.c > @@ -208,9 +208,9 @@ asmlinkage void do_page_fault(struct pt_regs *regs) > vmalloc_fault: > { > pgd_t *pgd, *pgd_k; > - pud_t *pud, *pud_k; > - p4d_t *p4d, *p4d_k; > - pmd_t *pmd, *pmd_k; > + pud_t *pud_k; > + p4d_t *p4d_k; > + pmd_t *pmd_k; > pte_t *pte_k; > int index; > > @@ -234,12 +234,10 @@ asmlinkage void do_page_fault(struct pt_regs *regs) > goto no_context; > set_pgd(pgd, *pgd_k); > > - p4d = p4d_offset(pgd, addr); > p4d_k = p4d_offset(pgd_k, addr); > if (!p4d_present(*p4d_k)) > goto no_context; > > - pud = pud_offset(p4d, addr); > pud_k = pud_offset(p4d_k, addr); > if (!pud_present(*pud_k)) > goto no_context; > @@ -248,11 +246,9 @@ asmlinkage void do_page_fault(struct pt_regs *regs) > * Since the vmalloc area is global, it is unnecessary > * to copy individual PTEs > */ > - pmd = pmd_offset(pud, addr); > pmd_k = pmd_offset(pud_k, addr); > if (!pmd_present(*pmd_k)) > goto no_context; > - set_pmd(pmd, *pmd_k); > > /* > * Make sure the actual PTE exists as well to > Better late than never: I do agree with this patch, once the PGD is copied into the user page table, it "comes with all its mappings" so there is no need to copy PMD, the only thing left to do is to make sure the mapping does exists in the kernel page table. So feel free to add: Reviewed-by: Alexandre Ghiti Tested-by: Alexandre Ghiti Thanks, Alex