From patchwork Wed Mar 6 10:41:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13583885 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FFA2C54E41 for ; Wed, 6 Mar 2024 10:43:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0EC386B0099; Wed, 6 Mar 2024 05:43:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 076166B00AD; Wed, 6 Mar 2024 05:43:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E0AAC6B00AE; Wed, 6 Mar 2024 05:43:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id CBC276B0099 for ; Wed, 6 Mar 2024 05:43:45 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8A329140C59 for ; Wed, 6 Mar 2024 10:43:45 +0000 (UTC) X-FDA: 81866278410.24.0361138 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf11.hostedemail.com (Postfix) with ESMTP id D6CF440015 for ; Wed, 6 Mar 2024 10:43:43 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QwImCDw0; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709721823; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EszM++ZyWA4F0AEHMeW0S6yDLENEL5nIwjErtg69nlA=; b=E6Ey9BN2vHwKQxsAvwfgzgMpa2p2U3l9eW520XMJdcE+EX6O6coyW2lbi7wCAD4pfH9kNX b/q9ISVXVDRkoJZjmxls4/hZwlrI7EjvJ/QkjCVmgnZfcOCrSJ6Z+/lwo+59tqjV7IrqDD Pe6e87PC/IFlWcEyeAcJhrqJPOyPjfs= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QwImCDw0; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709721823; a=rsa-sha256; cv=none; b=vJKmK1+5cF/Yv8bgpijaQ4pBufKsN7pMsw+qiJjnwIFMzAn3qGlvE/RRGY6UQYT70y8QN2 gvPrJobmN5hEbyCwwoTnXj4ctcL+x8slgerhXTcwqPxQKK5Zch0DvkCk1Z9V53H7a+PWT7 VM2Yl0hCspyouPxyTLvPTaWoAaghQvo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709721823; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EszM++ZyWA4F0AEHMeW0S6yDLENEL5nIwjErtg69nlA=; b=QwImCDw0wdZ9l0RwG9QsIXe+2dJtAuS2NkLzw8vYYXdQqVaq1PV9XNZuVyYcLvBFfb1uNW w5NwBAsSD7BmNK4EmMgxcC8aTvQHpdeRWYTLj2ABza3Zy1361QhztF9fwyJsOKQruxVvBg UrfvTHAWUQwM0wnuRCEy3HOyALLxbIs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-122-so8_Bz8AP0eINzkAwxTEYA-1; Wed, 06 Mar 2024 05:43:38 -0500 X-MC-Unique: so8_Bz8AP0eINzkAwxTEYA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0BD8284B0C5; Wed, 6 Mar 2024 10:43:38 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id A13A3111DD02; Wed, 6 Mar 2024 10:43:31 +0000 (UTC) From: peterx@redhat.com To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org, Andrew Morton , Muchun Song , Jason Gunthorpe , peterx@redhat.com, Matthew Wilcox , Mike Rapoport , Christophe Leroy , x86@kernel.org, sparclinux@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC 13/13] mm: Document pXd_leaf() API Date: Wed, 6 Mar 2024 18:41:47 +0800 Message-ID: <20240306104147.193052-14-peterx@redhat.com> In-Reply-To: <20240306104147.193052-1-peterx@redhat.com> References: <20240306104147.193052-1-peterx@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Rspamd-Queue-Id: D6CF440015 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: arxfhs9e9x8yu34sfechd6ffqn4qrppn X-HE-Tag: 1709721823-671345 X-HE-Meta: U2FsdG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UvLjtAvg0Ffw+Q8b7xajAwN2yqszeYbOHnp54PfnuWW49U6D5nAkBYBXA1AiU1awWxnZwvJqaOE4YiiSkE1p6yfTDtQhX2GyBd80vfxpZAUNDQY5r4N+4Ttno0dVq4ThuT0AzG6/uc7mYf8 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: List-Subscribe: List-Unsubscribe: From: Peter Xu There's one small section already, but since we're going to remove pXd_huge(), that comment may start to obsolete. Rewrite that section with more information, hopefully with that the API is crystal clear on what it implies. Signed-off-by: Peter Xu Reviewed-by: Jason Gunthorpe --- include/linux/pgtable.h | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 85fc7554cd52..6b0d222a7fad 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -1770,11 +1770,25 @@ typedef unsigned int pgtbl_mod_mask; #endif /* - * p?d_leaf() - true if this entry is a final mapping to a physical address. - * This differs from p?d_huge() by the fact that they are always available (if - * the architecture supports large pages at the appropriate level) even - * if CONFIG_HUGETLB_PAGE is not defined. - * Only meaningful when called on a valid entry. + * pXd_leaf() is the API to check whether a pgtable entry is a huge page + * mapping. It should work globally across all archs, without any + * dependency on CONFIG_* options. For architectures that do not support + * huge mappings on specific levels, below fallbacks will be used. + * + * A leaf pgtable entry should always imply the following: + * + * - It is a "present" entry. IOW, before using this API, please check it + * with pXd_present() first. NOTE: it may not always mean the "present + * bit" is set. For example, PROT_NONE entries are always "present". + * + * - It should _never_ be a swap entry of any type. Above "present" check + * should have guarded this, but let's be crystal clear on this. + * + * - It should contain a huge PFN, which points to a huge page larger than + * PAGE_SIZE of the platform. The PFN format isn't important here. + * + * - It should cover all kinds of huge mappings (e.g., pXd_trans_huge(), + * pXd_devmap(), or hugetlb mappings). */ #ifndef pgd_leaf #define pgd_leaf(x) false