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 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 31BEBC54E66 for ; Wed, 13 Mar 2024 21:57:37 +0000 (UTC) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=igPW2m98; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=FkzJnaD9; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4Tw4B75y02z3w3V for ; Thu, 14 Mar 2024 08:57:35 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=igPW2m98; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=FkzJnaD9; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=peterx@redhat.com; receiver=lists.ozlabs.org) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 lists.ozlabs.org (Postfix) with ESMTPS id 4Tw3yp30Yhz3dWC for ; Thu, 14 Mar 2024 08:47:46 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710366463; 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=RceLUqudgSYtio91tFrZNJeoSc+POoSD4WuQnIajVyw=; b=igPW2m98y9PDQ2C5zxIfhUYhnxbWw2PEQo6KV4UUC1fYYcLqbgVLCwVO+4+zIOhCWepIgb ZkRT+8XeerkLWCrMoFhENcQ6DH2Vs5rdFae63go7BvWzOwmBAa0g1dnXvQ/7MonZltS/tq 8OkpggoqDvBjxZAyl4zCYcL+YtP1bR0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710366464; 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=RceLUqudgSYtio91tFrZNJeoSc+POoSD4WuQnIajVyw=; b=FkzJnaD93OD4VFF/cZyW7YFhixb4sSulId052+op6mR1zP5q4mZMgtxuM7Y88xiDVpSFWi uqZBTcLHA0ziYRMYKW1RETujuElb2JbrUldia1tLZGqVgvOSeBQW6o9JedcxvoIuWn/yt8 iIci7ht8R1p2DMB/JEcHjol65he4UsM= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-541-JyuuWSdrPyy9Aq9Z_QqnaQ-1; Wed, 13 Mar 2024 17:47:41 -0400 X-MC-Unique: JyuuWSdrPyy9Aq9Z_QqnaQ-1 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-69120b349c9so1132056d6.1 for ; Wed, 13 Mar 2024 14:47:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710366461; x=1710971261; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RceLUqudgSYtio91tFrZNJeoSc+POoSD4WuQnIajVyw=; b=w1/VSvqEK+9nWPJlwZYBy2bOVuGXL0vJScOjKnvU84WbPxQ0lPKZg3GOQoujiTSj+S doFHPsIfl7z5ggrGZUUAqNsaFSVgfieOqafy1R7YlBs47aJUddwVYWda47JEy/pgfsSq xJIWbdZBv0mYXmkBnC5znlx5xdlrSVgdMjgABzfR5ve5r5QLPyadqv/ltGgWH4hhc++L IsHkuhKF56U+8PIxRE8KCTcAqIVMLunodOKg7IbJQUZW0SD33H6quOkQvrNCqVwY9Q4T 7ffm/ZxVlUzqWSyXPnIrFwv+K0a31A2DiBRhiQipNUHWVo1r6aJscnTveVWC3zhT414k Vx2w== X-Forwarded-Encrypted: i=1; AJvYcCUGHgAwYCCKBctU1CgFpbbGMsZQp8kxvtxJzEvTvzLIl7S+lLrz9PAVWn4hzlvM0YLhwhuv7nSDJ9HSxdNRuKQ8fADmtJVtrw1uf9V9BQ== X-Gm-Message-State: AOJu0YwWVilQ9/xvjyY9koCK9M+cae9iG6H1JALfUDP71lssuMEXSZBj QbyNM01hQm7rl3DGyqMGGMrf1aKhxGojsh/PWKyuFhA48ppYnLPBNn8JnV29dSaFDRgiUKW2E0G +L8GUFgeRPSh6q+M3EyIlFVVz0+Wg6P6rqQLm3vPn8UhmQHFJlKdCfBONRTZ37Lw= X-Received: by 2002:a0c:eb83:0:b0:68f:e779:70f2 with SMTP id x3-20020a0ceb83000000b0068fe77970f2mr5934046qvo.3.1710366461087; Wed, 13 Mar 2024 14:47:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzQ7u+SJJkcqXmUXcq37q3NbZvmeXcFSg9ZX/No2VaFoCndSeWwMBLZUu/Dqoea36C4ilydg== X-Received: by 2002:a0c:eb83:0:b0:68f:e779:70f2 with SMTP id x3-20020a0ceb83000000b0068fe77970f2mr5934040qvo.3.1710366460771; Wed, 13 Mar 2024 14:47:40 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id dv10-20020ad44eea000000b0069111c5cdd4sm60114qvb.100.2024.03.13.14.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 14:47:39 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 13/13] mm: Document pXd_leaf() API Date: Wed, 13 Mar 2024 17:47:19 -0400 Message-ID: <20240313214719.253873-14-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313214719.253873-1-peterx@redhat.com> References: <20240313214719.253873-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Muchun Song , Jason Gunthorpe , x86@kernel.org, peterx@redhat.com, Matthew Wilcox , Mike Rapoport , sparclinux@vger.kernel.org, Andrew Morton , linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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. Reviewed-by: Jason Gunthorpe Signed-off-by: Peter Xu --- 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 -- 2.44.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10EB65EE78 for ; Wed, 13 Mar 2024 21:47:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710366467; cv=none; b=nL+wXCKjr52wKxt4r3WaOPEZFmyWsHeEPNF7KQs6TXARfykZu77GEubibflmsaBM1v4QLG5lQQQN36d2oX+ZnYfE38bLKsQ7lk+8DPoWYlm0YgG+SS5y/8gX/Ja4NaSeTft0Qua1uRhtXISIl8iT2TNBgWNKAALg0EhoVvGJy8s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710366467; c=relaxed/simple; bh=OtdxslPn00ut3ZNOwlMQpC8bAo76CW3Q9+JhiTFcwrI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mpYd9cQxKsVf4hSmUcRLs6ovE9tS+f17Y9QrKRUmmwfEnmZOr9lagIs2CXVGEMgJyds8NP2cpIUG3bCkAJo6n2Qb0+TRgc5Ru+vWpQKzLHemB9eraPMmYqw1YnWM8Ye/5haxDDzNZbf/iu7kjrfKH+eDHLpKchryIO/JUw+Cp7E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=QtBNisYf; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="QtBNisYf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710366463; 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=RceLUqudgSYtio91tFrZNJeoSc+POoSD4WuQnIajVyw=; b=QtBNisYf7XfwYzICx0puyDSv7NCHTQ0Vr0rYjB5gnSkJnBK3UUrk1uxJT25RIZHtO/bfoJ QX5RuHcdVe3zSPZUoEsgIxuO4z52n3apo6g26vmTr79sgNYJhpMATW/tAqt6LRlrQjH95/ rIi7DsrSSvR1wPm24zeojaQC/4iu3NQ= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-541-nkyZhZhYPkK4geRtN9ne7Q-1; Wed, 13 Mar 2024 17:47:41 -0400 X-MC-Unique: nkyZhZhYPkK4geRtN9ne7Q-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-690ab2b0de1so1163206d6.0 for ; Wed, 13 Mar 2024 14:47:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710366461; x=1710971261; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RceLUqudgSYtio91tFrZNJeoSc+POoSD4WuQnIajVyw=; b=sQV8KvdtqF2HRz8o8dLSG1s23E2yBdDPojFZ7IlxQDF2qeKtUNsQSy5aiJvlPzlVk2 bVSNfJVk9/PT+uq+5XIpo+8vsgFxGb4g/AVcT3m5HM4n5PmySAwXPA6RQnZDa6YabK/S NsmcOF1B59r8+X5Ui+iFNLbCZZ2QoO94eActCCsQnKNntZgIC9IKup9VbY2eUGUoAsL5 xpnB06VfOLAI2FVL93OKXmbhpQXG9IhhxbtiveoOO09tBSnlY5atDVAHOmUH4kvvBy1g u4fiM/SCrdYyaWRsYJ7bLz7sRWG6fJX8PAeTwAxEZ8UNIlSo0l1npTfKWTWEAemBPw9+ 7uWg== X-Forwarded-Encrypted: i=1; AJvYcCVFwNgjSEjS5NKytjvBj+8wHezNqzmqx8hPZp4XkXItF5px1/9JuhmTo/2ZULJ1cwQoqe02DdL1jYCmhThvqlVAu1RlzIPsxhXOFA== X-Gm-Message-State: AOJu0YxkJvyFCiANR+LMqTY47xpbQMlC6qhNjmuj0Ppba7nNQ4IsmGjq yAxT7P5DLT+mmNkEuoK0c9A6rWoahRqaCSr0PmqRp12/LQafKPfYTWbK+w7VSGDwRmayMyhWJKt R/pVejOpZLAwiNUC+zdbaXMjkI5sX45YdYvi8GuACy8cj+JqaiYhRZz/GDMo= X-Received: by 2002:a0c:eb83:0:b0:68f:e779:70f2 with SMTP id x3-20020a0ceb83000000b0068fe77970f2mr5934048qvo.3.1710366461088; Wed, 13 Mar 2024 14:47:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzQ7u+SJJkcqXmUXcq37q3NbZvmeXcFSg9ZX/No2VaFoCndSeWwMBLZUu/Dqoea36C4ilydg== X-Received: by 2002:a0c:eb83:0:b0:68f:e779:70f2 with SMTP id x3-20020a0ceb83000000b0068fe77970f2mr5934040qvo.3.1710366460771; Wed, 13 Mar 2024 14:47:40 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id dv10-20020ad44eea000000b0069111c5cdd4sm60114qvb.100.2024.03.13.14.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 14:47:39 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: linux-arm-kernel@lists.infradead.org, Matthew Wilcox , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Andrew Morton , x86@kernel.org, peterx@redhat.com, Mike Rapoport , Muchun Song , sparclinux@vger.kernel.org, Jason Gunthorpe Subject: [PATCH 13/13] mm: Document pXd_leaf() API Date: Wed, 13 Mar 2024 17:47:19 -0400 Message-ID: <20240313214719.253873-14-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313214719.253873-1-peterx@redhat.com> References: <20240313214719.253873-1-peterx@redhat.com> Precedence: bulk X-Mailing-List: sparclinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. Reviewed-by: Jason Gunthorpe Signed-off-by: Peter Xu --- 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 -- 2.44.0 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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9A2CFC54E66 for ; Wed, 13 Mar 2024 21:48:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AE8jV/PGlmUC80Q2U2ALB7QQEJ826lxQD4RjL9gvhLY=; b=EYyKLgeX59E1Sa eJieQloAcWVMnHsolpBmKtjazKG1TUliADjD5qMHD6jonaJp/ZWpIg5sCeRtnr/8B4en9uJ36t5lS IH1jSuV1WNUD2YufMI8slpGT2xLui0Bol9H2e3D0c3YmlcgrcyFNp5d5aC0sfyFqwitf6af9M9rN/ 0Re442RTLy0cQopf8Tnz90Pdl9FNn/Py0+6YEwo7L7mcwy0ESEyDmzxr+ql4wE7dM9fjI9k7gmKkU gwk4dGJAVi0gOiT6FTtjfLtiCDlIxPYYSHwHwYt4GyeknSRrHfdfz4tHUlq3ZnDzCha2MLkKiORX6 WKwdnAXnqwIYXHqZphoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkWSM-0000000C0ed-21Ro; Wed, 13 Mar 2024 21:48:14 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rkWRu-0000000C0IV-0u8O for linux-arm-kernel@lists.infradead.org; Wed, 13 Mar 2024 21:47:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710366465; 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=RceLUqudgSYtio91tFrZNJeoSc+POoSD4WuQnIajVyw=; b=BYeqR4v7AYrv1j+ds7Zja+/IuWlBQZ79IGTyDMSRsqrhghcEL+j7XhAY/MU31iBQY19Hsd CO40r50pAvu7gSJRb7d5ePCfOhkm5XMm9r0h9LePyDOq3Xg2gRHbRW16rXt2mGrYCe292r iQnTdCZknsqtmIxIznh8+Y20ET2IXPk= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-684-e5c-7ogNOTubm2zNkVwmew-1; Wed, 13 Mar 2024 17:47:41 -0400 X-MC-Unique: e5c-7ogNOTubm2zNkVwmew-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-69120b349c9so1132136d6.1 for ; Wed, 13 Mar 2024 14:47:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710366461; x=1710971261; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RceLUqudgSYtio91tFrZNJeoSc+POoSD4WuQnIajVyw=; b=n7mkru1LIboodnbPAbUhZW+1ewFTpr6EhvoPE5OWj4XxYOusAbC5bM8BQTXEdz6QVU PO8G4PCqF74c2zvbIrbRkf2UER2dT1N5of6z1NZX02fE/KXSBI38dWUj561T7uIv8ooA VtTzg7Dh6AdPu1JOUER2ckcTORaWTmXDCypblwOd2sDhUg7Dnu6/0moXyL7cS8gEsKru y3BWloDN00xeysGQOlsJl/8nXmBotvLNXP3Z5teNWFLg4xYdTnFOhydI2wbRNgsIIQ3p J/kH4lEdJfD2l5BKDEAuR/vNuO9pR0utxwhTxYZNnuI8d2Nfn6wAvK45+6Up01TRTEfo 8SYw== X-Gm-Message-State: AOJu0YwRH5UVEnCUKKxKbjA7CnnAKxa3bRpmFR4lwJKa9cQ1EPEdBl83 am4tzeYla5oh084Bn5pjlUHPagkwK1ZtiddzGVw2+cLd5uc+fMBDXD2nXF/XfHnoyfCRoRKO+C/ E4xk1cPoQKNFfYjF6sPj7W6x+PC8BdtluDxUxLdRlcswlnqZIcQn0p9mqqn2i9Yk2rlkxuQ1GtP MYmN4Q X-Received: by 2002:a0c:eb83:0:b0:68f:e779:70f2 with SMTP id x3-20020a0ceb83000000b0068fe77970f2mr5934047qvo.3.1710366461088; Wed, 13 Mar 2024 14:47:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzQ7u+SJJkcqXmUXcq37q3NbZvmeXcFSg9ZX/No2VaFoCndSeWwMBLZUu/Dqoea36C4ilydg== X-Received: by 2002:a0c:eb83:0:b0:68f:e779:70f2 with SMTP id x3-20020a0ceb83000000b0068fe77970f2mr5934040qvo.3.1710366460771; Wed, 13 Mar 2024 14:47:40 -0700 (PDT) Received: from x1n.redhat.com ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id dv10-20020ad44eea000000b0069111c5cdd4sm60114qvb.100.2024.03.13.14.47.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 14:47:39 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: linux-arm-kernel@lists.infradead.org, Matthew Wilcox , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , Andrew Morton , x86@kernel.org, peterx@redhat.com, Mike Rapoport , Muchun Song , sparclinux@vger.kernel.org, Jason Gunthorpe Subject: [PATCH 13/13] mm: Document pXd_leaf() API Date: Wed, 13 Mar 2024 17:47:19 -0400 Message-ID: <20240313214719.253873-14-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240313214719.253873-1-peterx@redhat.com> References: <20240313214719.253873-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240313_144746_501901_7E2B4ACC X-CRM114-Status: GOOD ( 15.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. Reviewed-by: Jason Gunthorpe Signed-off-by: Peter Xu --- 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 -- 2.44.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel