Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp7357984rwl; Mon, 9 Jan 2023 22:58:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXufNqRGaYkyrE7fAQD2FZlijLzgSOBd1rJDUpOTDckZxcybfquZ7LFxhK0wkAoLkMpvaghk X-Received: by 2002:a17:903:330b:b0:193:30be:d146 with SMTP id jk11-20020a170903330b00b0019330bed146mr6256655plb.63.1673333883620; Mon, 09 Jan 2023 22:58:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673333883; cv=none; d=google.com; s=arc-20160816; b=mP98Wi36QDgBHanWHBnNcMF/oBKjHVSLFxyIi2+NDVRAIsQYMvntmqBjbRipkuzaR5 Ix560/cl35XO52nrIyjtia61m8UjdKXyjimKcScKmyPiT3k8niN8EmcMAevGrvwp8H4B IvADdhSxWNBDLGsMTI3TxfIft0NPWp+cH8m8blTt20034cEtlO9bqB5eCVEkTvTdZ5tn SG2dO1RMd+cr2xOq856goZ8NHw8DpmvN3cr2RaXWS2Xo/3GtjXZzkA/EnQHMQQ+//Pyv 99WzvBVqaB3xbHZTWIBQR15pmjgPmpISRHmBdyhbmzABdRs2sGx1jPGAp+FAUPC7Pv8a hX+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=buIzZ+Wv+kFl1CGBHkdPT4BO1g9zp5jmUSETwAcFF4k=; b=uOsRfSDefuG87GcK9gBUIQUp37qK7eV1yWj7kgEE/tQWPMfKi2e9lGSuhpsz67uPMe 09rb9FdKZNwTsx2QHUzx+C4DZmb3ZBkaBQOyduZG7n82TolO5JEyKyqwIuwIZi8KT/pl qG4ISFbaDxuoiQEPs/3Z2D9O+lYweCVmTzQTc9r+y1kmkPZ3u1UJ+EHR/4C+y0tRcT0Z FvyeX341+pvNxAcZj7X8qPCx7+hBpkmXJUlwR4MRPppeU+M57KembEOOYX04cmgaGyfw XL+3E8bWLMkDVf5DhIGBjgBggr52ChUU50ckkfwk+ulaepaQ70rtp9yYZooTDmZEEhHS fwng== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p23-20020a170902a41700b00189ca4f4613si10200756plq.72.2023.01.09.22.57.55; Mon, 09 Jan 2023 22:58:03 -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 S229848AbjAJGp1 convert rfc822-to-8bit (ORCPT + 55 others); Tue, 10 Jan 2023 01:45:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbjAJGpY (ORCPT ); Tue, 10 Jan 2023 01:45:24 -0500 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CED1CE26 for ; Mon, 9 Jan 2023 22:45:21 -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 8A8A224E217; Tue, 10 Jan 2023 14:45:19 +0800 (CST) Received: from EXMBX162.cuchost.com (172.16.6.72) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Tue, 10 Jan 2023 14:45:19 +0800 Received: from EXMBX066.cuchost.com (172.16.7.66) by EXMBX162.cuchost.com (172.16.6.72) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Tue, 10 Jan 2023 14:45:19 +0800 Received: from EXMBX066.cuchost.com ([fe80::5947:9245:907e:339f]) by EXMBX066.cuchost.com ([fe80::5947:9245:907e:339f%17]) with mapi id 15.00.1497.044; Tue, 10 Jan 2023 14:45:19 +0800 From: JeeHeng Sia To: Andrew Jones CC: "paul.walmsley@sifive.com" , "palmer@dabbelt.com" , "aou@eecs.berkeley.edu" , "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Leyfoon Tan , Mason Huo Subject: RE: [PATCH v2 2/3] RISC-V: mm: Enable huge page support to kernel_page_present() function Thread-Topic: [PATCH v2 2/3] RISC-V: mm: Enable huge page support to kernel_page_present() function Thread-Index: AQHZI/MEyk4BWxsDWk+SJDmuy1TBsK6VpAGAgAGQfoA= Date: Tue, 10 Jan 2023 06:45:19 +0000 Message-ID: <62163664add9493db394c8ca45b73ce2@EXMBX066.cuchost.com> References: <20230109062407.3235-1-jeeheng.sia@starfivetech.com> <20230109062407.3235-3-jeeheng.sia@starfivetech.com> <20230109144525.4xgnpeb6zcyyvx4j@orel> In-Reply-To: <20230109144525.4xgnpeb6zcyyvx4j@orel> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [60.49.128.133] x-yovoleruleagent: yovoleflag Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 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: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Andrew Jones > Sent: Monday, 9 January, 2023 10:45 PM > To: JeeHeng Sia > Cc: paul.walmsley@sifive.com; palmer@dabbelt.com; > aou@eecs.berkeley.edu; linux-riscv@lists.infradead.org; linux- > kernel@vger.kernel.org; Leyfoon Tan ; > Mason Huo > 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 > > Reviewed-by: Ley Foon Tan > > Reviewed-by: Mason Huo > > --- > > 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