Message ID | 20230109062407.3235-3-jeeheng.sia@starfivetech.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2002762wrt; Sun, 8 Jan 2023 22:28:13 -0800 (PST) X-Google-Smtp-Source: AMrXdXt3AqfWj2aFXH9Mm+Rh4BJ+fZDSZHfMpnL8Ed3LkKVAnKILB6jsPWzglarykZYn/4sRg5Ub X-Received: by 2002:a17:906:30ca:b0:7c1:6091:e73 with SMTP id b10-20020a17090630ca00b007c160910e73mr55547015ejb.1.1673245692977; Sun, 08 Jan 2023 22:28:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673245692; cv=none; d=google.com; s=arc-20160816; b=P/P3o6J6NmkkV/oxoalAvkSOYH/lUUZormAu4lF65BP66viYs78tcvkVEJFrkRceGT vhEdQ7grMWUXZRb8dT7c5DCRdUjMpFON+ht01wJZGIdi/DIRhKYV8pO6eKK9qewBR7ih uStrkdiGPbP07Np/EL9F29LMjvzHTQyG7uusmnrR1os07ZaSxqyqG/CXN08/BoI9n1MO xr8T4TwbfFnmqSe0cBrYr01/APwAeocRh4gWXpA9BBLHAvgmI9h00A2eKnRo2OdHj/Ku BLMiGz5lQWuWUd5HRBi6bOsEhWIU9zj7B5eA/T7XLnFbs85+HrwxnRgzrBU2HlV1j8NL qLPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=iD0SCivnYvA5HwZaAOXIMstCcOzijD2nJiqfdeW5H2s=; b=zghLwpodc0Q2KNbb+eShAyW+uKk/MAyMeQvIIICvq8hKD7YwGp/im3ofLu+lJui1VT EaY9e7wep49RWAmx2CTBW/amxjh0qEQ4N20m33k+QyEMl7NPvnOfbPzk7DjFH+bCrpiP ulv/VRLl3G4ULDStmqHE1qArojyDFRlpFBgK9+pquvWl+7joDmDoX8aWoOlSPXl4H5up Aim8vHYOjaLoyj88Kb/LUp3g6Mu+yRGJAlEyp8sQHG6m6a66Y1mOJXNOES0n+lI4TIvl 4/AT6DAmainesPb8EBBj8LdOJc+P7FNe92axbsm/TrQXNgpuszyfV0OnDGn1B+Tza9nW XNyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sa40-20020a1709076d2800b007306ac0faa0si9142421ejc.615.2023.01.08.22.27.49; Sun, 08 Jan 2023 22:28:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234205AbjAIGYy convert rfc822-to-8bit (ORCPT <rfc822;zhanglyra.2023@gmail.com> + 99 others); Mon, 9 Jan 2023 01:24:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233331AbjAIGY1 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 9 Jan 2023 01:24:27 -0500 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66661BE14 for <linux-kernel@vger.kernel.org>; Sun, 8 Jan 2023 22:24:26 -0800 (PST) Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by ex01.ufhost.com (Postfix) with ESMTP id 412F924E21B; Mon, 9 Jan 2023 14:24:25 +0800 (CST) Received: from EXMBX066.cuchost.com (172.16.7.66) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 9 Jan 2023 14:24:25 +0800 Received: from jsia-virtual-machine.localdomain (60.49.128.133) by EXMBX066.cuchost.com (172.16.6.66) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 9 Jan 2023 14:24:21 +0800 From: Sia Jee Heng <jeeheng.sia@starfivetech.com> To: <paul.walmsley@sifive.com>, <palmer@dabbelt.com>, <aou@eecs.berkeley.edu> CC: <linux-riscv@lists.infradead.org>, <linux-kernel@vger.kernel.org>, <jeeheng.sia@starfivetech.com>, <leyfoon.tan@starfivetech.com>, <mason.huo@starfivetech.com> Subject: [PATCH v2 2/3] RISC-V: mm: Enable huge page support to kernel_page_present() function Date: Mon, 9 Jan 2023 14:24:06 +0800 Message-ID: <20230109062407.3235-3-jeeheng.sia@starfivetech.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230109062407.3235-1-jeeheng.sia@starfivetech.com> References: <20230109062407.3235-1-jeeheng.sia@starfivetech.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [60.49.128.133] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) To EXMBX066.cuchost.com (172.16.6.66) X-YovoleRuleAgent: yovoleflag Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754525276062182673?= X-GMAIL-MSGID: =?utf-8?q?1754525276062182673?= |
Series |
RISC-V Hibernation Support
|
|
Commit Message
JeeHeng Sia
Jan. 9, 2023, 6:24 a.m. UTC
Currently kernel_page_present() function doesn't support huge page detection causes the function to mistakenly return false to the hibernation core. Add huge page detection to the function to solve the problem. Signed-off-by: Sia Jee Heng <jeeheng.sia@starfivetech.com> Reviewed-by: Ley Foon Tan <leyfoon.tan@starfivetech.com> Reviewed-by: Mason Huo <mason.huo@starfivetech.com> --- arch/riscv/mm/pageattr.c | 6 ++++++ 1 file changed, 6 insertions(+)
Comments
On Mon, Jan 09, 2023 at 02:24:06PM +0800, Sia Jee Heng wrote: > Currently kernel_page_present() function doesn't support huge page > detection causes the function to mistakenly return false to the > hibernation core. > > Add huge page detection to the function to solve the problem. > > Signed-off-by: Sia Jee Heng <jeeheng.sia@starfivetech.com> > Reviewed-by: Ley Foon Tan <leyfoon.tan@starfivetech.com> > Reviewed-by: Mason Huo <mason.huo@starfivetech.com> > --- > arch/riscv/mm/pageattr.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/arch/riscv/mm/pageattr.c b/arch/riscv/mm/pageattr.c > index 86c56616e5de..73fdec8c0a72 100644 > --- a/arch/riscv/mm/pageattr.c > +++ b/arch/riscv/mm/pageattr.c > @@ -221,14 +221,20 @@ bool kernel_page_present(struct page *page) > p4d = p4d_offset(pgd, addr); > if (!p4d_present(*p4d)) > return false; > + if (p4d_leaf(*pud)) ^ p4d I guess you got lucky with the stack garbage in your testing. > + return true; > > pud = pud_offset(p4d, addr); > if (!pud_present(*pud)) > return false; > + if (pud_leaf(*pud)) > + return true; > > pmd = pmd_offset(pud, addr); > if (!pmd_present(*pmd)) > return false; > + if (pmd_leaf(*pmd)) > + return true; > > pte = pte_offset_kernel(pmd, addr); > return pte_present(*pte); > -- > 2.34.1 > Thanks, drew
> -----Original Message----- > From: Andrew Jones <ajones@ventanamicro.com> > Sent: Monday, 9 January, 2023 10:45 PM > To: JeeHeng Sia <jeeheng.sia@starfivetech.com> > Cc: paul.walmsley@sifive.com; palmer@dabbelt.com; > aou@eecs.berkeley.edu; linux-riscv@lists.infradead.org; linux- > kernel@vger.kernel.org; Leyfoon Tan <leyfoon.tan@starfivetech.com>; > Mason Huo <mason.huo@starfivetech.com> > Subject: Re: [PATCH v2 2/3] RISC-V: mm: Enable huge page support to > kernel_page_present() function > > On Mon, Jan 09, 2023 at 02:24:06PM +0800, Sia Jee Heng wrote: > > Currently kernel_page_present() function doesn't support huge page > > detection causes the function to mistakenly return false to the > > hibernation core. > > > > Add huge page detection to the function to solve the problem. > > > > Signed-off-by: Sia Jee Heng <jeeheng.sia@starfivetech.com> > > Reviewed-by: Ley Foon Tan <leyfoon.tan@starfivetech.com> > > Reviewed-by: Mason Huo <mason.huo@starfivetech.com> > > --- > > arch/riscv/mm/pageattr.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/arch/riscv/mm/pageattr.c b/arch/riscv/mm/pageattr.c > > index 86c56616e5de..73fdec8c0a72 100644 > > --- a/arch/riscv/mm/pageattr.c > > +++ b/arch/riscv/mm/pageattr.c > > @@ -221,14 +221,20 @@ bool kernel_page_present(struct page *page) > > p4d = p4d_offset(pgd, addr); > > if (!p4d_present(*p4d)) > > return false; > > + if (p4d_leaf(*pud)) > ^ p4d > > I guess you got lucky with the stack garbage in your testing. You are right. But the reason it is added here is because kernel page table walk is checking for the p4d_leaf as well. For example: walk_p4d_range() in the mm/pagewalk.c. So, I just trying to make it consistent to the Kernel page table walk mechanism. Should I remove it? > > > + return true; > > > > pud = pud_offset(p4d, addr); > > if (!pud_present(*pud)) > > return false; > > + if (pud_leaf(*pud)) > > + return true; > > > > pmd = pmd_offset(pud, addr); > > if (!pmd_present(*pmd)) > > return false; > > + if (pmd_leaf(*pmd)) > > + return true; > > > > pte = pte_offset_kernel(pmd, addr); > > return pte_present(*pte); > > -- > > 2.34.1 > > > > Thanks, > drew
On Tue, Jan 10, 2023 at 06:45:19AM +0000, JeeHeng Sia wrote: > > > > -----Original Message----- > > From: Andrew Jones <ajones@ventanamicro.com> > > Sent: Monday, 9 January, 2023 10:45 PM > > To: JeeHeng Sia <jeeheng.sia@starfivetech.com> > > Cc: paul.walmsley@sifive.com; palmer@dabbelt.com; > > aou@eecs.berkeley.edu; linux-riscv@lists.infradead.org; linux- > > kernel@vger.kernel.org; Leyfoon Tan <leyfoon.tan@starfivetech.com>; > > Mason Huo <mason.huo@starfivetech.com> > > Subject: Re: [PATCH v2 2/3] RISC-V: mm: Enable huge page support to > > kernel_page_present() function > > > > On Mon, Jan 09, 2023 at 02:24:06PM +0800, Sia Jee Heng wrote: > > > Currently kernel_page_present() function doesn't support huge page > > > detection causes the function to mistakenly return false to the > > > hibernation core. > > > > > > Add huge page detection to the function to solve the problem. > > > > > > Signed-off-by: Sia Jee Heng <jeeheng.sia@starfivetech.com> > > > Reviewed-by: Ley Foon Tan <leyfoon.tan@starfivetech.com> > > > Reviewed-by: Mason Huo <mason.huo@starfivetech.com> > > > --- > > > arch/riscv/mm/pageattr.c | 6 ++++++ > > > 1 file changed, 6 insertions(+) > > > > > > diff --git a/arch/riscv/mm/pageattr.c b/arch/riscv/mm/pageattr.c > > > index 86c56616e5de..73fdec8c0a72 100644 > > > --- a/arch/riscv/mm/pageattr.c > > > +++ b/arch/riscv/mm/pageattr.c > > > @@ -221,14 +221,20 @@ bool kernel_page_present(struct page *page) > > > p4d = p4d_offset(pgd, addr); > > > if (!p4d_present(*p4d)) > > > return false; > > > + if (p4d_leaf(*pud)) > > ^ p4d > > > > I guess you got lucky with the stack garbage in your testing. > You are right. But the reason it is added here is because kernel page table walk is checking for the p4d_leaf as well. > For example: walk_p4d_range() in the mm/pagewalk.c. So, I just trying to make it consistent to the Kernel page table walk mechanism. > Should I remove it? The only thing I see wrong with it is the use of the uninitialized pointer. Just change 'pud' to 'p4d'. Thanks, drew > > > > > + return true; > > > > > > pud = pud_offset(p4d, addr); > > > if (!pud_present(*pud)) > > > return false; > > > + if (pud_leaf(*pud)) > > > + return true; > > > > > > pmd = pmd_offset(pud, addr); > > > if (!pmd_present(*pmd)) > > > return false; > > > + if (pmd_leaf(*pmd)) > > > + return true; > > > > > > pte = pte_offset_kernel(pmd, addr); > > > return pte_present(*pte); > > > -- > > > 2.34.1 > > > > > > > Thanks, > > drew
diff --git a/arch/riscv/mm/pageattr.c b/arch/riscv/mm/pageattr.c index 86c56616e5de..73fdec8c0a72 100644 --- a/arch/riscv/mm/pageattr.c +++ b/arch/riscv/mm/pageattr.c @@ -221,14 +221,20 @@ bool kernel_page_present(struct page *page) p4d = p4d_offset(pgd, addr); if (!p4d_present(*p4d)) return false; + if (p4d_leaf(*pud)) + return true; pud = pud_offset(p4d, addr); if (!pud_present(*pud)) return false; + if (pud_leaf(*pud)) + return true; pmd = pmd_offset(pud, addr); if (!pmd_present(*pmd)) return false; + if (pmd_leaf(*pmd)) + return true; pte = pte_offset_kernel(pmd, addr); return pte_present(*pte);