From patchwork Mon Mar 31 08:13:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 14033791 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 76A56C3600B for ; Mon, 31 Mar 2025 16:31:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 56CF9280008; Mon, 31 Mar 2025 12:31:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F39A280005; Mon, 31 Mar 2025 12:31:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3BB96280008; Mon, 31 Mar 2025 12:31:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 174BE280005 for ; Mon, 31 Mar 2025 12:31:06 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9DEE957A33 for ; Mon, 31 Mar 2025 08:13:47 +0000 (UTC) X-FDA: 83281132494.05.2DC2E0C 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 DF3A9C0004 for ; Mon, 31 Mar 2025 08:13:45 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JCAX5KaT; spf=pass (imf22.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743408825; 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=VpQkE/o6UqynMHBaEyGhtuzDswvJwtgU/N8i6Bf76yI=; b=Pm3oUVwgetOivgLc2oJvJVDLm/oIPN+3Rex2OeZFaMVMz3TTIaTgG5Hw8NmnvEnatFNhJd yjRQmwixq/C1c/70ShSIeLEhYqyjFMCZK+gSlOB8tKhiBEJ9bPmf7cmK6hjHtTcej1lVgp YiQiHplNHusBP7WEFJEPHgx+HLdzcuc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743408825; a=rsa-sha256; cv=none; b=LW5bJiqtQBSkDN17hFbGHqechXC2jULKxpw7979BaYKpdb1GrNUjxDxOIpF6v/TycuLeRN FwBZuch48ty63/tn6eN7M2dGSy52a1tlG8FvscVmwt9wHD9DSH7o21S2vWticf3jeFLhP+ L61aAw7nr71Rl/SrEUVYSVHdGkhkydQ= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JCAX5KaT; spf=pass (imf22.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743408825; 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=VpQkE/o6UqynMHBaEyGhtuzDswvJwtgU/N8i6Bf76yI=; b=JCAX5KaThZGkoi3RXSw4XhNz3zAJGxvfLUWTRGevlk/CikbrAtt242CCs/dUIMIx0MJVbP P9fH0HRXD3qsPK1H1EZ3qVdYI7aiWKisKpxKk1aoSBRRKiXyntXOyGkUzkZhYxDFpFw+EX DtlygZB3a2aDGMey5VV67Sd1s2Vr+qg= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-641-fGwKGbB3NxqKefEQ3WVoQw-1; Mon, 31 Mar 2025 04:13:39 -0400 X-MC-Unique: fGwKGbB3NxqKefEQ3WVoQw-1 X-Mimecast-MFC-AGG-ID: fGwKGbB3NxqKefEQ3WVoQw_1743408818 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4C260180882E; Mon, 31 Mar 2025 08:13:38 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.112.9]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2BCB11955BF1; Mon, 31 Mar 2025 08:13:34 +0000 (UTC) From: Baoquan He To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, yanjun.zhu@linux.dev, Baoquan He Subject: [PATCH v2 1/7] mm/gup: fix wrongly calculated returned value in fault_in_safe_writeable() Date: Mon, 31 Mar 2025 16:13:21 +0800 Message-ID: <20250331081327.256412-2-bhe@redhat.com> In-Reply-To: <20250331081327.256412-1-bhe@redhat.com> References: <20250331081327.256412-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Rspam-User: X-Rspamd-Server: rspam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mXYRDY r3LWGbFa4ubBYMgZoyhrnAlQhAPd8T/3Fg31cAtRO6oJQTLBckoru3oGbE+BrQ5qetYCixJ/I8TP0joJ71R9zLyreACla696yZRigqrTQJaleK5U2jYKiz98Lcr2O0/kvCZgVPjVPNONgIixKHNP4NtebOW0NoLpZ6F5c0auXR0mWpBZIelfGLttrZOZshqMfgakW4wUdMUB6oRUAVnpbc3Yq07TS13vGn1+hdN64ZKOfWhxcUEgffqgnr63tc2wGghHVtJWEVsZC5SOG9gUMzNSXKMH00lfL1+mHMqrej7amLNDJCaKE4e19PCuaXRjgGFP7PRM9ZkbgTjTzg9RM3rDT+l88XhLr9/GgQWE1TQ9LM/Q1Tbrcyjajjg== 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: Not like fault_in_readable() or fault_in_writeable(), in fault_in_safe_writeable() local variable 'start' is increased page by page to loop till the whole address range is handled. However, it mistakenly calcalates the size of handled range with 'uaddr - start'. Fix it here. Signed-off-by: Baoquan He --- v1->v2: - Fix a patch log typo caused by copy-and-paste error. Thanks to Yanjun. mm/gup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 855ab860f88b..73777b1de679 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2207,8 +2207,8 @@ size_t fault_in_safe_writeable(const char __user *uaddr, size_t size) } while (start != end); mmap_read_unlock(mm); - if (size > (unsigned long)uaddr - start) - return size - ((unsigned long)uaddr - start); + if (size > start - (unsigned long)uaddr) + return size - (start - (unsigned long)uaddr); return 0; } EXPORT_SYMBOL(fault_in_safe_writeable); From patchwork Mon Mar 31 08:13:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 14033788 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 C5F5EC36011 for ; Mon, 31 Mar 2025 16:29:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5231280003; Mon, 31 Mar 2025 12:29:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E01C2280001; Mon, 31 Mar 2025 12:29:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CCA0E280003; Mon, 31 Mar 2025 12:29:23 -0400 (EDT) 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 A87F4280001 for ; Mon, 31 Mar 2025 12:29:23 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A0844C0CD2 for ; Mon, 31 Mar 2025 08:13:51 +0000 (UTC) X-FDA: 83281132662.16.13DCCF0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id BEE6C14000E for ; Mon, 31 Mar 2025 08:13:49 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="PVe1/g9D"; spf=pass (imf26.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743408829; 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=w0gf9RGsw/MtUT85PnmYum3vQIHTxmH593ortJMGyJU=; b=goZ8M1V9JWt+Rk07TpDtRx9YiARxkdRKuEvWaO8Wj7ILFNHBOAABWGSmnVvFzGlwpWElDZ gAG/KdaQ4g3cXCfHQXNlXaJ2M5YUAn37cMXyXmsXNMtiHQ4eK+SN/O0SwpOUgPhIVmGNYR DEskxKBh8abIsTzyj45T1SrqtABXGjE= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="PVe1/g9D"; spf=pass (imf26.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743408829; a=rsa-sha256; cv=none; b=EmfnFqoX/IVkk3PKSUvN5C4mgC7LeAX8HDR14LNkkVxniCh13CCQ81H3nCuUcacgmfGt9j mi6z63t+YGGC6ns4qtMNfRSMDPyS9iB4KDnS0AqgLKcp0P1h5RkJoaI0dqpP0u6g0Zyvy4 eftYLdD881dCgorsHF6rdl3iWhjCyW0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743408829; 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=w0gf9RGsw/MtUT85PnmYum3vQIHTxmH593ortJMGyJU=; b=PVe1/g9DwaNvsyUwWvNp709Brrnckkzd3j9CK0J7mZd5Lwhlq7ASf0nP2BlLbu54hdTfT7 BqJn88fHqBgv8CRiu+gv7SOMIZ6OuIkA0be3ah2lT6r9yc6lIM+qAYwP+8AMDxlR8f22CT L1SDYqAvAZDWvY8dodZcLu7CpUT5Tdg= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-371-Vy8rpVrTPkeCly9O0-hLPQ-1; Mon, 31 Mar 2025 04:13:45 -0400 X-MC-Unique: Vy8rpVrTPkeCly9O0-hLPQ-1 X-Mimecast-MFC-AGG-ID: Vy8rpVrTPkeCly9O0-hLPQ_1743408824 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 34A251800258; Mon, 31 Mar 2025 08:13:43 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.112.9]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 07CC51955BEF; Mon, 31 Mar 2025 08:13:39 +0000 (UTC) From: Baoquan He To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, yanjun.zhu@linux.dev, Baoquan He Subject: [PATCH v2 2/7] mm/gup: check if both GUP_GET and GUP_PIN are set in __get_user_pages() earlier Date: Mon, 31 Mar 2025 16:13:22 +0800 Message-ID: <20250331081327.256412-3-bhe@redhat.com> In-Reply-To: <20250331081327.256412-1-bhe@redhat.com> References: <20250331081327.256412-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Rspamd-Queue-Id: BEE6C14000E X-Stat-Signature: 8mpjmkqaqreuz1mrxq5suu7cna4f5era X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1743408829-440999 X-HE-Meta: U2FsdGVkX1+ZMTDxIetRd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bPaYJjABKLSOuWM9Q2aBCHVBpcSXvSJccGOzFIwTKu2buweDh1fBgI06kQZHGdv1PRFh94+fj20M1Ase0UTPX5OwalWIZYb/ODdlwEnbZOyPKsOtCYXsy+z5f549oPZjb6iKPLATUIDUjs3B/Qrfcj/j3P8P/9+MYPOZSlLHHMz4K2Le4osxZ95WPyKETZWx0iR+NgC/qQR1WaBtu6VdLFRA8Gydu+LElJq0cA2bNJ9C0Y3D4ndz637jX45uH3GyqV18Nn1/w0vRHrZSjA== 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: In __get_user_pages(), it will traverse page table and take a reference to the page the given user address corresponds to if GUP_GET or GUP_PIN is et. However, it's not supported both GUP_GET and GUP_PIN are set. This check should be done earlier, but not doing it till entering into follow_page_pte() and failed. Here move the checking to the beginning of __get_user_pages(). Signed-off-by: Baoquan He --- v1->v2: - Fix code bug caused by copy-and-paste error, this is reported by lkp test robot. mm/gup.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 73777b1de679..f9bce14ed3cd 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -847,11 +847,6 @@ static struct page *follow_page_pte(struct vm_area_struct *vma, pte_t *ptep, pte; int ret; - /* FOLL_GET and FOLL_PIN are mutually exclusive. */ - if (WARN_ON_ONCE((flags & (FOLL_PIN | FOLL_GET)) == - (FOLL_PIN | FOLL_GET))) - return ERR_PTR(-EINVAL); - ptep = pte_offset_map_lock(mm, pmd, address, &ptl); if (!ptep) return no_page_table(vma, flags, address); @@ -1434,6 +1429,11 @@ static long __get_user_pages(struct mm_struct *mm, VM_BUG_ON(!!pages != !!(gup_flags & (FOLL_GET | FOLL_PIN))); + /* FOLL_GET and FOLL_PIN are mutually exclusive. */ + if (WARN_ON_ONCE((gup_flags & (FOLL_PIN | FOLL_GET)) == + (FOLL_PIN | FOLL_GET))) + return -EINVAL; + do { struct page *page; unsigned int page_increm; From patchwork Mon Mar 31 08:13:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 14033787 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 E1D32C3600B for ; Mon, 31 Mar 2025 16:29:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E362F280002; Mon, 31 Mar 2025 12:29:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE3F8280001; Mon, 31 Mar 2025 12:29:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD426280002; Mon, 31 Mar 2025 12:29:12 -0400 (EDT) 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 AEEC3280001 for ; Mon, 31 Mar 2025 12:29:12 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F2F34B9A2D for ; Mon, 31 Mar 2025 08:13:54 +0000 (UTC) X-FDA: 83281132788.14.C021D86 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 5E7B1180005 for ; Mon, 31 Mar 2025 08:13:53 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OnOLQ2Uh; spf=pass (imf24.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743408833; 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=Zh1/TrAESP0WnH+wS47UsqcVh/5ztuo1zl6IdlNR8C8=; b=UZMOHFaY3sSax1bNB2oZNkwzuYzBkl68jhDyMF7SspaX5M3TkDwrgQBPuS6MwMQtN6h/IV WFeAjaPChPMDgAhImM3BnAiizNX0o45tmwcBQCgYGd5TiFepC3dJAakL5TkChM+88iyZib 1cJPmcenfV5qIaClXJ1Wm7OQZm1c80U= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743408833; a=rsa-sha256; cv=none; b=Inuvo25QLnM0BYuNecyvqZIm9ebTLbGBUKnBI8mYV2cE9zBbaaIesrE1JbMwLmOwThNvfp nDaBvvSsFeHKwTWgMqru8k0bYbrrq+XtQQZ8+LPHS4FxdVhQAfaI5qRAjzG3vBSzxMAHz3 ohgRlCsLIQC+hdXpbyijG1oazPBPN70= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OnOLQ2Uh; spf=pass (imf24.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743408832; 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=Zh1/TrAESP0WnH+wS47UsqcVh/5ztuo1zl6IdlNR8C8=; b=OnOLQ2Uh5jb07mW41Bn6ECdTkHrfpYyyFcpqV4r96gz+wmYHSgBmtXI2jGWya+2eKH/bVo 6nNIAuMVg+42nDf07+F+6OjbH4scIruWugxgSMav/ntqvh7dHNE7/lCeYXmZhGJS/Dsv4M nqI0JCHTqG/tvZT9wcfQBGrsBEF3EBo= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-164-Dl07PehiO7uuJ-PB7EvKqQ-1; Mon, 31 Mar 2025 04:13:48 -0400 X-MC-Unique: Dl07PehiO7uuJ-PB7EvKqQ-1 X-Mimecast-MFC-AGG-ID: Dl07PehiO7uuJ-PB7EvKqQ_1743408827 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 602D31801A1A; Mon, 31 Mar 2025 08:13:47 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.112.9]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1BC941955BF1; Mon, 31 Mar 2025 08:13:43 +0000 (UTC) From: Baoquan He To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, yanjun.zhu@linux.dev, Baoquan He Subject: [PATCH v2 3/7] mm/gup: Fix the outdated code comments above get_user_pages_unlocked() Date: Mon, 31 Mar 2025 16:13:23 +0800 Message-ID: <20250331081327.256412-4-bhe@redhat.com> In-Reply-To: <20250331081327.256412-1-bhe@redhat.com> References: <20250331081327.256412-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Stat-Signature: ftxw81h4t9dahszytb7ex6d817morssd X-Rspam-User: X-Rspamd-Queue-Id: 5E7B1180005 X-Rspamd-Server: rspam08 X-HE-Tag: 1743408833-829039 X-HE-Meta: U2FsdGVkX19bkyXE7l4ZsuawNNVETaXBtFv0FJCnguEyD5F9VFiEf2Q7gGMuGbTNw5uyH5h9Fa2zs9sLYXmLEqXlrdHOZFlqSLoxOJZ2RPFpjCns++D9UxyaCveQ8HWbgWMwA3I+/ijc4z6pRuN/V695wCqzsnpwt1A/DLSECdjEKPwxqz37vumQxDgCXZIeYuwdfliG7XuqBkrf12h8x5zYCzsc68DOILfCxkJ05lx9rk58c+70koIAS4S9tbkRvjtIflBd2JTylPdVH+wjMnYo+dUjBJ2d6jPItI8AT/K7KVo8icYc/4QFWvdhGCIb8cd3n+TVukQbW5WlST2V2PgAbXmYwpIHR29+uVeZZWsrzJqULTQunfQJYPPpI7Xo6gSP/zeuctnibHz//usSKUu8SFSBWxSkk7zcveGOtJMaWL7hbZ3nvKP7fDQw3JleLdqP4U7/uL/d0AwTYyZJmboCDGgTBhy3zltdSyIVo7IGWae40qDiqLXSXyPxg1a5rhy7viQb137CJtChfWAJ1uJuBNtVS6KqCycKDeBoDUCn9QrahZ66dESKheKxw1jhMuvEJ1PD6oNgEKHPwGTfuQYMYQ8LKJ5Y6CliFv6qZs/abrQdSTxOrnSkog4DO/cE5t/EIadsjpAFWtqEvSio8L8cHndbMJImRewZtie8FB/AF2HMtVHXO69iAKLn5q8CRQJii9HSsWVjtCUure4UCFRTU3xM9N7pKsG0/VhBkb5e43YOkvN57mokM4vj6EtR0httfKBWLUs05pCbxpdxhVKBkbUzBpMUADgCpykAN1bEEOabJgb3//MmPIpYeF+T1MLCMuOxhkbOoUI3F+xNn/GPL7PEn2lGKcB4R3SmoHQaTehxcsqM/SKQRpVGkesF8Sle7M5Gt4WfBh1XVPBW7vLgKDydIm0viji5MifbUkKZocrhAhhLo+zCzueNPB37H7AVt31Hry7udvgECrR u2zeBLum ki7FiQWg38bZ5voTJYnq3ARe5sVv2n9St1Xtthgga88LreA+cdYUHbj2Nj8nx8ioSsAQIHO7B6YBlEGUHAZC3GdFey+F7sKcBNtNL6v2FsXX/3Sc= 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: Since commit f0818f472d8d ("mm: gup: add get_user_pages_locked and get_user_pages_unlocked"), get_user_pages() doesn't need to have mmap_lock held anymore. It calls __get_user_pages_locked() which can acquire and drop the mmap_lock internaly. Hence remove the incorrect code comments now. Signed-off-by: Baoquan He --- mm/gup.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index f9bce14ed3cd..a15317cf6641 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2702,19 +2702,9 @@ long get_user_pages(unsigned long start, unsigned long nr_pages, EXPORT_SYMBOL(get_user_pages); /* - * get_user_pages_unlocked() is suitable to replace the form: - * - * mmap_read_lock(mm); - * get_user_pages(mm, ..., pages, NULL); - * mmap_read_unlock(mm); - * - * with: - * - * get_user_pages_unlocked(mm, ..., pages); - * - * It is functionally equivalent to get_user_pages_fast so - * get_user_pages_fast should be used instead if specific gup_flags - * (e.g. FOLL_FORCE) are not required. + * get_user_pages_unlocked() is functionally equivalent to + * get_user_pages_fast so get_user_pages_fast should be used instead + * if specific gup_flags (e.g. FOLL_FORCE) are not required. */ long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages, struct page **pages, unsigned int gup_flags) From patchwork Mon Mar 31 08:13:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 14033796 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 6E090C3600B for ; Mon, 31 Mar 2025 16:33:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 05ABE28000B; Mon, 31 Mar 2025 12:33:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 008B8280005; Mon, 31 Mar 2025 12:33:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E128A28000B; Mon, 31 Mar 2025 12:33:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id C240A280005 for ; Mon, 31 Mar 2025 12:33:51 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 996E8140D7F for ; Mon, 31 Mar 2025 08:14:02 +0000 (UTC) X-FDA: 83281133124.24.CCB1390 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id CCBDA40009 for ; Mon, 31 Mar 2025 08:14:00 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ioFZUj5t; spf=pass (imf17.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743408840; 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=o7TFDmuhd1kibEufM0EW11EDmCZ8boAIcxccfqu0TA0=; b=2fYaegcnewf0P6Cnh45yLpW1n3VLHUNQelk5WS+xgys2hULqxCgCaR9ISy5QT3NmgRtnqt 3B77lcBQVN5hiMuMYuD+wrIuLmHNsRANEIAbeXphBkBKq6RCWaIY2aFXuOB789FBWV/hhT GjLOF4zbafguSHY7tbfIDJ1CGgBaaZk= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ioFZUj5t; spf=pass (imf17.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743408840; a=rsa-sha256; cv=none; b=kM2mFa/Geix15Aykhp+qLdSquJDpB2CiwThnU19RaRe6kg7jJ2Xv+pP9GC0DxXHVbvYvo6 3xlg7VZV+HqrrBWpfELc9trN45fjmSO0+dpqq6oCy9XaDUSXIfdFAXYgm8+t3nhJjCbXdR aKbDCMA3O9PR5y4sEss/spdpFUDBYkI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743408840; 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=o7TFDmuhd1kibEufM0EW11EDmCZ8boAIcxccfqu0TA0=; b=ioFZUj5tX7pBI8XAyvWRTEv2I46fHZZ5KTJtGoO3PxnXZg9lx2IeIvkeFQBKMIufXjUhBF S0++kCmxJTBtPdv2E/Ou4WcgX5Uq3lhwyRC12vXEfAk4maYByqr1RF+6qW/msDYwf0Ij4c G+p+/SNLGj422VjVxIyWFHRHgHbC30w= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-BaTzCZBMPDWfogDH-E7-JQ-1; Mon, 31 Mar 2025 04:13:57 -0400 X-MC-Unique: BaTzCZBMPDWfogDH-E7-JQ-1 X-Mimecast-MFC-AGG-ID: BaTzCZBMPDWfogDH-E7-JQ_1743408836 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7379319560B8; Mon, 31 Mar 2025 08:13:51 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.112.9]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 49E231955BEF; Mon, 31 Mar 2025 08:13:47 +0000 (UTC) From: Baoquan He To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, yanjun.zhu@linux.dev, Baoquan He Subject: [PATCH v2 4/7] mm/gup: remove gup_fast_pgd_leaf() and clean up the relevant codes Date: Mon, 31 Mar 2025 16:13:24 +0800 Message-ID: <20250331081327.256412-5-bhe@redhat.com> In-Reply-To: <20250331081327.256412-1-bhe@redhat.com> References: <20250331081327.256412-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Rspamd-Queue-Id: CCBDA40009 X-Rspamd-Server: rspam05 X-Rspam-User: X-Stat-Signature: pjhqwhgryxtq7upjbm7xxyfwz39sw6iq X-HE-Tag: 1743408840-903534 X-HE-Meta: U2FsdGVkX1/9wmhDG7vAzDON1GRsFcX2Rp1YlIq8qQGHviMaDnoG5aHhxuwqCfd//Mt+w4xJ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w+gNFRtdGddBxyC4XtFOLucwtXK60gq40UPsnux70O+p8SkpgQjDGjSoSbEaWJJ0vX3+g2WVbD7N8pk2Md6WPG6mIioZBKrrVPNihyrclrTnQL4MBydreOASAvcPQSLAXMHXO7CCUmJPWGw4kZbSaz8eBH324J8qG8ioo+pD/ByoLkfHJJJMqycrJ3iWSQ4kl8Mt/EJnApdAbYg== 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: In the current kernel, only pud huge page is supported in some architectures. P4d and pgd huge pages haven't been supported yet. And in mm/gup.c, there's no pgd huge page handling in the follow_page_mask() code path. Hence it doesn't make sense to have gup_fast_pgd_leaf() in gup_fast code path. Here remove gup_fast_pgd_leaf() and clean up the relevant codes. Signed-off-by: Baoquan He Acked-by: David Hildenbrand Reviewed-by: Oscar Salvador --- mm/gup.c | 49 +++---------------------------------------------- 1 file changed, 3 insertions(+), 46 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index a15317cf6641..58cdc5605a4a 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -3168,46 +3168,6 @@ static int gup_fast_pud_leaf(pud_t orig, pud_t *pudp, unsigned long addr, return 1; } -static int gup_fast_pgd_leaf(pgd_t orig, pgd_t *pgdp, unsigned long addr, - unsigned long end, unsigned int flags, struct page **pages, - int *nr) -{ - int refs; - struct page *page; - struct folio *folio; - - if (!pgd_access_permitted(orig, flags & FOLL_WRITE)) - return 0; - - BUILD_BUG_ON(pgd_devmap(orig)); - - page = pgd_page(orig); - refs = record_subpages(page, PGDIR_SIZE, addr, end, pages + *nr); - - folio = try_grab_folio_fast(page, refs, flags); - if (!folio) - return 0; - - if (unlikely(pgd_val(orig) != pgd_val(*pgdp))) { - gup_put_folio(folio, refs, flags); - return 0; - } - - if (!pgd_write(orig) && gup_must_unshare(NULL, flags, &folio->page)) { - gup_put_folio(folio, refs, flags); - return 0; - } - - if (!gup_fast_folio_allowed(folio, flags)) { - gup_put_folio(folio, refs, flags); - return 0; - } - - *nr += refs; - folio_set_referenced(folio); - return 1; -} - static int gup_fast_pmd_range(pud_t *pudp, pud_t pud, unsigned long addr, unsigned long end, unsigned int flags, struct page **pages, int *nr) @@ -3302,12 +3262,9 @@ static void gup_fast_pgd_range(unsigned long addr, unsigned long end, next = pgd_addr_end(addr, end); if (pgd_none(pgd)) return; - if (unlikely(pgd_leaf(pgd))) { - if (!gup_fast_pgd_leaf(pgd, pgdp, addr, next, flags, - pages, nr)) - return; - } else if (!gup_fast_p4d_range(pgdp, pgd, addr, next, flags, - pages, nr)) + BUILD_BUG_ON(pgd_leaf(pgd)); + if (!gup_fast_p4d_range(pgdp, pgd, addr, next, flags, + pages, nr)) return; } while (pgdp++, addr = next, addr != end); } From patchwork Mon Mar 31 08:13:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 14033789 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 8457AC36011 for ; Mon, 31 Mar 2025 16:29:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 825CB280004; Mon, 31 Mar 2025 12:29:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D785280001; Mon, 31 Mar 2025 12:29:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 69D7E280004; Mon, 31 Mar 2025 12:29:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 495C9280001 for ; Mon, 31 Mar 2025 12:29:32 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 69DE4C0D19 for ; Mon, 31 Mar 2025 08:14:05 +0000 (UTC) X-FDA: 83281133250.05.912425B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf06.hostedemail.com (Postfix) with ESMTP id AA476180007 for ; Mon, 31 Mar 2025 08:14:03 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Le218nlN; spf=pass (imf06.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743408843; 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=PPZQrdeQpegE/jTUY4XQbbWwgsN0SFY5JA/aTu23ar8=; b=yOJexZGONCbTnFT8NGxONreCrDPbK2PdCKElk8lXFHD+2TmG+u3S9gLTHaJ9nTkxpFv5fm 9ivX+S0z5Tr7voP0jA45RB7TJXoH5LXyd+0Bc+EOTrA9OKd6vZHqe+iKyc/FWY7AVHceAN WNh8bibx3teV9A+JVYlmcMhRx8+F5Gg= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Le218nlN; spf=pass (imf06.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743408843; a=rsa-sha256; cv=none; b=uvPE9b/GeXh9PLK6W+MBmfK4LwanspCksS/iKHSxxunmhBUTQPXCvVOasu5LwlqUPLij0C /ZznzYe7FY/8dxT6Z561mcsxCo94pyxHqIMx6Vei2fOePqm/PrLZuQh34OYBCQnDXRfU9+ g1LS1jGuclHt5nxJSAab4qPMDuTBjfU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743408843; 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=PPZQrdeQpegE/jTUY4XQbbWwgsN0SFY5JA/aTu23ar8=; b=Le218nlNJu1/RaOd1GS9zte31yEuE6nPcTQWjG06nzqjEddfD/tvmwjimvwOvAut1Pg0zr Zs3XKuoh3hwbo5Yc+7+55z6EGtrMykwzyqIgAVHTie5500rzMR5KvL6zLGwanh7NV4/X9r /ybq+SO/WE9szJ5YUjbwdJJkJw81uf8= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-529-bLJlnPblMYyLaxsQv9gwtA-1; Mon, 31 Mar 2025 04:13:57 -0400 X-MC-Unique: bLJlnPblMYyLaxsQv9gwtA-1 X-Mimecast-MFC-AGG-ID: bLJlnPblMYyLaxsQv9gwtA_1743408836 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C468019560B6; Mon, 31 Mar 2025 08:13:55 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.112.9]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4D8321955BF1; Mon, 31 Mar 2025 08:13:51 +0000 (UTC) From: Baoquan He To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, yanjun.zhu@linux.dev, Baoquan He , x86@kernel.org Subject: [PATCH v2 5/7] x86/mm: remove pgd_leaf definition in arch Date: Mon, 31 Mar 2025 16:13:25 +0800 Message-ID: <20250331081327.256412-6-bhe@redhat.com> In-Reply-To: <20250331081327.256412-1-bhe@redhat.com> References: <20250331081327.256412-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: AA476180007 X-Stat-Signature: fpkjiu3hyzca4t8rm3rsmrdzo9en613c X-HE-Tag: 1743408843-931264 X-HE-Meta: U2FsdGVkX1/He85V+QmrMW6S8DA/cuCF1QJAVUFFdLu0ml+rQewKa5MbIhF1ZOQxuZc/07h6/hPdGjpoMeGyC+pCaln9Du9M2h+mquChpbL4ByP3Vc8kT37boCntbk9OOmGlCT7gXrS3MtuuDP4t31qrox6cQMQMJwLRb6n5ss3OphCdOCIdexNNoJd5h+U1WfR2m3W4HlnVzGp6fNWJLqaD5CuXnHo6ls8FYq/hUZX8YR+6r37eY+90leZkcoK9xPCZrR6GeXOA1wYBt9Ng97Pn7cJUcuoXY7OED46AhzsUxZn3NdobbvYAkUTGqE/Lm46v9YJqAm/zT2bgty+YRRx8+XmmyeCw6ALfEF2043rfnzlGFGSkWRfIiXYATeRBOCeN4p7wY7m3fJqantcFAap2On/hZT32d9nrRw0pDAGzYQKIJMNFTRlM2j0i7eRybEqjtLqRjhzwHHr/MVQgqir8/ldwuO36qt/Q/tNMy9xsA1A8mO+HDnZLXuZ513q7CxfBin6uAyGMfNdaLDv/nZBFyylmXYAckv+guEoJAWY8B6Ycr5ElGRPzVdsDuBe+S/2KZERVp8v8rn8PfcJ0v0d/PtGhmj8xTSb6ciHl8S3Pp4IH2AQiLe55o/fb4fm0Rvnb1eDqpu1uFjWQecdBDGQ4WjzTrmxoHK6p8MCGelI4CHzmGa+GIYtZwVth3/C2uPcM3KPsqPtsX+zzuXAo1hH4QsQmTTAcqM6PNWxA1xA4wFOCv3zcFiwbtQ8sjQHm6I57z7a7oxuIQIB7Gus1MFhUI44hJ4dM0HUrAQQDjN/VPmbF9Tf4RDvI7amUlKL9nQLI3UGNKc5Vp7KNkKpc0Od2ilfavdOqmlQ56OgNj/etLb3gujEE/QYCK3DoqoE6bsj2nYVdS8Wr4b8lQFGzS+DxLbZyIJCyutM284up94FjbdQedd95gpBU+SpcT0ZfukmTVwkP/OV0YiEgozX GYTtbGez qrdENL4R/+rLiL3aa9052U5sjIo3mcDK8xRLtC/QV5y9OGLfJkC75gJtvZUTqMcWNui/7z2txqh05lHngSIDkSHh21c0ZspTnIzU9ubngzWIyr892PgOncj6k/jzWFQEs47sDYBAs7EeRmwqhblbCShVYmScC+CbUaPD1urtVpvZB7qUE5nS1sZzcKXS7Htt70wAv7GvVdYeBLjamUyhTh/ilcPgasxT7i7NycuT2TwD6yIe/1doeQ+b6XU/Py+Vg6dz+eegMgJ7/pHCXg1FAXxRUaQIDefdPz7BkP3PZOA3XUsLYV7lEvHf86lM0C4tfDFVaLO6sLvDIvduELml+Uh+zrE8PpSztPK9/GQArmWxv7g3NizxYq/yg6iZzOYWi1j3ZXF4M7ElZBcpszW5eIisP9g== 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: pgd huge page is not supported yet, let's use the generic definition in linux/pgtable.h. And also update the BUILD_BUG_ON() checking for pgd_leaf() in pti_user_pagetable_walk_p4d() because pgd_leaf() returns boolean value. Signed-off-by: Baoquan He Cc: x86@kernel.org Acked-by: David Hildenbrand Reviewed-by: Oscar Salvador --- arch/x86/include/asm/pgtable.h | 3 --- arch/x86/mm/pti.c | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 7bd6bd6df4a1..5f4fcc0eea17 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1472,9 +1472,6 @@ static inline bool pgdp_maps_userspace(void *__ptr) return (((ptr & ~PAGE_MASK) / sizeof(pgd_t)) < PGD_KERNEL_START); } -#define pgd_leaf pgd_leaf -static inline bool pgd_leaf(pgd_t pgd) { return false; } - #ifdef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION /* * All top-level MITIGATION_PAGE_TABLE_ISOLATION page tables are order-1 pages diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c index 5f0d579932c6..c2e1de40136f 100644 --- a/arch/x86/mm/pti.c +++ b/arch/x86/mm/pti.c @@ -185,7 +185,7 @@ static p4d_t *pti_user_pagetable_walk_p4d(unsigned long address) set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(new_p4d_page))); } - BUILD_BUG_ON(pgd_leaf(*pgd) != 0); + BUILD_BUG_ON(pgd_leaf(*pgd)); return p4d_offset(pgd, address); } From patchwork Mon Mar 31 08:13:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 14033790 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 8C3A2C3600B for ; Mon, 31 Mar 2025 16:29:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E1B61280001; Mon, 31 Mar 2025 12:29:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DC926280005; Mon, 31 Mar 2025 12:29:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C9106280001; Mon, 31 Mar 2025 12:29:32 -0400 (EDT) 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 AA474280005 for ; Mon, 31 Mar 2025 12:29:32 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 6D0DF160DAD for ; Mon, 31 Mar 2025 08:14:10 +0000 (UTC) X-FDA: 83281133460.21.253617C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id B10F140006 for ; Mon, 31 Mar 2025 08:14:08 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dIKTEZiO; spf=pass (imf07.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743408848; 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=lU8XHCD/pp6vsb0Fo6FpwHmvpoSyWoqbMK/saKstTlg=; b=KWab/1QRJbxlWnMhHMFVJmcX76BS6r7YhThCER6mhba/rBH7H9TZRNOjuJUyOy1XB2M3eJ rOggfanDMUcL43CT00PkzZrQjzVbICotpzYXyXRZhXTm5TuimVWKLWVp8iWZieXxCGImjq f5EpRT49kBzNx6TckNJmDy0gdavYqVs= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dIKTEZiO; spf=pass (imf07.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743408848; a=rsa-sha256; cv=none; b=WElsAN3WDnRHqyvvVLO+eBURxOv3j0vPM9/+7M/vzigozncfv3+3KF9WhQvetSLEGkOAqy y5HqJMhSEFzGNh/+YBTvZ+Spbfo/2YsV7nK7R4DLxgmZjeDPjHG10WSVUavFvHilMdhX/f K9GM8uz8tQwsj9Ogz99E60JxJblXq7Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743408848; 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=lU8XHCD/pp6vsb0Fo6FpwHmvpoSyWoqbMK/saKstTlg=; b=dIKTEZiOoGoiMOv+OvzDszB1DhcinqxEB5rre+O7DDTIkEWQwgqCWofhdW9MppdZ4tfn6B Az14DaPhZnQfh6UynpyiwLF27E67UwmR2gjHssEy8WvRx8y9c4/yOiEdntq4QkKn5pcSuD vVx+R4pGaDFwzAPByWttj0UcNVA6y7o= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-624-w3DzhzJnOJmOe7Q5-csrBw-1; Mon, 31 Mar 2025 04:14:02 -0400 X-MC-Unique: w3DzhzJnOJmOe7Q5-csrBw-1 X-Mimecast-MFC-AGG-ID: w3DzhzJnOJmOe7Q5-csrBw_1743408840 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CD80D180AB16; Mon, 31 Mar 2025 08:14:00 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.112.9]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4F53D1955BEF; Mon, 31 Mar 2025 08:13:56 +0000 (UTC) From: Baoquan He To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, yanjun.zhu@linux.dev, Baoquan He , x86@kernel.org Subject: [PATCH v2 6/7] x86/mm: remove p4d_leaf definition Date: Mon, 31 Mar 2025 16:13:26 +0800 Message-ID: <20250331081327.256412-7-bhe@redhat.com> In-Reply-To: <20250331081327.256412-1-bhe@redhat.com> References: <20250331081327.256412-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Rspamd-Queue-Id: B10F140006 X-Stat-Signature: kcznkmdwcrnk6xj5keu74u3ki9yff8ce X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1743408848-61584 X-HE-Meta: U2FsdGVkX1+0M6fEaXwGcsS1TC7YHunN2R1nyP50Ap4o+JrvqoSUHr0TDdQMtT8ykL1h8nUMcBnt8Yd0KiA8lIgJwIUjwEkGoRYv8fuf8GzpeVL15yfbXRvNtj+TX6ntBnjuTgKSC3fQ0xUODKb5zyiwGKrJ9i4WfQ/g2R8G9leDxTOgrdi/ek+YvNvfO7w7HsH0SKQKmvryiZ/hHcHunYiMyAYofaI4A9ToMzt8VTTPPso792U0IO39v22xh1UBjl7EMysdoSMNKb3O2jPK1dGC3OinRl6mwzs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dCi5Qz4GnHe7sixbCOpLcWrRYHVzW/6mH4g== 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: There's no p4d huge page support yet, let's use the generic definition. And also update the BUILD_BUG_ON() in pti_user_pagetable_walk_pmd() because p4d_leaf() returns boolean value. Signed-off-by: Baoquan He Cc: x86@kernel.org Reviewed-by: Oscar Salvador --- arch/x86/include/asm/pgtable.h | 7 ------- arch/x86/mm/pti.c | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 5f4fcc0eea17..5ddba366d3b4 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -292,13 +292,6 @@ static inline unsigned long pgd_pfn(pgd_t pgd) return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT; } -#define p4d_leaf p4d_leaf -static inline bool p4d_leaf(p4d_t p4d) -{ - /* No 512 GiB pages yet */ - return 0; -} - #define pte_page(pte) pfn_to_page(pte_pfn(pte)) #define pmd_leaf pmd_leaf diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c index c2e1de40136f..190299834011 100644 --- a/arch/x86/mm/pti.c +++ b/arch/x86/mm/pti.c @@ -206,7 +206,7 @@ static pmd_t *pti_user_pagetable_walk_pmd(unsigned long address) if (!p4d) return NULL; - BUILD_BUG_ON(p4d_leaf(*p4d) != 0); + BUILD_BUG_ON(p4d_leaf(*p4d)); if (p4d_none(*p4d)) { unsigned long new_pud_page = __get_free_page(gfp); if (WARN_ON_ONCE(!new_pud_page)) From patchwork Mon Mar 31 08:13:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 14033714 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 15C91C3600B for ; Mon, 31 Mar 2025 15:24:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F843280003; Mon, 31 Mar 2025 11:24:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 180BA280002; Mon, 31 Mar 2025 11:24:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F3E08280003; Mon, 31 Mar 2025 11:24:05 -0400 (EDT) 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 39D4C280002 for ; Mon, 31 Mar 2025 11:24:05 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 51A7EB4A6F for ; Mon, 31 Mar 2025 08:14:11 +0000 (UTC) X-FDA: 83281133502.11.6EBFFD4 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf24.hostedemail.com (Postfix) with ESMTP id B91D8180009 for ; Mon, 31 Mar 2025 08:14:09 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Wdo7LSv8; dmarc=pass (policy=quarantine) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743408849; a=rsa-sha256; cv=none; b=pqpeV+uptivm/3Q69BzTsaIjYGavEmrd+HwO4HqOWeUpXLLnWlhwGPUoRHkYa2u5dGjV2n hDChLM6xsr8XqTUAp+oZi/jTBF3KzOTyPqTx6EhogmzGVhiDwN65tXD/ZcCP1VWbDKns+3 Fdd1bTijT9KtdBeJJj5jvRAMEmsedes= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Wdo7LSv8; dmarc=pass (policy=quarantine) header.from=redhat.com; spf=pass (imf24.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743408849; 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=OLa+87RL1ZqH7qyvR+sAYoFO3JtN0cQjwozLl9C4JYM=; b=kPHkIx2l3OfYQlkCBPHFU12N6tX7kR4woEBMz8pfTyUNhmZmwkDUyH/mOvLXhCgh9xuJa1 d3sWER9M5jmGg3uDF0YlYTxjLqAgZLyq2WagmTbEJSrUCFjzG7uXXbOLM8W0iIGhED1xiz OMngNxRBfmgoN1KdvaBiPlyVRKIeHdo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1743408849; 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=OLa+87RL1ZqH7qyvR+sAYoFO3JtN0cQjwozLl9C4JYM=; b=Wdo7LSv8Ogh3017gT5VFsk8pBILk5AAszZ4urnWAvPjNrc3BSdhUYIdNrn556kHgF3+us7 CcZ7bzBSbINnHOPRG2Mlwti2WZxBT1JyisFfwHDTwTMax5JewXCX6Bgdf7gH6ldmA6JwzD cJZGQ6S1qWDkhuK91hHjIQ7P0+LoWYM= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-516-21WSEHhDPMuuTzpdv--LEg-1; Mon, 31 Mar 2025 04:14:05 -0400 X-MC-Unique: 21WSEHhDPMuuTzpdv--LEg-1 X-Mimecast-MFC-AGG-ID: 21WSEHhDPMuuTzpdv--LEg_1743408844 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id ADC0D1800260; Mon, 31 Mar 2025 08:14:04 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.112.9]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A6EF81955BF1; Mon, 31 Mar 2025 08:14:01 +0000 (UTC) From: Baoquan He To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, yanjun.zhu@linux.dev, Baoquan He Subject: [PATCH v2 7/7] mm/pgtable: remove unneeded pgd_devmap() Date: Mon, 31 Mar 2025 16:13:27 +0800 Message-ID: <20250331081327.256412-8-bhe@redhat.com> In-Reply-To: <20250331081327.256412-1-bhe@redhat.com> References: <20250331081327.256412-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: B91D8180009 X-Stat-Signature: ijpugx8tejsmfu6njwx4ia6ycwhhxf93 X-HE-Tag: 1743408849-629092 X-HE-Meta: U2FsdGVkX18vkAKHXlsO7oqOjO58DIA2ocxyznvI5YySP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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: There's no user of pgd_devmap() now, remove it from all ARCH-es and linux/pgtable.h. Signed-off-by: Baoquan He --- arch/arm64/include/asm/pgtable.h | 5 ----- arch/loongarch/include/asm/pgtable.h | 1 - arch/powerpc/include/asm/book3s/64/pgtable.h | 5 ----- arch/riscv/include/asm/pgtable-64.h | 5 ----- arch/x86/include/asm/pgtable.h | 5 ----- include/linux/pgtable.h | 4 ---- 6 files changed, 25 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 84f05f781a70..e0cab581edc9 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -1230,11 +1230,6 @@ static inline int pud_devmap(pud_t pud) { return 0; } - -static inline int pgd_devmap(pgd_t pgd) -{ - return 0; -} #endif #ifdef CONFIG_PAGE_TABLE_CHECK diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h index da346733a1da..d9b04296d9f5 100644 --- a/arch/loongarch/include/asm/pgtable.h +++ b/arch/loongarch/include/asm/pgtable.h @@ -615,7 +615,6 @@ static inline long pmd_protnone(pmd_t pmd) #ifdef CONFIG_TRANSPARENT_HUGEPAGE #define pud_devmap(pud) (0) -#define pgd_devmap(pgd) (0) #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ /* diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index 6d98e6f08d4d..0da1c8d7f778 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -1405,11 +1405,6 @@ static inline int pud_devmap(pud_t pud) { return pte_devmap(pud_pte(pud)); } - -static inline int pgd_devmap(pgd_t pgd) -{ - return 0; -} #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ #define __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION diff --git a/arch/riscv/include/asm/pgtable-64.h b/arch/riscv/include/asm/pgtable-64.h index 0897dd99ab8d..c6da4c8354a3 100644 --- a/arch/riscv/include/asm/pgtable-64.h +++ b/arch/riscv/include/asm/pgtable-64.h @@ -411,11 +411,6 @@ static inline int pud_devmap(pud_t pud) { return 0; } - -static inline int pgd_devmap(pgd_t pgd) -{ - return 0; -} #endif #endif /* _ASM_RISCV_PGTABLE_64_H */ diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 5ddba366d3b4..3d6e78af525a 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -361,11 +361,6 @@ static inline pud_t pud_mkspecial(pud_t pud) return pud_set_flags(pud, _PAGE_SPECIAL); } #endif /* CONFIG_ARCH_SUPPORTS_PUD_PFNMAP */ - -static inline int pgd_devmap(pgd_t pgd) -{ - return 0; -} #endif #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 94d267d02372..9d2dd5f71443 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -1615,10 +1615,6 @@ static inline int pud_devmap(pud_t pud) { return 0; } -static inline int pgd_devmap(pgd_t pgd) -{ - return 0; -} #endif #if !defined(CONFIG_TRANSPARENT_HUGEPAGE) || \