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=-16.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 50534C433ED for ; Tue, 20 Apr 2021 12:58:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 989E4613C8 for ; Tue, 20 Apr 2021 12:58:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 989E4613C8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A5A976B006C; Tue, 20 Apr 2021 08:58:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A320B6B006E; Tue, 20 Apr 2021 08:58:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 921C76B0070; Tue, 20 Apr 2021 08:58:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0180.hostedemail.com [216.40.44.180]) by kanga.kvack.org (Postfix) with ESMTP id 752756B006C for ; Tue, 20 Apr 2021 08:58:03 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 3A1758249980 for ; Tue, 20 Apr 2021 12:58:03 +0000 (UTC) X-FDA: 78052748046.26.4440D4C Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf26.hostedemail.com (Postfix) with ESMTP id C779140002DF for ; Tue, 20 Apr 2021 12:57:56 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 89A4A613C3; Tue, 20 Apr 2021 12:57:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618923481; bh=pj7iH5/7ryvKV0103e/WzDqoTVMCnCeOsU1aueXSSWs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AELGbPakwwA189udgGAWTMEERvHJSzMiJJ6zXc+pUHeHypJdz0V2fLe+BD1bzM3Nx u9j/1K2l5BkbehD9ogeiYm7EMiRtZo3pybYvM6cZGY5LcQAnHIi9VRZ7v8vxG+stQK GZ2TdxDIffeM0R+97tZrgAqWdhdoTu45VU5HxgOq9PfOoGh0glAUuurDI2Bad4nDOo KZECeDYreSNaGkVAIyk8uMOKfQSmqol2Tr19JuTT7Jw0eQB08RumVkZeFP3Qz2yLts SHCbpptQUT2ALWZS3QX0qSFE7JldhhO5+xK9SIm7k9tZyQCR2vjrXrovnnIkVMTz5M Ap+IrrXFwGzUw== Date: Tue, 20 Apr 2021 15:57:52 +0300 From: Mike Rapoport To: David Hildenbrand Cc: linux-arm-kernel@lists.infradead.org, Anshuman Khandual , Ard Biesheuvel , Catalin Marinas , Marc Zyngier , Mark Rutland , Mike Rapoport , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v1 1/4] include/linux/mmzone.h: add documentation for pfn_valid() Message-ID: References: <20210420090925.7457-1-rppt@kernel.org> <20210420090925.7457-2-rppt@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: C779140002DF X-Stat-Signature: ogwedyo4p5ybami57ki138ouk1pb48c3 X-Rspamd-Server: rspam02 Received-SPF: none (kernel.org>: No applicable sender policy available) receiver=imf26; identity=mailfrom; envelope-from=""; helo=mail.kernel.org; client-ip=198.145.29.99 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1618923476-864457 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 Tue, Apr 20, 2021 at 11:22:53AM +0200, David Hildenbrand wrote: > On 20.04.21 11:09, Mike Rapoport wrote: > > From: Mike Rapoport > > > > Add comment describing the semantics of pfn_valid() that clarifies that > > pfn_valid() only checks for availability of a memory map entry (i.e. struct > > page) for a PFN rather than availability of usable memory backing that PFN. > > > > The most "generic" version of pfn_valid() used by the configurations with > > SPARSEMEM enabled resides in include/linux/mmzone.h so this is the most > > suitable place for documentation about semantics of pfn_valid(). > > > > Suggested-by: Anshuman Khandual > > Signed-off-by: Mike Rapoport > > --- > > include/linux/mmzone.h | 11 +++++++++++ > > 1 file changed, 11 insertions(+) > > > > diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h > > index 47946cec7584..961f0eeefb62 100644 > > --- a/include/linux/mmzone.h > > +++ b/include/linux/mmzone.h > > @@ -1410,6 +1410,17 @@ static inline int pfn_section_valid(struct mem_section *ms, unsigned long pfn) > > #endif > > #ifndef CONFIG_HAVE_ARCH_PFN_VALID > > +/** > > + * pfn_valid - check if there is a valid memory map entry for a PFN > > + * @pfn: the page frame number to check > > + * > > + * Check if there is a valid memory map entry aka struct page for the @pfn. > > + * Note, that availability of the memory map entry does not imply that > > + * there is actual usable memory at that @pfn. The struct page may > > + * represent a hole or an unusable page frame. > > + * > > + * Return: 1 for PFNs that have memory map entries and 0 otherwise > > + */ > > static inline int pfn_valid(unsigned long pfn) > > { > > struct mem_section *ms; > > > > I'd rephrase all "there is a valid memory map" to "there is a memory map" > and add "pfn_valid() does to indicate whether the memory map as actually > initialized -- see pfn_to_online_page()." > > pfn_valid() means that we can do a pfn_to_page() and don't get a fault when > accessing the "struct page". It doesn't state anything about the content. Well, I mean valid in the sense you can access the struct page :) How about: /** * pfn_valid - check if there is a memory map entry for a PFN * @pfn: the page frame number to check * * Check if there is a memory map entry aka struct page for the @pfn and it * is safe to access that struct page; the struct page state may be * uninitialized -- see pfn_to_online_page(). * * Note, that availability of the memory map entry does not imply that * there is actual usable memory at that @pfn. The struct page may * represent a hole or an unusable page frame. * * Return: 1 for PFNs that have memory map entries and 0 otherwise. */ -- Sincerely yours, Mike.