From patchwork Wed Apr 2 18:16:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 14036360 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 C8505C36018 for ; Wed, 2 Apr 2025 18:17:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA8D128000E; Wed, 2 Apr 2025 14:17:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A2739280006; Wed, 2 Apr 2025 14:17:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 91D5B28000E; Wed, 2 Apr 2025 14:17:38 -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 75FFC280006 for ; Wed, 2 Apr 2025 14:17:38 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id AC04B1605ED for ; Wed, 2 Apr 2025 18:17:38 +0000 (UTC) X-FDA: 83289911796.26.E6CE02F Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf03.hostedemail.com (Postfix) with ESMTP id 01F7620004 for ; Wed, 2 Apr 2025 18:17:36 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=YAXCy6X1; spf=none (imf03.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743617857; 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=lziGZfROFPhpObpsaGUZ16kTN/pcfFau1WI7RqoG7Nk=; b=q4PfNztHjMGJg80T3nQmQYo006Yk6Zg53MNH2VR25+Yz1+awF79lCHzbyYlgci5T46pVcH clTdvg+1epVSzlqYAxMrroR5YukDOMDbfUyA5WD5SPqdopb+uemT46CL/Uk7QLtxd6riWc Tg1bBHupI1dii7AjiynVj5Az11czrp8= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=YAXCy6X1; spf=none (imf03.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743617857; a=rsa-sha256; cv=none; b=auzcRAos3mnr71FeBDHMbmzRB/DkPLIoplElN406Na3/3hSt2eKVN1/vNGO0p6zt2NmQBH fbOSlzMjDVvXUj7R4pnjInI+5hPjnAO/7pRC+JMWKV5H/sWC2CkBsHJKrML5FZCNYZeD29 h9NBRCRKp+w3ip1DwUhSzZM+Gr4guQE= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=lziGZfROFPhpObpsaGUZ16kTN/pcfFau1WI7RqoG7Nk=; b=YAXCy6X1G2bFcoaDIZGZDJIjcY CayYgL2F+q7RCw52YgbfwYENQP7LaVJJH8DKSUhlxIuWCu7KFD4zqWq7/vuLsTcwYOtWxQKvjJ9t/ ctqq5kCqm7yurpAKtOyciNlMMgUMPoG1ke2hHdsXtnhTqZD8SExb5iQSk+AduITgbWGe05cFpwNsI 7SHht3zFfW5/iNKBZtTpMDXMuJD+lVq1hUpZC5OZ6+f1VFrzpVuDvsIKcuEk1APt8W86WqBCQBHVo m7PmJMhxuBt+ZF5c0CKHPun/BSBF6eSv1JvFELqmRtI9S7P/9ZiD6vZj3FUQIa/ZC25srHY0l+S6r rJ2sR16w==; Received: from willy by casper.infradead.org with local (Exim 4.98.1 #2 (Red Hat Linux)) id 1u02eF-0000000A0iU-0796; Wed, 02 Apr 2025 18:17:11 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-arch@vger.kernel.org, David Hildenbrand , Alexander Gordeev Subject: [PATCH v2 01/11] mm: Set the pte dirty if the folio is already dirty Date: Wed, 2 Apr 2025 19:16:55 +0100 Message-ID: <20250402181709.2386022-2-willy@infradead.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402181709.2386022-1-willy@infradead.org> References: <20250402181709.2386022-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 01F7620004 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: tk5uiamjsj3dbsb5ihnsekqcnuioe6iy X-HE-Tag: 1743617856-724298 X-HE-Meta: U2FsdGVkX18Z9Yq4y1/t9MBLfpNRptvxNas3DXisShsV1NG6+0ES8dZpOlUccZh1eEoneZcAiI5FxkoevnhopWYg3Z5gDhU8Nb56AZcn2HnlYrf8eQz5HVIrdZmAwkoro+aA2DOk4JYjrAnJBBsmvf0lOBWawSnNuVRtbRDFqsQ3cMUrYUnInjfRlxSpC0Dq6akQuQGou0Ng5g+oqeFpX7zAwns/Jc/7+em/wGvw2TuUmuh8ebceU6sBFvpPl7/YT11atHLKTtd0GOd2/z6D4/eVJipYQUvXKD8p0DSMA/JSWd9bidscWFgxh5A/bYmT2bKfOx/8K0C40KjPBZQpfBRS9WoYnJk+mHwOpHQ2hlvMVumibYvzR4VY22SJTHc+2/OoR1H73Cu5JZ6/Orvqy2drOM0O3sAe47yY+zEulCNzi8zz4WEVtYO1F2Tq6GvTKf8dwICyO5qnXkRnUXop+nHAy7+ODii8ZFs3lUGmWWyR5XSPhnsviOQpnN3XgR8UQPWi16W9T4x4NbVayycXoUQ8D+LBx/RgiQaR4Tc4+IP/kViCfBScUWrlxY+Epw84NzeE9Ta1mP654Q9nFa0hKzPXlzXKhmpROaBlWG5n2dNvEK07pA61453ySmze7kN5rkw9Nuq9lLzobDqcaWN5Xe/B6kBmN78GByzmCu01bvd0o6aZRPW/OY1bdHR332Sfl4Wf4aZi9W8PbVAcr0C6kuRQIRvIbgtgp7wQJy4qS20MXgAJsGtcDDMGVrJBqrjseVQgs2o8OmHuWdLp8sDX2uTHql+PHrJa+k2O4Rbzx49tA9GuZ/oEb9tm5s+si1jyc6wpM7zfmXbnX6diKsvMyAWGc+nFClZ4JZevTI7z9oOwN5k7DVHAnA3HhLmY07hQxRZ0kyZ9G005zzq7N5PAOu0hFnQbzh21+/aosqJj9qXO+3qC81+NiojMLsSSu78FWKygZc4Hrmf9S5d/rLu K1WnYJgv ZygkToqJWwQEcuB69qSuWkTRi2Rt5+KKmjeHd90uRUOtZC2cP7iG6winLpTSFSLGNO99t69+mXyqGapWv5q7Kwktn0V+QGVFNwP73Ij1z9R+y4pye5+pNzbtl0kw/Bs5IF+1Rn25h+YCu5w8Ff22lS/uziH+4E015kRK9epPMoycG2lSgTl44AFVLzuSRF3N0UmkRsHJMBxLSdlGLJNRGYTdURJPrsILoWQU8zLJlE5jxRCxXkny4S9EnM/f7ZDc7RPKVtbI0zcGf94NYQjnSg23QvQ== 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: If the first access to a folio is a read that is then followed by a write, we can save a page fault. s390 implemented this in their mk_pte() in commit abf09bed3cce ("s390/mm: implement software dirty bits"), but other architectures can also benefit from this. Signed-off-by: Matthew Wilcox (Oracle) Acked-by: David Hildenbrand Reviewed-by: Alexander Gordeev # for s390 --- arch/s390/include/asm/pgtable.h | 7 +------ mm/memory.c | 2 ++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h index f8a6b54986ec..49833002232b 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h @@ -1450,12 +1450,7 @@ static inline pte_t mk_pte_phys(unsigned long physpage, pgprot_t pgprot) static inline pte_t mk_pte(struct page *page, pgprot_t pgprot) { - unsigned long physpage = page_to_phys(page); - pte_t __pte = mk_pte_phys(physpage, pgprot); - - if (pte_write(__pte) && PageDirty(page)) - __pte = pte_mkdirty(__pte); - return __pte; + return mk_pte_phys(page_to_phys(page), pgprot); } #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) diff --git a/mm/memory.c b/mm/memory.c index 2d8c265fc7d6..68bcf639a78c 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5245,6 +5245,8 @@ void set_pte_range(struct vm_fault *vmf, struct folio *folio, if (write) entry = maybe_mkwrite(pte_mkdirty(entry), vma); + else if (pte_write(entry) && folio_test_dirty(folio)) + entry = pte_mkdirty(entry); if (unlikely(vmf_orig_pte_uffd_wp(vmf))) entry = pte_mkuffd_wp(entry); /* copy-on-write page */ From patchwork Wed Apr 2 18:16:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 14036351 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 D895DC28B20 for ; Wed, 2 Apr 2025 18:17:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B0338280005; Wed, 2 Apr 2025 14:17:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A8C98280004; Wed, 2 Apr 2025 14:17:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84F3F280006; Wed, 2 Apr 2025 14:17:15 -0400 (EDT) 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 4D0A8280004 for ; Wed, 2 Apr 2025 14:17:15 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 689221C9C25 for ; Wed, 2 Apr 2025 18:17:15 +0000 (UTC) X-FDA: 83289910830.26.9642AB2 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf29.hostedemail.com (Postfix) with ESMTP id 9E366120008 for ; Wed, 2 Apr 2025 18:17:13 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=YSZBO7t2; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743617833; 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=1wq3v4nGa9HUiW04c2ahSAHRdzegDEv6zd4tZt+jerA=; b=Dnj2WAgJ4mMzo0B1O8Fr98Kk6bF5akutgN82hwwGt7YvtXSTf6ITfoNKO9DLJMMr6/k0BU W0uffWrfNblM9+dD0dqTl+OsW8h9+hGrccstVM4a8qIyAL0B5I2VhWMuQDOaWYeNzTj9z4 PdUkFhdtOoteG5T6ZbCIh5YXaw5Uc+I= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=YSZBO7t2; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743617833; a=rsa-sha256; cv=none; b=dkBzp9cZdKRS+K3Yo4wDhvk4RcEQi5M6gA2zDnQUkoWvRfjOJZr4BICAMV5/rW9M9ibCmn /V+2a6NPvHg87ZsEmKrR/7pPmsO5mdKFKHidZHEEFVdduCspT3NbH6zP2ba2v6qdjPIc6w ffAd9IXZn2EzynInJlL1pdirqgl10Vg= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=1wq3v4nGa9HUiW04c2ahSAHRdzegDEv6zd4tZt+jerA=; b=YSZBO7t21Vx0gCYJQWwAi5CRMY N0EgCWk6JRcpUaKE6ESyHK1tHJEUuKuz2aTgUTsXfCabEQzvgQXXSrl1/dAe2O6/oHp9MNOXXg0eI k8ZlELmTR7mQtqg6gD0vPHZu1cFQH/3O40TMgirtTYJhPOZPyc6KcKGTo30X2yrcpLHiGCwp1sDxb nXLlIMZi0wyaQTUPV4Lug3haMSi/9Gn+7lHz2ue8OGYL7w6idvrzZCqFDRoTxMyfKIv8/LJ3P1SPw CE1DixSOPneec7yOukaJAd+TY4GrmVgmGY6EEJjtS47VNpNRR4ZF5OVBZzdZYtHKXUzQ1xl99pVUJ NzoqgGww==; Received: from willy by casper.infradead.org with local (Exim 4.98.1 #2 (Red Hat Linux)) id 1u02eF-0000000A0iW-0ToL; Wed, 02 Apr 2025 18:17:11 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-arch@vger.kernel.org, Geert Uytterhoeven , David Hildenbrand , Alexander Gordeev Subject: [PATCH v2 02/11] mm: Introduce a common definition of mk_pte() Date: Wed, 2 Apr 2025 19:16:56 +0100 Message-ID: <20250402181709.2386022-3-willy@infradead.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402181709.2386022-1-willy@infradead.org> References: <20250402181709.2386022-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 9E366120008 X-Stat-Signature: 8zrpq8fyrosc5ht4eozo75tp1bkwki9u X-HE-Tag: 1743617833-67477 X-HE-Meta: U2FsdGVkX1+prjP74nKnHvdqsgN+4ejm+f1tmYi2+3/qMf0J2tGO8Kh7ul7GASftkEgcm6YrocRmc6DJ0LabC2yNhLA5ppMwGC7iI3XkGv0/0du/T/w27+UDG0wFx+I+oT0kMyoF97n1U74ElYJUEcHWiLTxHFmFr3CvvxBe3fKKXmbcJlFQKt30e24oJKMXV9ZOyNZxPYv5ZHPMqnW5bQKAtxhLIA8o6/kNt+ksQC5+kHNicK12bineR7jcliFQbMocF6UCqh/NC8VEF21p/QWZeg4wvHYiIQuTskyC+dtiFEddQ6nfwKQcAzVzD1KCagxKMudmrQwjJXtRiRpDhKGZL/BXZf90Rjb0ZtoUZMzZofWR1EkFrAhPNjdcBBTRv82aApr38DE5RRzsuPItKMBhCbKeBxuUedo16bhcPFtVaaBrv0LEzZYjLgEQSZEPdxGZO7dllXQqQI/Clznef0TaSkYbsrnuRrUQtCD7hSOeKnm3z+vX3l08HzUpA91jewNvVL/yl7BUw1qffaQCP/1mMeOvsxRO0rBhZ6iv4bAtF1ZseezLIvuJCC1QN98kajQqF0x4RC5z9SyPIZyc0WwFwZ0LEKV/QKaNrkByodR6QIWwHPZFeJGvIwlv94x3LM4cPbIA6uQAaBAq8QBwXIbCBnj+tr5ct2611TMwFNxGBMhmdmc/9Q6rB0tVrqR1Bp0kOUWqRNU046NZVACRF8Ri05HDMbZeTQa6aYiZSQRnIg6VknnGc0HVy+GCrK81GLF8GQh0c9PgN/slFNXTIZjIO8XAnOxh7DCyw58uKskWPOhIhncAdS8j6vYTwCOyYyuqJ5R8G2Q7u9UT1k7em+0rn1L8dKwALmndWLpkpfw7y4nbU4CSnEIWgGmpjxK51LXYr3utjc9OEdwpYEBMiNf4k2jcExHHinJUxgkgoV4KsBCpkoUiIXxJ0zZ62k92ht4vcGCOt7VrQcZMd/y LnGXp/Ut ErNmUaEDWvSEFG20dZW6Tlao8gcIuZdcOtHmp2oG/HFkL8nP5eK+Q1E0TUPycs9SXirb0+DzEB7a8wL0MPAHkHViJODZhVPDmWUHJ5b3OQD+8RK2b1YIo8KAXRvivijYB3quCXzvAV2E6HqtPal7i0Gbt87DBvKq457xztPGPTw6FdLFBJxm9tb7Q4F20cO4rsgGTlXnFSH5JW5BmavGQMiA00eWjL47rLuS/dKaLy/Vi4Y8mcFbMQwM5Ay06I8tzNJcYMmtL8U8Rj8WFCHzSwpCCQwX1jeC7sMqV6t0xIe0ItKH4mUByt3MXmmev0ryG1utPelYfukOAIJmDvFlV+qzCRyUBN2TlqvnWbBHjpI6Ci+xG6Tq+gZ7a8buZsImN6gLr/s7GXo2mBY8= 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: Most architectures simply call pfn_pte(). Centralise that as the normal definition and remove the definition of mk_pte() from the architectures which have either that exact definition or something similar. Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Geert Uytterhoeven # m68k Acked-by: David Hildenbrand Reviewed-by: Alexander Gordeev # s390 --- arch/alpha/include/asm/pgtable.h | 7 ------- arch/arc/include/asm/pgtable-levels.h | 1 - arch/arm/include/asm/pgtable.h | 1 - arch/arm64/include/asm/pgtable.h | 6 ------ arch/csky/include/asm/pgtable.h | 5 ----- arch/hexagon/include/asm/pgtable.h | 3 --- arch/loongarch/include/asm/pgtable.h | 6 ------ arch/m68k/include/asm/mcf_pgtable.h | 6 ------ arch/m68k/include/asm/motorola_pgtable.h | 6 ------ arch/m68k/include/asm/sun3_pgtable.h | 6 ------ arch/microblaze/include/asm/pgtable.h | 8 -------- arch/mips/include/asm/pgtable.h | 6 ------ arch/nios2/include/asm/pgtable.h | 6 ------ arch/openrisc/include/asm/pgtable.h | 2 -- arch/parisc/include/asm/pgtable.h | 6 ------ arch/powerpc/include/asm/pgtable.h | 3 +-- arch/riscv/include/asm/pgtable.h | 2 -- arch/s390/include/asm/pgtable.h | 5 ----- arch/sh/include/asm/pgtable_32.h | 8 -------- arch/sparc/include/asm/pgtable_64.h | 1 - arch/xtensa/include/asm/pgtable.h | 6 ------ include/linux/mm.h | 9 +++++++++ 22 files changed, 10 insertions(+), 99 deletions(-) diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h index 02e8817a8921..2676017f42f1 100644 --- a/arch/alpha/include/asm/pgtable.h +++ b/arch/alpha/include/asm/pgtable.h @@ -192,13 +192,6 @@ extern unsigned long __zero_page(void); #define pte_pfn(pte) (pte_val(pte) >> PFN_PTE_SHIFT) #define pte_page(pte) pfn_to_page(pte_pfn(pte)) -#define mk_pte(page, pgprot) \ -({ \ - pte_t pte; \ - \ - pte_val(pte) = (page_to_pfn(page) << 32) | pgprot_val(pgprot); \ - pte; \ -}) extern inline pte_t pfn_pte(unsigned long physpfn, pgprot_t pgprot) { pte_t pte; pte_val(pte) = (PHYS_TWIDDLE(physpfn) << 32) | pgprot_val(pgprot); return pte; } diff --git a/arch/arc/include/asm/pgtable-levels.h b/arch/arc/include/asm/pgtable-levels.h index 86e148226463..55dbd2719e35 100644 --- a/arch/arc/include/asm/pgtable-levels.h +++ b/arch/arc/include/asm/pgtable-levels.h @@ -177,7 +177,6 @@ #define set_pte(ptep, pte) ((*(ptep)) = (pte)) #define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT) #define pfn_pte(pfn, prot) __pte(__pfn_to_phys(pfn) | pgprot_val(prot)) -#define mk_pte(page, prot) pfn_pte(page_to_pfn(page), prot) #ifdef CONFIG_ISA_ARCV2 #define pmd_leaf(x) (pmd_val(x) & _PAGE_HW_SZ) diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h index 6b986ef6042f..7f1c3b4e3e04 100644 --- a/arch/arm/include/asm/pgtable.h +++ b/arch/arm/include/asm/pgtable.h @@ -168,7 +168,6 @@ static inline pte_t *pmd_page_vaddr(pmd_t pmd) #define pfn_pte(pfn,prot) __pte(__pfn_to_phys(pfn) | pgprot_val(prot)) #define pte_page(pte) pfn_to_page(pte_pfn(pte)) -#define mk_pte(page,prot) pfn_pte(page_to_pfn(page), prot) #define pte_clear(mm,addr,ptep) set_pte_ext(ptep, __pte(0), 0) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 84f05f781a70..53832ec0561f 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -818,12 +818,6 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd) /* use ONLY for statically allocated translation tables */ #define pte_offset_kimg(dir,addr) ((pte_t *)__phys_to_kimg(pte_offset_phys((dir), (addr)))) -/* - * Conversion functions: convert a page and protection to a page entry, - * and a page entry and page directory to the page they refer to. - */ -#define mk_pte(page,prot) pfn_pte(page_to_pfn(page),prot) - #if CONFIG_PGTABLE_LEVELS > 2 #define pmd_ERROR(e) \ diff --git a/arch/csky/include/asm/pgtable.h b/arch/csky/include/asm/pgtable.h index a397e1718ab6..b8378431aeff 100644 --- a/arch/csky/include/asm/pgtable.h +++ b/arch/csky/include/asm/pgtable.h @@ -249,11 +249,6 @@ static inline pgprot_t pgprot_writecombine(pgprot_t _prot) return __pgprot(prot); } -/* - * Conversion functions: convert a page and protection to a page entry, - * and a page entry and page directory to the page they refer to. - */ -#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) { return __pte((pte_val(pte) & _PAGE_CHG_MASK) | diff --git a/arch/hexagon/include/asm/pgtable.h b/arch/hexagon/include/asm/pgtable.h index 8c5b7a1c3d90..9fbdfdbc539f 100644 --- a/arch/hexagon/include/asm/pgtable.h +++ b/arch/hexagon/include/asm/pgtable.h @@ -238,9 +238,6 @@ static inline int pte_present(pte_t pte) return pte_val(pte) & _PAGE_PRESENT; } -/* mk_pte - make a PTE out of a page pointer and protection bits */ -#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) - /* pte_page - returns a page (frame pointer/descriptor?) based on a PTE */ #define pte_page(x) pfn_to_page(pte_pfn(x)) diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h index da346733a1da..9ba3a4ebcd98 100644 --- a/arch/loongarch/include/asm/pgtable.h +++ b/arch/loongarch/include/asm/pgtable.h @@ -426,12 +426,6 @@ static inline unsigned long pte_accessible(struct mm_struct *mm, pte_t a) return false; } -/* - * Conversion functions: convert a page and protection to a page entry, - * and a page entry and page directory to the page they refer to. - */ -#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) - static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) { return __pte((pte_val(pte) & _PAGE_CHG_MASK) | diff --git a/arch/m68k/include/asm/mcf_pgtable.h b/arch/m68k/include/asm/mcf_pgtable.h index 48f87a8a8832..f5c596b211d4 100644 --- a/arch/m68k/include/asm/mcf_pgtable.h +++ b/arch/m68k/include/asm/mcf_pgtable.h @@ -96,12 +96,6 @@ #define pmd_pgtable(pmd) pfn_to_virt(pmd_val(pmd) >> PAGE_SHIFT) -/* - * Conversion functions: convert a page and protection to a page entry, - * and a page entry and page directory to the page they refer to. - */ -#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) - static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) { pte_val(pte) = (pte_val(pte) & CF_PAGE_CHG_MASK) | pgprot_val(newprot); diff --git a/arch/m68k/include/asm/motorola_pgtable.h b/arch/m68k/include/asm/motorola_pgtable.h index 9866c7acdabe..040ac3bad713 100644 --- a/arch/m68k/include/asm/motorola_pgtable.h +++ b/arch/m68k/include/asm/motorola_pgtable.h @@ -81,12 +81,6 @@ extern unsigned long mm_cachebits; #define pmd_pgtable(pmd) ((pgtable_t)pmd_page_vaddr(pmd)) -/* - * Conversion functions: convert a page and protection to a page entry, - * and a page entry and page directory to the page they refer to. - */ -#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) - static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) { pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot); diff --git a/arch/m68k/include/asm/sun3_pgtable.h b/arch/m68k/include/asm/sun3_pgtable.h index 30081aee8164..73745dc0ec0e 100644 --- a/arch/m68k/include/asm/sun3_pgtable.h +++ b/arch/m68k/include/asm/sun3_pgtable.h @@ -76,12 +76,6 @@ #ifndef __ASSEMBLY__ -/* - * Conversion functions: convert a page and protection to a page entry, - * and a page entry and page directory to the page they refer to. - */ -#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) - static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) { pte_val(pte) = (pte_val(pte) & SUN3_PAGE_CHG_MASK) | pgprot_val(newprot); diff --git a/arch/microblaze/include/asm/pgtable.h b/arch/microblaze/include/asm/pgtable.h index e4ea2ec3642f..b1bb2c65dd04 100644 --- a/arch/microblaze/include/asm/pgtable.h +++ b/arch/microblaze/include/asm/pgtable.h @@ -285,14 +285,6 @@ static inline pte_t mk_pte_phys(phys_addr_t physpage, pgprot_t pgprot) return pte; } -#define mk_pte(page, pgprot) \ -({ \ - pte_t pte; \ - pte_val(pte) = (((page - mem_map) << PAGE_SHIFT) + memory_start) | \ - pgprot_val(pgprot); \ - pte; \ -}) - static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) { pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot); diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h index c29a551eb0ca..d69cfa5a8ac6 100644 --- a/arch/mips/include/asm/pgtable.h +++ b/arch/mips/include/asm/pgtable.h @@ -504,12 +504,6 @@ static inline int ptep_set_access_flags(struct vm_area_struct *vma, return true; } -/* - * Conversion functions: convert a page and protection to a page entry, - * and a page entry and page directory to the page they refer to. - */ -#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) - #if defined(CONFIG_XPA) static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) { diff --git a/arch/nios2/include/asm/pgtable.h b/arch/nios2/include/asm/pgtable.h index eab87c6beacb..f490f2fa0dca 100644 --- a/arch/nios2/include/asm/pgtable.h +++ b/arch/nios2/include/asm/pgtable.h @@ -217,12 +217,6 @@ static inline void pte_clear(struct mm_struct *mm, set_pte(ptep, null); } -/* - * Conversion functions: convert a page and protection to a page entry, - * and a page entry and page directory to the page they refer to. - */ -#define mk_pte(page, prot) (pfn_pte(page_to_pfn(page), prot)) - /* * Conversion functions: convert a page and protection to a page entry, * and a page entry and page directory to the page they refer to. diff --git a/arch/openrisc/include/asm/pgtable.h b/arch/openrisc/include/asm/pgtable.h index 60c6ce7ff2dc..71bfb8c8c482 100644 --- a/arch/openrisc/include/asm/pgtable.h +++ b/arch/openrisc/include/asm/pgtable.h @@ -299,8 +299,6 @@ static inline pte_t __mk_pte(void *page, pgprot_t pgprot) return pte; } -#define mk_pte(page, pgprot) __mk_pte(page_address(page), (pgprot)) - #define mk_pte_phys(physpage, pgprot) \ ({ \ pte_t __pte; \ diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h index babf65751e81..e85963fefa63 100644 --- a/arch/parisc/include/asm/pgtable.h +++ b/arch/parisc/include/asm/pgtable.h @@ -338,10 +338,6 @@ static inline pte_t pte_mkspecial(pte_t pte) { pte_val(pte) |= _PAGE_SPECIAL; re #endif -/* - * Conversion functions: convert a page and protection to a page entry, - * and a page entry and page directory to the page they refer to. - */ #define __mk_pte(addr,pgprot) \ ({ \ pte_t __pte; \ @@ -351,8 +347,6 @@ static inline pte_t pte_mkspecial(pte_t pte) { pte_val(pte) |= _PAGE_SPECIAL; re __pte; \ }) -#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) - static inline pte_t pfn_pte(unsigned long pfn, pgprot_t pgprot) { pte_t pte; diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index 2f72ad885332..93d77ad5a92f 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h @@ -53,9 +53,8 @@ void set_ptes(struct mm_struct *mm, unsigned long addr, pte_t *ptep, #define MAX_PTRS_PER_PGD PTRS_PER_PGD #endif -/* Keep these as a macros to avoid include dependency mess */ +/* Keep this as a macro to avoid include dependency mess */ #define pte_page(x) pfn_to_page(pte_pfn(x)) -#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) static inline unsigned long pte_pfn(pte_t pte) { diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h index 050fdc49b5ad..293a7776fe07 100644 --- a/arch/riscv/include/asm/pgtable.h +++ b/arch/riscv/include/asm/pgtable.h @@ -339,8 +339,6 @@ static inline pte_t pfn_pte(unsigned long pfn, pgprot_t prot) return __pte((pfn << _PAGE_PFN_SHIFT) | prot_val); } -#define mk_pte(page, prot) pfn_pte(page_to_pfn(page), prot) - static inline int pte_present(pte_t pte) { return (pte_val(pte) & (_PAGE_PRESENT | _PAGE_PROT_NONE)); diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h index 49833002232b..3ef5d2198480 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h @@ -1448,11 +1448,6 @@ static inline pte_t mk_pte_phys(unsigned long physpage, pgprot_t pgprot) return pte_mkyoung(__pte); } -static inline pte_t mk_pte(struct page *page, pgprot_t pgprot) -{ - return mk_pte_phys(page_to_phys(page), pgprot); -} - #define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1)) #define p4d_index(address) (((address) >> P4D_SHIFT) & (PTRS_PER_P4D-1)) #define pud_index(address) (((address) >> PUD_SHIFT) & (PTRS_PER_PUD-1)) diff --git a/arch/sh/include/asm/pgtable_32.h b/arch/sh/include/asm/pgtable_32.h index f939f1215232..db2e48366e0d 100644 --- a/arch/sh/include/asm/pgtable_32.h +++ b/arch/sh/include/asm/pgtable_32.h @@ -380,14 +380,6 @@ PTE_BIT_FUNC(low, mkspecial, |= _PAGE_SPECIAL); #define pgprot_noncached pgprot_writecombine -/* - * Conversion functions: convert a page and protection to a page entry, - * and a page entry and page directory to the page they refer to. - * - * extern pte_t mk_pte(struct page *page, pgprot_t pgprot) - */ -#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) - static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) { pte.pte_low &= _PAGE_CHG_MASK; diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h index dc28f2c4eee3..d9c903576084 100644 --- a/arch/sparc/include/asm/pgtable_64.h +++ b/arch/sparc/include/asm/pgtable_64.h @@ -225,7 +225,6 @@ static inline pte_t pfn_pte(unsigned long pfn, pgprot_t prot) BUILD_BUG_ON(_PAGE_SZBITS_4U != 0UL || _PAGE_SZBITS_4V != 0UL); return __pte(paddr | pgprot_val(prot)); } -#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) #ifdef CONFIG_TRANSPARENT_HUGEPAGE static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot) diff --git a/arch/xtensa/include/asm/pgtable.h b/arch/xtensa/include/asm/pgtable.h index 1647a7cc3fbf..cb1725c40e36 100644 --- a/arch/xtensa/include/asm/pgtable.h +++ b/arch/xtensa/include/asm/pgtable.h @@ -269,17 +269,11 @@ static inline pte_t pte_mkwrite_novma(pte_t pte) ((__pgprot((pgprot_val(prot) & ~_PAGE_CA_MASK) | \ _PAGE_CA_BYPASS))) -/* - * Conversion functions: convert a page and protection to a page entry, - * and a page entry and page directory to the page they refer to. - */ - #define PFN_PTE_SHIFT PAGE_SHIFT #define pte_pfn(pte) (pte_val(pte) >> PAGE_SHIFT) #define pte_same(a,b) (pte_val(a) == pte_val(b)) #define pte_page(x) pfn_to_page(pte_pfn(x)) #define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) -#define mk_pte(page, prot) pfn_pte(page_to_pfn(page), prot) static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) { diff --git a/include/linux/mm.h b/include/linux/mm.h index d66bc0e97632..a2bdfd7afb1b 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1987,6 +1987,15 @@ static inline struct folio *pfn_folio(unsigned long pfn) return page_folio(pfn_to_page(pfn)); } +#ifndef mk_pte +#ifdef CONFIG_MMU +static inline pte_t mk_pte(struct page *page, pgprot_t pgprot) +{ + return pfn_pte(page_to_pfn(page), pgprot); +} +#endif +#endif + static inline bool folio_has_pincount(const struct folio *folio) { if (IS_ENABLED(CONFIG_64BIT)) From patchwork Wed Apr 2 18:16:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 14036355 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 B73ABC28B20 for ; Wed, 2 Apr 2025 18:17:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE6A9280009; Wed, 2 Apr 2025 14:17:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9FC81280006; Wed, 2 Apr 2025 14:17:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8250B280009; Wed, 2 Apr 2025 14:17:20 -0400 (EDT) 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 5DB7F280006 for ; Wed, 2 Apr 2025 14:17:20 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 893C5140579 for ; Wed, 2 Apr 2025 18:17:20 +0000 (UTC) X-FDA: 83289911040.27.A4363EE Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id EFB0F160007 for ; Wed, 2 Apr 2025 18:17:18 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=AGMdqYWW; dmarc=none; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743617839; 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=j0C36cwE02tcp83xir3MVAFQIG4vvurnU5t2AtfKn0w=; b=GEY03naHMxR/RV+6oLYd3vyi0Ng5EqIvPmG86HMt2AlV44EC6LCIojvt5nFJl7HrAtqCCW TwSWZ1CBhtcpfmF1K2DkGMMwojUlMLDx8nijFZraxPfqRjR9FDyqqDUuA7MpH8OxwNU5/J bCRZiA0u3IHO6kBGu2qWPDOc7yuZ+zU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743617839; a=rsa-sha256; cv=none; b=WPym52EpCI6/NnNETm2nqQ/jdX/5Vu/46peLD/8o1GwZzyydDN2m/l6zw0QDzG7cnffgi5 iqAin0ZxQP/ZD8SNyfnHRgIQMg88ScnDCmWj1HXvs55+yZKns2VtCBnV51wrTdArBbxUMf OdrhDktp3OemLYokiXp/Nyjx2EOMfFs= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=AGMdqYWW; dmarc=none; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=j0C36cwE02tcp83xir3MVAFQIG4vvurnU5t2AtfKn0w=; b=AGMdqYWWGQSORj9lU/Z8Sy1eH9 tIHnQDCaBsu30kPuU4g0U+oHAqpw9pYvrGDhW+hJVCo4yCYZTURo4QuY1+owis/vl5TmOvxIiR+oc N+v+tMBiZBS3VlUtABggFTeGRqBB//GTNzKGXykjmH+7cA2ti/VMfv/MYKRpfL7cktkEwRIDp+PhN CdhSPOZ3gdcLjcYwq79JWFPRrfEndBSzLCrSwod1NGqavu3KNYLNi0bvEaa6+WY5xTnKwDlJXGVe2 /ld56D9mczQUqaFcYQYBh31qKiO2L0EuFhG2Na2FV580cZ9D6gzfanPPc4yvoXCF/IdcKwWaSWsKF e3bbMJMQ==; Received: from willy by casper.infradead.org with local (Exim 4.98.1 #2 (Red Hat Linux)) id 1u02eF-0000000A0iY-0rHI; Wed, 02 Apr 2025 18:17:11 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-arch@vger.kernel.org Subject: [PATCH v2 03/11] sparc32: Remove custom definition of mk_pte() Date: Wed, 2 Apr 2025 19:16:57 +0100 Message-ID: <20250402181709.2386022-4-willy@infradead.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402181709.2386022-1-willy@infradead.org> References: <20250402181709.2386022-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: EFB0F160007 X-Stat-Signature: 7befsznutbq9k5myo1dhfdhazni4c5r6 X-Rspam-User: X-HE-Tag: 1743617838-875345 X-HE-Meta: U2FsdGVkX18ujPjU1+ZwkKXo2oe+TDpU2bEq6zLsRcvEQ/uwFpJ0iW4w9KSPFTCjP1whLBE26UTgiLHMXyc2FjsvIINXsD/5RIXSnaZ9fK6+uVlmUpak2eldRyEdJXGQ5LExtuhzVP/Dd4RkIx/Mr5+5SR8Kgao4stSKKKbXweN29q2zeExZXKX9pn0uUYNiNMZXXMV8/K+mjo+omSOjeBgB2HN9ZjxQGdYyfYm1smf8Wm0kK+s+CbdVu/7euH8yjhQrhsEDeW7Y8PpE3mcrwyyG8G+zUF/g+NVcXXMLWvnWxXLWTOAjSzSwaB1+79VejmF+NOGHASIll5DZPY+KwnjNsib6wpFbcb+xArV75psFOw/8kIjlIIQ8d3DuNV70Lia3pzIHcd0lL5MidCGXsD7klimed50k5dXGxKgHI8W2zFue5y0fscKGQoiM7rH7K0w5frN8Mv2zEmn/MSd2aSmERgP8ck7lWoA3gOZhIKlStzELj08Oqx2bgqwGr0LJqStt64CQQXRZb0jVWv2ObMs/bGp7oI1m6G5U5DZ2yITncySCfJdCC3T3c9Wzr4v0NgZf8GLI6VtK81DhmpoQV5kKaukIiL0m4EWHD5PmBkdLKb+jBQDHQz9uBCqUmOC5ISZSnXmh2j7Nz94d5S2Up8lQPFcJhrjMArKTNXiMJdmgLRRQjABzc99hYNQjjpoKfmwG/RD9qbIYhfFD0KUBcT0UejFFKcnMQ7T87dGxX+HajO9Med8ExCSUG5UJ3td1KbU9ZYZsL+rejG2AeJikRgclqx4DpSWVg9YN7NTh3QuWs0KPaGPG9xPLU0qsEg3eARw8RVD0ycvEMI8U7anokaSFk4EBe8XX04Nf73/ts06/AA9WFgwXhYhhzL5SHa8/TJaUwC6KUlOxhIZhKqFRYGwlelsH6c12hM3A+GtYiVbfZZmEN5uP17HAHmgk6O//b/8WI8XGirXKaUE0juF Pri+xudo YXBUam+ViBmhWGBP1WvQNJAM5zo02NlyWUvtYzV+sNlvwgFeIY9QwWlQCtTIqvSxxBHGoJvR4kv+X6bTtpRpJxzwdhxJ/wt8jUs8BDtDBJibXo4UHJYssxhhboba9p7q+T1KdC936RXsK0axETl7Qm80QzooQbyYG/IYu7Ho53rqZqrswJnV13Uw8/8qbnIWvSkVq0uwbQxQoQ2JJvkSm6oALVm6yP7uJ61S6xbIuYusjNVJhyEX4mjs55aFJi5RKUafl2XGbojgF5MIMT3D8p9FFFXvBDxF2S56o 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: Instead of defining pfn_pte() in terms of mk_pte(), make pfn_pte() the base implementation. That lets us use the generic definition of mk_pte(). Signed-off-by: Matthew Wilcox (Oracle) --- arch/sparc/include/asm/pgtable_32.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h index 62bcafe38b1f..1454ebe91539 100644 --- a/arch/sparc/include/asm/pgtable_32.h +++ b/arch/sparc/include/asm/pgtable_32.h @@ -255,7 +255,11 @@ static inline pte_t pte_mkyoung(pte_t pte) } #define PFN_PTE_SHIFT (PAGE_SHIFT - 4) -#define pfn_pte(pfn, prot) mk_pte(pfn_to_page(pfn), prot) + +static inline pte_t pfn_pte(unsigned long pfn, pgprot_t pgprot) +{ + return __pte((pfn << PFN_PTE_SHIFT) | pgprot_val(pgprot)); +} static inline unsigned long pte_pfn(pte_t pte) { @@ -272,15 +276,6 @@ static inline unsigned long pte_pfn(pte_t pte) #define pte_page(pte) pfn_to_page(pte_pfn(pte)) -/* - * Conversion functions: convert a page and protection to a page entry, - * and a page entry and page directory to the page they refer to. - */ -static inline pte_t mk_pte(struct page *page, pgprot_t pgprot) -{ - return __pte((page_to_pfn(page) << (PAGE_SHIFT-4)) | pgprot_val(pgprot)); -} - static inline pte_t mk_pte_phys(unsigned long page, pgprot_t pgprot) { return __pte(((page) >> 4) | pgprot_val(pgprot)); From patchwork Wed Apr 2 18:16:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 14036352 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 8CBC4C36017 for ; Wed, 2 Apr 2025 18:17:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1D9D7280004; Wed, 2 Apr 2025 14:17:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0EEF4280006; Wed, 2 Apr 2025 14:17:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF3D4280004; Wed, 2 Apr 2025 14:17:15 -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 B09D9280006 for ; Wed, 2 Apr 2025 14:17:15 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9C344805AE for ; Wed, 2 Apr 2025 18:17:15 +0000 (UTC) X-FDA: 83289910830.05.4E63E08 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf01.hostedemail.com (Postfix) with ESMTP id F1E7F4000E for ; Wed, 2 Apr 2025 18:17:13 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=mVU4fMKY; spf=none (imf01.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743617834; 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=lQt3ECF7HP7bKw8TGZlgthrOL2Fo1yD9YApfXehCXOA=; b=jkq1x65C9vFWKJnhJpIivYUn+qbw4H3Chc/TUk+CK6mVl/NcCVd2MAXyYFKcKrp7viAU8x CTF0wyO1XgXvrJrO52QmcjacczDh3FskIH5CMVch57fysUeOl/e8tdUcawlzaL74tmIdxm xYOVMhF+hMai26XtDeqo1+0o27cXLYg= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=mVU4fMKY; spf=none (imf01.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743617834; a=rsa-sha256; cv=none; b=Q8z3SqNms2RTp4QMV8L044wcjEgquv77fLuaVIPrrfOpoPvZPBRbBg6Y0vEB52Q+NICAaG xzFAo7M08UjZoxWCH/RogtGV96nYlaoffPqbEWrm/rk61J2lSmvngCiqM82o9S2v4O6OCG r9RsmOJPjZizhnHupJfVFZR3l1Gw3gg= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=lQt3ECF7HP7bKw8TGZlgthrOL2Fo1yD9YApfXehCXOA=; b=mVU4fMKYZo4fhGv5FW3wmjkyha 8dHahroqgFb7sZtNN2N+AHtl+dt2Ff+FfCd4lL+h/tMyoMn/FyLIkwpK2QAI+JxgljprXpxK8nHz9 SX0gs9Wny+MF7sDRAOxub0bkZea7+as8ouymgZxreUFJ4DiLQPM0KWS+7V4l9z609wCP5icxwhCcY 0NsLvQq3fRfXgvyeWPA4vT64X6UTn7Xuw32h98DvGzCHe2rRFE+IrmZZyGeDOhDiksLgQvMRTVaRm zVBBnin0afWIEBR5+q3BDEE+MC8QytkOMKTHUdxyomgJ2xH3rdz/VUZSDUfoeTNYhFx3z9MeUx7yu 1qHOeZYQ==; Received: from willy by casper.infradead.org with local (Exim 4.98.1 #2 (Red Hat Linux)) id 1u02eF-0000000A0ia-1FWC; Wed, 02 Apr 2025 18:17:11 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-arch@vger.kernel.org, Dave Hansen Subject: [PATCH v2 04/11] x86: Remove custom definition of mk_pte() Date: Wed, 2 Apr 2025 19:16:58 +0100 Message-ID: <20250402181709.2386022-5-willy@infradead.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402181709.2386022-1-willy@infradead.org> References: <20250402181709.2386022-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: F1E7F4000E X-Rspamd-Server: rspam05 X-Rspam-User: X-Stat-Signature: z95j9waoybmfxormspifq48z3tzwcp6b X-HE-Tag: 1743617833-352280 X-HE-Meta: U2FsdGVkX19ZxlPjRP9ZrdMYihVmHElRcG2mt4cFmW0lwaJR4SEKubSMjVc6fzyS500xdIx63y/7m0VEQ/XHGdksW3sieq1hoe38dMewV3t37aPLNULjiIW2OX5z4p5LwEtp0RetZsZiyFKO4dFjA2vGay8nNjWdpwBrjVrnyzF4oFAqsoq6UzfBA8iBnp/cV4BMh2zlRgC0+WxxyuQZsPrM+Lz9kgH0RR9mIaHIg0K3tmGvhNJui4palX5cbdBsMu26iEKKLk1JrkdXbKIpmsyCFvZc18Z4hkuyXdA9+BROW3QEP2Azlk0BBch8mOIU6TnONM79oKVCYiAF1n8z68SEbLLhv//ofpYb8JdDXj6umqI+fc8Rv6gzCKM2pQMa46VKTJXkG5pc6Faxx8EVxAVMnkFI4S3An2DYwolJLGPm/5Jp45hEIySjIqhm0rDonTKIW4fSOvDcwRaXQSEfKlpIo30y2pDY7ivqukzdgxRiwU43rjXyMS/uHKIzRTF2UlDeY+KfMWPn4iiFxrHb5YaAoZqP3WPmM943WhXkBXsXPR1T6K/Lj9jSaJP9lbf29gid6I1I6xaGn/D0C687jStp14JUNPqdAMYnL0Od8JcaYRgAItoDhYZfpnrDhQDcL0NzPm1MOEOPleFVgNU2s4jTp48e1QysdZhgt78jUYuJk+jR9hJmdy/NZ/16r9CuUECC846pk23EQqZOk4FUSiuns5f8KzFpFQm/7SepcXhDxikoi5AK8afDyfzwMeTIPYzD8IZxaYK+hAqUK6/17kKnjfYENlSpIkR8zaQegRtVJF3yGcYCeE0KrmRGJCp5dX6ZzUbvbUfrQCV9xF0eaFxhBKZZFt3frAT8+h48EM9x4W2ba3wcFxhWPgz4yYtnoax8dlLp10INDJSP99eqpSJHxmGkaE4AIKqDl7fiTp+K04rNUK/jrgNaMsamXGqDp/kLJzS4g/ais/ADczL a6AhV2fk lhEsIDmjMHSsm8G0FNZ55SfSk1EWNb7VsSPGqC7VZzZ3X1xYvTb/VOoygcOAND9Mx9xFoY8KzWe8uRBaj+ShDOPhMsK1Hsq19q6z2R3aerOs6N7zI5scSLelpP7J1wak7UJeeQB+KEDZ1uudjvk/UaEq4FeAxqBWYJcpGDn1rlVWMI+YyqOQuiWRkSFIPMBu2eJm1N+P3DH8hkqas7wfVcBP+Ya7BFyobKwmt/14Ho4SLx14Cwhv0fUGP86ma6jqGIINEDPhs3JNP3JK9rNOXpOaae7i85TCRnf0PR3w7TDb/h9RxVg4ool+7cA== 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: Move the shadow stack check to pfn_pte() which lets us use the common definition of mk_pte(). Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Dave Hansen --- arch/x86/include/asm/pgtable.h | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 7bd6bd6df4a1..2ce98b547a25 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -784,6 +784,9 @@ static inline pgprotval_t check_pgprot(pgprot_t pgprot) static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot) { phys_addr_t pfn = (phys_addr_t)page_nr << PAGE_SHIFT; + /* This bit combination is used to mark shadow stacks */ + WARN_ON_ONCE((pgprot_val(pgprot) & (_PAGE_DIRTY | _PAGE_RW)) == + _PAGE_DIRTY); pfn ^= protnone_mask(pgprot_val(pgprot)); pfn &= PTE_PFN_MASK; return __pte(pfn | check_pgprot(pgprot)); @@ -1080,22 +1083,6 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd) */ #define pmd_page(pmd) pfn_to_page(pmd_pfn(pmd)) -/* - * Conversion functions: convert a page and protection to a page entry, - * and a page entry and page directory to the page they refer to. - * - * (Currently stuck as a macro because of indirect forward reference - * to linux/mm.h:page_to_nid()) - */ -#define mk_pte(page, pgprot) \ -({ \ - pgprot_t __pgprot = pgprot; \ - \ - WARN_ON_ONCE((pgprot_val(__pgprot) & (_PAGE_DIRTY | _PAGE_RW)) == \ - _PAGE_DIRTY); \ - pfn_pte(page_to_pfn(page), __pgprot); \ -}) - static inline int pmd_bad(pmd_t pmd) { return (pmd_flags(pmd) & ~(_PAGE_USER | _PAGE_ACCESSED)) != From patchwork Wed Apr 2 18:16:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 14036356 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 EACE2C36017 for ; Wed, 2 Apr 2025 18:17:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FE9F28000A; Wed, 2 Apr 2025 14:17:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2AF0B280006; Wed, 2 Apr 2025 14:17:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 152E528000A; Wed, 2 Apr 2025 14:17:24 -0400 (EDT) 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 E3B80280006 for ; Wed, 2 Apr 2025 14:17:23 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B729312065D for ; Wed, 2 Apr 2025 18:17:23 +0000 (UTC) X-FDA: 83289911166.11.33A10B4 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf02.hostedemail.com (Postfix) with ESMTP id 2657F80012 for ; Wed, 2 Apr 2025 18:17:21 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=DiiWRSGF; dmarc=none; spf=none (imf02.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743617842; 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=irsUPCJDDf9sWPbOR5tfnHLkyAVI2ujQHmur4Rc6/5I=; b=kZuMmgARg8W/gXYO/q4hCRsEyhJOdZk7iXjm5do3hbbsHNbamN7Gq6mhlRZHohS8pvivkv ij311jQAH1JdZLgyikL4a8d9aN6dSHLr0tctAknFryqUUTN5kv35+y/6+JioaWJXtbLkkT /Oj5n6ZX8uAeiE6967/9UoYg1+rTdRc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743617842; a=rsa-sha256; cv=none; b=a3IS1+Io8LJChA5qJ0HKma9CUNHLAX2ibAvdi7JgeasM/L5NRKThYudTbnv1WgmeUsqIvj jQyxfjZ2hy3EFBowV8y6JmNcpY1NNyrwHdpxDZAeZdBkkDhGCs89Iij3mRWu4Yy+R85Ujh 9zV9KPpMubDFWzijAxZWTTZRnWTdVDQ= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=DiiWRSGF; dmarc=none; spf=none (imf02.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=irsUPCJDDf9sWPbOR5tfnHLkyAVI2ujQHmur4Rc6/5I=; b=DiiWRSGFkDv/1wb2fMATmgO0vc GPHSBhKGsY40maSdYr53ANtoYmy+Q9JbmLRz6xIplGek+MQ/LURoGK9tpG7tAXsWIh/VZUClVjnxE NS7WQlrkUv/c70EHHrj7ePkHPMs0QLCT29rmZwcJ2wCsen3CVmvie+eTBlaENziQMmwAOZSi+eZHT ZytgqdauVNdVUj3q9U+y8YtSFQQ+ZbvJNGFRZDYi7A5VdTI4CUzMje6BlLAO6g2fQMV1Hngn5X5My YG+ApHc+jeaNZXFOb2sCIKDGvmzY0sScCa5PVNe5JVe9qPQX6WNLDxAk+yIpKdrwjvEecqx0fHKij Uf3znXEg==; Received: from willy by casper.infradead.org with local (Exim 4.98.1 #2 (Red Hat Linux)) id 1u02eF-0000000A0ic-1hFm; Wed, 02 Apr 2025 18:17:11 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-arch@vger.kernel.org Subject: [PATCH v2 05/11] um: Remove custom definition of mk_pte() Date: Wed, 2 Apr 2025 19:16:59 +0100 Message-ID: <20250402181709.2386022-6-willy@infradead.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402181709.2386022-1-willy@infradead.org> References: <20250402181709.2386022-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2657F80012 X-Stat-Signature: fxqpkcgypyg5bes85oz3cx5kxsu7zs87 X-Rspam-User: X-HE-Tag: 1743617841-168660 X-HE-Meta: U2FsdGVkX1/9DWhTvAtlUtUpIiWoEH4TYJ6aRlPv8oGah5sXSat6LM3ZUxl2OPbzlmphmlkiL7UlXLz6EpqNFwQt5JLnDp6mjHCKYvOzshKF9Rx0626WtKMeXjGevdYYvNFqCA5xV0j5m/o+jSyh2Enz4ekNQhcLpUHmwlBfxcQ9jNSTonkiaag0JEw1x80RzGjouD73rJDFx8bgFybJwXfmZbMR9TF5RyEEajRZjEGw2PDaYMEqAHKr/tJEG8f84lbP4k6kH6kLTcep05ww4ooM0Px8G5Ys/b9BIB90jsDl/svr8vYBapDOHNxOBp8LtpQuhd2mgGmyp6s9HTIA7F/55OpacIiDkTq3CMgl33ZqvbCw4pzVRFr4s0AgAAc2RfVOusTVWH6BKEUTTSp9NrMvzYAqtjGCUU24vKfq7wUPYm5+j6X5ALtt6AVzbg7DUV3y5S6tkbg+nrMrEV7VkbGq8fsOXSootLQmzNfgBk/DxShskd1urT2YOtRixx4+FwpBHOafm3dZc3cnnzpf06UZGqT+Ahla2nQNW+k8ukYKev3QJdWI2YYMbsLtJnVDFFnn93TYtec06ntPmBfqP7LY6H9qQgu2xx+5Udueb3muHxyzUeBKQVfpLUcI4b6OLEfjoesVJHgx/y9zpuof8+JYjPzgExJYaJOWNfmBQKeAN8fA0M64g1NBSsUmUt6sy1CKdazzUBA7J4i4Cju2GuUM4+dCip7UH445ZJz3TG628k3ovF3haA78ui8GB4csabJSD3cZyN3+1drQmVAFMbVLJZkks1BRsWkRQmtrj/bSIOdI8dNqVVclRkS4lYSCHzMmZP4nsJZK2d2dDGBRdDDJwEPH6obgMwoW11I6roQxNudXu9B6bXRafFifiJ+9V4T8nQf8JuCd1M9LUwD6khJd4rxdEIJO8OX0rs9Jxs4gcYGJpF7dnvMbBUTJaAXIDPq9vXQ/92Y= 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: Move the pfn_pte() definitions from the 2level and 4level files to the generic pgtable.h and delete the custom definition of mk_pte() so that we use the central definition. Signed-off-by: Matthew Wilcox (Oracle) --- arch/um/include/asm/pgtable-2level.h | 1 - arch/um/include/asm/pgtable-4level.h | 9 --------- arch/um/include/asm/pgtable.h | 18 ++++++++---------- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/arch/um/include/asm/pgtable-2level.h b/arch/um/include/asm/pgtable-2level.h index ab0c8dd86564..14ec16f92ce4 100644 --- a/arch/um/include/asm/pgtable-2level.h +++ b/arch/um/include/asm/pgtable-2level.h @@ -37,7 +37,6 @@ static inline void pgd_mkuptodate(pgd_t pgd) { } #define set_pmd(pmdptr, pmdval) (*(pmdptr) = (pmdval)) #define pte_pfn(x) phys_to_pfn(pte_val(x)) -#define pfn_pte(pfn, prot) __pte(pfn_to_phys(pfn) | pgprot_val(prot)) #define pfn_pmd(pfn, prot) __pmd(pfn_to_phys(pfn) | pgprot_val(prot)) #endif diff --git a/arch/um/include/asm/pgtable-4level.h b/arch/um/include/asm/pgtable-4level.h index 0d279caee93c..7a271b7b83d2 100644 --- a/arch/um/include/asm/pgtable-4level.h +++ b/arch/um/include/asm/pgtable-4level.h @@ -102,15 +102,6 @@ static inline unsigned long pte_pfn(pte_t pte) return phys_to_pfn(pte_val(pte)); } -static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot) -{ - pte_t pte; - phys_t phys = pfn_to_phys(page_nr); - - pte_set_val(pte, phys, pgprot); - return pte; -} - static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot) { return __pmd((page_nr << PAGE_SHIFT) | pgprot_val(pgprot)); diff --git a/arch/um/include/asm/pgtable.h b/arch/um/include/asm/pgtable.h index 5601ca98e8a6..ca2a519d53ab 100644 --- a/arch/um/include/asm/pgtable.h +++ b/arch/um/include/asm/pgtable.h @@ -260,19 +260,17 @@ static inline int pte_same(pte_t pte_a, pte_t pte_b) return !((pte_val(pte_a) ^ pte_val(pte_b)) & ~_PAGE_NEEDSYNC); } -/* - * Conversion functions: convert a page and protection to a page entry, - * and a page entry and page directory to the page they refer to. - */ - #define __virt_to_page(virt) phys_to_page(__pa(virt)) #define virt_to_page(addr) __virt_to_page((const unsigned long) addr) -#define mk_pte(page, pgprot) \ - ({ pte_t pte; \ - \ - pte_set_val(pte, page_to_phys(page), (pgprot)); \ - pte;}) +static inline pte_t pfn_pte(unsigned long pfn, pgprot_t pgprot) +{ + pte_t pte; + + pte_set_val(pte, pfn_to_phys(pfn), pgprot); + + return pte; +} static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) { From patchwork Wed Apr 2 18:17:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 14036357 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 63013C36018 for ; Wed, 2 Apr 2025 18:17:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D92E28000B; Wed, 2 Apr 2025 14:17:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8823B280006; Wed, 2 Apr 2025 14:17:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 722E428000B; Wed, 2 Apr 2025 14:17:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 50835280006 for ; Wed, 2 Apr 2025 14:17:26 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7109AABD58 for ; Wed, 2 Apr 2025 18:17:26 +0000 (UTC) X-FDA: 83289911292.10.EB8D3CE Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf18.hostedemail.com (Postfix) with ESMTP id 05E3B1C0005 for ; Wed, 2 Apr 2025 18:17:24 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="A4mVtz/r"; dmarc=none; spf=none (imf18.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743617845; 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=1R/HHCzGcwjg+fBXbbAq3H5FDI7HZRKgEBZ7xd5xOnk=; b=K+nTNbhI9s+Y4UwErfPzCrdDNwHqoVFJWhQPZbX2TftJ84mv5owUqgF9qWDryz/A/q8W6Y cTE8+YFjzGHpFpxyD2b6Kf6UdUzqSVfF4llk+/S7wGjKwTv1oKbhMNPSh08BsTX82/0s8z co/hr6ZcoB8haFcPn8erzTu10M7Ildg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743617845; a=rsa-sha256; cv=none; b=J9EchfHRxdcQmy+8KtqwkRIjKoXN79SC5/c53HyL89kcGj/VN2gQCmn5+n0+G6Xy8A1ukN bKm35ikty5uY2JOvnAsmWPYjbbWnXlQ/ANjh9l8fhXSzEBG4YY+2OW8tj2F9rlETBW6lC+ T+5mpkMHSfFkkP5v4WRXGe31MDhxJs8= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="A4mVtz/r"; dmarc=none; spf=none (imf18.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=1R/HHCzGcwjg+fBXbbAq3H5FDI7HZRKgEBZ7xd5xOnk=; b=A4mVtz/rbieK66CYPTXQ2f2CIZ uWjFJipDitx7TfiRyvzMSpRtcElQyboe3flkofx0qSYFgFKXlH3FF3QGRMAHjw64A0MlPmh+WPYaD cEbjJNyGR3JP6P/0XT412dtDt1skwUnhFCu4kiHeuLNg2qvrhkSNe2c9XybdpbfU3JWLAS42SwoC0 NZQthenBY1B2DTuXQn+LEZw50bKmccoKAlu59MKPRqOH44YXDz2mp0G87vJJB6sKIgDgkcDzNfodN nRsxRBNQZNkGuYCUk/TU/gJx45KbMgv373+YEdJN7AOiqPynm37z/17jXE9k1iAtQqkaVtRywdXfm +i/NJPyA==; Received: from willy by casper.infradead.org with local (Exim 4.98.1 #2 (Red Hat Linux)) id 1u02eF-0000000A0ie-22tt; Wed, 02 Apr 2025 18:17:11 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-arch@vger.kernel.org, David Hildenbrand Subject: [PATCH v2 06/11] mm: Make mk_pte() definition unconditional Date: Wed, 2 Apr 2025 19:17:00 +0100 Message-ID: <20250402181709.2386022-7-willy@infradead.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402181709.2386022-1-willy@infradead.org> References: <20250402181709.2386022-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 05E3B1C0005 X-Stat-Signature: 9fat6njqh39rpqkqw7dbn9nygwduhtw8 X-Rspam-User: X-HE-Tag: 1743617844-518262 X-HE-Meta: U2FsdGVkX1+73YMlmk3c7KheSJcKQ4eSBED365ZgAOskVQOym3XE2nFQJKjssIJZZTSDPxPUrkQhrohRk5Ic1gZq0EbgIQiVdNj3hPa3dg8wdK84YwgR+uzOjI8z16i4B1SB6Qm6ZzIkkOtXRj0XOvdOn19BGHs167EOiVmagwRl4EAIQ4CeaRPm1lFasqkmfVabLlSqYM4OPtODK89SOgFweYtB5Q6aiLorjtSvL++DUtiwKwQ3nV+DvugbGeIPxk+QyaefIHEPCpcMd8b/8hQewuxrTF8KXYnu67/PTlhBvoeBZbx+Us8q8keU5OwybpmRkUZR9yvayBVypBeWBPAMQqEbK+RYZsraMa/O+N07xeoESgITp2HRvNJ0Slg/uHnSzk2EC91H5fJBemgeW0nk+DLYqnwQdAYipE7othVw6vdjhIcuP05rtZJE7qe9yf7am7U9qbpVUlABuKZbU46jwgMMne2SJXCzJncFj1SCKdrApWGhsCF/tmpy9iHVzo7D7pDHWX0UrqnbkIX2X122OjD8yNlpsA2zHl1tKjasEMJK5ce1uxovOZ67fpO1t2jdj/JzGDii2zghkHQz7vip+wKP1l8W2NKyqip9cVN475c+J8UgtArDcc5HCLlY3U5/xHxfdFZaLABY2CMWv4eIPdmkBpBMzyPBafv8g4yLGmIJ18GJ0O1rCBYXNlUCiT6oGgzQk3VRUlG+wsn8OcLgplS6ORJp3gqO+1PaNjs1j9dts8M678NRDSbQzsEIVr4+J8dIPQUlFovvExy86c7ygC/FdHNRCKBytHQhvZ1UP04Md9KZRfFpUzywSgAmdjnvlsjD5S/69t9Ghnbw9ZrEs//iB4UTZI5T/7urQhYbq2AR7OIgCYiKcL+sc+M+DC5PV2pug3NkEdPInOAhA6NEzyBWM2WgzPxuGyoZluSvf6zGwP4/e24O+ZTNBx72u60rt9CmlHk= 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: All architectures now use the common mk_pte() definition, so we can remove the condition. Signed-off-by: Matthew Wilcox (Oracle) Acked-by: David Hildenbrand --- include/linux/mm.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index a2bdfd7afb1b..5dc097b5d646 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1987,14 +1987,12 @@ static inline struct folio *pfn_folio(unsigned long pfn) return page_folio(pfn_to_page(pfn)); } -#ifndef mk_pte #ifdef CONFIG_MMU static inline pte_t mk_pte(struct page *page, pgprot_t pgprot) { return pfn_pte(page_to_pfn(page), pgprot); } #endif -#endif static inline bool folio_has_pincount(const struct folio *folio) { From patchwork Wed Apr 2 18:17:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 14036354 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 704F1C36018 for ; Wed, 2 Apr 2025 18:17:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4068B280008; Wed, 2 Apr 2025 14:17:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3654C280006; Wed, 2 Apr 2025 14:17:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0FA73280009; Wed, 2 Apr 2025 14:17:17 -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 CD51F280006 for ; Wed, 2 Apr 2025 14:17:17 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 05E1016044C for ; Wed, 2 Apr 2025 18:17:18 +0000 (UTC) X-FDA: 83289910956.04.719C326 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf02.hostedemail.com (Postfix) with ESMTP id 023E18000D for ; Wed, 2 Apr 2025 18:17:15 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=awmYQ8yE; spf=none (imf02.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743617836; 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=qTiP2D3OrGMsSaRwxahGkUod//8qVelF/nv7EzuQ3uQ=; b=ZWy9RAgfbXRaoCc0lUVYkLg6G+C5zpRjCikQJRDJNwL8f3wUNq32Oc6aUwcFZz21cn40oP j+ToU91fv6f9H1CcXGrjwCegmLjsFt76z3OhbZ0kx0ZgxyXQJWirBWY7PMuiAcRRGtPZ0R G1otcjae23XDyzsUfh4GJUCIRTz5ruI= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=awmYQ8yE; spf=none (imf02.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743617836; a=rsa-sha256; cv=none; b=NXl2N1Ar2KvmXtoR09iuBfdZv7YnURTm0vTAVibjtGp0/9p3R57UdZV6RSf9Gd65KwkVTY oHYZPGJzTcbzuUplDi1iQbcGi9unSFmzALYEae8qA8eK3S6w+n9PKCZBz5T8UuU8WnnTu4 UyR1Jy7/yAU99Ld4r68Tl2BFbhOhSY0= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=qTiP2D3OrGMsSaRwxahGkUod//8qVelF/nv7EzuQ3uQ=; b=awmYQ8yEmw1Xbw+DXL1UpX4cf4 7g2FBet0xAZTYuMgfxIQPDUKNDEnYG1OojGXMU8dzq8v0Dm3Xg3bIZxZ8jUMHjYuLKpJaXjCPWDNj +P50tTxGfQW8TlF4INZKosrHKKdTKnkDF68CNIfsChqxVOgk92zVkt8mqJGO8NGK/rUmK8+TUCIhb E75NdS4YZUF7WIpVdxcrszpVRkKB+DuwbeD1pFngn1Pvl8oYcCadm7nkua9ReUvkYbuR3kNolwx1W dj13ssBLhJrGdpSmvHqvjztT1dip9P2Iv/lTxyo8Evgs/vo05MpzggO07vRbTvtVJBZIVCnwoKpwm g8QuymMA==; Received: from willy by casper.infradead.org with local (Exim 4.98.1 #2 (Red Hat Linux)) id 1u02eF-0000000A0ig-2MTV; Wed, 02 Apr 2025 18:17:11 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-arch@vger.kernel.org, David Hildenbrand Subject: [PATCH v2 07/11] mm: Add folio_mk_pte() Date: Wed, 2 Apr 2025 19:17:01 +0100 Message-ID: <20250402181709.2386022-8-willy@infradead.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402181709.2386022-1-willy@infradead.org> References: <20250402181709.2386022-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 023E18000D X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: gsjcbbzuj39sm5koph3g5j7dhzonkssn X-HE-Tag: 1743617835-791264 X-HE-Meta: U2FsdGVkX19ZPwtjtqTxz89HWb3Vwf/3ki0E8pNndPwZK+wgIs2MvVgODZQS/dwxNCHXq++APEW9E/LHrlQt8CSdJVFp7NDDNRORkk0wI9OOMghmLP2wXRCMvbSxzdQw4zkI2y2dMgCJj9VRTFhQ/48u1XFPEg6ldYUKa8ccONP5ecBkFba1vudvWvMnlFEhGNwpBc++yIv9lCqDug9P+RVSbTJexePLcYj7YKpGa4u6Pxa86+PyinTt62XKKBFD5Eejsz0IbmtKfnMLPhVjZNdYSh/vu6PmZigIiEGTTRzS0i0kBnqPL0YTmEKh0p0q5uV2d6Hh1KNy2eL2xgv+U4qe0Pwx6+jlAKR96At2wpgS8KIAz7jbQypzkUi/YstlrWeqbZLgNCUOyHMoRmSrCaUUfPeFH/gVFAyyKU8hsAhICJSO7OkCGXn4m4/NQv9F2YrdwJ30meyiE2LOKas5/sRduZW3OU4EPF9KXDzY1W9Y/61UCRAeXbZyEmmC+dH0iBlwIOF2hYhg0kvtB00HUcuBSGfDMxRfn5ISCyxhiOxpoJiyk19FjfT+610gTvE6Uort2Ml+Ed14OBm6gcHj8nsUCLbNnybXGjuiZ7fYxD6iGCDnEkoZ4tmwuqsy7YRqMGCHMiWZtCYFzuBN+nZ+oUWAK1Qr4tz0dGLlsYFPWd4o55Oh9GrC22gST8AZEsAsjcLZx52JmrJ/fHFYQRhV5b6FynDUn2iofeo7KYRP/i/aVvCWlcsV+0kPx0k/vqBQ9wI9/0Ky5P4R/gC4yCu6j9e7jH0bNKbc6RGl3wcK0Xb3w3wSUphSUajCCTlRYmbxfcvu45SvXomDjZAKn/oeXyAhkx3ToDtMzIUji4Rw/KVwv2XtnZBnkOm3cIDPcfB1A8iAQBK+8xMKHWDvhuSnxrnOSH7/Fv4kqoBacJIOH0qTp8k4LRw2EI9KUPW95SfSC5QFQ5+tTRqEA3XDmyH SNxgmQV4 nNwT1Mc+ItYPHJaAmCSmvNep7TKmtolGSZ75fNB+OIldpfVEyv+jIqZJIzF4lgb87mukcgN4/wt6OYlMBIhz+VnGuswpCP6AkLpZKpQBbv+vbHkv4we2bagwvT5QlU/akhe1PPGt5zyrKLszah5JphmnJVU2W6ExpX4WZaUsXO/GuMEEiOuF0qc8xNpmBoLoI+X/f61qSwIjsm9OxnsCFjj0pKgRmVA5Q4cvZWK86liogo/nU3v2tNF8LagIyKk8ZK2oMJQjeI/1nZBbY+tdvIgZPlHTNB6Q4jSvTMHnePjpPERoydJjTAW3MoA== 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: Removes a cast from folio to page in four callers of mk_pte(). Signed-off-by: Matthew Wilcox (Oracle) Acked-by: David Hildenbrand --- include/linux/mm.h | 15 +++++++++++++++ mm/memory.c | 6 +++--- mm/userfaultfd.c | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 5dc097b5d646..d657815305f7 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1992,6 +1992,21 @@ static inline pte_t mk_pte(struct page *page, pgprot_t pgprot) { return pfn_pte(page_to_pfn(page), pgprot); } + +/** + * folio_mk_pte - Create a PTE for this folio + * @folio: The folio to create a PTE for + * @pgprot: The page protection bits to use + * + * Create a page table entry for the first page of this folio. + * This is suitable for passing to set_ptes(). + * + * Return: A page table entry suitable for mapping this folio. + */ +static inline pte_t folio_mk_pte(struct folio *folio, pgprot_t pgprot) +{ + return pfn_pte(folio_pfn(folio), pgprot); +} #endif static inline bool folio_has_pincount(const struct folio *folio) diff --git a/mm/memory.c b/mm/memory.c index 68bcf639a78c..fc4d8152a2e4 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -929,7 +929,7 @@ copy_present_page(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma rss[MM_ANONPAGES]++; /* All done, just insert the new page copy in the child */ - pte = mk_pte(&new_folio->page, dst_vma->vm_page_prot); + pte = folio_mk_pte(new_folio, dst_vma->vm_page_prot); pte = maybe_mkwrite(pte_mkdirty(pte), dst_vma); if (userfaultfd_pte_wp(dst_vma, ptep_get(src_pte))) /* Uffd-wp needs to be delivered to dest pte as well */ @@ -3523,7 +3523,7 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) inc_mm_counter(mm, MM_ANONPAGES); } flush_cache_page(vma, vmf->address, pte_pfn(vmf->orig_pte)); - entry = mk_pte(&new_folio->page, vma->vm_page_prot); + entry = folio_mk_pte(new_folio, vma->vm_page_prot); entry = pte_sw_mkyoung(entry); if (unlikely(unshare)) { if (pte_soft_dirty(vmf->orig_pte)) @@ -5013,7 +5013,7 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) */ __folio_mark_uptodate(folio); - entry = mk_pte(&folio->page, vma->vm_page_prot); + entry = folio_mk_pte(folio, vma->vm_page_prot); entry = pte_sw_mkyoung(entry); if (vma->vm_flags & VM_WRITE) entry = pte_mkwrite(pte_mkdirty(entry), vma); diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index fbf2cf62ab9f..3d77c8254228 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -1063,7 +1063,7 @@ static int move_present_pte(struct mm_struct *mm, folio_move_anon_rmap(src_folio, dst_vma); src_folio->index = linear_page_index(dst_vma, dst_addr); - orig_dst_pte = mk_pte(&src_folio->page, dst_vma->vm_page_prot); + orig_dst_pte = folio_mk_pte(src_folio, dst_vma->vm_page_prot); /* Follow mremap() behavior and treat the entry dirty after the move */ orig_dst_pte = pte_mkwrite(pte_mkdirty(orig_dst_pte), dst_vma); From patchwork Wed Apr 2 18:17:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 14036358 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 0D328C36017 for ; Wed, 2 Apr 2025 18:17:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A3C0E28000C; Wed, 2 Apr 2025 14:17:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 99D4A280006; Wed, 2 Apr 2025 14:17:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77A6528000C; Wed, 2 Apr 2025 14:17:29 -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 49B09280006 for ; Wed, 2 Apr 2025 14:17:29 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 896971A063E for ; Wed, 2 Apr 2025 18:17:29 +0000 (UTC) X-FDA: 83289911418.20.2C9D4B0 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id 0170C160003 for ; Wed, 2 Apr 2025 18:17:27 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=KLXmh9XL; dmarc=none; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743617848; a=rsa-sha256; cv=none; b=SqomqHlFR2MM3L5IAlKqs9vaOIGh83IQt2ZY0fW2If7znofWJCgxUUUFf9CGV3+w2nJNMH uTr5ltqktUifcmd9Sfv3jfch1KhELSluiZXrV3m21KdkDHQP0+RDin3/SsPW5/TFPMiUtD /+30ijB87g6VzmPwA8XeBiQu9won6M0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=KLXmh9XL; dmarc=none; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743617848; 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=YUZaMbW4I7OXHp12rW2s26jw5pZRBiflAQO7xH+epdQ=; b=LGHp1mzUZfGyJaMWRK4kNYNhkyCV1qzHAe4oKJ4Gsx3QkA4D4Im9w8Y6Kc6SuPpkdGfnyq 8H8imSpj4fhcTYFBKVauzgYeHC48/Ch4DdzPxVV6tXcNK24YtmdPE9mt5Z5z4Wwrd/z1g0 7V5XBngx7Uzh/KgPY8RLbDVB/qewQBU= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=YUZaMbW4I7OXHp12rW2s26jw5pZRBiflAQO7xH+epdQ=; b=KLXmh9XLowoSpHwZ9zM4XJydIz TqWk5i77jSlCFxWbMVP41th0m7mltbbAIhyscjEcZ2rqKCIEuoMRoD8m+tkh+GNG9gDl8rWlkOZkP fJKzIOFKoDy/lc/b2zPnyKxlgkgynJROldGu/GnUwxMQC1WFVqZaJlZssQ/5IhiixPJWsYVjXY6Lh iyp0jtqktkLNuxr/NRsw1lQda/qG6kWQ495VsU3nd+AJoAD5ypvjFgJm47HQeJFCQCKwnv0D/c3Mx DMSfkFCF4wKXPSKifK0Q0DRnMg3cMaeKkoAqLdt4f6wurG5VoJc5sbOu5ynI+5BSeypDTnkuW9GD+ Mt8qEIRg==; Received: from willy by casper.infradead.org with local (Exim 4.98.1 #2 (Red Hat Linux)) id 1u02eF-0000000A0ii-2im4; Wed, 02 Apr 2025 18:17:11 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-arch@vger.kernel.org Subject: [PATCH v2 08/11] hugetlb: Simplify make_huge_pte() Date: Wed, 2 Apr 2025 19:17:02 +0100 Message-ID: <20250402181709.2386022-9-willy@infradead.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402181709.2386022-1-willy@infradead.org> References: <20250402181709.2386022-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 0170C160003 X-Stat-Signature: shpe1eutrc6da4qeqjht7iemxhr4d9a7 X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1743617847-855534 X-HE-Meta: U2FsdGVkX18yVHof1rRdpbE6w0L+PUyiV5X86/Oo3h1AGuD/0oiGUith1YSQ+nqcuhMJniYWcGY1Vr92w0RyDb/+le3/TN+GjEF0DLqZIufuWcbka+ciXTSd+Fd1eXpxNRQg43vnACYxx3y66FDK8bersZx3opGPJr9BD/piEYcVaOQru7Rc1CCGbR14A+N7PJr9302LPMxXSevIxsnvDbouhdMbxR/Ux5OfuGRYBzyFUyRF2sntgbueC3syR98nhAV5LDoUNrNhOGyfTNZsvKQJjRAan8bj9TcqRq/7IngOFZgjPTo0s17gSEld0C2YKfu1fM2BjvOsH+IZTdnvmIYiT87CE48WZq4PGZi89wk7ILDeL17QW51Pf95xOPTgy6UnC8vRN6xItd8pbLY6Xpp0jDjWafgcILIcLscpSGKsmKnDHW7BFSXq4Jw3abMPxCdpKRVAqUiuKHVA3arRW2XEVJKRJCOGJrVb6Xn4ar2vYmIQGtoKptHg2eM6Soj/dok1YfFLtA8kLhEXK/Uvo5BTH8cx+1MQWCFQxp2gWd2nira0Qq2YkY7X+58PIZcnsv4ZSuUVSBAl00VUX9D83j6i7n1f5/n8oGge4WwgmGRFwHq13Cg87qoOsTdLdfRSBxSB8WJpPmw8JpBQ7Iw41dx4UJ8ccPG1SstjxZ99lXKePoL6aOFjGor6GH9us08/it9xLUG/VDbF3d5Y/fF/OXhfENjs655mQXqcs+ZhxiADMtFB1HL4MwHVyYV4vu1ARBVWLC0tbhKB/XHWstvGcoC9ya2i+mwe3/e2uk2rXghCBy+lu9sXMK9YLgZIldhFTqTwIW6SSXZHbdMRqKk8j/V2dzqupxOJPWDDGLsytw20Lez7WFpmXBMFsE6uaiY2ZkfuDSUKZPv2TVJ4P4zBfYhC11ndjSiVjS2Z7IZ8n/8hIFwc/iGd0QtYHp13CqjyWRae4XUvDpf7QD0LA0G hQ8El2R3 smjY/M/kvHAMWw2DbnhSnRg1XUMT+evHdebsq0jPCxAmrV980jVTIho6eX6sFD4agm0EbJutL+GrcMQD2aEdbANP+cKp0QIx6C02e1X75BzAf2v4oN1eIiqY0GsVCGQIrODWfOKi9dlx5MYt04ub8mAlIs7g/dTVo3gfwajrvLsh4yGx2IY4Ej27gATGG+9mpVZX8fqJxw45HtIwl2W9t0EnABBZMPz7d0z0AAtUtPTCRkJUGmuEmLH2EQFK3HY7kOQBG8AqwqDjdQBqjbJVBW6XQp4ASdIU1XsrC 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: mk_huge_pte() is a bad API. Despite its name, it creates a normal PTE which is later transformed into a huge PTE by arch_make_huge_pte(). So replace the page argument with a folio argument and call folio_mk_pte() instead. Then, because we now know this is a regular PTE rather than a huge one, use pte_mkdirty() instead of huge_pte_mkdirty() (and similar functions). Signed-off-by: Matthew Wilcox (Oracle) --- mm/hugetlb.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 6fccfe6d046c..df185f10bc9e 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5441,18 +5441,16 @@ const struct vm_operations_struct hugetlb_vm_ops = { .pagesize = hugetlb_vm_op_pagesize, }; -static pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page, +static pte_t make_huge_pte(struct vm_area_struct *vma, struct folio *folio, bool try_mkwrite) { - pte_t entry; + pte_t entry = folio_mk_pte(folio, vma->vm_page_prot); unsigned int shift = huge_page_shift(hstate_vma(vma)); if (try_mkwrite && (vma->vm_flags & VM_WRITE)) { - entry = huge_pte_mkwrite(huge_pte_mkdirty(mk_huge_pte(page, - vma->vm_page_prot))); + entry = pte_mkwrite_novma(pte_mkdirty(entry)); } else { - entry = huge_pte_wrprotect(mk_huge_pte(page, - vma->vm_page_prot)); + entry = pte_wrprotect(entry); } entry = pte_mkyoung(entry); entry = arch_make_huge_pte(entry, shift, vma->vm_flags); @@ -5507,7 +5505,7 @@ static void hugetlb_install_folio(struct vm_area_struct *vma, pte_t *ptep, unsigned long addr, struct folio *new_folio, pte_t old, unsigned long sz) { - pte_t newpte = make_huge_pte(vma, &new_folio->page, true); + pte_t newpte = make_huge_pte(vma, new_folio, true); __folio_mark_uptodate(new_folio); hugetlb_add_new_anon_rmap(new_folio, vma, addr); @@ -6257,7 +6255,7 @@ static vm_fault_t hugetlb_wp(struct folio *pagecache_folio, spin_lock(vmf->ptl); vmf->pte = hugetlb_walk(vma, vmf->address, huge_page_size(h)); if (likely(vmf->pte && pte_same(huge_ptep_get(mm, vmf->address, vmf->pte), pte))) { - pte_t newpte = make_huge_pte(vma, &new_folio->page, !unshare); + pte_t newpte = make_huge_pte(vma, new_folio, !unshare); /* Break COW or unshare */ huge_ptep_clear_flush(vma, vmf->address, vmf->pte); @@ -6537,7 +6535,7 @@ static vm_fault_t hugetlb_no_page(struct address_space *mapping, hugetlb_add_new_anon_rmap(folio, vma, vmf->address); else hugetlb_add_file_rmap(folio); - new_pte = make_huge_pte(vma, &folio->page, vma->vm_flags & VM_SHARED); + new_pte = make_huge_pte(vma, folio, vma->vm_flags & VM_SHARED); /* * If this pte was previously wr-protected, keep it wr-protected even * if populated. @@ -7022,7 +7020,7 @@ int hugetlb_mfill_atomic_pte(pte_t *dst_pte, * For either: (1) CONTINUE on a non-shared VMA, or (2) UFFDIO_COPY * with wp flag set, don't set pte write bit. */ - _dst_pte = make_huge_pte(dst_vma, &folio->page, + _dst_pte = make_huge_pte(dst_vma, folio, !wp_enabled && !(is_continue && !vm_shared)); /* * Always mark UFFDIO_COPY page dirty; note that this may not be From patchwork Wed Apr 2 18:17:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 14036359 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 9C943C28B20 for ; Wed, 2 Apr 2025 18:17:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E62EF28000D; Wed, 2 Apr 2025 14:17:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DC310280006; Wed, 2 Apr 2025 14:17:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C183428000D; Wed, 2 Apr 2025 14:17:32 -0400 (EDT) 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 9E6C7280006 for ; Wed, 2 Apr 2025 14:17:32 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id ABF331A0622 for ; Wed, 2 Apr 2025 18:17:32 +0000 (UTC) X-FDA: 83289911544.24.A560936 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf15.hostedemail.com (Postfix) with ESMTP id 0C5CAA0011 for ; Wed, 2 Apr 2025 18:17:30 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=N5iTz+gB; dmarc=none; spf=none (imf15.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743617851; a=rsa-sha256; cv=none; b=bAA+0NFOjnZr/ELMj7Qo7D88uE8QnQ1R55ikKMDRMZTKkBb7RXtaVJ8CKGBqixQLtN1GWq d3Q7ZwAT0KYSbgs+sFX3g8UcgaDQnM3a/UWbiuIFZH8pkpiJZ/IAjA2+d7wFGaRNdClmbA kodI37K1PLOyA6ow4/b8l6yqBU7An1w= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=N5iTz+gB; dmarc=none; spf=none (imf15.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743617851; 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=ryaa6rOT3ubAlWnemzdFbAbwh8PCgJz1kds6GBMukSk=; b=5ryb9+BT18WUmOf9PFrD9Y9gnZ0+cCOg7iZwyQ5VgnwTgnj2jyKr2ZnBYQKadx/Z2Vf0LC nQpi168WMSNRBe/duNuEjgzY/nvmwcRnip24e//1MEwgsWAhtg36doS3UALlBCE47EIDER OhEx7EGiJC7m3vnVwA+/4h5tf5zgE5o= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=ryaa6rOT3ubAlWnemzdFbAbwh8PCgJz1kds6GBMukSk=; b=N5iTz+gBXug4FAnm6+9WRrVDV5 N5OwVI3QLw6iDzLQfZCZcslVW62ZuycySPvBm3xIBto/uwwBx2OhcddV5uJhSMI97jW/ZXpoFqX+X VhIZc2A+9E1BWxZu/xIz+KKIdhF+oIqDPteqhpNml00kdtNM4paJfX5OjpT6Bxl12ocBS2sB8Maan tiX4bMbTvDEHfx4UysgRjKNgz45cXpVG6NG3nFlzYZbO8L6FNOJIAWtl5btGM0s5mfYpLyc7vUoi8 0B1K0CNi/pLXeBxMKLXOTZ9Uq4FUZPzmHQxkp76p+HEkeyjC8ZwYtsp+tLgP3x/YoQYk/ou8RpykR hA2Yk0Mg==; Received: from willy by casper.infradead.org with local (Exim 4.98.1 #2 (Red Hat Linux)) id 1u02eF-0000000A0ik-347A; Wed, 02 Apr 2025 18:17:11 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-arch@vger.kernel.org Subject: [PATCH v2 09/11] mm: Remove mk_huge_pte() Date: Wed, 2 Apr 2025 19:17:03 +0100 Message-ID: <20250402181709.2386022-10-willy@infradead.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402181709.2386022-1-willy@infradead.org> References: <20250402181709.2386022-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 0C5CAA0011 X-Stat-Signature: ph579jxz4qdjfa8hxkn968mzwuccek1m X-HE-Tag: 1743617850-636878 X-HE-Meta: U2FsdGVkX1/h6+JoIL4v82U/HUO/irkJUfUjGC5j8Lgw8KGYjfr/hgFE4Bu4t152P9IiEr7oY84u7LZH15o5ael/qL58P9neudcxtxf2WrpRkxLTMTgRfyGB6CvXLtdv/3bsmzOQgKjSEmdvb+Xd2R8wxnabKme+RbL/wywCq/PDLE9IOQnAv1v5Frerw+uJTTClY74CMC/7B0uKfWZEoPsITiLE2e+wKfeeDDF/Z8TJWn2I9qyPMDnyZR96zCkQttpyTx42mbRuT9VGUPjV5ibVaDQaRZfgPFEsaOdNqfWCIRwKeO1flcmdNbTmTZzF2IqmWmUR+lpXcgE6VkIYfG1J6+Bd5rqxQucjz/GUvscG6iP6c5CShCwndXlzSa5h5gzT5BvZrXMh/pSzxHnWY1yHPz18D4o2r/ACzByl58WZ9v5slwaFSBp4wfMvWCfejywyvgjLsXf3Zum2rPaGsQzilNo+Uj/MagyYNHzQFHZkKUWjKM6nyAcESW0lxiWBs+fuBzXY0jZogpE4xB/5a5PFDRn6CKfbpDVUKEsgA2ud/+OLPjddCnDTv4TNnk7hGQH5JRQ/6IRB2e5rMM8QphVo1ynvJ9g67mvjaKLqU/rohRE67xJ7GKMY5zQ4l20PdnLctBrXBkb9Bai4YU/1dUMto951GXrZ3tvJ97ri9HKXvNAnC0kEcRLan3Y5/rFqBNsZlrvZEgH2Nl4H28mTBCbQoAZLTj7b/fqPcsLZD92NqHPSrcf5u2LIwUVfy4bFGpzjx/AVAooQCy61LCI6DdbaTo3Wnh4RQIa8K5iCDaqHq2CUWL2f15DLhzVXD+080OgcAT7wSABmkblI68OjEK6WyDDcFqutn504lYJpWmVP9aIASBgXcFw1BHlPUAdNoCwj7xU2Bro+FGEXt364xWt5pz707oyxhPw65d40kIGnHdDmFm5g0oMOeqQobPgxySAakg+u/tclUqjji96 AQGG+3ZW 2uFn9gOcYyFY2wPoK2iuYzIS+LQrj/wN0Go2fYwUC2EFL8P70HR3FhO6W6pMZrrgkV9EuCyXtA4WWuW7mk/DEHw4N8pF3XDI5DFiKxFxJ5vcBH72Xu2K1UefJs6B1SPwjD0Kk1TwCqfpxioXHTVSZenWyWrsvWBCnFwVLtByqOPS+ByZPjc91rfuZ9MX0drvZfOxVElQTBQ8nc6AadEnek0uLD9EJQJObmegY6zOb2mHEZCjVdJt2XL3LqJ5PIh+KZLFGISQ/C2NB6kJqv5oZ/0oBYhfcrGeaVuAk 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: The only remaining user of mk_huge_pte() is the debug code, so remove the API and replace its use with pfn_pte() which lets us remove the conversion to a page first. We should always call arch_make_huge_pte() to turn this PTE into a huge PTE before operating on it with huge_pte_mkdirty() etc. Signed-off-by: Matthew Wilcox (Oracle) --- include/asm-generic/hugetlb.h | 5 ----- mm/debug_vm_pgtable.c | 18 +++++------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/include/asm-generic/hugetlb.h b/include/asm-generic/hugetlb.h index 2afc95bf1655..3e0a8fe9b108 100644 --- a/include/asm-generic/hugetlb.h +++ b/include/asm-generic/hugetlb.h @@ -5,11 +5,6 @@ #include #include -static inline pte_t mk_huge_pte(struct page *page, pgprot_t pgprot) -{ - return mk_pte(page, pgprot); -} - static inline unsigned long huge_pte_write(pte_t pte) { return pte_write(pte); diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c index bc748f700a9e..7731b238b534 100644 --- a/mm/debug_vm_pgtable.c +++ b/mm/debug_vm_pgtable.c @@ -910,26 +910,18 @@ static void __init swap_migration_tests(struct pgtable_debug_args *args) #ifdef CONFIG_HUGETLB_PAGE static void __init hugetlb_basic_tests(struct pgtable_debug_args *args) { - struct page *page; pte_t pte; pr_debug("Validating HugeTLB basic\n"); - /* - * Accessing the page associated with the pfn is safe here, - * as it was previously derived from a real kernel symbol. - */ - page = pfn_to_page(args->fixed_pmd_pfn); - pte = mk_huge_pte(page, args->page_prot); + pte = pfn_pte(args->fixed_pmd_pfn, args->page_prot); + pte = arch_make_huge_pte(pte, PMD_SHIFT, VM_ACCESS_FLAGS); +#ifdef CONFIG_ARCH_WANT_GENERAL_HUGETLB + WARN_ON(!pte_huge(pte)); +#endif WARN_ON(!huge_pte_dirty(huge_pte_mkdirty(pte))); WARN_ON(!huge_pte_write(huge_pte_mkwrite(huge_pte_wrprotect(pte)))); WARN_ON(huge_pte_write(huge_pte_wrprotect(huge_pte_mkwrite(pte)))); - -#ifdef CONFIG_ARCH_WANT_GENERAL_HUGETLB - pte = pfn_pte(args->fixed_pmd_pfn, args->page_prot); - - WARN_ON(!pte_huge(arch_make_huge_pte(pte, PMD_SHIFT, VM_ACCESS_FLAGS))); -#endif /* CONFIG_ARCH_WANT_GENERAL_HUGETLB */ } #else /* !CONFIG_HUGETLB_PAGE */ static void __init hugetlb_basic_tests(struct pgtable_debug_args *args) { } From patchwork Wed Apr 2 18:17:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 14036350 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 6B307C36017 for ; Wed, 2 Apr 2025 18:17:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6B871280001; Wed, 2 Apr 2025 14:17:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 61AB3280005; Wed, 2 Apr 2025 14:17:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4946A280001; Wed, 2 Apr 2025 14:17:15 -0400 (EDT) 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 29EA3280004 for ; Wed, 2 Apr 2025 14:17:15 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 12D8E805D5 for ; Wed, 2 Apr 2025 18:17:15 +0000 (UTC) X-FDA: 83289910830.04.F7F2FD8 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf04.hostedemail.com (Postfix) with ESMTP id 3D79540012 for ; Wed, 2 Apr 2025 18:17:13 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="QK/QZFk6"; spf=none (imf04.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743617833; 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=TC2yKBXkWKOZQx81epWNSMRYD1pOXcRjkX0E8HuUhGM=; b=rrurP736ey1w2nKJVxwcpJM6m3EaapQrxq5W0AQ2ymGV8SUn6r4rQqAjgC1o2XpysHFRNw L80muv7fp83f1JROwbmlAHkO3DicKVQ+knOSan1iwJfCZ9d06iAcWj+fKkN4HOed3wc2Gy aHnuWkUIIpOwWiVm2Iae565SCkDASZo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743617833; a=rsa-sha256; cv=none; b=n6wrVseDC6XTl6tFvZ8eaeObHy2Aam1iIz2VnejxFmEE0fN9LDV5egRBYGvKLANagIVmUM jrQ1b77xlRTBra+/k07qpdMfZ+dev8HF8JKutnoBvfnuxJkNFnBD5TL8ezJDxA2OJCxPnM 8e547XN8W3GsuU1UpsUl6n8ZA71/2uk= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="QK/QZFk6"; spf=none (imf04.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=TC2yKBXkWKOZQx81epWNSMRYD1pOXcRjkX0E8HuUhGM=; b=QK/QZFk6HxEr6OedWH+SCq4BWC bgbgLXIDTvHDcE4mAWxdsZWn78kp4SHX0M3bD7+s8eDNqnKMKO5c8uyStYSObxMBhON2fJz4VKIq+ fcALIGc2g6KEl/5xhUphfJ31WvZHmEjMUq5tc63OgbSUma9f6rR1pmL2QsgjQO6aV+6omgzNyWHAL 2aDQBoyu5ArtRlU7mUOijUNjVnLVWAK6jgCyPR/NoLA/e0g/ivZ/8FF1hcEoFShxCV6wZZZYRukBK dsCBmO1e3Tu73j6nVneBVMn3Sr/WepqmCco9qUpJX23E3Qn0VNg76LrvLW+Bq/snm2SQyAHzYIpd/ H8MHXklA==; Received: from willy by casper.infradead.org with local (Exim 4.98.1 #2 (Red Hat Linux)) id 1u02eF-0000000A0im-3XGI; Wed, 02 Apr 2025 18:17:11 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-arch@vger.kernel.org Subject: [PATCH v2 10/11] mm: Add folio_mk_pmd() Date: Wed, 2 Apr 2025 19:17:04 +0100 Message-ID: <20250402181709.2386022-11-willy@infradead.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402181709.2386022-1-willy@infradead.org> References: <20250402181709.2386022-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 3D79540012 X-Stat-Signature: xjgrix6hytd7rm5q43czawrykng69464 X-HE-Tag: 1743617833-214159 X-HE-Meta: U2FsdGVkX19+6Ipyu60rlvCbnsauISKW+lwiU0vhBmrn7Kj1HfxDLLOY00kFYn6eUlVVeHbLzAMKWcMrPlEE0Saz2ulsa9NtSgAfxiZ6yFG0Fxj4H+46bzqvsVcwqwrILk7N+aZmJqqceMX05HPO0jKjwvS1KRqfTvSUvT+gB4Yw5dfYoWuihkPB/CtP6KmqsJGAbONnwPeop2zYDqHlM7wLL0jFW9/1fyWTXW+ZK1TvnW8l+x+d067i58f8o0UkOkWNAeMhoin3c1Q9G4TQWh3n6PhkcpOYfZE4JWbIQat/LeMNpp924onMUulfU0jwQEJNUcIdTJd8dHDDra+JWueV9emTrbBaVGm7zRogmHAyGky5GtyyWE7lWDunnMzf8AE+4XH8Kzw/pPGrQAVVWjo3AKvYOGAUrUHOHiLDznSc7tL5vv61Fyz4XHdBBn0kvKJJzw+YvEn2cp2COQ6gzEQGaqD1hF8Mty0E8NRkxVMUCPIopghW0jTJS8PrWn/VWpaF2FdkqAp+07Ze3XrGHEqTdU6yd3fhZC2GxF4FdCv4mM7jlkmEbjB7lNNNt0EtWSlw34O91V/bzLJVexQihqTAsedM17C/YGi6ttjVbrJo+YjLuuGbxAx2MOWR5xyfQPUNoOBZJvwvniz37lAQxEKJ29+6D/LMZaB6UnuzWKieHkpF5vFmlfas2LQKM/LWn7m8Qve7LJ4f2uw4jpeL5vgmch7Yl0tdZZgDXT5wFsvVcoN+Eh+/devPFGKVcu/jJ02D4rqvofMlRj8fqBPgYGjKeFqpYzTkRUqYSZ/7F4O7I7kmUJZDwdVAFLxvH5jfRlUs0t6MQd70/LPrj/y1/1zLxD3qCDMCXoq4pQ67FQ/8kOJicjgVFOeREQbGnxh/Fs3URC1iyThtPMEoaiFa6qA4vLeeQBjWj087gXglCRcnDgxJM8Z4gOAjfF+/I2BRSwuJ84VfZTpnI/OmHQf JWVxCP39 UbXGDMUzotvfXUyvqEyC+fO5w/yxajzw/ZoqH6nra3qpAh53Rixdlu1FmW+y6ZzbvzKR/Pxu18iYB323m/1sBvDOPYxau13jz3XbeOMAYv/vwEjL+vG0zP/GENjddigO8LETMVI3wMw1Jc77j1xwfthzsXkeaKWONQDAGppMzX3L/ODJ8xSbM6qmZjRtppAYSXZ+qgKx+l2LWbTHWCM/4J8tWEJ0uJshiQJnd7geYwkhybjqXtX/sOnfCMZILySM2I+z5FfkbcanUTt+9tbttEj/IYNlnv/kpMRSQ 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: Removes five conversions from folio to page. Also removes both callers of mk_pmd() that aren't part of mk_huge_pmd(), getting us a step closer to removing the confusion between mk_pmd(), mk_huge_pmd() and pmd_mkhuge(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/dax.c | 3 +-- include/linux/mm.h | 17 +++++++++++++++++ mm/huge_memory.c | 11 +++++------ mm/khugepaged.c | 2 +- mm/memory.c | 2 +- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index af5045b0f476..564e44a31e40 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -1421,8 +1421,7 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf, pgtable_trans_huge_deposit(vma->vm_mm, vmf->pmd, pgtable); mm_inc_nr_ptes(vma->vm_mm); } - pmd_entry = mk_pmd(&zero_folio->page, vmf->vma->vm_page_prot); - pmd_entry = pmd_mkhuge(pmd_entry); + pmd_entry = folio_mk_pmd(zero_folio, vmf->vma->vm_page_prot); set_pmd_at(vmf->vma->vm_mm, pmd_addr, vmf->pmd, pmd_entry); spin_unlock(ptl); trace_dax_pmd_load_hole(inode, vmf, zero_folio, *entry); diff --git a/include/linux/mm.h b/include/linux/mm.h index d657815305f7..d910b6ffcbed 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2007,7 +2007,24 @@ static inline pte_t folio_mk_pte(struct folio *folio, pgprot_t pgprot) { return pfn_pte(folio_pfn(folio), pgprot); } + +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +/** + * folio_mk_pmd - Create a PMD for this folio + * @folio: The folio to create a PMD for + * @pgprot: The page protection bits to use + * + * Create a page table entry for the first page of this folio. + * This is suitable for passing to set_pmd_at(). + * + * Return: A page table entry suitable for mapping this folio. + */ +static inline pmd_t folio_mk_pmd(struct folio *folio, pgprot_t pgprot) +{ + return pmd_mkhuge(pfn_pmd(folio_pfn(folio), pgprot)); +} #endif +#endif /* CONFIG_MMU */ static inline bool folio_has_pincount(const struct folio *folio) { diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 2a47682d1ab7..28c87e0e036f 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1203,7 +1203,7 @@ static void map_anon_folio_pmd(struct folio *folio, pmd_t *pmd, { pmd_t entry; - entry = mk_huge_pmd(&folio->page, vma->vm_page_prot); + entry = folio_mk_pmd(folio, vma->vm_page_prot); entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma); folio_add_new_anon_rmap(folio, vma, haddr, RMAP_EXCLUSIVE); folio_add_lru_vma(folio, vma); @@ -1309,8 +1309,7 @@ static void set_huge_zero_folio(pgtable_t pgtable, struct mm_struct *mm, struct folio *zero_folio) { pmd_t entry; - entry = mk_pmd(&zero_folio->page, vma->vm_page_prot); - entry = pmd_mkhuge(entry); + entry = folio_mk_pmd(zero_folio, vma->vm_page_prot); pgtable_trans_huge_deposit(mm, pmd, pgtable); set_pmd_at(mm, haddr, pmd, entry); mm_inc_nr_ptes(mm); @@ -2653,12 +2652,12 @@ int move_pages_huge_pmd(struct mm_struct *mm, pmd_t *dst_pmd, pmd_t *src_pmd, pm folio_move_anon_rmap(src_folio, dst_vma); src_folio->index = linear_page_index(dst_vma, dst_addr); - _dst_pmd = mk_huge_pmd(&src_folio->page, dst_vma->vm_page_prot); + _dst_pmd = folio_mk_pmd(src_folio, dst_vma->vm_page_prot); /* Follow mremap() behavior and treat the entry dirty after the move */ _dst_pmd = pmd_mkwrite(pmd_mkdirty(_dst_pmd), dst_vma); } else { src_pmdval = pmdp_huge_clear_flush(src_vma, src_addr, src_pmd); - _dst_pmd = mk_huge_pmd(src_page, dst_vma->vm_page_prot); + _dst_pmd = folio_mk_pmd(src_folio, dst_vma->vm_page_prot); } set_pmd_at(mm, dst_addr, dst_pmd, _dst_pmd); @@ -4675,7 +4674,7 @@ void remove_migration_pmd(struct page_vma_mapped_walk *pvmw, struct page *new) entry = pmd_to_swp_entry(*pvmw->pmd); folio_get(folio); - pmde = mk_huge_pmd(new, READ_ONCE(vma->vm_page_prot)); + pmde = folio_mk_pmd(folio, READ_ONCE(vma->vm_page_prot)); if (pmd_swp_soft_dirty(*pvmw->pmd)) pmde = pmd_mksoft_dirty(pmde); if (is_writable_migration_entry(entry)) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index cc945c6ab3bd..b8838ba8207a 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1239,7 +1239,7 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, __folio_mark_uptodate(folio); pgtable = pmd_pgtable(_pmd); - _pmd = mk_huge_pmd(&folio->page, vma->vm_page_prot); + _pmd = folio_mk_pmd(folio, vma->vm_page_prot); _pmd = maybe_pmd_mkwrite(pmd_mkdirty(_pmd), vma); spin_lock(pmd_ptl); diff --git a/mm/memory.c b/mm/memory.c index fc4d8152a2e4..e6e7abb83c0b 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5188,7 +5188,7 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page) flush_icache_pages(vma, page, HPAGE_PMD_NR); - entry = mk_huge_pmd(page, vma->vm_page_prot); + entry = folio_mk_pmd(folio, vma->vm_page_prot); if (write) entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma); From patchwork Wed Apr 2 18:17:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 14036353 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 04125C28B20 for ; Wed, 2 Apr 2025 18:17:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EB024280007; Wed, 2 Apr 2025 14:17:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E67DC280008; Wed, 2 Apr 2025 14:17:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB1F2280007; Wed, 2 Apr 2025 14:17:17 -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 ADD0B280006 for ; Wed, 2 Apr 2025 14:17:17 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id CB19EABD59 for ; Wed, 2 Apr 2025 18:17:17 +0000 (UTC) X-FDA: 83289910914.26.8B46AD4 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf22.hostedemail.com (Postfix) with ESMTP id 1FEC5C0005 for ; Wed, 2 Apr 2025 18:17:15 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=gV1P+IhD; spf=none (imf22.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743617836; 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=fS2PMscCelr2p4rUSdgC+67eZkZlHh1lrlPj3wtKD4Y=; b=7ayUk+dfZfqym963zP3eNQXpQlnVcUOxsU2BrtiQ/Xlo5UGkIQuazJN5Dj9Ocq8T+0GDzW y8tAMfRAOigp/kheL3gcOQWnW+KEJDZ//VgFii5s91ecWdAHu5snfVO9JBoX8n2CcDxFto xUAPWcG4qn4+KzO9uBQKgvxHyPQH5+o= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743617836; a=rsa-sha256; cv=none; b=VvdK+5x4CpRF3eFyt47vP/MoI7MgYFlVy6kbmCM8raX0DZMhH/hzni7aFQtNqGla4uzHAm lFLacYx6pl6e/9jarSsZmVsLU1GF7HgsyNmPYcw4iJlot6FGNTGjgZOUO0jpeynk1/jgq7 ftlAkpGOd9wx0QTsXQhCWKBkHsTLJKA= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=gV1P+IhD; spf=none (imf22.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=fS2PMscCelr2p4rUSdgC+67eZkZlHh1lrlPj3wtKD4Y=; b=gV1P+IhD2igi0rHiwQrOnFJAlD HQI7TMULlDe+cOeNwXlzjBIrYxSgl8Ahf4iVCacLjQtPUC+laBFiP99Uy1cGixasDU4yNFKwza+wh 1laD6OxYm2S0o6s3QTlUpKjyNptwqnWzbM3MeSzbyq9apucpNAjnVRb9lxDgncSpOe7eUvHMyeGGn xAcMPm1wYCIFDXtQQ863eOwMnw9xXzYw8kyrxaOcIYf3cIodu+8Tj8MtVnqF5H9VdXBhIwiloIf/k FNUEv2aywTqovWVVs+A92m/pTwBUe6nI5vGXc47EkjGJi0EnhodNE/T6qUZ2BMSOCDlkibczJkVBN +OFiKRnw==; Received: from willy by casper.infradead.org with local (Exim 4.98.1 #2 (Red Hat Linux)) id 1u02eF-0000000A0iw-3wUe; Wed, 02 Apr 2025 18:17:11 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, linux-arch@vger.kernel.org Subject: [PATCH v2 11/11] arch: Remove mk_pmd() Date: Wed, 2 Apr 2025 19:17:05 +0100 Message-ID: <20250402181709.2386022-12-willy@infradead.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250402181709.2386022-1-willy@infradead.org> References: <20250402181709.2386022-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 1FEC5C0005 X-Stat-Signature: 7wdgnt5hfkeu1hh5kikmg8iwrj98d7zw X-HE-Tag: 1743617835-74813 X-HE-Meta: U2FsdGVkX1/BokerNGrMRygsAPfcZ5bFFcoXWEMRI3KABnp2PBHIkOtOH6TfASLZ0JMkjTKBgj8lD5y+f2wBvChpeewmw4GowUCeBuT8Jib552PeDR9kzk0qL+D6f0/qR9od8A0nT7Gn8Wgljh+jDsfA0r/0zjBIpS16mBBkN7fkio//dN9rVYRIQelkMsoyh/3QIPNasHitDjYhbV7keTy8VYoNVZDDlYb+7wm9UusP7kBGkvwPPd47KdzLCl5kI+6kbHYhWTyY8+6knFRHH68s8CYxKlO0PWChhf7Qr5l2NDJwl6crZ4dngF+nukViWrJX/PUdNZSq5p8KbcrdiG53nXiDfE5z5MATrnpUpahx1KOmkLfcoJmf59xGZ6mqoPfHJuAC7EpqovqGKfFa9zavaZkWqJH1ctG622j7DI7MoRBYM7sRzSb1zOVj7Y8eNtKLN0ZZ6TziaEx9K2wdVMbp4GoDBH7cLSxFLxQIkaeI7U5t+/Kz8icLc7MAmw9kmXTGL4hvBrY0sgeGaXD0lDt1KdlaqJeHMqf4AyJkesXh/NE0jVl7hy5taHJNpFh7RqP76z2w/cwpMJhmkuM77XPXXlOkODdZRTVojHJUwkhnT1xkxl9E33BimudDXmhC7JWiCNURF0gGmWGkiueU3IahGKBPMCaCtth55e5UnBWVgp7M83qtt5tmTN1QgjJerhvDJGA7cwvNJMoEZjJtzT1fJnKgE52mvq2+NtIRqMYohaoWO8sqa1+p3emvQqkvsTXI9l0G1z2eoM3FPM1JZ0V5drt9Ftd2adHNx0Z8uKHbZ+liV/4M6rX1O8u0CmAOm6C/ctUvKwjD1WHmccq5hNs7IrLRpQ7fS2VLsD/GphqwL7wc0/XcBXeQXMyquN5xa7XoJMvr+wzmX33A6Malng9OrDLmww2ntsvDWenZscDuETRCRGDteBshPZm50jSXMIsdCuy4DqHTKcdBob1 nXl+opmN lgJ9rb4pNJKhu73JoCtnBOoXAFz8oBDYxOkTe+iXnGbC6d16qr2nsWf1b4W8Ret1uWV31l961k9h+2l/of0XjO/U80z5gn/taR0hvTZ9Yza6AweCwWh14V5RJxsyrUMV/36rbrsVvl9WOxXLispbwCwh+lpwXsnvq1VKknSx3Uma/PXx3SBpOJJq0sfhOS2dlIsHvyYMQnUuPizuuTF/Dp5yry6v0wb3xXP883O3mNUrKx6zBIgPRgJaEBRxCHTZxh+mo2e2sGBxL6uJ4gzpgiKvzud+340s31Lj1 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 are now no callers of mk_huge_pmd() and mk_pmd(). Remove them. Signed-off-by: Matthew Wilcox (Oracle) --- arch/arc/include/asm/hugepage.h | 2 -- arch/arc/include/asm/pgtable-levels.h | 1 - arch/arm/include/asm/pgtable-3level.h | 1 - arch/arm64/include/asm/pgtable.h | 1 - arch/loongarch/include/asm/pgtable.h | 1 - arch/loongarch/mm/pgtable.c | 9 --------- arch/mips/include/asm/pgtable.h | 3 --- arch/mips/mm/pgtable-32.c | 10 ---------- arch/mips/mm/pgtable-64.c | 9 --------- arch/powerpc/include/asm/book3s/64/pgtable.h | 1 - arch/powerpc/mm/book3s64/pgtable.c | 5 ----- arch/riscv/include/asm/pgtable-64.h | 2 -- arch/s390/include/asm/pgtable.h | 1 - arch/sparc/include/asm/pgtable_64.h | 1 - arch/x86/include/asm/pgtable.h | 2 -- include/linux/huge_mm.h | 2 -- 16 files changed, 51 deletions(-) diff --git a/arch/arc/include/asm/hugepage.h b/arch/arc/include/asm/hugepage.h index 8a2441670a8f..7765dc105d54 100644 --- a/arch/arc/include/asm/hugepage.h +++ b/arch/arc/include/asm/hugepage.h @@ -40,8 +40,6 @@ static inline pmd_t pte_pmd(pte_t pte) #define pmd_young(pmd) pte_young(pmd_pte(pmd)) #define pmd_dirty(pmd) pte_dirty(pmd_pte(pmd)) -#define mk_pmd(page, prot) pte_pmd(mk_pte(page, prot)) - #define pmd_trans_huge(pmd) (pmd_val(pmd) & _PAGE_HW_SZ) #define pfn_pmd(pfn, prot) (__pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))) diff --git a/arch/arc/include/asm/pgtable-levels.h b/arch/arc/include/asm/pgtable-levels.h index 55dbd2719e35..d1ce4b0f1071 100644 --- a/arch/arc/include/asm/pgtable-levels.h +++ b/arch/arc/include/asm/pgtable-levels.h @@ -142,7 +142,6 @@ #define pmd_pfn(pmd) ((pmd_val(pmd) & PMD_MASK) >> PAGE_SHIFT) #define pfn_pmd(pfn,prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) -#define mk_pmd(page,prot) pfn_pmd(page_to_pfn(page),prot) #endif diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h index fa5939eb9864..7b71a3d414b7 100644 --- a/arch/arm/include/asm/pgtable-3level.h +++ b/arch/arm/include/asm/pgtable-3level.h @@ -209,7 +209,6 @@ PMD_BIT_FUNC(mkyoung, |= PMD_SECT_AF); #define pmd_pfn(pmd) (((pmd_val(pmd) & PMD_MASK) & PHYS_MASK) >> PAGE_SHIFT) #define pfn_pmd(pfn,prot) (__pmd(((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot))) -#define mk_pmd(page,prot) pfn_pmd(page_to_pfn(page),prot) /* No hardware dirty/accessed bits -- generic_pmdp_establish() fits */ #define pmdp_establish generic_pmdp_establish diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 53832ec0561f..379fcc6a1295 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -609,7 +609,6 @@ static inline pmd_t pmd_mkspecial(pmd_t pmd) #define __phys_to_pmd_val(phys) __phys_to_pte_val(phys) #define pmd_pfn(pmd) ((__pmd_to_phys(pmd) & PMD_MASK) >> PAGE_SHIFT) #define pfn_pmd(pfn,prot) __pmd(__phys_to_pmd_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot)) -#define mk_pmd(page,prot) pfn_pmd(page_to_pfn(page),prot) #define pud_young(pud) pte_young(pud_pte(pud)) #define pud_mkyoung(pud) pte_pud(pte_mkyoung(pud_pte(pud))) diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h index 9ba3a4ebcd98..a3f17914dbab 100644 --- a/arch/loongarch/include/asm/pgtable.h +++ b/arch/loongarch/include/asm/pgtable.h @@ -255,7 +255,6 @@ static inline void pmd_clear(pmd_t *pmdp) #define pmd_page_vaddr(pmd) pmd_val(pmd) -extern pmd_t mk_pmd(struct page *page, pgprot_t prot); extern void set_pmd_at(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp, pmd_t pmd); #define pte_page(x) pfn_to_page(pte_pfn(x)) diff --git a/arch/loongarch/mm/pgtable.c b/arch/loongarch/mm/pgtable.c index 22a94bb3e6e8..352d9b2e02ab 100644 --- a/arch/loongarch/mm/pgtable.c +++ b/arch/loongarch/mm/pgtable.c @@ -135,15 +135,6 @@ void kernel_pte_init(void *addr) } while (p != end); } -pmd_t mk_pmd(struct page *page, pgprot_t prot) -{ - pmd_t pmd; - - pmd_val(pmd) = (page_to_pfn(page) << PFN_PTE_SHIFT) | pgprot_val(prot); - - return pmd; -} - void set_pmd_at(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp, pmd_t pmd) { diff --git a/arch/mips/include/asm/pgtable.h b/arch/mips/include/asm/pgtable.h index d69cfa5a8ac6..4852b005a72d 100644 --- a/arch/mips/include/asm/pgtable.h +++ b/arch/mips/include/asm/pgtable.h @@ -713,9 +713,6 @@ static inline pmd_t pmd_clear_soft_dirty(pmd_t pmd) #endif /* CONFIG_HAVE_ARCH_SOFT_DIRTY */ -/* Extern to avoid header file madness */ -extern pmd_t mk_pmd(struct page *page, pgprot_t prot); - static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot) { pmd_val(pmd) = (pmd_val(pmd) & (_PAGE_CHG_MASK | _PAGE_HUGE)) | diff --git a/arch/mips/mm/pgtable-32.c b/arch/mips/mm/pgtable-32.c index 84dd5136d53a..e2cf2166d5cb 100644 --- a/arch/mips/mm/pgtable-32.c +++ b/arch/mips/mm/pgtable-32.c @@ -31,16 +31,6 @@ void pgd_init(void *addr) } #if defined(CONFIG_TRANSPARENT_HUGEPAGE) -pmd_t mk_pmd(struct page *page, pgprot_t prot) -{ - pmd_t pmd; - - pmd_val(pmd) = (page_to_pfn(page) << PFN_PTE_SHIFT) | pgprot_val(prot); - - return pmd; -} - - void set_pmd_at(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp, pmd_t pmd) { diff --git a/arch/mips/mm/pgtable-64.c b/arch/mips/mm/pgtable-64.c index 1e544827dea9..b24f865de357 100644 --- a/arch/mips/mm/pgtable-64.c +++ b/arch/mips/mm/pgtable-64.c @@ -90,15 +90,6 @@ void pud_init(void *addr) #endif #ifdef CONFIG_TRANSPARENT_HUGEPAGE -pmd_t mk_pmd(struct page *page, pgprot_t prot) -{ - pmd_t pmd; - - pmd_val(pmd) = (page_to_pfn(page) << PFN_PTE_SHIFT) | pgprot_val(prot); - - return pmd; -} - void set_pmd_at(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp, pmd_t pmd) { diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index 6d98e6f08d4d..6ed93e290c2f 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -1096,7 +1096,6 @@ static inline bool pmd_access_permitted(pmd_t pmd, bool write) #ifdef CONFIG_TRANSPARENT_HUGEPAGE extern pmd_t pfn_pmd(unsigned long pfn, pgprot_t pgprot); extern pud_t pfn_pud(unsigned long pfn, pgprot_t pgprot); -extern pmd_t mk_pmd(struct page *page, pgprot_t pgprot); extern pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot); extern pud_t pud_modify(pud_t pud, pgprot_t newprot); extern void set_pmd_at(struct mm_struct *mm, unsigned long addr, diff --git a/arch/powerpc/mm/book3s64/pgtable.c b/arch/powerpc/mm/book3s64/pgtable.c index c0c45d033cba..2c88532ed7fb 100644 --- a/arch/powerpc/mm/book3s64/pgtable.c +++ b/arch/powerpc/mm/book3s64/pgtable.c @@ -270,11 +270,6 @@ pud_t pfn_pud(unsigned long pfn, pgprot_t pgprot) return __pud_mkhuge(pud_set_protbits(__pud(pudv), pgprot)); } -pmd_t mk_pmd(struct page *page, pgprot_t pgprot) -{ - return pfn_pmd(page_to_pfn(page), pgprot); -} - pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot) { unsigned long pmdv; diff --git a/arch/riscv/include/asm/pgtable-64.h b/arch/riscv/include/asm/pgtable-64.h index 0897dd99ab8d..188fadc1c21f 100644 --- a/arch/riscv/include/asm/pgtable-64.h +++ b/arch/riscv/include/asm/pgtable-64.h @@ -262,8 +262,6 @@ static inline unsigned long _pmd_pfn(pmd_t pmd) return __page_val_to_pfn(pmd_val(pmd)); } -#define mk_pmd(page, prot) pfn_pmd(page_to_pfn(page), prot) - #define pmd_ERROR(e) \ pr_err("%s:%d: bad pmd %016lx.\n", __FILE__, __LINE__, pmd_val(e)) diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h index 3ef5d2198480..1c661ac62ce8 100644 --- a/arch/s390/include/asm/pgtable.h +++ b/arch/s390/include/asm/pgtable.h @@ -1869,7 +1869,6 @@ static inline pmd_t pmdp_collapse_flush(struct vm_area_struct *vma, #define pmdp_collapse_flush pmdp_collapse_flush #define pfn_pmd(pfn, pgprot) mk_pmd_phys(((pfn) << PAGE_SHIFT), (pgprot)) -#define mk_pmd(page, pgprot) pfn_pmd(page_to_pfn(page), (pgprot)) static inline int pmd_trans_huge(pmd_t pmd) { diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h index d9c903576084..4af03e3c161b 100644 --- a/arch/sparc/include/asm/pgtable_64.h +++ b/arch/sparc/include/asm/pgtable_64.h @@ -233,7 +233,6 @@ static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot) return __pmd(pte_val(pte)); } -#define mk_pmd(page, pgprot) pfn_pmd(page_to_pfn(page), (pgprot)) #endif /* This one can be done with two shifts. */ diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h index 2ce98b547a25..3f59d7a16010 100644 --- a/arch/x86/include/asm/pgtable.h +++ b/arch/x86/include/asm/pgtable.h @@ -1347,8 +1347,6 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, #define flush_tlb_fix_spurious_fault(vma, address, ptep) do { } while (0) -#define mk_pmd(page, pgprot) pfn_pmd(page_to_pfn(page), (pgprot)) - #define __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS extern int pmdp_set_access_flags(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp, diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index e893d546a49f..f190998b2ebd 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -495,8 +495,6 @@ static inline bool is_huge_zero_pmd(pmd_t pmd) struct folio *mm_get_huge_zero_folio(struct mm_struct *mm); void mm_put_huge_zero_folio(struct mm_struct *mm); -#define mk_huge_pmd(page, prot) pmd_mkhuge(mk_pmd(page, prot)) - static inline bool thp_migration_supported(void) { return IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION);