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=-17.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 0EE11C433B4 for ; Tue, 20 Apr 2021 12:59:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 70960613CD for ; Tue, 20 Apr 2021 12:59:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70960613CD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D67636B006E; Tue, 20 Apr 2021 08:58:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D3ECC6B0070; Tue, 20 Apr 2021 08:58:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BDFB16B0071; Tue, 20 Apr 2021 08:58:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0037.hostedemail.com [216.40.44.37]) by kanga.kvack.org (Postfix) with ESMTP id A17BA6B006E for ; Tue, 20 Apr 2021 08:58:59 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 60FAF3637 for ; Tue, 20 Apr 2021 12:58:59 +0000 (UTC) X-FDA: 78052750398.28.EFE8CFF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 136E9C0007CB for ; Tue, 20 Apr 2021 12:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618923538; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=InC/09SU2jowBshG+H/mXghIo0fijTDczsPvBvuygWs=; b=V9HkKsJEs+iXVBZ19m0IwEmBxNHpDWJprZ4tTQq+3jrsa3cNXxYXC8RyXVuV1lUrhM4v78 6AQq2KLKklcoh/WI0Zkqa1ZnhQwkAUxK6Hcat645vrhZozNU78d23hwYsz93wtCbgyb+wU d90+9bmFH2jXpZiuXJN3hOWyh8tQIjM= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-547-jcvdnLakPHC_P49I-aYIHQ-1; Tue, 20 Apr 2021 08:58:56 -0400 X-MC-Unique: jcvdnLakPHC_P49I-aYIHQ-1 Received: by mail-wr1-f69.google.com with SMTP id y13-20020adfdf0d0000b02901029a3bf796so10857244wrl.15 for ; Tue, 20 Apr 2021 05:58:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=InC/09SU2jowBshG+H/mXghIo0fijTDczsPvBvuygWs=; b=oCL8nDtI9kbkFhk4TjqRkrn13KjLJnmt0/1I56nR9gs19vlAvvyz7Yc9DalJbhqs+P 7nsXVTZPtvMpAg95hLzkDBu+80BiB4siifMrb5QRvANMtKjvDsRqKLKLiP3K8kOucaVc qE9xJoUCmueZAiTeae3LQWawkoRkKFtNtEG6LuHl0pv4pLKNqj8l9+kBS22t+wS2gOqL FIwbOl1AAD5c4RusbdIDow7tXamDGO6aEG9WNorOMNQR7C+fN6X4ZIuJ4z4VrzN9bjeD H0ud2huaXkvwXfWFcOtmn0CcMejvue8Bh1llpc4zPSy1eoEyw+pxGiU+ytCoFER0rV8Y mPjA== X-Gm-Message-State: AOAM531q+g4pA4BkSfVGTsvlwecEafbnE2UHFRHid7XfH7PH/cEQTXtF dPVBdp3L+nlNUcstkTuz1VqRps++K4g5OqoG9rsRFgmsPz5eyYIdrAYm+2/YunqESCaOXK8sfy2 jdOpWP2jzhhwCNSvweusfh7CobRBXzdXw/5dAdvAY6Nn72rhgxB5NSA1ERTY= X-Received: by 2002:a1c:454:: with SMTP id 81mr4372393wme.186.1618923535356; Tue, 20 Apr 2021 05:58:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzN432Bkl8h0VlShbz+ZgmHfmV79yLlF8E3/1xyjGalQUC9+ROSAJDjYzCWA1CcV6ig2Ye5wQ== X-Received: by 2002:a1c:454:: with SMTP id 81mr4372354wme.186.1618923534988; Tue, 20 Apr 2021 05:58:54 -0700 (PDT) Received: from [192.168.3.132] (p4ff2390a.dip0.t-ipconnect.de. [79.242.57.10]) by smtp.gmail.com with ESMTPSA id x2sm30458360wrg.31.2021.04.20.05.58.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Apr 2021 05:58:54 -0700 (PDT) Subject: Re: [PATCH v1 1/4] include/linux/mmzone.h: add documentation for pfn_valid() To: Mike Rapoport 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 References: <20210420090925.7457-1-rppt@kernel.org> <20210420090925.7457-2-rppt@kernel.org> From: David Hildenbrand Organization: Red Hat Message-ID: <07216f89-369f-0dcc-7bc0-97c204981396@redhat.com> Date: Tue, 20 Apr 2021 14:58:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Stat-Signature: a1ikgbq19g4r31h4xufddxaok4h747hz X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 136E9C0007CB Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf14; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=216.205.24.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1618923527-745058 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 20.04.21 14:57, Mike Rapoport wrote: > 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. > */ > Sounds good to me -- thanks! Reviewed-by: David Hildenbrand -- Thanks, David / dhildenb