From patchwork Mon Mar 18 20:04:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13595785 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 9B710C54E5D for ; Mon, 18 Mar 2024 20:05:53 +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=I92qej5j7vlK/z e7YR6m6xYlLbvcVRY6jSDOCLhp+DF8B5ujGhuMpuKgKjW6jFeNCgy92qVZP43JM97oC/mfRAZnMyl qNix1tggdiJ5al5mKY63LqWLmeq/ukv4JHbm0v6VMJAZ67KxYivVe1G0WBlQaP88EwZBKX6CZeHWf kH3pCTnxsSxhsWWTxcJIFeaWHF55D31SQ4IwEHhLkK9w4RhoK16lvdPutC7U+mxBO51MmHJL4NEYW JmCAHJWjPTju/Fmdomkv4lISoRZOn48iocFQMQMKlzxICD7+DJ7xAyONeMjIIfAvJNeqnUpDB3CjU G/O2leCEw/ZvFRGg0fxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmJEp-00000009y8I-3Qoh; Mon, 18 Mar 2024 20:05:39 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmJDs-00000009xL9-0aYX for linux-arm-kernel@bombadil.infradead.org; Mon, 18 Mar 2024 20:04:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Content-Transfer-Encoding :MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Sender:Reply-To:Content-ID:Content-Description; bh=RceLUqudgSYtio91tFrZNJeoSc+POoSD4WuQnIajVyw=; b=LW4Zx7Fhr9n/9hXa+Nb6vbYIo+ hsNgGkDGopPt/4YSBG8Y4UnmzRvlwCcY0M8kLX0If4PdTfru2NlkrSp0OktMs3q4IUIBoSGp2vEJM xAMzlVCqcNW0Gan/gahQMbYXIEJ2lbBS+gd9IRdiVvkf4jNEU8wRII3oIZnytLxNMDI5KSy1H3zee sLZenJ1VXJ46+8uCYxQ4HLAjjC29JasMkEA47BPd9uk5vyyGXUAN8kDqdIWF9L19SHAYSnlDEOBAa PsQszYAKf8WM5mc2z9O96yQBCtBObogMpnT+MyjmAex4B/FlDju4z12HQBmrP/XMz61GkWc0Cgf51 KDAiIq0g==; Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmJDl-0000000Cp5I-1fMR for linux-arm-kernel@lists.infradead.org; Mon, 18 Mar 2024 20:04:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710792270; 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=bkYRqCLnM9RWDEZ70HtHvIfW8KDnj9D16fe0ACOygWrzCLnYO4NsX4VaM1Mt3nytRXoCuh cGYbO0W+uphvTY8CVY+x7qxb/5wQtoC5vV94rH5+cY8vfBhpz/ASJPmjqjchhVE/1iRUxR aJj0qR1v9eKXvGQ/QRvNXrkqa3meG/c= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710792270; 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=bkYRqCLnM9RWDEZ70HtHvIfW8KDnj9D16fe0ACOygWrzCLnYO4NsX4VaM1Mt3nytRXoCuh cGYbO0W+uphvTY8CVY+x7qxb/5wQtoC5vV94rH5+cY8vfBhpz/ASJPmjqjchhVE/1iRUxR aJj0qR1v9eKXvGQ/QRvNXrkqa3meG/c= Received: from mail-oo1-f72.google.com (mail-oo1-f72.google.com [209.85.161.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-115-j3aTsjvGMWGUCwN-SIrEtg-1; Mon, 18 Mar 2024 16:04:29 -0400 X-MC-Unique: j3aTsjvGMWGUCwN-SIrEtg-1 Received: by mail-oo1-f72.google.com with SMTP id 006d021491bc7-5a4aaa1bc96so479388eaf.1 for ; Mon, 18 Mar 2024 13:04:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710792268; x=1711397068; 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=dswhxQScwcam+XFVgjVLTNCZL3D1YNvPkHUFq/5okLV/jeRC9nrjhunJ2FmXQ6Ezcu UuPHQX07ZamtdvsnrmtcyKUz2v8lJ9sCqwftkOgoODK8tu+fQKBBFoFRtNrhtKwOZ9Tl cRX6aubTZZS/8367NzCO8mE3piDgKBecbNb3RmbGahlAJhY3VM+L08BOUYvkz5DTl4mq +QzZKMgvQTNAxBAEXXZBmG63FvgMvOAeXa0T9+D7kJUvhaBFlAtWv4aMMlUskLeEtQzl i7vV/U/xiKmrU9TjssWNIUzhH/1BfAFISbbGYH8u4ZSaB1zH3W1IPQ6POLoZ0xmj9s0V o1ew== X-Forwarded-Encrypted: i=1; AJvYcCXiOC2YJ4Kyc0WIBlsM0zuORL+z2qWcqrOO/37JSwQp/CWUy2iLwFoOQTV4hPWAdpeTYQjc/PuP60Bh0lL8TkRffSdskHBao9VuN4QTfj/gIde1tis= X-Gm-Message-State: AOJu0Yy4kFH8r4/Mg89TYLF2Mh5Dc3ZToziHIxY4QV16Ab/MrmzaklYp obZicqu2/6tFtKrCv89bUY/CIKNsvfA15wNfZJOZdfFfJ1kdj5a+ougWBH6mpHisbS/6+CI9lAn FqhFvF5E6ul3hXT6Y4moiY0KY7JT22zGn/uR7zj/YToaOqi2hu9xbW6LJdaTZ7ky27FMDXb5p X-Received: by 2002:a05:6358:65a5:b0:17e:b905:ae1a with SMTP id x37-20020a05635865a500b0017eb905ae1amr174638rwh.0.1710792268106; Mon, 18 Mar 2024 13:04:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGISjMhnC6jpMGGK6QBF7/frbKYlLqkW40smiDqxegPdY+XDqO7mpvYlvBe3yHbKZyIwRsTRA== X-Received: by 2002:a05:6358:65a5:b0:17e:b905:ae1a with SMTP id x37-20020a05635865a500b0017eb905ae1amr174607rwh.0.1710792267562; Mon, 18 Mar 2024 13:04:27 -0700 (PDT) Received: from x1n.. ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id hj10-20020a05622a620a00b0042ebbc1196fsm3484491qtb.87.2024.03.18.13.04.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 13:04:27 -0700 (PDT) From: peterx@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Andrew Morton , x86@kernel.org, Muchun Song , Mike Rapoport , Matthew Wilcox , sparclinux@vger.kernel.org, Jason Gunthorpe , linuxppc-dev@lists.ozlabs.org, Christophe Leroy , linux-arm-kernel@lists.infradead.org, peterx@redhat.com Subject: [PATCH v2 14/14] mm: Document pXd_leaf() API Date: Mon, 18 Mar 2024 16:04:04 -0400 Message-ID: <20240318200404.448346-15-peterx@redhat.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240318200404.448346-1-peterx@redhat.com> References: <20240318200404.448346-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-20240318_200435_580392_3655AB70 X-CRM114-Status: GOOD ( 16.38 ) 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: , 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