From patchwork Wed Mar 6 10:41:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13583873 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 074DDC5475B for ; Wed, 6 Mar 2024 10:42:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94CAD6B009A; Wed, 6 Mar 2024 05:42:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FDA46B009B; Wed, 6 Mar 2024 05:42:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79F886B009C; Wed, 6 Mar 2024 05:42:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 624676B009A for ; Wed, 6 Mar 2024 05:42:13 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 316E1140C2A for ; Wed, 6 Mar 2024 10:42:13 +0000 (UTC) X-FDA: 81866274546.29.AF745BE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf12.hostedemail.com (Postfix) with ESMTP id A8E8240015 for ; Wed, 6 Mar 2024 10:42:10 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GL254M44; spf=pass (imf12.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709721730; 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=20nNimBrOEQv87l0vyMx8t0O66X6ZMzRQtOERvnhrUo=; b=YR94ceFBua48EasnTIUZVEzyRNGMh0+3QhfO4SBXKkYksewab8hPsvcvHKCCvvFz1RUpoZ R1HqqqYIYj5yV4aRIEHeF3zT8XV9sW+QWHmZcTBWbV3FQwBlOf/ccFh06y9uw8K7eCVT9A VNwH7xH88aq7j3K+Hu4xTTWjm4Thjlc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709721730; a=rsa-sha256; cv=none; b=qISrNK0++zzozKOFlMr0zKKqmcOCJ7gbE1yGvdXBoByulCisvyBppazinDyO3HFbA11nhe uuvRlb7y0y5YApfOVZk+114fr7tPrmQvLlgcyotCwhhGa8WN8bj5RHQh2bYfPU/DchztkN OZkKuDlPEZNouqAanrbtt/J8nx6ut2s= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GL254M44; spf=pass (imf12.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709721730; 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=20nNimBrOEQv87l0vyMx8t0O66X6ZMzRQtOERvnhrUo=; b=GL254M44hJe8AuZDn1fsdC3oAjkAu5DsCgTDeDFgBeNi2HktIM3VY/f1uKGmdDc4g6zwxc nRG5J9t+amnMkhMdZikbtDiIaaKWT1SvWO6Y7if/lOPTkAb195nRHz9xOszvO0ekUc3d4b HnKHW+TZgsE3k4oPzl9BVWbRfUWKqG8= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-651-oo52lPpuOsCDdbHCtpeneA-1; Wed, 06 Mar 2024 05:42:04 -0500 X-MC-Unique: oo52lPpuOsCDdbHCtpeneA-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 C7D471C05AF3; Wed, 6 Mar 2024 10:42:03 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C2C5112131D; Wed, 6 Mar 2024 10:41:56 +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, Alistair Popple Subject: [PATCH RFC 01/13] mm/hmm: Process pud swap entry without pud_huge() Date: Wed, 6 Mar 2024 18:41:35 +0800 Message-ID: <20240306104147.193052-2-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: A8E8240015 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 1wrmps7ambfarnrhkncm7ko3j7nnuhzd X-HE-Tag: 1709721730-587190 X-HE-Meta: U2FsdGVkX1/3ovT1VGqBspRlKzhTzRV0NxJG5Cnd29MGe5dLidUTzUFpkO47qfMDkjHkGVh64pPAAD3XwitJXDd+3QECuvuDhdiWsoKRkU+uQLyvGi9hhZnoL3HtMJKTvZ61up+5QuIBoLGrTuGoDZMaiyV0nks3I1HwrJ0AfNlr+4zku2cjUrnPcx+aDJlIQrLf+42ayiqMciUF0oAlDu41CQfGk8rYTAVBPS5pqOa41EcNMbqzFwYsVk1yvmp8NKQqwmKxVJNc59jA7IsGzAZQXbS2tVB17h1+I5/z1CgzK2u/8TNJB1MPKECy3quzX3hsOgPcsVJw5sg8bDcKF97cBN/fDc9WH9VTnncfXsgzlIsnHvhfCWTxm0cFUatrsWQ7YBDLEDQkbVbBnZ9DOSjr6YpyXwQ4z3C+msgckeCVvj3NJSVUk08NNnFP4TraxGJ/bSNBP9+T7SEToMADcKxQZ+jvAIpl5cI5mb6yoPO4FwkZwItEhHdxfJMVjWya2Sh5NCfjkc50mZVc87WA1+28RmqXly8dwq/rsAto+toqQlr3GMDl44yD2TOCUp9xUvtgLEaIy26JHeMAJjfoJIt4oY/K8aHbMfJAHMBgSk5YNKjVtSYDKyIxPhyYNpzS3ng0lANQyklD8abjPfOM7DwOS6jAJAvB+fB0Vbmacayfftplwpl+v8m9buJ7MO9amEgtE6Cuxj1jRwEMcJDxLT6m9Ju6G7BfPjv6qVkSURmBP9DFACNAeOScv0lzoHBgU45DR90AwRgPrMNEZOljvrHu7Im0jph3rGRCKprnHtGEAUXj7TuISul5ytJCx5V5SKSuXm9yVulgk40T2TAVXOjdVVCnHpA4TbAbvNX+f1IV2hIcmVSZya98zGYGopuOyHCq2QorUaq+pYIbT53WxffmACebFLqNpPZME9bpJhK5VJBj5MRyzkdCRlXLqFOj 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 Swap pud entries do not always return true for pud_huge() for all archs. x86 and sparc (so far) allow it, but all the rest do not accept a swap entry to be reported as pud_huge(). So it's not safe to check swap entries within pud_huge(). Check swap entries before pud_huge(), so it should be always safe. This is the only place in the kernel that (IMHO, wrongly) relies on pud_huge() to return true on pud swap entries. The plan is to cleanup pXd_huge() to only report non-swap mappings for all archs. Cc: Alistair Popple Signed-off-by: Peter Xu Reviewed-by: Jason Gunthorpe --- mm/hmm.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/mm/hmm.c b/mm/hmm.c index 277ddcab4947..c44391a0246e 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -424,7 +424,7 @@ static int hmm_vma_walk_pud(pud_t *pudp, unsigned long start, unsigned long end, walk->action = ACTION_CONTINUE; pud = READ_ONCE(*pudp); - if (pud_none(pud)) { + if (pud_none(pud) || !pud_present(pud)) { spin_unlock(ptl); return hmm_vma_walk_hole(start, end, -1, walk); } @@ -435,11 +435,6 @@ static int hmm_vma_walk_pud(pud_t *pudp, unsigned long start, unsigned long end, unsigned long *hmm_pfns; unsigned long cpu_flags; - if (!pud_present(pud)) { - spin_unlock(ptl); - return hmm_vma_walk_hole(start, end, -1, walk); - } - i = (addr - range->start) >> PAGE_SHIFT; npages = (end - addr) >> PAGE_SHIFT; hmm_pfns = &range->hmm_pfns[i]; From patchwork Wed Mar 6 10:41:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13583874 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 56271C5475B for ; Wed, 6 Mar 2024 10:42:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1E076B009C; Wed, 6 Mar 2024 05:42:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CA70E6B009D; Wed, 6 Mar 2024 05:42:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B48A36B009E; Wed, 6 Mar 2024 05:42:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 978696B009C for ; Wed, 6 Mar 2024 05:42:19 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 598CB1A0DF1 for ; Wed, 6 Mar 2024 10:42:19 +0000 (UTC) X-FDA: 81866274798.20.4C3B7DD Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id BF465A001D for ; Wed, 6 Mar 2024 10:42:17 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GFsbtedn; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.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=1709721737; 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=3D9LYre9es5Pr/ZmF0ksBqg/v+REJVkPqwZxeVyu2sc=; b=0ME6JoL+XpyF/d7Lehd4vP1OyM8Jh6cVFOBIeE6YjwuegXH0lOaXYL6icANMcZ1hD75NY8 XoyTX0WJqIzwb+iVK0S5ErYXMTzSDzO7XEhPXYUNUsiLActFI1TRRTnFuE0b7Yk600tFdu C2iAleWQde5yB1BT2eAVFgSVFqnBpcU= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GFsbtedn; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.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=1709721737; a=rsa-sha256; cv=none; b=Xt4HzzgTCLIcAdLyfnB22hjgbv5cc2ZO2UCUkQjeH+nyElV9XAOEuPCo7UzlEBIzVPSFpG OGBxK2dYEfcBcEbNoWYe29GPUoCKSij//JQVVFlfiUoLGTj1ekwJUWdYYnT0L2E1TXu/n7 xGIRqIsrVl1/Paic2eaBE6Y/QcfERWk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709721737; 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=3D9LYre9es5Pr/ZmF0ksBqg/v+REJVkPqwZxeVyu2sc=; b=GFsbtednPaA4KzBXKK4uD2Jr3QnquLYWokFhihg3yKEZtwQz5lSCOeMM1En2bXVZdG+B3O bb3sSycZFo37y/kkG824fNpqyHd1nXYKC+TxucQVFov0onk9xFv4J9OI6wv1IL8KTgK3zu FeQB+z2QRO/C1H2pcyjNHtQnuBvN+hE= 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-158-uC-oagQgMFWs_CgooWNVxQ-1; Wed, 06 Mar 2024 05:42:11 -0500 X-MC-Unique: uC-oagQgMFWs_CgooWNVxQ-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 D81EA8007A2; Wed, 6 Mar 2024 10:42:10 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 97C19112131D; Wed, 6 Mar 2024 10:42:04 +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 02/13] mm/gup: Cache p4d in follow_p4d_mask() Date: Wed, 6 Mar 2024 18:41:36 +0800 Message-ID: <20240306104147.193052-3-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-Server: rspam09 X-Rspamd-Queue-Id: BF465A001D X-Stat-Signature: naeceea4irde6oc9phyhhkzmmnj56nq6 X-Rspam-User: X-HE-Tag: 1709721737-307520 X-HE-Meta: U2FsdGVkX19fd6oVEOcDKRL2H6adZcGw7p/Br+R8uhz3j9V426yMFvCiPw49E3JBDNRRQ+iPN6leTNsLEI47ilSHKgjIJ6K5Ltg21Ul/CZ+eeZKqJoIJST+0BaXiRbnT4En2aaU7LpeFHavIgXeApPnue5FUR4Xl0i+izRBF8RumYUviRFnrLwaO3J6F6dg87U1x7xD+QeVYXVmNZ2PZz+HfRipokM8CW6DYVeFLXkDm1qcYoUfVtP1aqr4XtrVAiDUB63KCsPi7+RAokGvOylqZJ9yJmcqBZBkY2HUTI+fc/Bii5IG2fbVW/BWIuHrJ4W6Wvz8tP/0om0VubeGeKBSRyIf7DFS6iUpPGkkTbKKfsnDXvXNJMZ1JlkcYgeLSLdC6M+AMIExN0WIqs7Z5t/5RRfbw3CI556hJVC9AqfswblZTz/+WKsNKLLSabEovQBhJ4RYxO3Us4rk1AyQmGbbFSLbOOoLD2RLiB7aVeC9MkAP2N6fY5r6c8IYmw81xukEeftQk3I/ZvuQrX4mFSX/Qc0YMIoSOJpXqWEIlzLJfv/7fCZF2hEFZGFCws+gkZQuHJqHEKmKQO/NgrhxnNsQqgfYnUips5EscpfnY18Xbrt/rDThu+PoOq6/gafJ/LuUOYlD8j7UdVV+I5OyMa5qRmA9lwyrpCPw0eoHnAyTu5zSL083zcTwpI67Okq6Zby6br/TJPBjGtMwdECCA8d/VEuu7bohDeKdZ+N5A0LAjglmFhZc1YRXtM+Lng4wwzdUyy7RhRhSxTOf94tRVGv51wCGALe27cp1Ali6pL9GoAMzqu8N7R59gXLEPxU07wA1gsjHjzf62UYSTpN0XiK4zXOuWsbOby/HM3JSzKPWk7CJm2W+r7tdm8Zqaq7SqdYu7c4ZnRlIbBTEg4Xhpzt+GcvYrceeEiazaawGvE7XSn8xivyM3Ss/XzbtS+Ho+ 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 Add a variable to cache p4d in follow_p4d_mask(). It's a good practise to make sure all the following checks will have a consistent view of the entry. Signed-off-by: Peter Xu --- mm/gup.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index df83182ec72d..69a777f4fc5c 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -772,16 +772,17 @@ static struct page *follow_p4d_mask(struct vm_area_struct *vma, unsigned int flags, struct follow_page_context *ctx) { - p4d_t *p4d; + p4d_t *p4dp, p4d; - p4d = p4d_offset(pgdp, address); - if (p4d_none(*p4d)) + p4dp = p4d_offset(pgdp, address); + p4d = READ_ONCE(*p4dp); + if (p4d_none(p4d)) return no_page_table(vma, flags); - BUILD_BUG_ON(p4d_huge(*p4d)); - if (unlikely(p4d_bad(*p4d))) + BUILD_BUG_ON(p4d_huge(p4d)); + if (unlikely(p4d_bad(p4d))) return no_page_table(vma, flags); - return follow_pud_mask(vma, address, p4d, flags, ctx); + return follow_pud_mask(vma, address, p4dp, flags, ctx); } /** From patchwork Wed Mar 6 10:41:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13583875 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 B667DC54E41 for ; Wed, 6 Mar 2024 10:42:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 507196B009E; Wed, 6 Mar 2024 05:42:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4B7AC6B009F; Wed, 6 Mar 2024 05:42:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 359336B00A0; Wed, 6 Mar 2024 05:42:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 20C9B6B009E for ; Wed, 6 Mar 2024 05:42:27 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id CD307A0B8C for ; Wed, 6 Mar 2024 10:42:26 +0000 (UTC) X-FDA: 81866275092.06.0C3D110 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 205CB40006 for ; Wed, 6 Mar 2024 10:42:24 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="XH/CyYsl"; spf=pass (imf01.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709721745; 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=1JTq1zOoPcvZLzyDHIG6xTSG66u1JMVbpFEt5kpx07M=; b=7xIF4ySfHLQAAI3qd2YGXFGTosKIN9wVgiUIAWUihhWP50Qw5r2uS+yoEcY5nwWTnPdqh4 bw0AJTPq/2wuMgTaalVYpQ9v6hCcSPsUZvuEHQNRJy8rCh9p7GfJvaVdenEv7H4ywGrQqk QcnrBAMY6dQgChTv15t7nPuN/Vgwv+c= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709721745; a=rsa-sha256; cv=none; b=boRfWm2CyCLWLvdeeV7UR/PHUuIEfFX1YajMQslAzcIpgsdRQLSVzGHoPKzmDctdK161en 6k7kdS3X+wYcUFiYZlGgGCR4XJ0GlvBoarWeTItiCBsxTasRSq5v4dITnjgNIlLcrHrMiM ANdRavzMRpAO7CTSbEeu9cUI4y52iiU= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="XH/CyYsl"; spf=pass (imf01.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709721744; 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=1JTq1zOoPcvZLzyDHIG6xTSG66u1JMVbpFEt5kpx07M=; b=XH/CyYslzUhUiwZa5q9LWSJSx1XaUejmTPGU6RHS3o+G2O+pG07eLCIjftNysD4GUQBgdL htrkhv23yOVQu6c22PxeESGPut1HEmtveHXmMQ0/iXt2afq51ICDlIqyHzM7Mw3zve3iyK lDf2hhhCkPrJ/ZTL6QWWfbMpAP4CTcM= 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-630-w92BStQdNuqU_EljwB5_jw-1; Wed, 06 Mar 2024 05:42:18 -0500 X-MC-Unique: w92BStQdNuqU_EljwB5_jw-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 6AC0E800267; Wed, 6 Mar 2024 10:42:17 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7360111E3F3; Wed, 6 Mar 2024 10:42:11 +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 03/13] mm/gup: Check p4d presence before going on Date: Wed, 6 Mar 2024 18:41:37 +0800 Message-ID: <20240306104147.193052-4-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: 205CB40006 X-Rspam-User: X-Stat-Signature: 16twokg5141sdniwrzi5ipkert4dxuq5 X-Rspamd-Server: rspam03 X-HE-Tag: 1709721744-523378 X-HE-Meta: U2FsdGVkX1+ra/05keMhNKGb72K8DUUmS18RKkiO/G2WB4SJgJPpbZG9YaJnUcFkow423b7XRRsQhJ7VjMkEzO8fK+ufAgVtBhdZlLyPjJTEzRkYXn09YKeTdvdfxYIwIONjq7IRKkkaJz5vRRQ2SunemqJFLuNlhsQSmzSQ/rgQ/8z841NByNuwiSVQ3pCy5RnEP+7krzP3wjtUkycED9HtGANHwXhfaB5CNu/iqpdVowSeNVU5XFsmuN0Y6bdw6kUPBPK+YeWWgQYr3Rrphv0RumaSc23kslNktqVPoIW5VKYag4N+B19cjwSp4aGNk8YO/chTKvB/THDEGhXfjbPCZ29t2Btu6wXwogOu9e4MK6Dg2ZCIEgmTDN+aiDV3MZ2WHe0FS9N+JI4ihR76rP9m/jVylIXP/aNHhkeIrmwg+moy+ebtzgc/79Z5JxLF9etQE+IpwQt8zj4qNsJeFUxhf+pOKlOSYdG7bEZwP1qgTUXdMGZ7HzyDOSF8KlcWrKI+aA3Y++HyyUIwQOU09vBoE4B9Z3CMW47Ay8gR29lyJPDOh3mbD1Z8jZbMTXBuU5O3XlMON5Bma0U82w+Qr0XbY2rTCHBt/Ieuh/CGMbLtgye3+x6zBTMqfLX7Tf3YsLZ6IxeMp7j3/cle0o/QwKH/FpawLm/o3JKcRyQfjM5qIKfDtVpHKSa99hGkXRjmsGqaIDKbbvRIPCv9FI+g6ITVgQXK7jGDWiGD5llLLZUZr68HsQMt23sv4RiWJiz6pmAF43wf982CRInQ7KfeBvkbanvsIL7kTPwCR2xWyJ43bPkpL8hRMQQ1GSTJnNmiVLqHRDaoxLxy49uPr/vgJVJvnFJGhOHNY8gg4tqK1o4mp1JbXigfS91OGvjNoi9dPQlseexx3L4ZiVRTEU8sOmhKFWlgsYNWt2QVVlacFk4Fnrj4CacmgDVQVojKF59NbZzQf92ldcVf18ApCTW HFh4KS0b eI+4OsBq7MeDZn9OQw/5EovwGUTneDtRLPFXREksdQXPTyOlNAyUfvxFn71bzs6UjQcbeXvOMPEO+baMGmm0nW/lt+MJM6Cu9IcA2SWV46zTZs1XjuWEpoPeuZWyVT9Bb99Uw/2C544jdhIlcZEtoXNiCySFQ21KiWqxGY/ykeaqYdEE= 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 Currently there should have no p4d swap entries so it may not matter much, however this may help us to rule out swap entries in pXd_huge() API, which will include p4d_huge(). The p4d_present() checks make it 100% clear that we won't rely on p4d_huge() for swap entries. Signed-off-by: Peter Xu --- mm/gup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 69a777f4fc5c..f87a7d90f2ae 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -776,7 +776,7 @@ static struct page *follow_p4d_mask(struct vm_area_struct *vma, p4dp = p4d_offset(pgdp, address); p4d = READ_ONCE(*p4dp); - if (p4d_none(p4d)) + if (p4d_none(p4d) || !p4d_present(p4d)) return no_page_table(vma, flags); BUILD_BUG_ON(p4d_huge(p4d)); if (unlikely(p4d_bad(p4d))) @@ -3069,7 +3069,7 @@ static int gup_p4d_range(pgd_t *pgdp, pgd_t pgd, unsigned long addr, unsigned lo p4d_t p4d = READ_ONCE(*p4dp); next = p4d_addr_end(addr, end); - if (p4d_none(p4d)) + if (p4d_none(p4d) || !p4d_present(p4d)) return 0; BUILD_BUG_ON(p4d_huge(p4d)); if (unlikely(is_hugepd(__hugepd(p4d_val(p4d))))) { From patchwork Wed Mar 6 10:41:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13583876 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 6461EC54E41 for ; Wed, 6 Mar 2024 10:42:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA3B96B00A0; Wed, 6 Mar 2024 05:42:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E537D6B00A1; Wed, 6 Mar 2024 05:42:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CCED76B00A2; Wed, 6 Mar 2024 05:42:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B39546B00A0 for ; Wed, 6 Mar 2024 05:42:32 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7C941140C4F for ; Wed, 6 Mar 2024 10:42:32 +0000 (UTC) X-FDA: 81866275344.06.682BDDE Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf22.hostedemail.com (Postfix) with ESMTP id DC155C001A for ; Wed, 6 Mar 2024 10:42:30 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VRjm1fdi; spf=pass (imf22.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709721750; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=vtZJyICZEGrBJHpYWSu5beimQ7UmPGzVa4S5UCB/Dcs=; b=xAUkvCXEq7Rg0pMtXxePJBdbB3xQB4SFjWYb5ptk+P1RoJ0CX/0J9Cc8jGVRJm5snaV681 lxhsV/TM4uQs9MlZZ41QbbDw6lAqFZBf9IdrnzSvaDXer1uO+/LOjKfAQnP31WsnzanRK+ EQmb8q59x1SZvMJZZE2HBoolItt9gt8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709721750; a=rsa-sha256; cv=none; b=qcnmU+rNF0dvJilOjblvPjvAMOEPAak7z1FiQx9J0//7LGk3X8aIsD++uEgdJuRPpC2AwF t3OPx3ciFszpI3/INInUfcjs2KHOfEsSB8ANrEuXuOnc6AO6AXC4PZcf7d+sVa3nUeIGeH Xq5A8kefA4RdGJmX/VPb7QK3Zwh9V9M= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VRjm1fdi; spf=pass (imf22.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709721750; 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=vtZJyICZEGrBJHpYWSu5beimQ7UmPGzVa4S5UCB/Dcs=; b=VRjm1fdi9IkjkEYwRTvp3lQqzyJKLYUGUs7D0K5tF8+0MQOJ8Blf4Uq/jnwHJSv8lBach3 Fm6jcvee1YDSWtw+GWZ+F7DwpVfOz5VLXBIkWMGyvLegp9sQ7Q9kSZJxmhOXQ1mAGj25gH 7jyWP0ekFp+V5COySdFO+W3snmuhmIY= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-543-pSuV4CgQPZqjr3JAlJcBuA-1; Wed, 06 Mar 2024 05:42:27 -0500 X-MC-Unique: pSuV4CgQPZqjr3JAlJcBuA-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 22C123C0DF60; Wed, 6 Mar 2024 10:42:26 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 252A3112131D; Wed, 6 Mar 2024 10:42:17 +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, Naoya Horiguchi , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen Subject: [PATCH RFC 04/13] mm/x86: Change pXd_huge() behavior to exclude swap entries Date: Wed, 6 Mar 2024 18:41:38 +0800 Message-ID: <20240306104147.193052-5-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: DC155C001A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: mo4wpqej4toqqq8uzcdfxkekwuindhh5 X-HE-Tag: 1709721750-724240 X-HE-Meta: U2FsdGVkX19zNzl32lD5E0/KwUi5EMQ73LxCDrMSuZwZ+gZqH0GoFzdWEFX8k13my2qTZU0/Ur3SZRFN/xgmOrFMWmpOXBb9UpMJZPnBmrsNKosXyO8xBmLjGwtrLZ6FEwRQbSDTfijs5xNKsWGImXhPYpJH5HyGxr6k4fm2D7CSO79zQvynwwXwv2qHlClhXxEDm3EsJMBZdHDlUNc15rVYIId1O6yqkMfe5gLurfV0kaUrbjBclSsgJOrnMj+rIhyxVySIsmvJkAeIALGcNmb1LsdJts8oovfBZaaS3RLNWHc0p6PRC/+NadrzTImTxM0w5qf8BGZsubmDZBLlNOI/fg1bnL95871IQPIsld76fTtP0bSHpwe0+zz47lQRQfWycwACzjVmE+ihNh1DwhXZalKFH+28070YjektATRzmpU8h4p/GCg7IhZEAOhnP7zLg/znkcJF6Tr5ZWVeI+bfjcxHNvZl4ndIEvIWAzAJ/ktLuPXRKrZJvkX1JpiYhv60XMCAMQSmElANCTFQ0RniWonzZ5SUQy30W4oL3HR4S4zPRsH5LzmzOVXEceD9r/gxnD8Gp+/uaCrb8kcfYr8SkY5ao2wgrx+k6YwvYpjEH+a8RA7eADIaZljBmRN8y8xoP8YO0BQA4SyHUQGio3bBcpY6QM1H15oT8spAij7gCM+RV9fhLGTeO88XPY0yYcRHjPL2fLKDSsg/H6fHGBE4MLeOs9VJgpSCFD9hUb+COzPSPR5ftTg7iSDwMhnCe8XwbG2dgDIuWCdFT2RqTKqABjZIOmqof4R2uxvDZLxJNuYWzB78jldNhawN4B4Wou0TEjdHy1sBez4Tg/VMX5S1rj56VQNyrHkgGfD8YpUi0k9kNG2JJPf2fl+UAcAZprih/StuJ4H3oSTpi5T538s/ITII+E24 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 This patch partly reverts below commits: 3a194f3f8ad0 ("mm/hugetlb: make pud_huge() and follow_huge_pud() aware of non-present pud entry") cbef8478bee5 ("mm/hugetlb: pmd_huge() returns true for non-present hugepage") Right now, pXd_huge() definition across kernel is unclear. We have two groups that think differently on swap entries: - x86/sparc: Allow pXd_huge() to accept swap entries - all the rest: Doesn't allow pXd_huge() to accept swap entries This is so confusing. Since the sparc helpers seem to be added in 2016, which is after x86's (2015), so sparc could have followed a trend. x86 proposed such swap handling in 2015 to resolve hugetlb swap entries hit in GUP, but now GUP guards swap entries with !pXd_present() in all layers so we should be safe. We should define this API properly, one way or another, rather than keep them defined differently across archs. Gut feeling tells me that pXd_huge() shouldn't include swap entries, and it turns out that I am not the only one thinking so, the question was raised when the current pmd_huge() for x86 was proposed by Ville Syrjälä: https://lore.kernel.org/all/Y2WQ7I4LXh8iUIRd@intel.com/ I might also be missing something obvious, but why is it even necessary to treat PRESENT==0+PSE==0 as a huge entry? It is also questioned when Jason Gunthorpe reviewed the other patchset on swap entry handlings: https://lore.kernel.org/all/20240221125753.GQ13330@nvidia.com/ Revert its meaning back to original. It shouldn't have any functional change as we should be ready with guards on !pXd_present() explicitly everywhere. Note that I also dropped the "#if CONFIG_PGTABLE_LEVELS > 2", it was there probably because it was breaking things when 3a194f3f8ad0 was proposed, according to the report here: https://lore.kernel.org/all/Y2LYXItKQyaJTv8j@intel.com/ Now we shouldn't need that. Instead of reverting to _PAGE_PSE raw check, leverage pXd_leaf(). Cc: Naoya Horiguchi Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: Dave Hansen Cc: x86@kernel.org Signed-off-by: Peter Xu --- arch/x86/mm/hugetlbpage.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c index 5804bbae4f01..8362953a24ce 100644 --- a/arch/x86/mm/hugetlbpage.c +++ b/arch/x86/mm/hugetlbpage.c @@ -20,29 +20,19 @@ #include /* - * pmd_huge() returns 1 if @pmd is hugetlb related entry, that is normal - * hugetlb entry or non-present (migration or hwpoisoned) hugetlb entry. - * Otherwise, returns 0. + * pmd_huge() returns 1 if @pmd is hugetlb related entry. */ int pmd_huge(pmd_t pmd) { - return !pmd_none(pmd) && - (pmd_val(pmd) & (_PAGE_PRESENT|_PAGE_PSE)) != _PAGE_PRESENT; + return pmd_leaf(pmd); } /* - * pud_huge() returns 1 if @pud is hugetlb related entry, that is normal - * hugetlb entry or non-present (migration or hwpoisoned) hugetlb entry. - * Otherwise, returns 0. + * pud_huge() returns 1 if @pud is hugetlb related entry. */ int pud_huge(pud_t pud) { -#if CONFIG_PGTABLE_LEVELS > 2 - return !pud_none(pud) && - (pud_val(pud) & (_PAGE_PRESENT|_PAGE_PSE)) != _PAGE_PRESENT; -#else - return 0; -#endif + return pud_leaf(pud); } #ifdef CONFIG_HUGETLB_PAGE From patchwork Wed Mar 6 10:41:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13583877 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 EF903C54E41 for ; Wed, 6 Mar 2024 10:42:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 864466B00A2; Wed, 6 Mar 2024 05:42:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7ED0D6B00A3; Wed, 6 Mar 2024 05:42:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68CD96B00A4; Wed, 6 Mar 2024 05:42:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4A3AB6B00A2 for ; Wed, 6 Mar 2024 05:42:45 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 1B4EEA0EA8 for ; Wed, 6 Mar 2024 10:42:45 +0000 (UTC) X-FDA: 81866275890.25.5E66D3E 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 6539E4001B for ; Wed, 6 Mar 2024 10:42:42 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=R812D10y; 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=1709721762; 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=dXyJDuJosTa0kFBnhKvW1aqbtapsaxz0OHU+bPr+fnc=; b=vCp7GDiS+e39a7BBwVAWpiYc9k4zVO36Ua768L7PMv7wxxO8WHq4RKJ0Z6C7JiVF8bf6N1 cF4F7saGm50a+XmKFLT877LBRFXzEiyThM1jk2tk4Xl0XYxLbdLegTp6oJ4zycOpR82k57 TphodOnH7o2V9YIIF86ZiLllcdoJPlY= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=R812D10y; 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=1709721762; a=rsa-sha256; cv=none; b=qJdeid+J2K2T0a9s3QyEXa2rz3T8jrEfcJ0lf/z4Ghre6/voEGiuBG+Bw0v0xJne2FgWHE A028ODXBfkbX4gy0og3X+WLnlM/ZHn1naQ5clAxeAj/VMPQnDBrQppPp1yrvRw8D4vdzFJ v0n7RPTrp6CZ5b9cXHlXAXF7leDrS8s= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709721760; 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=dXyJDuJosTa0kFBnhKvW1aqbtapsaxz0OHU+bPr+fnc=; b=R812D10ytOvKsfCtDnbpm/T6YR68+MBQ1r43EzdYjP+WBKUFNYthJ5Aqv3kowBtaqHFMo6 1IHZHQS3ku8Je8vAK36216oTx+1yqVfjFEjFI9zzRq5juMNkGVrZ2X/VrtrYPDBperyYx0 vcYHC5lB3Ok/pPWAJ2n+xzpdpAZK81g= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-204-DuM7_ICQNPWc0Qhye-aEuA-1; Wed, 06 Mar 2024 05:42:34 -0500 X-MC-Unique: DuM7_ICQNPWc0Qhye-aEuA-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 068C21C05AED; Wed, 6 Mar 2024 10:42:34 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id D10DC111DCFF; Wed, 6 Mar 2024 10:42:26 +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, "David S . Miller" , Andreas Larsson Subject: [PATCH RFC 05/13] mm/sparc: Change pXd_huge() behavior to exclude swap entries Date: Wed, 6 Mar 2024 18:41:39 +0800 Message-ID: <20240306104147.193052-6-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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 6539E4001B X-Stat-Signature: ameyx38zbjzrkx8fsa9qng5fu487c1ph X-HE-Tag: 1709721762-404115 X-HE-Meta: U2FsdGVkX18wL/kXmhte+9FamnSIvQZwaMjqF8MLloTD2fh0a+/XLEOooLr+f2izqUDdjEx8vEnce2T4+OY5rI2OgF5nB2kGKRg6eyNX4fvcloNAKtbzntBWyN8KSgYfC9h7xRmULEtlb9v1oautPwy3HNvV3dPnpEKVZO8GZNx/UP3dgGg0fBTMC/EOMDss2nsnCQPV16jnbS/L9xwAvf4glnE1RL8PkdXzFMe5u9/7WggOW1vrvvRdmTp02ZeT0Ywl57WT4jwPrTFQjrT3GZ8m2PJ19Fc8pf8WljokCNvNU2dJucBjulHRcKsW6EMDyb65JqktX5n7RmNbUP2wlMD6VEY2NePi1wq6GJTw1Eng3Q5GNNVYZB/cihfACk+cS+TeKyhE7ioB9+3mMA8vuItUoFJswqTsP/Xqxi2QbTwFJ79NU9w1B6SXeKEmBydxnDc/qMTezolAM83nShVxzdRsfjm/Kn1BetRvEx800+6UiNF4ddfdNpfeRTdycsCjTLzylXZgOQf7mSgOGHUx4um/lUBD+2Ju5f5Cl1PJ8TRsHn3TdyAn0625PV4oyHdt+dpXG/CV9dUnHMjG1r19K+Hs0Lln46hFpze189ulN2Q4hD3A6cM8PtZjGlKioBDJPaIoPRSKbKxGSUxmX11ZmxGuQjNQAy6VXXBTHRpW76x+fp6LT2ddScufc4qlA91APx9vHVdVDptyxGMGcDQm8iRaBT/2WciO6d6J8+QGT1vLO9jBpf1CsrwYnUes9Gfn2gA6Afi9VWJC38vXmtfQHgUX6ETrHe3GHJhoLwuRGLS7zEwvYheOIvFZM2V2ZvL2WIwMSb1BVbwhev/OXxP6SNG/MZ/6tfZULH8rg+GPp2pjEOb30v71mR9s5rCE2y6kxEZIRnfPwfq7VFvtp2vgA0EQuosoKl52e56QmRzXjd1/y8GwX8Pp2inJKs41kcACW6EC3p73dXoaeoeMhUY xZs+/NJz F7Y3JA6YniaAwu/r+p+c0PSwAeT0yEWeQe9zHDExNqk/cQgH3qAj19pnsVBaR1JB3aZMDro/jtCNq0mNyZNaeJ1jIkaDdRNi4594/h2q3qxkSODz11m9rOjC/Paizp5GBtiCqTf5XAZg1b6QVffpXjh7isXi2x4rOu/q83un3/0FctYZ6vmgKe3PiXd2pf4//WaPLbAHwgEAdDYQ9wkcufhyvTO29JCzQx495SqtbHLZNaVZoVEUMnxySYddwsECytkAuiNSZf9Q097Tir2bL8fygYrLvkEC2BEwA4fo/lJJNYsaeLnHodD0zFgaGFIZgxAXTF9Y9nNFImFFjIkepCXN4RUY5l59QNb+lWw/MXoqnlwe+hig+d2ZcHPFGT1tQ9WzWh3BEE8/AOQ8= 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 Please refer to the previous patch on the reasoning for x86. Now sparc is the only architecture that will allow swap entries to be reported as pXd_huge(). After this patch, all architectures should forbid swap entries in pXd_huge(). Cc: David S. Miller Cc: Andreas Larsson Cc: sparclinux@vger.kernel.org Signed-off-by: Peter Xu --- arch/sparc/mm/hugetlbpage.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c index b432500c13a5..d31c2cec35c9 100644 --- a/arch/sparc/mm/hugetlbpage.c +++ b/arch/sparc/mm/hugetlbpage.c @@ -409,14 +409,12 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, int pmd_huge(pmd_t pmd) { - return !pmd_none(pmd) && - (pmd_val(pmd) & (_PAGE_VALID|_PAGE_PMD_HUGE)) != _PAGE_VALID; + return pmd_leaf(pmd);; } int pud_huge(pud_t pud) { - return !pud_none(pud) && - (pud_val(pud) & (_PAGE_VALID|_PAGE_PUD_HUGE)) != _PAGE_VALID; + return pud_leaf(pud); } static void hugetlb_free_pte_range(struct mmu_gather *tlb, pmd_t *pmd, From patchwork Wed Mar 6 10:41:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13583878 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 94308C5475B for ; Wed, 6 Mar 2024 10:42:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 074D26B00A4; Wed, 6 Mar 2024 05:42:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F41A56B00A5; Wed, 6 Mar 2024 05:42:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D91E16B00A6; Wed, 6 Mar 2024 05:42:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C07EC6B00A4 for ; Wed, 6 Mar 2024 05:42:51 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8E0B080BA4 for ; Wed, 6 Mar 2024 10:42:51 +0000 (UTC) X-FDA: 81866276142.16.C91712C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id E61D4160010 for ; Wed, 6 Mar 2024 10:42:48 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="OqK/Z0pc"; spf=pass (imf08.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709721769; 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=PXv9WADGZnpW9LG755UO1HRR+yBh/xYRmZG+iRDILn4=; b=JpvVnIbOGuu/HN9zHH/x8plnsf2vkDkq9YpTNaMkH6p8UhK0jPWG70rcBYdciDe+9gpmfV iKbZuEVyI6q7stJQvUGrZY6ufPJhu5/O1ZRhEIYosS+Nv8hzpfpi8r+N6r9FOB8EaVO44z BplNcUXQc4m4jFKDXEP3/4FB1LBq1NQ= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="OqK/Z0pc"; spf=pass (imf08.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709721769; a=rsa-sha256; cv=none; b=pt8DYw4nuDL9IHHeJZrAVoYfwtW02jgDQSmqHiCeXRTBHMR1AJyTdxlpBk7LWIGXQo0vwZ piW+Z5IPQE2A9BipzmyeSyibpM4k+b4kdBYOUee60emLjfY9nNlv30u6BaqIVEmYdeb0nn YJSm3mRqhFM0aOjdgbkjshYO05YAufE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709721768; 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=PXv9WADGZnpW9LG755UO1HRR+yBh/xYRmZG+iRDILn4=; b=OqK/Z0pc0AxhAWE3xo5vR9PG1pnkVhfAX9M3chFmT3wvd11iEjxeqcwDcGQB7bfWWoxdAQ GVEaDEOGki4DtnNt+FRAx40MwwuW04H5/KJgTB+a0F9UJwMSVscizt4gbZ9CGbDen8+jTE fCeQcrzfjpCjOqEk3UvPgNuVX4fRDmY= 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-624-Wb-frT--OHqzyYxRKxeqiw-1; Wed, 06 Mar 2024 05:42:44 -0500 X-MC-Unique: Wb-frT--OHqzyYxRKxeqiw-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 E994B10189AC; Wed, 6 Mar 2024 10:42:43 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id CA310111DD02; Wed, 6 Mar 2024 10:42:34 +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, Russell King , Shawn Guo , Krzysztof Kozlowski , Bjorn Andersson , Arnd Bergmann , Konrad Dybcio , Fabio Estevam Subject: [PATCH RFC 06/13] mm/arm: Use macros to define pmd/pud helpers Date: Wed, 6 Mar 2024 18:41:40 +0800 Message-ID: <20240306104147.193052-7-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: E61D4160010 X-Rspam-User: X-Stat-Signature: n3gx5weuy4ox1k1b9uhcca8g7ecodtcq X-Rspamd-Server: rspam01 X-HE-Tag: 1709721768-996944 X-HE-Meta: U2FsdGVkX18czduhvcK5ERQM6Qm0HSLJIwAMaC/T2+c/YkwHYMJ55TWGsStxpsPsThuvFZS1RZ6a6SNiupkTKyhT4FgmAK/wgGunaqu5xoAT1lSPy5so9vsTaAPrKAxcq4tBV5PCws2fyN3oja0DXVpxuY0I2EbfR29N+j4Qm1rtfn5Z0FeXXRlFNMi+kTOzBeO1i1Z3+IblL9GQhZ8efVDY4U+EDbau11P+7Axs3e5Es+8WlZYvvqubtPCyM9rHlFp2Rr2JKpWJfy24cYTkMWWWnBIQmVkj9sQYAIU+xVNM/I1uZDTh9EIEiWzphnTipuFsJIsicPt6Vi0GDLhm42e+IZJh/fHzqqxgb2CcM5/z1VhLYVz6ut2LFsnpUz1VyNjO+X/nMfFKp0RviGyYNxyn24WGMidm/SZNl5ETnh7RN1UiSWkYFD+C2iBQuc6GbUXJAgGvEalK/vx8v/opMioYg2CyJSDP9SjT8jumLTRqh0ICXEMDY5O7Acz9v1bc+S46B7jeoEhPUcGXT65Dy+jCT6nAR42jY9mGgU5y0WRz4yFMRuxtruNHwpoP+qD8X/DDiiccEB/5TKXzKjThClC/UY5W1KapbJqeh7ebqQomFMFG7TWW7JQGfhnAHntBur0KMmoV1OrViNYPY2Zdkc5CDnzVEweG6IOA04Z3Zs90fKcPrNoC2lFoubeCPLgwMtzPINeBP1EWTV7L4nDiAn5bemSZqQQXSLcY6/nernnVa6PJRYGRhkn9UmsRIQbBloznT5StxbUh0NQ8HxdsMumA2YyNsGlUi9+LtAnvtXyadOf/ozsv+QCK2AlQJApXXDIJXIELubNL77DktpzaH3feGA8aIuho1Xyjyz+jQ3AIMIvbPhb9Xdt1bmW3Ym3Arj7DbAlPERXxPvmqtIKqFF6d18vgKD/fAltX9oyF3ejcZTsn1d9X7l1xlRYdQSRRTejwimZb7csxx12TPym uveg7OCY V0G6Nmh8XWsGK+QuSGhm5Q1sIa/6NHexFWSAVer8hEkG593C8J4S49LVQ00JIRUgYqUiyUVl+JACsH4onHUS+mkvgP9ZdHk7myLkZmKmsJon1ebKBYLNg622QZU/mY4hyzbq3uMlTShBo8x7yysZz9zkUzwQe5IFw4wFjFVgr1oTqvKtd2uUid56b3o+NcEV5MEkKWZhZ1fi9ySOmpS3QZ56x2hg1ui1XdsTYJTjiStiqYPIp92bpQZzDmAtwe4AfOugMmay8ppt1JKoZk0OXmlHt0bg1crtWN+JzN1U/ggc9MRB9Vnm0/WcvXteci7A1lUrO4Stz6T345zFIra34v6z08vpJkVlXHeHWBu0s/eizI4mp1LAv7t6E8KQzLxJDGdiuZXleyLGSGGi+aAhWkU4WyGMA5esn+1H5 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 It's already confusing that ARM 2-level v.s. 3-level defines SECT bit differently on pmd/puds. Always use a macro which is much clearer. Cc: Russell King Cc: Shawn Guo Cc: Krzysztof Kozlowski Cc: Bjorn Andersson Cc: Arnd Bergmann Cc: Konrad Dybcio Cc: Fabio Estevam Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Peter Xu --- arch/arm/include/asm/pgtable-2level.h | 4 ++-- arch/arm/include/asm/pgtable-3level-hwdef.h | 1 + arch/arm/include/asm/pgtable-3level.h | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h index b0a262566eb9..4245c2e74720 100644 --- a/arch/arm/include/asm/pgtable-2level.h +++ b/arch/arm/include/asm/pgtable-2level.h @@ -213,8 +213,8 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr) #define pmd_pfn(pmd) (__phys_to_pfn(pmd_val(pmd) & PHYS_MASK)) -#define pmd_leaf(pmd) (pmd_val(pmd) & 2) -#define pmd_bad(pmd) (pmd_val(pmd) & 2) +#define pmd_leaf(pmd) (pmd_val(pmd) & PMD_TYPE_SECT) +#define pmd_bad(pmd) pmd_leaf(pmd) #define pmd_present(pmd) (pmd_val(pmd)) #define copy_pmd(pmdpd,pmdps) \ diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h index 2f35b4eddaa8..e7b666cf0060 100644 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h @@ -14,6 +14,7 @@ * + Level 1/2 descriptor * - common */ +#define PUD_TABLE_BIT (_AT(pmdval_t, 1) << 1) #define PMD_TYPE_MASK (_AT(pmdval_t, 3) << 0) #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0) #define PMD_TYPE_TABLE (_AT(pmdval_t, 3) << 0) diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h index 4b1d9eb3908a..e7aecbef75c9 100644 --- a/arch/arm/include/asm/pgtable-3level.h +++ b/arch/arm/include/asm/pgtable-3level.h @@ -112,7 +112,7 @@ #ifndef __ASSEMBLY__ #define pud_none(pud) (!pud_val(pud)) -#define pud_bad(pud) (!(pud_val(pud) & 2)) +#define pud_bad(pud) (!(pud_val(pud) & PUD_TABLE_BIT)) #define pud_present(pud) (pud_val(pud)) #define pmd_table(pmd) ((pmd_val(pmd) & PMD_TYPE_MASK) == \ PMD_TYPE_TABLE) @@ -137,7 +137,7 @@ static inline pmd_t *pud_pgtable(pud_t pud) return __va(pud_val(pud) & PHYS_MASK & (s32)PAGE_MASK); } -#define pmd_bad(pmd) (!(pmd_val(pmd) & 2)) +#define pmd_bad(pmd) (!(pmd_val(pmd) & PMD_TABLE_BIT)) #define copy_pmd(pmdpd,pmdps) \ do { \ From patchwork Wed Mar 6 10:41:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13583879 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 D7058C54E49 for ; Wed, 6 Mar 2024 10:43:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7042D6B0072; Wed, 6 Mar 2024 05:43:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B4826B0082; Wed, 6 Mar 2024 05:43:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 554E76B00A6; Wed, 6 Mar 2024 05:43:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 3FCDD6B0072 for ; Wed, 6 Mar 2024 05:43:00 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0F19B120459 for ; Wed, 6 Mar 2024 10:43:00 +0000 (UTC) X-FDA: 81866276520.20.5A14183 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 5B75616001D for ; Wed, 6 Mar 2024 10:42:58 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eVWZ5zwK; spf=pass (imf08.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709721778; 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=4C+lWpN1qDfU+nymiqOVXkY7IqPiijqTb8F5rFjpmTU=; b=LdIPf9KmDqGhgA7Uw2+G7EPzOPK77p1z6fyuCahvWEopBbEov2rlawJCNXfl+AeH5ZIq1p yZBjtOv6RVfk88LEUexfnLzp7gJ+HFTIv04AUErXEVpNbulJMZ8a+eB+39PmjD94lLMep5 hBhI+UbJhQAs+aZzR5U0df0kVQNBVFg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709721778; a=rsa-sha256; cv=none; b=TQ4zK2TLy26+TYeOhj27okJjHLPFXftTqlHz0hI/5Sx7Y8DpegvLBO4YavBE0ih9ph4a5i Y9eh7j05w53aJL+VBzqPvtJCekxTJslJtfQxm2d2zFNkwz0loeaRrq8acsgN6Cnhdha6PM 6nNgTLbXqDH6jaHI4Az76+ufIqrLoYg= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eVWZ5zwK; spf=pass (imf08.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709721777; 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=4C+lWpN1qDfU+nymiqOVXkY7IqPiijqTb8F5rFjpmTU=; b=eVWZ5zwKEn8D25OPaGhlp+G77eC1s/VFSQZFX7ZvRMeh6LSTS7vORfQP5vYpnprelmrGn3 KuJgJbsHcZH70ERCBmFUM804XqyGrD2HnaJJymlEBNvkXJBUR+R4uXsI/nPNmfie/tWYzv 8M0w72q+B0hvNuAmvVSMi4M5yivXI3k= 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-622-aSR7lTs0MGOXGlrFM8hoQg-1; Wed, 06 Mar 2024 05:42:54 -0500 X-MC-Unique: aSR7lTs0MGOXGlrFM8hoQg-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 7927980F7E3; Wed, 6 Mar 2024 10:42:53 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id A34D7111DCFF; Wed, 6 Mar 2024 10:42:44 +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, Russell King , Shawn Guo , Krzysztof Kozlowski , Bjorn Andersson , Arnd Bergmann , Konrad Dybcio , Fabio Estevam Subject: [PATCH RFC 07/13] mm/arm: Redefine pmd_huge() with pmd_leaf() Date: Wed, 6 Mar 2024 18:41:41 +0800 Message-ID: <20240306104147.193052-8-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: 5B75616001D X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ca3q84oigg6q19exdhbhfnbtcwtpaf7c X-HE-Tag: 1709721778-144681 X-HE-Meta: U2FsdGVkX1/GV3qV0zayHHti7SHlvYjgJFIgfRzlheAfWY7g0bKfp/h8tmISM6Y86GxaCDLpbKTgfMgE2kl+eILmQRjkjP5a5wVjfHWoKl7wAI7UWPxNseOZRhA25qtM0RqqeetEZdx6Q1GSz3kYN1dW7YmWC40ct0RAl5anD7Qph+HrN6Xx2THT98nZ/j+UTjgDLAXJYGJNgG5lQfnsPKnKpruXZKXq0jvmbAjTiGrs7XnxO5cBYyzDhquoIN4P6+FCZyz1zw5nxEw+57rL7c51WBZ7NAaRID8NcHcdNmAu756xjUp3FVkCg4Rmnp9Kpu8w0rGORvF/Y6vmVAdRqFAYqW4OEM+yxgT0gMG49VzxSgbaoDdmLUGfyk/zdSOo5hhfK5GqZjBLQCR654JFU8+Bn0txm5oSHlkk1SQP4zPC9rmsLe+UxBDInn0/GteEWVZsAQCiKNretBRrwF5MKHY0pTdkPrDBJO3KfBlm4XaM6plAlmOfAwPZinrZ0OR12EACeRcLO8Do9FVoKGbCr8F3Ja5JFnYDONEyykwMVkvvX981u+vKk3Jl8102C7FPjMhq4/9itEo6Zi2Hv+JnGTrqUfz05AzJpmDFWvrmU96ucg2mhIOMP57tN0i4fsuHEJ43uktlbSCqK6d0FV+FCSkTVNFo/nlX3I34+xyi2vcmglqpWmNSUZYfxe58AoitxOfha7pL1Cv8ON0d57aoN7KzKmZSHlEtX3Yi5JYwWkw8ReFlgg1N8/QislC2hzrk8ZcCkLPHTNQFjAE+zPLK6Gbni5VyWgw9UoTCSteuVgatT0qGMoXiv03xhYKmiG4Qv3Kpmpoef/q/s8HNo+AKPx7jSvcyOX1MT9XluWkAs+8cfsNHP7rofI4Q6Wq5RfFYa0tmWaZMIL0De8NClSjM9F5p9hC3SWwIxzVP/3b9LEWbCUs4YxOjACGPbTyDikMSvs9ZWRp3TSMvEIxWTU2 HXwGXsFq cNdc2DwPa/jD3qvfs2cNHIwlWTrqXE2i3tknH4JDmIFxETgFjBhjM7fdyB15ky2IHWaVogobRHH/lJOPfskYWCHyNcHeSmdKl1WjxZhy6npZkmSd866z45KLlWt0bSOAyWkxOCnuelCcc4WGUVWLyf7EoKM6V0o3HE5lZvO3uwr0ZFQUG4TF1hM3pdSKrIDcbt9/StmhVS2M4L82TCn9pnnQLAS6EnDBe1waHBjSvjTsOKlo34zyLFLoFAGoJJ0YS620suTH9bTgxf7vaSzp6UK0qoMqQ9r32ncCOt5Krkt86ohxc5s+ud1NxuAJTtRIGZIZi87hB++Xz7PWdyAWH1H7psNyF0I5kKcM18OPVeufgwnLDvHv08Bnxip42/4no85vxkoxsHEqiRmanX2ywKvYrk5QxDmIsCYuFAVnXdsjRUrQtT/dgkEhKErpK2EFhkHZfdWBcV+UhVko= 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 Most of the archs already define these two APIs the same way. ARM is more complicated in two aspects: - For pXd_huge() it's always checking against !PXD_TABLE_BIT, while for pXd_leaf() it's always checking against PXD_TYPE_SECT. - SECT/TABLE bits are defined differently on 2-level v.s. 3-level ARM pgtables, which makes the whole thing even harder to follow. Luckily, the second complexity should be hidden by the pmd_leaf() implementation against 2-level v.s. 3-level headers. Invoke pmd_leaf() directly for pmd_huge(), to remove the first part of complexity. This prepares to drop pXd_huge() API globally. When at it, drop the obsolete comments - it's outdated. Cc: Russell King Cc: Shawn Guo Cc: Krzysztof Kozlowski Cc: Bjorn Andersson Cc: Arnd Bergmann Cc: Konrad Dybcio Cc: Fabio Estevam Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Peter Xu --- arch/arm/mm/hugetlbpage.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/arm/mm/hugetlbpage.c b/arch/arm/mm/hugetlbpage.c index dd7a0277c5c0..c2fa643f6bb5 100644 --- a/arch/arm/mm/hugetlbpage.c +++ b/arch/arm/mm/hugetlbpage.c @@ -18,11 +18,6 @@ #include #include -/* - * On ARM, huge pages are backed by pmd's rather than pte's, so we do a lot - * of type casting from pmd_t * to pte_t *. - */ - int pud_huge(pud_t pud) { return 0; @@ -30,5 +25,5 @@ int pud_huge(pud_t pud) int pmd_huge(pmd_t pmd) { - return pmd_val(pmd) && !(pmd_val(pmd) & PMD_TABLE_BIT); + return pmd_leaf(pmd); } From patchwork Wed Mar 6 10:41:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13583880 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 52A1EC54E41 for ; Wed, 6 Mar 2024 10:43:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2F9B6B0082; Wed, 6 Mar 2024 05:43:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DE0266B0096; Wed, 6 Mar 2024 05:43:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA7B26B00A6; Wed, 6 Mar 2024 05:43:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id B50C76B0082 for ; Wed, 6 Mar 2024 05:43:12 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 92746120459 for ; Wed, 6 Mar 2024 10:43:12 +0000 (UTC) X-FDA: 81866277024.06.F199E7C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id E40D3160019 for ; Wed, 6 Mar 2024 10:43:10 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CpTT+gFD; spf=pass (imf08.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709721790; 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=xZurg04juSYF/uW9HtnhgkfMM1C/gArxmrpoVNEgvCQ=; b=Ptg18d1t2liIpQ53NrBhPWuIxjvdQ8pNdxi8uiQ/MkscNI+wtzmXpH12rGwCETBc9k1oBH tWjKaAva1kKrKUvIKa6NaWNaEULLm+gkqbY9bdImoCH1xLpsjGIFtB5S99PFxybOaUbB0I Ri/IUcTQ5fIgApVqADbFQSUJIQouorc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709721790; a=rsa-sha256; cv=none; b=pHWvApi/DgornWSwLFcJFS1R27Hrm+mQKEHwHwf4n155xa8K5s1lEXrOsBX1rxQJIg7Ugx HlMRwf9LIlxauk8Q+Wpeu+YmX+oIKNyvW1BspLxk/8NtrvDhsEPo1PnAeYkFvor+yK0CV4 4WTF3oh1eYc3JeUQ3q6MGS2CDtoUFo0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=CpTT+gFD; spf=pass (imf08.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709721789; 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=xZurg04juSYF/uW9HtnhgkfMM1C/gArxmrpoVNEgvCQ=; b=CpTT+gFDFHdZsNHw9svmtJhTBir+8SlkK0yrwilbVRhPQDrPDIS2h8ltBpW4IN9IM89Qjh EjqIKq7niYdTLdzKi7h1NtqcKJFB7raXNynj/aTjatjkKyXPu5EjPABdTQO6l+I27eiBkT qu0T4FsDSQZSjUDM7I2bvxdXb9qyCQ0= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-392-yz4Oyb-YMiytY0-QZ4ib3A-1; Wed, 06 Mar 2024 05:43:02 -0500 X-MC-Unique: yz4Oyb-YMiytY0-QZ4ib3A-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 79C4B3C0DF76; Wed, 6 Mar 2024 10:43:01 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45DD5111DCFF; Wed, 6 Mar 2024 10:42:53 +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, Mark Salter , Catalin Marinas , Will Deacon Subject: [PATCH RFC 08/13] mm/arm64: Merge pXd_huge() and pXd_leaf() definitions Date: Wed, 6 Mar 2024 18:41:42 +0800 Message-ID: <20240306104147.193052-9-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-Stat-Signature: wf5usprfyjnpnrqx4symno14xg1crq8r X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: E40D3160019 X-Rspam-User: X-HE-Tag: 1709721790-985340 X-HE-Meta: U2FsdGVkX18XoS1TOepjLUbd1XZrqqryqUv2QgIgCYqwG9gl5CZE+gRcFRCzXW0a6Nsf0rybHNRKiNdDfcO0lOB65Day8XJZmtbRwlHQz9YxlHDrgi2aHPDX4JAppGo+zHoSqdFWxtKA16DZniR/t/OALWvsWtDDEqY0XY8TNjQgmVlAyeZLWzkzyUT+6zQzXcHKwmGg1Sm9IIrbB9oJ8nztbuqMr0+wds0Yn6Y/anpkQEXdObAsunXCJbCFyO5fQkmnQIYOQVEzZtyxLiLnVRfPJJFWVumpTk7GGuKcWFuz3BjNRxOiwOE//8mnA/shOXRM6A4ZtBb6D7DqrYOBtROv8zyGf3U77/QxutwXlT/0nhrOz1nzu4CGEuceEsTD8b4A5Dyp2J0wTEpE1BUrzhjjMsPNgI2dQia/0RFH7Y/USBwp2jzl9lBMUlXcHxbNGDD2B0GJkqj4ZngiVY2OIzgHm58bWcMGU3Dfmc1x6X+ZsQent5bXjug0Yfj9yAzWOUW29vENbsYwwaVSUMwd9MbOKgU96Y2IgKXYuzE1u4hKdO1m1g8lGL87xDlakP+JtwPxYr/j2I4sE5epfKmFPXJ93OUfkIfjEe38rGNJSlSWgdEUBARSRe0su0fn498AnmiYAn/4ZQILGNLqfVwtoeLuYood+QXgg4MXLw7j542OFWY5WW4qjtATAKVcColLsE+bN1n4u6D1nq3d3ke5af01HP2ZeYZM1S4Rxobgaa+IrX5yTBMlU/2TYCV1dPlrwXjvzZ2m0GC5CQXiqnsoaasXwLoDXd4Aup3a8mkOMvHSA4zQfFy6XDszH0hCRwc+CigAaIx66GfVVSzqdDf07Swr0GF9vnVUmgiWZWy5ilCd72ABsuH53j/KK2+qKiCxuSi8JyDK2Y8e4wIcw4J8ij8jRtzBBLow4mXISS6/dJeOYIgBeJw0sIt5BDIjnm7o4HqfbdFq6ke5DrLCqyz yXlukpIh kCR6a2h75GiZ9hL3yXuobO0qBkrY2rcRw5K1Ghr5D+Iu2rMgMNHyfL9HvhlGiKSvncPoXvmVCkMfqnCxqSfaEFBsfNMgFovbgJMsQrtRc6uj3WlR3Z4YeXKLGH8ap8imuPsd3VLBlwwy7gxUEsD1X66FQqtpTAzazVJg0/vZSGO1bnPJ4T9/uSHVezogiT+/ZMD1D634LyxbhCkhQuW8XbrEPWvhzhRArJjff/GXtXBqnqBk9BTDfVgzfYwbWM+ImUIAh2LhT4UGmBrZWOEQrOTTOeArH1VFvHU15EgLewaX+L3mGLFbCw/Q6i91+CcrQ1fo0d2L8/0tjVhg/u1WZV0QdtC7n2dd8cNMeKwmz85iSLFZcoUE5l8izUWPbwNkLgraseJX0TED4G1c= 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 Unlike most archs, aarch64 defines pXd_huge() and pXd_leaf() slightly differently. Redefine the pXd_huge() with pXd_leaf(). There used to be two traps for old aarch64 definitions over these APIs that I found when reading the code around, they're: (1) 4797ec2dc83a ("arm64: fix pud_huge() for 2-level pagetables") (2) 23bc8f69f0ec ("arm64: mm: fix p?d_leaf()") Define pXd_huge() with the current pXd_leaf() will make sure (2) isn't a problem (on PROT_NONE checks). To make sure it also works for (1), we move over the __PAGETABLE_PMD_FOLDED check to pud_leaf(), allowing it to constantly returning "false" for 2-level pgtables, which looks even safer to cover both now. Cc: Muchun Song Cc: Mark Salter Cc: Catalin Marinas Cc: Will Deacon Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Peter Xu --- arch/arm64/include/asm/pgtable.h | 4 ++++ arch/arm64/mm/hugetlbpage.c | 8 ++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 401087e8a43d..14d24c357c7a 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -704,7 +704,11 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd) #define pud_none(pud) (!pud_val(pud)) #define pud_bad(pud) (!pud_table(pud)) #define pud_present(pud) pte_present(pud_pte(pud)) +#ifndef __PAGETABLE_PMD_FOLDED #define pud_leaf(pud) (pud_present(pud) && !pud_table(pud)) +#else +#define pud_leaf(pud) false +#endif #define pud_valid(pud) pte_valid(pud_pte(pud)) #define pud_user(pud) pte_user(pud_pte(pud)) #define pud_user_exec(pud) pte_user_exec(pud_pte(pud)) diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 0f0e10bb0a95..1234bbaef5bf 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -81,16 +81,12 @@ bool arch_hugetlb_migration_supported(struct hstate *h) int pmd_huge(pmd_t pmd) { - return pmd_val(pmd) && !(pmd_val(pmd) & PMD_TABLE_BIT); + return pmd_leaf(pmd); } int pud_huge(pud_t pud) { -#ifndef __PAGETABLE_PMD_FOLDED - return pud_val(pud) && !(pud_val(pud) & PUD_TABLE_BIT); -#else - return 0; -#endif + return pud_leaf(pud); } static int find_num_contig(struct mm_struct *mm, unsigned long addr, From patchwork Wed Mar 6 10:41:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13583881 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 448B5C54E41 for ; Wed, 6 Mar 2024 10:43:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C83E56B00A6; Wed, 6 Mar 2024 05:43:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C33CE6B00A7; Wed, 6 Mar 2024 05:43:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD43E6B00A8; Wed, 6 Mar 2024 05:43:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 973906B00A6 for ; Wed, 6 Mar 2024 05:43:18 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 790EFA0BC2 for ; Wed, 6 Mar 2024 10:43:18 +0000 (UTC) X-FDA: 81866277276.06.4B2FF0D 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 BD1F14000A for ; Wed, 6 Mar 2024 10:43:16 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PPuFoIgI; 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=1709721796; 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=Kmh1r8OzIBeRtjZdwvZUDbG8Rg7aEeeC8h0p+1IZUgI=; b=NCtPFQ/49yEU478U+LZ+D67yUMRBmsY/BsnLdUA7hiivYaj+ZqOq8mJyJA4lBHjL0lCqsO euTTMIM24N4sEj9SV83s776BwvZsypCeaaW1CRHXVJy2PzSgzshV39ULsA5ABI6pxu1LqT F6pvKiiEmETfcH4BAUphHbsSgjVed5U= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PPuFoIgI; 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=1709721796; a=rsa-sha256; cv=none; b=gljr8qrfjuBoAtbSvgJWxHMw4NP6qnMLha7kpLf42pnrmrrP5Q55q6iiQTYB4yUJRMkl+u uFIzi0lfn94b07fMnh+XwP17gpY6JY+wvX0SeKgX0ynZEMkMkaBIuQ928s1yEbTOAbVSEH cV10ySKYYZWH1lIDWDE9zVe6HjlOBr4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709721796; 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=Kmh1r8OzIBeRtjZdwvZUDbG8Rg7aEeeC8h0p+1IZUgI=; b=PPuFoIgIiKciUD+TSkStwFywxOLWqi9gs/5XWHMggSk0LMOg8VhvWqVe6RZWeiJRzQ3yin bZCoCdewUkBuJEmLRimwe+TL+R3p4gG0Jk7PYB5WWRV4sytZ84OSUjcrWWAzGla7X8bWgz 2oGN7RQuEWkii+yw49V1UDeKWq5LTr0= 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-132-28RiKZlpPQu-76jARwQEkw-1; Wed, 06 Mar 2024 05:43:10 -0500 X-MC-Unique: 28RiKZlpPQu-76jARwQEkw-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 13B1C8007A7; Wed, 6 Mar 2024 10:43:10 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 294B5111DD03; Wed, 6 Mar 2024 10:43:01 +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, Michael Ellerman , Nicholas Piggin , "Aneesh Kumar K.V" , "Naveen N. Rao" Subject: [PATCH RFC 09/13] mm/powerpc: Redefine pXd_huge() with pXd_leaf() Date: Wed, 6 Mar 2024 18:41:43 +0800 Message-ID: <20240306104147.193052-10-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-Rspam-User: X-Stat-Signature: k4tw43gku7eee1ddehfmmsccg53w7wp1 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: BD1F14000A X-HE-Tag: 1709721796-169638 X-HE-Meta: U2FsdGVkX1+qvSIG36EVRp4xuHNqfiT1rCXHm1cHg3jqCubLNBFV5AdDoJll3jJrDEvbSFP1Iqw6W2stw0je5Apd6kCcDqLVrc8ieQ0UWnHF4ZJqYDpXZ63jLX26V6rwt0ApLCJsTihqmdRYFIZ5uxLgaPnsCx5IlD40xSOh3fzsYEeeSEa/ofvkyRqI6Q+nlENFwZ9Aoa1muQgaxt1J9qugnjW+QHWmbueJYv6f2U67BfRlQB7wFICVxvHQhOTy8idyJZyCrfLXb52VIMTXQWcao3UwLOHaiS/M9Kz7AILHUB4bHSLu3L+Qo4ZB/bBR6595MPcGMHxYJcYKstFaRjcvZ8SDA4XeMwOR8cllE6Glunp8oIhVKPFztj+cQSEfPUWNR6+dG6w+6m2Oe1YjC2QEIuLZvlprOYDJnOostUr9sqtVw8oiHk8BRmbWcnKuE6Ry1VwMWi7zwtyiqcmzol7DGNjuIks75XfzLlf09yPpnNKHK6WF06kj6VpdBbXxZlzDWwIS6HOVJIFSVrQRjJPW2UCqr3wTeMweS+9vwrdzNKdhttMmAQWmANqJYXKi8u0zzZA751lu3Cx0uh8Q2Du8TRR7LtW1Oqg49zQKIeP4OiGUuL3mWcpp8rTnVc1ZQQyj4y7A0rARn8JfWT8ZPFZWyNZbCK8q2KnJUgJ5KjBWFQdnqSyvcbdIewtig+2pcOfIrN8pjj+YWa2/Ampynno8OUQEWZ9s+BNYa0kbg1ZCe8AQcFbDt0obKzVAg9cHE2vDgb8v6Y6+s5gdF07p51roupq0Gj0U80KzOr86UaJK8neItHilIzw3Y1W/Um9eNpYzRRo4QLaszr4/kArtvpgcPICxSm2ClWQiaDxER8pMSIYY3nRZhiAQqeSUahuY5HBcR8zNaYi6zLiag0gRviSIiPu/OcO9xnf24GlFNBcWMepUSCO+Hko9y9wUHtVX3TiXNy3VT6vpXbfIpWi nLJipQYN Ml+73U/4Q/ZMknWzUj6JjcUMOUJCSzF3/SXIfru7dUu9nnt2b9DlgIw81Vt+8Y/W4lc2421xhd2MWpfoZvb8NsIkRskzYVAZjax23+6rcsckheaDPsj5duEXj7WbgJ7NCwx3uvEsEs/n++LFMT630obXn2kv05o2ajNLbdOlW+g22Su1jYZZnoBnHE0UwTKsIxHouaGqmSMEXxktLEH7gEbhx+MAmjTxd9zPBYNsDXtYziqP7l0dHg67hHYJXG+kP89KXjH7J7E8akTzDXIXu7cK7wAOxMjXJOG24Vl9R+56UPJy3eE7KV/6IvKN5QmFLwZL4gmsvx1UBdSiGJ80obi6P/69Yzq67z/Bt8djyrBHWMT0C+3+oEaomx9iJdvi6323p8KEWq67Q7qSj2QcGHRBRIhWFipA1JS3MkMnphk2AJGCp13kJIlT6b3tM+a+nAdI0 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 PowerPC book3s 4K mostly has the same definition on both, except pXd_huge() constantly returns 0 for hash MMUs. AFAICT that is fine to be removed, because pXd_huge() reflects a hugetlb entry, while it's own hugetlb pgtable lookup function (__find_linux_pte() shared by all powerpc code) already use pXd_leaf() irrelevant of the MMU type. It means pXd_leaf() should work all fine with hash MMU pgtables or something could already went wrong. The goal should be that we will have one API pXd_leaf() to detect all kinds of huge mappings. AFAICT we need to use the pXd_leaf() impl (rather than pXd_huge() ones) to make sure ie. THPs on hash MMU will also return true. This helps to simplify a follow up patch to drop pXd_huge() treewide. Cc: Michael Ellerman Cc: Nicholas Piggin Cc: Christophe Leroy Cc: "Aneesh Kumar K.V" Cc: "Naveen N. Rao" Cc: linuxppc-dev@lists.ozlabs.org Signed-off-by: Peter Xu Signed-off-by: Peter Xu --- arch/powerpc/include/asm/book3s/64/pgtable-4k.h | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/pgtable-4k.h b/arch/powerpc/include/asm/book3s/64/pgtable-4k.h index 48f21820afe2..92545981bb49 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable-4k.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable-4k.h @@ -8,22 +8,12 @@ #ifdef CONFIG_HUGETLB_PAGE static inline int pmd_huge(pmd_t pmd) { - /* - * leaf pte for huge page - */ - if (radix_enabled()) - return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); - return 0; + return pmd_leaf(pmd); } static inline int pud_huge(pud_t pud) { - /* - * leaf pte for huge page - */ - if (radix_enabled()) - return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); - return 0; + return pud_leaf(pud); } /* From patchwork Wed Mar 6 10:41:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13583882 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 7EC92C5475B for ; Wed, 6 Mar 2024 10:43:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1AE246B00A8; Wed, 6 Mar 2024 05:43:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 15D5A6B00A9; Wed, 6 Mar 2024 05:43:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 024DE6B00AA; Wed, 6 Mar 2024 05:43:25 -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 E30C76B00A8 for ; Wed, 6 Mar 2024 05:43:25 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id AFDC040B70 for ; Wed, 6 Mar 2024 10:43:25 +0000 (UTC) X-FDA: 81866277570.29.166A2FA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 27EBD2000B for ; Wed, 6 Mar 2024 10:43:23 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="U/saFQoS"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.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=1709721804; 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=e0nyH5cfLKLNUyYVewKsf1JegzIgt6HCOMbuZo9oALU=; b=Pkjs/5Qg5w3QxLE2uu/dcCvUTK7LHFqf5Fzs3h3e9GYbx73DBEEqC0IX7cT0p/Rp2sUGBZ g3vf5bJdeFqek2nwWGdQUhN39TgYxGHjJnpYAozbV6GbjhM/iHfzLISizs1vFXxvpNGYgI aYnyn2rydSNJa6/moB6tG0P6lragtIE= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="U/saFQoS"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709721804; a=rsa-sha256; cv=none; b=RHdHyeISb0X5APj2bicDb7cZxrpWBkbNdP+afeJop7BBA84tGZny0o9PyIN8GDP/CEwx2C wx7OD83JwuJUPYyACDJZLa8miWotlaoCMdN4mmeiWY+vv5pCbF5PCDc6lj+xqtiZwQmZg6 YyKNx7ZupZehgYIk7Uly+HL/+3NQt0k= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709721803; 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=e0nyH5cfLKLNUyYVewKsf1JegzIgt6HCOMbuZo9oALU=; b=U/saFQoSaa2gLQYIAVmfL84J4eagyTmcQlO374bDKZJV1U8VefCN9s4za3pyYcaXHYdfyZ ekGTs0QLpJ2xTYY1yqHLk6Kc4iFcs1orZdyD8TAbbq4SJl6x8HRd5M0fw0+q90T7jfm4tJ HddCfmC+LXHL8Peyto0oPJTJ84dL9Pw= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-459-Hl-hIAJEPjGHPHHTtG8PNw-1; Wed, 06 Mar 2024 05:43:17 -0500 X-MC-Unique: Hl-hIAJEPjGHPHHTtG8PNw-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 21BBC1C0513A; Wed, 6 Mar 2024 10:43:17 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id D539F111DCFF; Wed, 6 Mar 2024 10:43:10 +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 10/13] mm/gup: Merge pXd huge mapping checks Date: Wed, 6 Mar 2024 18:41:44 +0800 Message-ID: <20240306104147.193052-11-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: 27EBD2000B X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 3ztfjbij4y6oggd5c9khe51g4jdowtwz X-HE-Tag: 1709721803-272238 X-HE-Meta: U2FsdGVkX19c3pffKg0WnZUE+3e6I71QbwFw+t9k+kLSvyp5bmQDXqLVHSrt/ao7hxUHweRc4z043IvTF1Gyg8A5I/Qt2tX6KtaqRnS9gVFzFdlXHZUZvTxwUFpUsE74oOcQ7Dv/t9SQsfca7RrrfnFjJD40CGHkVstBo8kR0qpT/y074z0z4kOIQ4Q0AJepkqWBdtljaW5NUuYcUfMDR9uypN+TYU2QUJEKUeQ3KQ9pKGnSW2J/D8tCx+2gpi/qlvw2Tzc9CY5aUidRCnRTEXpk/GyNUgENIYl12HYtK7FDJN2hEWDjJGi/O/wEcHIlrEmut2kZq0SkYZaOWH/eHcLcWzH4yH4HXeFS/nAOLyMUxaYVis27boo1lwIYOhnwZ9V+cLirPRyj118KxAcB26WO3v2bvNeOzhJzTHe01h5O9+ZuAqHEo6jaxOGqsaZQOpm30HBRj4PIaqDVnU8M8ilVPhgWUHbXMric27wWm7i3VHgzfAM9m8ZMNSGsmb1XZDkFJGu6TShYDuIZr7ebxsuRjpwu4d6HDVVlVzyx/g203eN9iwjZbEKE30Hx+hwJ8S2m6tlOyntWo7DkUvc3hisR6KaECgPVCk6etL2SnIyZA5/pa+E5pzv/YQN1DlbbsDGh9hJ/qhzlm5YyWBtCK0Qfr9myI4YoovMrOflcto+DBxabZ0vYYVhk5h7CekoVETHb5PFYaWljKfrfRa1dvIJHEi8SIbplq+lvY3fErVJP1w29XuHYjloldUwc4kh9MYDxuv0bXorhLLg8YksRjldnDyrnXEsSCqGw+nsVALXDn+LfRvuVgNgwI16zKfahzF/v+qOXIzXAM5tMhHHpeoXRD1EFOL1WbEyoFyqZe+jL+BHxg2ziWSa8zYuKPsUqT3gWI2XA88Q2EcaIRFw4rQ== 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 Huge mapping checks in GUP are slightly redundant and can be simplified. pXd_huge() now is the same as pXd_leaf(). pmd_trans_huge() and pXd_devmap() should both imply pXd_leaf(). Time to merge them into one. Signed-off-by: Peter Xu Reviewed-by: Jason Gunthorpe --- mm/gup.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index f87a7d90f2ae..de7188d2af86 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -3005,8 +3005,7 @@ static int gup_pmd_range(pud_t *pudp, pud_t pud, unsigned long addr, unsigned lo if (!pmd_present(pmd)) return 0; - if (unlikely(pmd_trans_huge(pmd) || pmd_huge(pmd) || - pmd_devmap(pmd))) { + if (unlikely(pmd_leaf(pmd))) { /* See gup_pte_range() */ if (pmd_protnone(pmd)) return 0; @@ -3043,7 +3042,7 @@ static int gup_pud_range(p4d_t *p4dp, p4d_t p4d, unsigned long addr, unsigned lo next = pud_addr_end(addr, end); if (unlikely(!pud_present(pud))) return 0; - if (unlikely(pud_huge(pud) || pud_devmap(pud))) { + if (unlikely(pud_leaf(pud))) { if (!gup_huge_pud(pud, pudp, addr, next, flags, pages, nr)) return 0; @@ -3096,7 +3095,7 @@ static void gup_pgd_range(unsigned long addr, unsigned long end, next = pgd_addr_end(addr, end); if (pgd_none(pgd)) return; - if (unlikely(pgd_huge(pgd))) { + if (unlikely(pgd_leaf(pgd))) { if (!gup_huge_pgd(pgd, pgdp, addr, next, flags, pages, nr)) return; From patchwork Wed Mar 6 10:41:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13583883 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 EEEE9C54E41 for ; Wed, 6 Mar 2024 10:43:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 815436B0098; Wed, 6 Mar 2024 05:43:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C5AA6B00AA; Wed, 6 Mar 2024 05:43:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 666D96B00AB; Wed, 6 Mar 2024 05:43:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 534F86B0098 for ; Wed, 6 Mar 2024 05:43:31 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 28A3B16038B for ; Wed, 6 Mar 2024 10:43:31 +0000 (UTC) X-FDA: 81866277822.26.2F7377A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 8A604140002 for ; Wed, 6 Mar 2024 10:43:29 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="c8/LyKvp"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.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=1709721809; 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=NvhYOoORCLpxz/No1Zw0ldOZIymUNMLffxfrF8V0mdw=; b=2/0pKZ4tmhKVPRI5jZeYXc61hzYW3j5QH5fLiTGWvhyyvPQmJRX1BaeCdVmMN15n0SOiyW TMwGclaeJHZ9nx9/EX1ho8AVPYbTTOxnjqu4EA2sJ8/rUk3BScw15WFEyQFhjtKODRNEMO lV0SxAu7qH4FKySt8xM7eQTSq0s+vio= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="c8/LyKvp"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709721809; a=rsa-sha256; cv=none; b=d1+mAvkOt9eC20+u1AaA2vTI927FcQB062d5e1HxIZUj6jWeuCCoHddf30yqW5UR+IylqK bkI358ec4AIj/5uhRx9UgXnfp6ucUjsNJT5/i+lTVZ2ao4E/kwT7m0vdHd71hnb7sRzdJc xu2L1Bksm5Uz8crApvjhS2P8SW6mnk4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709721808; 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=NvhYOoORCLpxz/No1Zw0ldOZIymUNMLffxfrF8V0mdw=; b=c8/LyKvpdikSk/o2hwWrf1OSTc/vAcdjmhg7S45EyXARGPr69V4T4OqlG8vfwK5KmjTg4A vIliN+tvL52yGmtu1fPydGnzH5WdZsjINZuIH+dVmwWf4XQluzKehv7EBFT/MawwGI9KTK TN2xiekX7jnguCTMqlUMNZv5PCsXE+k= 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-461-M8jx121_PeO5YuMfMxkl1g-1; Wed, 06 Mar 2024 05:43:24 -0500 X-MC-Unique: M8jx121_PeO5YuMfMxkl1g-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 32C3C800262; Wed, 6 Mar 2024 10:43:24 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5593111DD03; Wed, 6 Mar 2024 10:43:17 +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 11/13] mm/treewide: Replace pXd_huge() with pXd_leaf() Date: Wed, 6 Mar 2024 18:41:45 +0800 Message-ID: <20240306104147.193052-12-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-Rspam-User: X-Stat-Signature: m3j3ahwu8r4c1izrgjih1nheap1hs5bx X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8A604140002 X-HE-Tag: 1709721809-428158 X-HE-Meta: U2FsdGVkX1/lDxUwg/Vq3ayi4IAwCnHm9me9gZTWM8jIB4Jt3uAmykztePm5fislTXQYAOGkZM/mCoHUoE1fEmPZtHfZKSvk5gtAYD659I+Q+xjJnjewkrdpw+bMh0ZYt2HB+CpAFWG1f67pRDpE/5KkOl07fDw1sRzEvhyfIwygq6/o5ZU1YnMt9laBOpN1mK+Z2nns96P5SRK8Mn5EdPZNSTTygWpCRJnJBsYrUkBQZMiEM2V6+krzxiZmW2UOgXV3boH89i6QR5kF+35Gad+L+gI8vDOi8Qk7VAml9U74eN1UWFwSpRjQxKfXeylaoe29P4FizBxA5q7HpWy3orx2jYzeK+fzik26VENWlbofAxELRVHjBYuVz/9Ik+8wI0WXCZFiHkcES1UV+hQsLeUEd+Loc1bSjuxbSwZ1OYzaAmtUVO5Nb3K+i+QK2MlMpDkFpEuRJBMNk1bY8RD3pfJKv2ZhIPV2Yeicru6iC144TmvoTVVcR76adU1ACD14KE5Yid1jam/GRpeOn62/6zqZmaXPtWDFUkYgDJccFQFT/AFLu/xPJnPieGkiNSne1IlkK/ynTH7U99zl062qvCQVw1Noib73tfseUtPgsH80Ns+QvJ+u10MPC+cuKrFiAo/6wg+Q4ZPKrB8GFsaNQLOXnk03OCaLqHqpnPO14h4tEAlrkTzNDOXwambvV1tkLwvsFvRBXpYy9bPbMAX0C+K8HjACIH6ZyvcqzjRG21LegpibVbQa1NEd0a8PoblsrverLx86bn70y6kOuO7ODvLonMALLQgwRI5m8m4Wg2+XXUiZGddwlUnAkV5iz+4L9s9SQJ8cBIRBTALJmt87tSD9IGG6uUN1O3yyQj2juvhnivsi5IPwuMYNT5i9SaGytsZKWMSMEuxuZNdvbiGYpw1/MHr2hYLSCmDcoMP2djD1OjK47TA0H8UFxQsz0SNW 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 Now after we're sure all pXd_huge() definitions are the same as pXd_leaf(), reuse it. Luckily, pXd_huge() isn't widely used. Signed-off-by: Peter Xu --- arch/arm/include/asm/pgtable-3level.h | 2 +- arch/arm64/include/asm/pgtable.h | 2 +- arch/arm64/mm/hugetlbpage.c | 4 ++-- arch/loongarch/mm/hugetlbpage.c | 2 +- arch/mips/mm/tlb-r4k.c | 2 +- arch/powerpc/mm/pgtable_64.c | 6 +++--- arch/x86/mm/pgtable.c | 4 ++-- mm/gup.c | 4 ++-- mm/hmm.c | 2 +- mm/memory.c | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h index e7aecbef75c9..9e3c44f0aea2 100644 --- a/arch/arm/include/asm/pgtable-3level.h +++ b/arch/arm/include/asm/pgtable-3level.h @@ -190,7 +190,7 @@ static inline pte_t pte_mkspecial(pte_t pte) #define pmd_dirty(pmd) (pmd_isset((pmd), L_PMD_SECT_DIRTY)) #define pmd_hugewillfault(pmd) (!pmd_young(pmd) || !pmd_write(pmd)) -#define pmd_thp_or_huge(pmd) (pmd_huge(pmd) || pmd_trans_huge(pmd)) +#define pmd_thp_or_huge(pmd) (pmd_leaf(pmd) || pmd_trans_huge(pmd)) #ifdef CONFIG_TRANSPARENT_HUGEPAGE #define pmd_trans_huge(pmd) (pmd_val(pmd) && !pmd_table(pmd)) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 14d24c357c7a..c4efa47fed5f 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -512,7 +512,7 @@ static inline pmd_t pmd_mkinvalid(pmd_t pmd) return pmd; } -#define pmd_thp_or_huge(pmd) (pmd_huge(pmd) || pmd_trans_huge(pmd)) +#define pmd_thp_or_huge(pmd) (pmd_leaf(pmd) || pmd_trans_huge(pmd)) #define pmd_write(pmd) pte_write(pmd_pte(pmd)) diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 1234bbaef5bf..f494fc31201f 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -321,7 +321,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, if (sz != PUD_SIZE && pud_none(pud)) return NULL; /* hugepage or swap? */ - if (pud_huge(pud) || !pud_present(pud)) + if (pud_leaf(pud) || !pud_present(pud)) return (pte_t *)pudp; /* table; check the next level */ @@ -333,7 +333,7 @@ pte_t *huge_pte_offset(struct mm_struct *mm, if (!(sz == PMD_SIZE || sz == CONT_PMD_SIZE) && pmd_none(pmd)) return NULL; - if (pmd_huge(pmd) || !pmd_present(pmd)) + if (pmd_leaf(pmd) || !pmd_present(pmd)) return (pte_t *)pmdp; if (sz == CONT_PTE_SIZE) diff --git a/arch/loongarch/mm/hugetlbpage.c b/arch/loongarch/mm/hugetlbpage.c index 1e76fcb83093..a4e78e74aa21 100644 --- a/arch/loongarch/mm/hugetlbpage.c +++ b/arch/loongarch/mm/hugetlbpage.c @@ -64,7 +64,7 @@ uint64_t pmd_to_entrylo(unsigned long pmd_val) { uint64_t val; /* PMD as PTE. Must be huge page */ - if (!pmd_huge(__pmd(pmd_val))) + if (!pmd_leaf(__pmd(pmd_val))) panic("%s", __func__); val = pmd_val ^ _PAGE_HUGE; diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c index 4106084e57d7..76f3b9c0a9f0 100644 --- a/arch/mips/mm/tlb-r4k.c +++ b/arch/mips/mm/tlb-r4k.c @@ -326,7 +326,7 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte) idx = read_c0_index(); #ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT /* this could be a huge page */ - if (pmd_huge(*pmdp)) { + if (pmd_leaf(*pmdp)) { unsigned long lo; write_c0_pagemask(PM_HUGE_MASK); ptep = (pte_t *)pmdp; diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c index 9b99113cb51a..6621cfc3baf8 100644 --- a/arch/powerpc/mm/pgtable_64.c +++ b/arch/powerpc/mm/pgtable_64.c @@ -102,7 +102,7 @@ struct page *p4d_page(p4d_t p4d) { if (p4d_leaf(p4d)) { if (!IS_ENABLED(CONFIG_HAVE_ARCH_HUGE_VMAP)) - VM_WARN_ON(!p4d_huge(p4d)); + VM_WARN_ON(!p4d_leaf(p4d)); return pte_page(p4d_pte(p4d)); } return virt_to_page(p4d_pgtable(p4d)); @@ -113,7 +113,7 @@ struct page *pud_page(pud_t pud) { if (pud_leaf(pud)) { if (!IS_ENABLED(CONFIG_HAVE_ARCH_HUGE_VMAP)) - VM_WARN_ON(!pud_huge(pud)); + VM_WARN_ON(!pud_leaf(pud)); return pte_page(pud_pte(pud)); } return virt_to_page(pud_pgtable(pud)); @@ -132,7 +132,7 @@ struct page *pmd_page(pmd_t pmd) * enabled so these checks can't be used. */ if (!IS_ENABLED(CONFIG_HAVE_ARCH_HUGE_VMAP)) - VM_WARN_ON(!(pmd_leaf(pmd) || pmd_huge(pmd))); + VM_WARN_ON(!pmd_leaf(pmd)); return pte_page(pmd_pte(pmd)); } return virt_to_page(pmd_page_vaddr(pmd)); diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c index ff690ddc2334..d74f0814e086 100644 --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c @@ -731,7 +731,7 @@ int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot) return 0; /* Bail out if we are we on a populated non-leaf entry: */ - if (pud_present(*pud) && !pud_huge(*pud)) + if (pud_present(*pud) && !pud_leaf(*pud)) return 0; set_pte((pte_t *)pud, pfn_pte( @@ -760,7 +760,7 @@ int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot) } /* Bail out if we are we on a populated non-leaf entry: */ - if (pmd_present(*pmd) && !pmd_huge(*pmd)) + if (pmd_present(*pmd) && !pmd_leaf(*pmd)) return 0; set_pte((pte_t *)pmd, pfn_pte( diff --git a/mm/gup.c b/mm/gup.c index de7188d2af86..9c0bc9d49c32 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -778,7 +778,7 @@ static struct page *follow_p4d_mask(struct vm_area_struct *vma, p4d = READ_ONCE(*p4dp); if (p4d_none(p4d) || !p4d_present(p4d)) return no_page_table(vma, flags); - BUILD_BUG_ON(p4d_huge(p4d)); + BUILD_BUG_ON(p4d_leaf(p4d)); if (unlikely(p4d_bad(p4d))) return no_page_table(vma, flags); @@ -3070,7 +3070,7 @@ static int gup_p4d_range(pgd_t *pgdp, pgd_t pgd, unsigned long addr, unsigned lo next = p4d_addr_end(addr, end); if (p4d_none(p4d) || !p4d_present(p4d)) return 0; - BUILD_BUG_ON(p4d_huge(p4d)); + BUILD_BUG_ON(p4d_leaf(p4d)); if (unlikely(is_hugepd(__hugepd(p4d_val(p4d))))) { if (!gup_huge_pd(__hugepd(p4d_val(p4d)), addr, P4D_SHIFT, next, flags, pages, nr)) diff --git a/mm/hmm.c b/mm/hmm.c index c44391a0246e..3b526c529b55 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -429,7 +429,7 @@ static int hmm_vma_walk_pud(pud_t *pudp, unsigned long start, unsigned long end, return hmm_vma_walk_hole(start, end, -1, walk); } - if (pud_huge(pud) && pud_devmap(pud)) { + if (pud_leaf(pud) && pud_devmap(pud)) { unsigned long i, npages, pfn; unsigned int required_fault; unsigned long *hmm_pfns; diff --git a/mm/memory.c b/mm/memory.c index e17669d4f72f..96562053be9c 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2763,7 +2763,7 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud, unsigned long next; int err = 0; - BUG_ON(pud_huge(*pud)); + BUG_ON(pud_leaf(*pud)); if (create) { pmd = pmd_alloc_track(mm, pud, addr, mask); From patchwork Wed Mar 6 10:41:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13583884 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 4781DC54E49 for ; Wed, 6 Mar 2024 10:43:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1E866B00AB; Wed, 6 Mar 2024 05:43:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CCED26B00AC; Wed, 6 Mar 2024 05:43:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B6FC46B00AD; Wed, 6 Mar 2024 05:43:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id A3E3B6B00AB for ; Wed, 6 Mar 2024 05:43:37 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7BD3A1C0FE1 for ; Wed, 6 Mar 2024 10:43:37 +0000 (UTC) X-FDA: 81866278074.16.75B1E63 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf09.hostedemail.com (Postfix) with ESMTP id C4E02140009 for ; Wed, 6 Mar 2024 10:43:35 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bS8sa99d; spf=pass (imf09.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709721815; 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=Xvz813LBdD6KfIiJu0YrLJw0jIHhy/6tbusNo7kv74Y=; b=5vGSz90d4yWNYob8nmuXueKlpKbvR91rmAB1uWcBMo4bEJM0MugnJ3BY7eRKfBJiq/5Vy/ i20wWdWcPzuuS6fSYWmbRx6NiEivOkgZGG0xncR8ltf8DsIGrormmyEc+DEn/pz0Diunhg p0gvZ9aq4BHDezSnE1ZtZqbpEizRErQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709721815; a=rsa-sha256; cv=none; b=QrFAR6BFc9rG+4SdgloPKcGCsTrLBXuTf2Wfka0gGr2ViNi7+HW1vD/qc6IL9Qwe9l1wGZ WLK9jG8kg+V9xXh/CRsJVFsP5lzyebLdzeITUqh+S3JaYlFOS0xNkC8Y5vTWvcqGzSOxPe c9tXTVQW1vb0dNSeg/72LUotKHUUmeY= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bS8sa99d; spf=pass (imf09.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709721815; 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=Xvz813LBdD6KfIiJu0YrLJw0jIHhy/6tbusNo7kv74Y=; b=bS8sa99d3TIPd3UbtBIsr6QNf9hLaQHWdHMHz7dedZ6xRuk4lteT6qwXzhBuPyTOk87v6E WvbUijDh7iI1L9Y7WvwutXiXEjtkK52kAHt3J104gDi2kpwC98fL5jrvockUWEAzms6bxS Ml6YJT/nUL9kFgxt9ymrkX3g7Sf0plk= 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-313-L24BTaYGPsqZY-a0Fdh6Vw-1; Wed, 06 Mar 2024 05:43:31 -0500 X-MC-Unique: L24BTaYGPsqZY-a0Fdh6Vw-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 D19AE18A6670; Wed, 6 Mar 2024 10:43:30 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01513112131D; Wed, 6 Mar 2024 10:43:24 +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 12/13] mm/treewide: Remove pXd_huge() Date: Wed, 6 Mar 2024 18:41:46 +0800 Message-ID: <20240306104147.193052-13-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: C4E02140009 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: d3eb1xqsqpqoubrnpxxmzrbkte8pupdw X-HE-Tag: 1709721815-577962 X-HE-Meta: U2FsdGVkX19ZCKyj6uq0NHsKLCD8GpnicM4o/I5WynLA6tgRpbElZxksdgXD1UXmlUCJcSreHZfJRjDbtbdz5iD/Ot93j/kuMPtZQr0eTIRyl1CAuKHrEDEArvMm+oL5Z8sacgyzNbDmmYwmwCrUWI3+b76FpYUjU/rU5jv+fvwP3XKr0dtrkvV4TuWuRnHEkl2+/7WDISX/1yJCmyiri0A0RVG6n+kUhZeueUFWHEoaxbxKEiWqUFI9dArGkrH+hol2Y2JuKOl26rCHg6VZRPa/lIqYGWTvYJS9/zk9LPHCN/nQI1WC3X63Dx7UdFR4S94f+0F/wSNmRDDRwQMrcZ5j7LLHwwziob3qeqtKZddBwJNyShafmftCLZuFFGRGtGwf6Nsy2DdP2Kfoq2nMemHTUJ68/E+ihKx57V6X95vXoFLXCKgoN53NfnT2sMohsHB6+U0+MQ/ex42/s5jkz4EFwTwIan8FCopuLFfNxATCDj2gAj+NiDy0SH6gVd53BDoRAAyD6kQLWB+dEbxfvJlqgSV7HGFl2BSnA1eAcx4Q9uby0U1a41nzRghCTiFIVAJTHDXo0mcFaYpqrAWLbuXeitnAOSCP/H2ZSdX+KevSe+c+iI7VUWf59XV1hfQrx32o5IUPcL91j441zr2BjxACyBCX18Tg3xTjB0DYab2KVeTYRY5xUb0/rFoZfv5SvPu+xtFc3WuVOLkoDmtGVr14aRxV9q+P6NbpS9nAs+1TPydfCUVZE0+2TQsfRT2G5hCsU2F3MC0k6fpRJGz/iJlejKC0g1Z8ukSao64D1dp32LKRW4TKYwmyZNt1Fkb38XHOsIkzmUaniad/Y4hasTuUUS8NwzjlYXkzqOSegGqGIL9gxfUq5XWZ0IpqVVkjWLiYxEtUgCBfYVlwXgh5AEPT5Dn6AHbQwgaEbo5PVQwhKf9VJMJvJvAZR9cEsXG9Sd0St0OmAC3wZhYogrF b+zuXhty vxe3vyc+VIMoh3HhMubn+503Ou9477wd77hkVZrqnVGj8Qbw0A1KvS+2J+gWgvNbF3dtxYlLWsdx/rYspzR0qkbYODIV8jZcq+Tx2oRzPUhST6dx53sCNcqE8PnJ7bhS//Tg+IvaFUZesIdVirldfZkwNWIpaDYISwr6u5PwhgtVegLAz/MpzlocKJgVvwHtLwxDXgweCBWM2Pqfo5Q6Amq8//AZ4Vv9/Sleb 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 This API is not used anymore, drop it for the whole tree. Signed-off-by: Peter Xu --- arch/arm/mm/Makefile | 1 - arch/arm/mm/hugetlbpage.c | 29 ------------------- arch/arm64/mm/hugetlbpage.c | 10 ------- arch/loongarch/mm/hugetlbpage.c | 10 ------- arch/mips/include/asm/pgtable-32.h | 2 +- arch/mips/include/asm/pgtable-64.h | 2 +- arch/mips/mm/hugetlbpage.c | 10 ------- arch/parisc/mm/hugetlbpage.c | 11 ------- .../include/asm/book3s/64/pgtable-4k.h | 10 ------- .../include/asm/book3s/64/pgtable-64k.h | 25 ---------------- arch/powerpc/include/asm/book3s/64/pgtable.h | 3 -- arch/powerpc/include/asm/nohash/pgtable.h | 10 ------- arch/riscv/mm/hugetlbpage.c | 10 ------- arch/s390/mm/hugetlbpage.c | 10 ------- arch/sh/mm/hugetlbpage.c | 10 ------- arch/sparc/mm/hugetlbpage.c | 10 ------- arch/x86/mm/hugetlbpage.c | 16 ---------- include/linux/hugetlb.h | 24 --------------- 18 files changed, 2 insertions(+), 201 deletions(-) delete mode 100644 arch/arm/mm/hugetlbpage.c diff --git a/arch/arm/mm/Makefile b/arch/arm/mm/Makefile index 71b858c9b10c..1779e12db085 100644 --- a/arch/arm/mm/Makefile +++ b/arch/arm/mm/Makefile @@ -21,7 +21,6 @@ KASAN_SANITIZE_physaddr.o := n obj-$(CONFIG_DEBUG_VIRTUAL) += physaddr.o obj-$(CONFIG_ALIGNMENT_TRAP) += alignment.o -obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o obj-$(CONFIG_ARM_PV_FIXUP) += pv-fixup-asm.o obj-$(CONFIG_CPU_ABRT_NOMMU) += abort-nommu.o diff --git a/arch/arm/mm/hugetlbpage.c b/arch/arm/mm/hugetlbpage.c deleted file mode 100644 index c2fa643f6bb5..000000000000 --- a/arch/arm/mm/hugetlbpage.c +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * arch/arm/mm/hugetlbpage.c - * - * Copyright (C) 2012 ARM Ltd. - * - * Based on arch/x86/include/asm/hugetlb.h and Bill Carson's patches - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -int pud_huge(pud_t pud) -{ - return 0; -} - -int pmd_huge(pmd_t pmd) -{ - return pmd_leaf(pmd); -} diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index f494fc31201f..ca58210d6c07 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -79,16 +79,6 @@ bool arch_hugetlb_migration_supported(struct hstate *h) } #endif -int pmd_huge(pmd_t pmd) -{ - return pmd_leaf(pmd); -} - -int pud_huge(pud_t pud) -{ - return pud_leaf(pud); -} - static int find_num_contig(struct mm_struct *mm, unsigned long addr, pte_t *ptep, size_t *pgsize) { diff --git a/arch/loongarch/mm/hugetlbpage.c b/arch/loongarch/mm/hugetlbpage.c index a4e78e74aa21..12222c56cb59 100644 --- a/arch/loongarch/mm/hugetlbpage.c +++ b/arch/loongarch/mm/hugetlbpage.c @@ -50,16 +50,6 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr, return (pte_t *) pmd; } -int pmd_huge(pmd_t pmd) -{ - return (pmd_val(pmd) & _PAGE_HUGE) != 0; -} - -int pud_huge(pud_t pud) -{ - return (pud_val(pud) & _PAGE_HUGE) != 0; -} - uint64_t pmd_to_entrylo(unsigned long pmd_val) { uint64_t val; diff --git a/arch/mips/include/asm/pgtable-32.h b/arch/mips/include/asm/pgtable-32.h index 0e196650f4f4..92b7591aac2a 100644 --- a/arch/mips/include/asm/pgtable-32.h +++ b/arch/mips/include/asm/pgtable-32.h @@ -129,7 +129,7 @@ static inline int pmd_none(pmd_t pmd) static inline int pmd_bad(pmd_t pmd) { #ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT - /* pmd_huge(pmd) but inline */ + /* pmd_leaf(pmd) but inline */ if (unlikely(pmd_val(pmd) & _PAGE_HUGE)) return 0; #endif diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h index 20ca48c1b606..7c28510b3768 100644 --- a/arch/mips/include/asm/pgtable-64.h +++ b/arch/mips/include/asm/pgtable-64.h @@ -245,7 +245,7 @@ static inline int pmd_none(pmd_t pmd) static inline int pmd_bad(pmd_t pmd) { #ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT - /* pmd_huge(pmd) but inline */ + /* pmd_leaf(pmd) but inline */ if (unlikely(pmd_val(pmd) & _PAGE_HUGE)) return 0; #endif diff --git a/arch/mips/mm/hugetlbpage.c b/arch/mips/mm/hugetlbpage.c index 7eaff5b07873..0b9e15555b59 100644 --- a/arch/mips/mm/hugetlbpage.c +++ b/arch/mips/mm/hugetlbpage.c @@ -57,13 +57,3 @@ pte_t *huge_pte_offset(struct mm_struct *mm, unsigned long addr, } return (pte_t *) pmd; } - -int pmd_huge(pmd_t pmd) -{ - return (pmd_val(pmd) & _PAGE_HUGE) != 0; -} - -int pud_huge(pud_t pud) -{ - return (pud_val(pud) & _PAGE_HUGE) != 0; -} diff --git a/arch/parisc/mm/hugetlbpage.c b/arch/parisc/mm/hugetlbpage.c index a9f7e21f6656..0356199bd9e7 100644 --- a/arch/parisc/mm/hugetlbpage.c +++ b/arch/parisc/mm/hugetlbpage.c @@ -180,14 +180,3 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma, } return changed; } - - -int pmd_huge(pmd_t pmd) -{ - return 0; -} - -int pud_huge(pud_t pud) -{ - return 0; -} diff --git a/arch/powerpc/include/asm/book3s/64/pgtable-4k.h b/arch/powerpc/include/asm/book3s/64/pgtable-4k.h index 92545981bb49..baf934578c3a 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable-4k.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable-4k.h @@ -6,16 +6,6 @@ */ #ifndef __ASSEMBLY__ #ifdef CONFIG_HUGETLB_PAGE -static inline int pmd_huge(pmd_t pmd) -{ - return pmd_leaf(pmd); -} - -static inline int pud_huge(pud_t pud) -{ - return pud_leaf(pud); -} - /* * With radix , we have hugepage ptes in the pud and pmd entries. We don't * need to setup hugepage directory for them. Our pte and page directory format diff --git a/arch/powerpc/include/asm/book3s/64/pgtable-64k.h b/arch/powerpc/include/asm/book3s/64/pgtable-64k.h index 2fce3498b000..579a7153857f 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable-64k.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable-64k.h @@ -4,31 +4,6 @@ #ifndef __ASSEMBLY__ #ifdef CONFIG_HUGETLB_PAGE -/* - * We have PGD_INDEX_SIZ = 12 and PTE_INDEX_SIZE = 8, so that we can have - * 16GB hugepage pte in PGD and 16MB hugepage pte at PMD; - * - * Defined in such a way that we can optimize away code block at build time - * if CONFIG_HUGETLB_PAGE=n. - * - * returns true for pmd migration entries, THP, devmap, hugetlb - * But compile time dependent on CONFIG_HUGETLB_PAGE - */ -static inline int pmd_huge(pmd_t pmd) -{ - /* - * leaf pte for huge page - */ - return !!(pmd_raw(pmd) & cpu_to_be64(_PAGE_PTE)); -} - -static inline int pud_huge(pud_t pud) -{ - /* - * leaf pte for huge page - */ - return !!(pud_raw(pud) & cpu_to_be64(_PAGE_PTE)); -} /* * With 64k page size, we have hugepage ptes in the pgd and pmd entries. We don't diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index df66dce8306f..05a91c99d431 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -1436,9 +1436,6 @@ static inline bool is_pte_rw_upgrade(unsigned long old_val, unsigned long new_va return false; } -/* - * Like pmd_huge(), but works regardless of config options - */ #define pmd_leaf pmd_leaf static inline bool pmd_leaf(pmd_t pmd) { diff --git a/arch/powerpc/include/asm/nohash/pgtable.h b/arch/powerpc/include/asm/nohash/pgtable.h index 427db14292c9..f5f39d4f03c8 100644 --- a/arch/powerpc/include/asm/nohash/pgtable.h +++ b/arch/powerpc/include/asm/nohash/pgtable.h @@ -351,16 +351,6 @@ static inline int hugepd_ok(hugepd_t hpd) #endif } -static inline int pmd_huge(pmd_t pmd) -{ - return 0; -} - -static inline int pud_huge(pud_t pud) -{ - return 0; -} - #define is_hugepd(hpd) (hugepd_ok(hpd)) #endif diff --git a/arch/riscv/mm/hugetlbpage.c b/arch/riscv/mm/hugetlbpage.c index 29c7606414d2..9a4bc4bd2a01 100644 --- a/arch/riscv/mm/hugetlbpage.c +++ b/arch/riscv/mm/hugetlbpage.c @@ -399,16 +399,6 @@ static bool is_napot_size(unsigned long size) #endif /*CONFIG_RISCV_ISA_SVNAPOT*/ -int pud_huge(pud_t pud) -{ - return pud_leaf(pud); -} - -int pmd_huge(pmd_t pmd) -{ - return pmd_leaf(pmd); -} - static bool __hugetlb_valid_size(unsigned long size) { if (size == HPAGE_SIZE) diff --git a/arch/s390/mm/hugetlbpage.c b/arch/s390/mm/hugetlbpage.c index c2e8242bd15d..ca43b6fce71c 100644 --- a/arch/s390/mm/hugetlbpage.c +++ b/arch/s390/mm/hugetlbpage.c @@ -233,16 +233,6 @@ pte_t *huge_pte_offset(struct mm_struct *mm, return (pte_t *) pmdp; } -int pmd_huge(pmd_t pmd) -{ - return pmd_leaf(pmd); -} - -int pud_huge(pud_t pud) -{ - return pud_leaf(pud); -} - bool __init arch_hugetlb_valid_size(unsigned long size) { if (MACHINE_HAS_EDAT1 && size == PMD_SIZE) diff --git a/arch/sh/mm/hugetlbpage.c b/arch/sh/mm/hugetlbpage.c index 6cb0ad73dbb9..ff209b55285a 100644 --- a/arch/sh/mm/hugetlbpage.c +++ b/arch/sh/mm/hugetlbpage.c @@ -70,13 +70,3 @@ pte_t *huge_pte_offset(struct mm_struct *mm, return pte; } - -int pmd_huge(pmd_t pmd) -{ - return 0; -} - -int pud_huge(pud_t pud) -{ - return 0; -} diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c index d31c2cec35c9..8ed5bdf95d25 100644 --- a/arch/sparc/mm/hugetlbpage.c +++ b/arch/sparc/mm/hugetlbpage.c @@ -407,16 +407,6 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, return entry; } -int pmd_huge(pmd_t pmd) -{ - return pmd_leaf(pmd);; -} - -int pud_huge(pud_t pud) -{ - return pud_leaf(pud); -} - static void hugetlb_free_pte_range(struct mmu_gather *tlb, pmd_t *pmd, unsigned long addr) { diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c index 8362953a24ce..dab6db288e5b 100644 --- a/arch/x86/mm/hugetlbpage.c +++ b/arch/x86/mm/hugetlbpage.c @@ -19,22 +19,6 @@ #include #include -/* - * pmd_huge() returns 1 if @pmd is hugetlb related entry. - */ -int pmd_huge(pmd_t pmd) -{ - return pmd_leaf(pmd); -} - -/* - * pud_huge() returns 1 if @pud is hugetlb related entry. - */ -int pud_huge(pud_t pud) -{ - return pud_leaf(pud); -} - #ifdef CONFIG_HUGETLB_PAGE static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file, unsigned long addr, unsigned long len, diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 77b30a8c6076..300de33c6fde 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -272,13 +272,9 @@ void hugetlb_vma_unlock_write(struct vm_area_struct *vma); int hugetlb_vma_trylock_write(struct vm_area_struct *vma); void hugetlb_vma_assert_locked(struct vm_area_struct *vma); void hugetlb_vma_lock_release(struct kref *kref); - -int pmd_huge(pmd_t pmd); -int pud_huge(pud_t pud); long hugetlb_change_protection(struct vm_area_struct *vma, unsigned long address, unsigned long end, pgprot_t newprot, unsigned long cp_flags); - bool is_hugetlb_entry_migration(pte_t pte); bool is_hugetlb_entry_hwpoisoned(pte_t pte); void hugetlb_unshare_all_pmds(struct vm_area_struct *vma); @@ -399,16 +395,6 @@ static inline void hugetlb_vma_assert_locked(struct vm_area_struct *vma) { } -static inline int pmd_huge(pmd_t pmd) -{ - return 0; -} - -static inline int pud_huge(pud_t pud) -{ - return 0; -} - static inline int is_hugepage_only_range(struct mm_struct *mm, unsigned long addr, unsigned long len) { @@ -493,16 +479,6 @@ static inline vm_fault_t hugetlb_fault(struct mm_struct *mm, static inline void hugetlb_unshare_all_pmds(struct vm_area_struct *vma) { } #endif /* !CONFIG_HUGETLB_PAGE */ -/* - * hugepages at page global directory. If arch support - * hugepages at pgd level, they need to define this. - */ -#ifndef pgd_huge -#define pgd_huge(x) 0 -#endif -#ifndef p4d_huge -#define p4d_huge(x) 0 -#endif #ifndef pgd_write static inline int pgd_write(pgd_t pgd) 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: U2FsdGVkX19UE1bVTR3L4njQnvB0J3+GdhN3qBU2x+Fm1CtdfsMBkKweSExnhlFfj5hxi6H2zbaDSRk9p3sMJgMLeBNW9mbOjHLa/JQZIJrIVk/6UmH3dEnu9lkETPn5aK0k/7UGHBF2Lqy9lqzvGmsMKOCdP7ZGJTwOsFDhTVQLJJH+11vS6vtAjpp1cNpIr+hOZk6Sb8e9O+kbfDa5NsepErRT1KLTvGu38QeXsLFWNH9Ylf/WtMn+Wi6imMNPxv6Pvt3GQ+jbZ4/IEazfBgycuXI9UdTtuzpTQkj1517ZAeXV52m9UnAijkcUBvqnBpg22jUUtoldO/uvKS9Rysq6DdeZwm9rowYBhlpaw/93Nj6l9S8Uk0KlM493SUBJXOpVnRaJdflOxcqGPpG9/aFP8/UxEreml0g1f5zEAFpONhY3sHrFieHIDLGS0qH2VFb0H4CdCoCCLMhlsvfnPgo/IPWR+Fx1hX2Hp1W+cmTcQGPNTm+h5r6og76IJUn+Bv+AiXwi+P8H1bCuOrfmp3GBkk98p0A3hC1Lbk4Dq7GC2cqRKXMrVa+a3XnYpskoZRkSOHc7HB+sefyE7g7h16tN7vTtYw6yyIW7A0toMFRK5hLLEqjHHmjy55QY0stuyiaQ1nb7uY5eqMHfduzCI7w/2zmw7aD74hI4Jf8t/EXxRp7oyx0bfla8M6xX4c3Oxyrsvpdf7vQ5DHViLC6L6XH3UfiizB0f5uXxDbvZG3dTWd0MwSVJSOJmE6n8nS3LBxLvfg82BlaKL95Lnl7gY1IzZL4mPfRrBLAvPvm+pTfGMz/flGCYAGik7ti179uR11R3WWw+nzVUhLVxratlNQ/avHNcttd8fYm8WDCAk+T4szujGV9QpNC9WD2LkJvTJtI7bFrLZamyWxPaCsxjP356ruwv3VGTE54xey8Ayr5R2uO3pKrx6j73voExJUJC40qiuVSWm7YXJqIJvHf WBNAl45p hS398nzNsmdHnnVMSW2F2MEUz9rZZ7fZpQR6uRb2g7er4BnxQI9HhDZbQGCPAV0Amc8Pa6R8L58kEE++mA6/nnUvLjtAvg0Ffw+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