From patchwork Tue Mar 26 17:10:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13604744 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 026FBC54E67 for ; Tue, 26 Mar 2024 17:11:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 458FC6B00A0; Tue, 26 Mar 2024 13:10:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BA5E6B00A1; Tue, 26 Mar 2024 13:10:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20CD86B00A2; Tue, 26 Mar 2024 13:10:55 -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 0AF856B00A0 for ; Tue, 26 Mar 2024 13:10:55 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D8895C0D77 for ; Tue, 26 Mar 2024 17:10:54 +0000 (UTC) X-FDA: 81939830028.26.806BCC7 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf15.hostedemail.com (Postfix) with ESMTP id 287E4A0008 for ; Tue, 26 Mar 2024 17:10:52 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Nv4zpwsI; 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=1711473053; 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=FjUWHQrn4FbgqZDhW3tfi340RZXU1+nbifFSALnT85s=; b=FkEwZ+bbZQ/WAguhIsdRSsiXssqh98q7HaFridQ0e9m5pN7/tpbl6SfsLEw1A935WbcY38 KVdgImBtr1CMnKfyBFckZH1wULbyERTP97hrBXzKAJV+n81hk1ZUZ0u0p/DC+Y2GPXs9d6 rkkGL405ciwkDcm6w9kbFfZYKjA33ps= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Nv4zpwsI; 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=1711473053; a=rsa-sha256; cv=none; b=S5iCLwmmed3xXHG+ZandkUXnDkqnr+K4qLPT+7w3s0TtHJ72GZ53SqPcrC9M3z2sgnWMWN wsO/3rDoYELPrwRsLTNACz+0uhX3LxRqDU1A9wOP/U+YtTOWt/vFhS0X5HO9ZXpuOA+nZG eH6kvzYMCnk60noh4dZS3rViBzD0JFE= 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=FjUWHQrn4FbgqZDhW3tfi340RZXU1+nbifFSALnT85s=; b=Nv4zpwsISRfvdUvqCXOaT2bEqG MNZxrIICQ6CVMZFFRajePmkRTL1loEtrFYnnNC4nH0PgeiVzl9VpNkRRevyZnkaVF4zqbsobHk3ho wOimlW1AAcXLTs7sGhhUZ8mJhh3xaZ31NV2uUISBGv/NDm33w4mTYC+iJzAVV2tSxdwx29krKmKQn Eg0KpAyWG39G74oRQXEI3SOkx9H+JPlOloxqvnlE3UUweyyms4ik+hAesK0EBuM5fM5ZmUefryZUB 6w26KxX+Sj22qnODxCdbWR1zgdrFd7U7+/L5ufLQBfKZR9fpwk7EsAKbFmmp85ysfBqBZFoSEz8ww p8gkV+zg==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpAJz-00000001irz-3RMM; Tue, 26 Mar 2024 17:10:47 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 01/10] sh: Remove use of PG_arch_1 on individual pages Date: Tue, 26 Mar 2024 17:10:23 +0000 Message-ID: <20240326171045.410737-2-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240326171045.410737-1-willy@infradead.org> References: <20240326171045.410737-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 287E4A0008 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: jm8gknsa3ykshmo766tx3kj83hxrrud7 X-HE-Tag: 1711473052-70041 X-HE-Meta: U2FsdGVkX1/eHwgdkiB6WzfWwCUzgYbaKLUwnrV2BP3B860T5gYON2w7N1TpCAVnYJG7b0XruJadfOe2i259QWlcpkZpbPBuOTT1jpRkIFR1eKfZ9kDZAbQqepFl9eRZoJLYA40lPYfQAe7E+kP0zKRgIXNMy/fcZQE2mupWPGT86YGdhIN/Qom/L58r4BQWJHhwkgYLqqX9EMTXI3uyPXl1Oe6R7rFHAub9MZOi+ZDT+NmkXpEFzqGQ1ect+zSdKp/eeT3sBs9/iUt4q9WZ9oVTAJFp0T+1cVD4bib9PlKJ7PoqiTQmFL2wNuUAIIOCpUlEsE/VLqWca0mM0vsOi3wWKEIm/mh37mfAq2HO/I4F/a9uuBJNC9kYWS9MEkrdh04UiAwfN6ROEDGKbsireg9r2de4RSnwNBwqWxtkCxzIKPpy4paBIZVdP9h6HtflqPPdfkpley/MrnClLDNoTew+zJp6t7XMsVzcaruRXiHyB/ki6MCb6fs3rdknFP1LUCWasLs8k5FFaPzG3LiJc9Ov2ZLnhzG93r4odq26I7OX5q6mgBmJK9ao9/CvOYcrbs5otDfUMvG26509e7/jiwwkd0pKU6Pq3WaPBEtK186d0pEafsIcE/lhxyIlYmiMueFJF+XICNiah8p3b5jEAN/kXNbqfYdzWBNHfrD43iHCSLtqcjYWIF+bRgpYwr8B8uzNSzWX80+AqwUYdEN9yf9xd0rY16Sb7fHyoqrnpiz+9iP/QUqcImPG+y+dBVS9It2cbGYe1tTSOppu4MX2XBCkSZ+FyKJQ7cFMb0yqdafi4vT3VmLjlA+dAdO9rLzFPazXS1P+NRyiwpMoORRscaCnsNXpNlOxMQvPZZTzKongC47NO87OC5eiijF0FVYI+NlT+edoRxhsMsb4F6l1/+sXTzZihXDjQKIQXJkprLjaTOph3615xvlMztyvyRh9D6KRop7jZvisvVrwrrH ZkLMgoZO HyXWP04YxcBPEJEXodf+DpaDoqY3IHsxy/blOj1w5x8rDjLnxtCygOazzEeANnEHF1Fi+7EEMtIoXf3QGMR4QQW615yZ5f7lFLfu8goJMclB7Yjqy6flWLp/2VM7aFe/XJcyI6pFBVnO0hTzWsYnA9EYsw7b47KDOFkSR0ZtWHGKRAvi1cFUH5RN2gpjFZfFrp8aP4VqYcOBQKJMe6Ql5i2h69Prbcs8aRuij X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Since switching to the new page table range API, we do not set the PG_arch_1 (aka dcache clean) flag on tail pages, only on the folio. Test it on the folio. Also use page_mapped() instead of page_mapcount() as it is more efficient. Signed-off-by: Matthew Wilcox (Oracle) --- arch/sh/mm/cache-sh4.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/sh/mm/cache-sh4.c b/arch/sh/mm/cache-sh4.c index 862046f26981..cea8f1693908 100644 --- a/arch/sh/mm/cache-sh4.c +++ b/arch/sh/mm/cache-sh4.c @@ -241,13 +241,14 @@ static void sh4_flush_cache_page(void *args) if ((vma->vm_mm == current->active_mm)) vaddr = NULL; else { + struct folio *folio = page_folio(page); /* * Use kmap_coherent or kmap_atomic to do flushes for * another ASID than the current one. */ map_coherent = (current_cpu_data.dcache.n_aliases && - test_bit(PG_dcache_clean, &page->flags) && - page_mapcount(page)); + test_bit(PG_dcache_clean, folio_flags(folio)) && + page_mapped(page)); if (map_coherent) vaddr = kmap_coherent(page, address); else From patchwork Tue Mar 26 17:10:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13604741 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 CFDF5C6FD1F for ; Tue, 26 Mar 2024 17:10:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C8336B009B; Tue, 26 Mar 2024 13:10:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 345106B009E; Tue, 26 Mar 2024 13:10:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20ED96B00A1; Tue, 26 Mar 2024 13:10:54 -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 0A44A6B009E for ; Tue, 26 Mar 2024 13:10:54 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E01DF1A0CB2 for ; Tue, 26 Mar 2024 17:10:53 +0000 (UTC) X-FDA: 81939829986.26.3FC3B50 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id 3188016000C for ; Tue, 26 Mar 2024 17:10:51 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=jhVmfrdL; 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=1711473052; a=rsa-sha256; cv=none; b=uR3TeLuw6T9Xjsj96Sj/3m+sTNN8aaMyClBDWqo89VGv31zTI6X/a02NqxNW3ZKqrTkuXJ zu8v2lQXMtZyn81Jfd0ktIiZ+SJVK9V0gUW2q7dzBgqXmCwCTqdObGm2SOI+7D3UyjhzS7 p8cs4WLQti+OIMpVdiNsb9LdOoglqgI= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=jhVmfrdL; 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=1711473052; 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=eh+y/Gz3jtyBErmulO4A9pG+bQi4rxb/s4S22X7OGTQ=; b=klyv6rl6aloXjCbvMv6W5ZWbzUcW10/xNwEyIB0Be+ZdKkxzu6RIkdrDgp71Ki8lwa2dcb TgggZGgFaadYDu/ex3mSpmYecAzMlHZK3bZzE5hp/qnKwfaX6qzsDLwxxN7xAVQuOLx1by J4Ba+HaDswrmS8SK31l1pqCNKl5IQ9g= 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=eh+y/Gz3jtyBErmulO4A9pG+bQi4rxb/s4S22X7OGTQ=; b=jhVmfrdL7c+z5L40IDU0Uwc4IV acR5z9GRmHu73ObY3ewFem+eB5Xnabb11CghpJOagk+YWZJFQH5we8sQTM0LDuZivmDycqwyC+3aS +obiHMxYCyeHqJeL0BK6QNDPADlseeyVzgDlEdyxIYgUOq/Jm5myBO5ckemclAFcaQpj1bm2Nqqpp cOBDbZ7bmYef8Y/hnivD0pb4yRoXxbLDvMhP76CxqZIpWgpB/RcGv/3frbDSVrEiCsrSLBjBUWzHD LNjNRj0KEiCtsdOD2Ud+ZxZfm0EE4VHERJKzaJJrEkUWu6SM0if9wPYdJwYc1f/ULvTHol5RJv8bH 7t+w7TDA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpAJz-00000001is1-3n3U; Tue, 26 Mar 2024 17:10:47 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Svetly Todorov Subject: [PATCH 02/10] xtensa: Remove uses of PG_arch_1 on individual pages Date: Tue, 26 Mar 2024 17:10:24 +0000 Message-ID: <20240326171045.410737-3-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240326171045.410737-1-willy@infradead.org> References: <20240326171045.410737-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 3188016000C X-Stat-Signature: i7i9pndm6xatff519iuyf89t9rokskm1 X-HE-Tag: 1711473051-945318 X-HE-Meta: U2FsdGVkX1/Z0F4/SjVocGTh9R5fXACOZW7I5tiLTngxbqnkvxA2UMis05s+mKaDqWhvQiu9QJApJxOk2eEdk8PRkOAs8SE5SmI9bZTNGkiIZdxJY+eM0EnIasEoPzjoTqQxNXBrpgh40nz7yEvb5km/cAWeALgcQA8uJHxI83xOhBRCrWiwZRtTIkka0veFA/BGJh8CdMF+ikYGMVaawtGvI0P+wu+t4WsiiV7pDizEqqkmARg7+d53IiuZTJGgHRAMcTmKl3HUmfj4WRmzTw4L5TywHBmrSnlmalfVeLMzZZdI2yOXHBl9+TEUX7YXCT+7qxB/5qIPVyHGCt3RnXBKO54jHrDJiydQWmjY+ZSSiHLSyX6uON1rXZtrvahcGAeGgWk0ZB0DIz3aPc5HBKFpcNnR+J55OmQn+dfZCu9f4Xx2NE9hfP7DJlruLVLtupj+sfXslnUcy272MJUTPAh0ssV8vB3Ynx4I3u3seMMVCkkgvMWSlZfIGWMn/Yc1R3wvz019qwW+aTwciL0KqBiwdgsJWiMufOkpYlOCaFzv01aBrGfjQ7hL9acdHzidv9YWof4GGhCv15Cfmb+ifsZ/zTJtwZ6ZCCKGW09K98ziQoICBtTvXSalwMwCTKHW/WnzBqc6GpBPYRL/07YMvkQ1olOcqwld7ogYrd3240z0a/iQsYp/u4sHU2+uHFc1T2COtIFpwhBPzHY1RXX2MI1kYAiUPKHgdmEA4DQyeOZq98zQKUvbvVT+4Oh31r7ZSJSKCcDNvsBWN2rGr1l8GQVEcfW9q9OGhZTWcBw4UlimlHB/xBPFuPhqEywhsgeGboCNYzptUZ3/rJa/BhKNOZmpXHAOXTk0aooRNDtjpa0fqiWvU9rJk2t79Gng/tAbevJCfvFHMFqX450YYG4xIQ5YsBdqGCJi3tzdN5nSSFeb1X2vFPmfDZ8+uGC9c/cf2rktBlTLTxhsZ2I9On8 bNveY9tU gN/WPhaSZCFEfyRRxTTitW2kg5wUG8xVYYy343EddR7kXn2NksDy2HZwwEqqu3A9FgaM3BMIZ3r90jTwTg+7v0Hxp4GywboSeVkJ/639SOSCzqZKUFMCmsYHjMQN+qsVNPigEt27AMKthRizeZCBwj4rXg1vb8CuZhCTYGvfH3JfUKgMIipZZH/43HFL2aAFk/0ACuEOpMr7x3jdgYU1IKZeJRKSbBy3OoB5IvRHpGd6+XNXL8aaLGtLd/DEV7yTzkCT9XYpyWxfksNa/Y0H32AZXsRJnUDVO8pyJ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Since switching to the new page table range API, we disregard the PG_arch_1 (aka dcache dirty) flag on tail pages, and only pay attention to it on the folio. Fix these two missed spots where we were setting it on arbitrary pages. Reported-by: Svetly Todorov Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Svetly Todorov --- arch/xtensa/mm/cache.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/xtensa/mm/cache.c b/arch/xtensa/mm/cache.c index 7ec66a79f472..23be0e7516ce 100644 --- a/arch/xtensa/mm/cache.c +++ b/arch/xtensa/mm/cache.c @@ -87,12 +87,13 @@ static inline void *coherent_kvaddr(struct page *page, unsigned long base, void clear_user_highpage(struct page *page, unsigned long vaddr) { + struct folio *folio = page_folio(page); unsigned long paddr; void *kvaddr = coherent_kvaddr(page, TLBTEMP_BASE_1, vaddr, &paddr); preempt_disable(); kmap_invalidate_coherent(page, vaddr); - set_bit(PG_arch_1, &page->flags); + set_bit(PG_arch_1, folio_flags(folio, 0)); clear_page_alias(kvaddr, paddr); preempt_enable(); } @@ -101,6 +102,7 @@ EXPORT_SYMBOL(clear_user_highpage); void copy_user_highpage(struct page *dst, struct page *src, unsigned long vaddr, struct vm_area_struct *vma) { + struct folio *folio = page_folio(dst); unsigned long dst_paddr, src_paddr; void *dst_vaddr = coherent_kvaddr(dst, TLBTEMP_BASE_1, vaddr, &dst_paddr); @@ -109,7 +111,7 @@ void copy_user_highpage(struct page *dst, struct page *src, preempt_disable(); kmap_invalidate_coherent(dst, vaddr); - set_bit(PG_arch_1, &dst->flags); + set_bit(PG_arch_1, folio_flags(folio, 0)); copy_page_alias(dst_vaddr, src_vaddr, dst_paddr, src_paddr); preempt_enable(); } From patchwork Tue Mar 26 17:10:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13604748 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 73671CD11DF for ; Tue, 26 Mar 2024 17:11:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E1C706B0087; Tue, 26 Mar 2024 13:11:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DCD136B0088; Tue, 26 Mar 2024 13:11:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C46016B0099; Tue, 26 Mar 2024 13:11:23 -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 B579C6B0087 for ; Tue, 26 Mar 2024 13:11:23 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 95941120E08 for ; Tue, 26 Mar 2024 17:11:23 +0000 (UTC) X-FDA: 81939831246.27.91D52F9 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf07.hostedemail.com (Postfix) with ESMTP id EA48A40005 for ; Tue, 26 Mar 2024 17:11:21 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=tkWgyz2o; dmarc=none; spf=none (imf07.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=1711473082; 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=0T1BzIrxwYy/rsmBWKCabOr0L5fd6baKhpuvPYzfXmM=; b=Y/Bx70CSnR65OSYe6njKTxCvdkswNkXsE1erUqFsUdYP1wb/2zpQXa1f7aFTH4+PvW+w9h u7Azf5k2eZ2dqmd/beaIffWGU0AMA9p/onZrBk04O3qYs5HFkf9pVYf6NDP0Zh/jA9+9zs eWKwjry1vWBdZuOHF+6L8QR/EeQ6Uhc= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=tkWgyz2o; dmarc=none; spf=none (imf07.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=1711473082; a=rsa-sha256; cv=none; b=Iu+FVJn6nqGjSz6X2kZ8IEQAyvahv36CvgeyxNeGOwM7Npny3tgCzJPd2nUe9TZ7vbSENU Yheg5qM/kxHywNxht3p1cOXn2xZxMBWyfKy6p0dqrLm0DCyjHBvyEn5I4N8GP8kYqqXz7+ B62r7o2q/E9+0ytFZ4a8O65+D8zegeo= 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=0T1BzIrxwYy/rsmBWKCabOr0L5fd6baKhpuvPYzfXmM=; b=tkWgyz2o0lAYHIR/c7OGHAgCqw wSdAEYzZauYcC/o+lMb0SNoE8IjO+kKW2e7l4HbYgWk+5+pJBrQz9fmT7wm4JdsI5yGijF691iHVW lJTg7xARfv6C0MudCiedSGwIvMb985SFjf2RmM/wOzuC+Ewopt/GKW7wpSAFHanAB8NBjy20pbd99 N16j241NZ94nyDZAydaWhLTx44rjW9HUy6oCP6a/+RbPspfomzAxMSEmzMMurTJq5r9Q2W3h9GqU5 i5y0DJhOpZ1UskaScfuEDq6q19QLjzCMZrD/HMgTYbOBwN6FYD+wcBdCrzADSvBlhTVCPva7VcufC L4jWYjag==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpAJz-00000001is3-49po; Tue, 26 Mar 2024 17:10:48 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 03/10] mm: Make page_ext_get() take a const argument Date: Tue, 26 Mar 2024 17:10:25 +0000 Message-ID: <20240326171045.410737-4-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240326171045.410737-1-willy@infradead.org> References: <20240326171045.410737-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: EA48A40005 X-Stat-Signature: pm34j74jr8ufzsreyb5wogqj198bfjp5 X-Rspam-User: X-HE-Tag: 1711473081-697577 X-HE-Meta: U2FsdGVkX19z8Oq4BECSvtvc0Latpgem37NKxrfjNl8qP/I2/s7EuApu8yN8Se4YeKN+AJj+cRpzVfYMbOv56jMi0zJU6tcdJE1jDX/bV0N+4ixL6MvpNJVhy+69cEyDeObmhGQY/TSjDF02DgzgFegL1KWOMagv+eNpDwYnpQWGKo8Q5qs7CJb77xi73MdTxbFph1enEzPvOX2FNlxXNLQ3ARe8XuJ/GTKabXoW6x1vqle4cMrlORoLQUGyENwWtowOo/ulw+omR+HTwhU/nZ2iY7nMOFAQ9Sx8DtzRRTGKMoh7ssGTm3NE+RZQ4ivANAjbsGNJzFQ7+CeuAgfx0NcYfLRrWcXisiti6WJx/EbF155VeqF/25OvneZcXFXNue4QyLJgm85JWZt+8Qhgs4locD/f8A2vp+2/peDYS9hmpQmSXYCU+B3nKlsIJ2dF8m/rKiybcqYgTd5T/EHUC2+ay5ZlA2cFKB0JV5j1Y8GGWRObCwAR95T8oefprqVPyg1uMwIqUTaaH2K4ryMvArY7F+uEoDCutRt6EifkOndt8X2gp8P7ShZB1x9r0gyQZCcVAmhUMPz8YbEpomBpK1dbDfOCeM9YQIJxyUmdLrhPX2VE3tBLWORmHDvF1eol6OeUQsVoxiKU36DlHPT2JXcD1gJ639P4Mc5rMK+2jD4DmYBzTliuq6Hy6DHidBGbtDLxv2Jjw+8f+6Yyr/oYXfVhqb6v/cmnr8TXjPPwTF8e9Gd9M32jh8qUGehcImc1NucYm/0ldYxha0rxhVSwzyktUeLitET3V6Lab8gidaetbUnidAMzvVlAjbGmpfIIBPvzg+Txzxun/ewE4H/n68TPLPF8BC2GmdWTUh98/kaMDdINUsUI/hRUmCp+J+4f63mXkOIXaxEwqeXmm5Nbh8So+v2OgHjiPzrzbEASVh5bC49aO7XyFlMvgyXMCl3h0B8M6wDfcx1QiChzsnI Q3Xtig78 bwzUifad4eDtzvWWof4ksjTGr1XcHILhxjWJdx6Z3rDVglf2PwndpswPzRTa5v12uYmFm77rjGRi474Vv7oNs0wRIxJ3jyEPiwBkc3BuktFEnKOcPTyf1giFLBAZ3ubBXbeoS29HqJ/tW9ckFwExkPF8EZM6/tgxyG9lSCiVS8nDDy5X1AuBXIFj2wVwaqor+lCY0WW2wQlPYrYd+C4lcNSaegiDKrlshUCEz X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In order to constify other functions, we need page_ext_get() to be const. This is no problem as lookup_page_ext() already takes a const argument. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/page_ext.h | 4 ++-- include/linux/pgalloc_tag.h | 2 -- mm/page_ext.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/include/linux/page_ext.h b/include/linux/page_ext.h index 07e0656898f9..e4b48a0dda24 100644 --- a/include/linux/page_ext.h +++ b/include/linux/page_ext.h @@ -77,7 +77,7 @@ static inline void page_ext_init(void) } #endif -extern struct page_ext *page_ext_get(struct page *page); +extern struct page_ext *page_ext_get(const struct page *page); extern void page_ext_put(struct page_ext *page_ext); static inline void *page_ext_data(struct page_ext *page_ext, @@ -117,7 +117,7 @@ static inline void page_ext_init_flatmem(void) { } -static inline struct page_ext *page_ext_get(struct page *page) +static inline struct page_ext *page_ext_get(const struct page *page) { return NULL; } diff --git a/include/linux/pgalloc_tag.h b/include/linux/pgalloc_tag.h index 62d8dad74b37..86ba5d33e43b 100644 --- a/include/linux/pgalloc_tag.h +++ b/include/linux/pgalloc_tag.h @@ -12,8 +12,6 @@ #include extern struct page_ext_operations page_alloc_tagging_ops; -extern struct page_ext *page_ext_get(struct page *page); -extern void page_ext_put(struct page_ext *page_ext); static inline union codetag_ref *codetag_ref_from_page_ext(struct page_ext *page_ext) { diff --git a/mm/page_ext.c b/mm/page_ext.c index e7d8f1a5589e..95dd8ffeaf81 100644 --- a/mm/page_ext.c +++ b/mm/page_ext.c @@ -514,7 +514,7 @@ void __meminit pgdat_page_ext_init(struct pglist_data *pgdat) * Context: Any context. Caller may not sleep until they have called * page_ext_put(). */ -struct page_ext *page_ext_get(struct page *page) +struct page_ext *page_ext_get(const struct page *page) { struct page_ext *page_ext; From patchwork Tue Mar 26 17:10:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13604740 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 7FDA8CD11DF for ; Tue, 26 Mar 2024 17:10:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EC8586B009D; Tue, 26 Mar 2024 13:10:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C6C576B009F; Tue, 26 Mar 2024 13:10:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A71906B009B; Tue, 26 Mar 2024 13:10:53 -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 794CA6B009C for ; Tue, 26 Mar 2024 13:10:53 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 22917C0D34 for ; Tue, 26 Mar 2024 17:10:53 +0000 (UTC) X-FDA: 81939829986.13.77BAEFD Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf18.hostedemail.com (Postfix) with ESMTP id 837911C0009 for ; Tue, 26 Mar 2024 17:10:49 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=lMDBhqTz; 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=1711473051; 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=yLB9fRmL27Mn3KGQOeYYZ+UTkGS5oCjoLLO67g9U514=; b=ir5xOetX8T+nWGHgFyXOMxzcil/jWJtaFKNrzRKzu0F4Gioi6n6LzMGuV00rq5iS2sq19V /6i493jvgf9rDIsS54rndqksWoasW5bWDHEn3wNNuD0cOTGS5Rh9WMKQc4EtlS3a9kiPDn c3yucwRLdR/Y/5WaRMS3c5NacqIldpc= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=lMDBhqTz; 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711473051; a=rsa-sha256; cv=none; b=AIBlGEuVw9Gk+cqUj8K1ekZGsKAB9ineFHqYCY3kDUMQR30TvRumrmel5LGrCflyl1CVMw WH0JPdwTVg9jRKe9rDhrly++0xwFrLq9ecICsYaO7l+dQGQatx9jBbc1eS2CWViBc1Mg+l w31qRkTzz6chxpBIA1tHinAzMy5Qby0= 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=yLB9fRmL27Mn3KGQOeYYZ+UTkGS5oCjoLLO67g9U514=; b=lMDBhqTzPMCzaZQ+qhgjzoZBo6 sWsALAHSgoX/lHXVJ67148gO4EcUSrVWQQvc7IhsytcOMuYyPukR9mtnl8o0Z1bE5Nf1lEcY9mwcd sIRvf+KAR2ZQycws44gZKZPRh1u1+q3m5p3Ocl1W1QDufs88Os1d9X8/d90hs2RtRdZBkOpFeLfGj D9aIs+eRqNqS8Lr1lji4+3WJdDv706oMC+pkVtoDJ12NnCft+FobyriQ7AdZzDJ1Q+w9fHsCzo0Ag Afq9E6hgonNL40dMmnpQoUW6qCgrpKunVjQDvkZUl8jFG3ontV0X9aZsE2bPjNp/umcQxqj2MXGNh MDKWV/SQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpAK0-00000001is7-0GPj; Tue, 26 Mar 2024 17:10:48 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 04/10] mm: Make folio_test_idle and folio_test_young take a const argument Date: Tue, 26 Mar 2024 17:10:26 +0000 Message-ID: <20240326171045.410737-5-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240326171045.410737-1-willy@infradead.org> References: <20240326171045.410737-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 837911C0009 X-Stat-Signature: 3qop8ezwcruy4f33pzmg8t19suryzt6m X-HE-Tag: 1711473049-26765 X-HE-Meta: U2FsdGVkX19b/hFTTAMtU6OzbEzxA9jJchrqqGK5hJ5Hq5KwCiU7lHtGHlvbc8Hf8Bk9cGMe7gslQsfg2h8Ofh3h4PsadMRveCr6KGMbd8YbzjGIu1h2BRch/UlmqJe5fXVa4yAosV5zCtd2h1i89u/gTWBUiymn/L0ahqRFcq4ttFaxwH+OIJm/gTCbHVz13SUVnJh/IK1lR+KYtntcgbNJriPLVa76fsFhkP0SxG96uCleCt0RjgVJAwOxUol1Pf9gxvxYdl7hK3FgMcUVWMU8+zKZ0OYqU+KDodrX7iTl0BxoAxrAkIpSMKv4aVhIz13aCHXsGAeLqT9etpfToRLG1FYxYc2Oz2LeLN1J3AFpTjI8qHJCoUsYJqHgtSdOGEh9P+ir7icOy3dY6rAgpCL+vS00SP3CK6j/ETgztsZSnB43VR6HGvUEnM045jfx3+uk1+FxUySicX5tszeB8tTF29H2I8M2MaTGpN0PNd7O4im+hrvNQPRHAbeUdtYGdZrNnivy/5eTrqn/Yv2mX0qjDmycN9jUIoeSIk5mk8vWc1z4jCrKPiVYmyP807EpyNUwlqobusa5MsEAOd+Ib93VIcaBUKs6BWiRSHorITZupt/cn1iFr4U2QcRL2niEjS72W66DZt42w1IsN7fn9ZtVnZ6EH2BJuEMS8JrE4pjWhOPziIgU9961KUZBn+B5vJQbMFYN1Q3bFMj+/iBwF/zqXf9s95zAgsj3mPFZ3PqS1gFbLkrgUG0Du5165vS3X9IN6ETMCl2OcLCAX///zMDA7TD5Erk2LZEupr15zAM9vW4n5t2aSbM8P0fGD8akyxQCY346GhE7biS7qlQ3617ruOfdmbrgFnyB10RXmaPEswKTB0M1+briAPMgCQp9TiviXdBWmNf9Yrid88CEyC/9puYmE8o1CzA6NfKd7C8eT5OVs0gYNUoko1O+zqL34LsmBuln8jVoyYjmi+G 0YK04swP Vu98rjfwcL10aiM1V9gxrs2zKrCl2QxkKonnjehFzSwvJVlLRaxwDKdTCVaJBpRChRPeOdRlT15ltHB/8r+qs2nA0hdc4gMiofBvHW2eSYcVUA0UnbN/zacLq6cn5vJ/AiQH26MgEektuMjetJVnVvUhh4+cmlLNlr75asvw0irtXmXw1PIlYIoUoyPK4NfWKifQ3zQ42FFc3+yk26Jj6XfUVGo+47ak3kziW 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 these functions are defined in page-flags.h, they already take a const argument; make it true for these alternate definitions too. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/page_idle.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/page_idle.h b/include/linux/page_idle.h index d8f344840643..511e22ef459f 100644 --- a/include/linux/page_idle.h +++ b/include/linux/page_idle.h @@ -13,7 +13,7 @@ * If there is not enough space to store Idle and Young bits in page flags, use * page ext flags instead. */ -static inline bool folio_test_young(struct folio *folio) +static inline bool folio_test_young(const struct folio *folio) { struct page_ext *page_ext = page_ext_get(&folio->page); bool page_young; @@ -52,7 +52,7 @@ static inline bool folio_test_clear_young(struct folio *folio) return page_young; } -static inline bool folio_test_idle(struct folio *folio) +static inline bool folio_test_idle(const struct folio *folio) { struct page_ext *page_ext = page_ext_get(&folio->page); bool page_idle; @@ -60,7 +60,7 @@ static inline bool folio_test_idle(struct folio *folio) if (unlikely(!page_ext)) return false; - page_idle = test_bit(PAGE_EXT_IDLE, &page_ext->flags); + page_idle = test_bit(PAGE_EXT_IDLE, &page_ext->flags); page_ext_put(page_ext); return page_idle; @@ -91,7 +91,7 @@ static inline void folio_clear_idle(struct folio *folio) #else /* !CONFIG_PAGE_IDLE_FLAG */ -static inline bool folio_test_young(struct folio *folio) +static inline bool folio_test_young(const struct folio *folio) { return false; } @@ -105,7 +105,7 @@ static inline bool folio_test_clear_young(struct folio *folio) return false; } -static inline bool folio_test_idle(struct folio *folio) +static inline bool folio_test_idle(const struct folio *folio) { return false; } From patchwork Tue Mar 26 17:10:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13604746 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 80609C6FD1F for ; Tue, 26 Mar 2024 17:11:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BA59F6B00A2; Tue, 26 Mar 2024 13:10:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9671D6B00A5; Tue, 26 Mar 2024 13:10:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 800686B00A4; Tue, 26 Mar 2024 13:10:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 47BA76B00A3 for ; Tue, 26 Mar 2024 13:10:55 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 11B68A09F0 for ; Tue, 26 Mar 2024 17:10:55 +0000 (UTC) X-FDA: 81939830070.22.1B26362 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf18.hostedemail.com (Postfix) with ESMTP id 5A1E71C0009 for ; Tue, 26 Mar 2024 17:10:53 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=ScIc0uVT; 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=1711473053; 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=RMKKjvj0inVCJhorJ4shbO4waA45G/h+x3MvxIXNfzc=; b=I1oxfB8Et3ePqRCznk2u5N3Lpb08jl3h8tnfSmb7dc3YSbWnwmva8rahPH8Mp9pbohVhzj T8HVlipejdUVdgoQEIax4JSr+PQECC0v7RXyVaKI4nTXuXtUfjHfQKUh1DtmEAlsXWpyf5 f8YvbMaE+kd5Ji0NEbGoFf8lxjriQps= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=ScIc0uVT; 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711473053; a=rsa-sha256; cv=none; b=d/Hz03XISN4ntTVmkqcQMiC6fLsqXBlioBxkG/8d3LCXHTA8SKaWU79CzTGpR0RfFHku0k w/lrjkzAIuI1nGwMQPuowtR/JR7k3MvqkYB4KjmY5lTLWAy0i/UZfoxLXHC/ZhdsKuGfQd rY2TRTwjmFDL116f2BbfLw63lP+zccc= 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=RMKKjvj0inVCJhorJ4shbO4waA45G/h+x3MvxIXNfzc=; b=ScIc0uVTqU6nBWoa/ushFmAet+ C53qGOdSfW9E7mbpJoXBpaSA7QplOtpecp+dvw0i25PfCwXOemYwZCeyLwKAnt/Aw73smpddln80c TNwX9EnYBnxjGlApS5cXIpkdlS1rvaQFCwa86tiH0wcKsaN9iX+gtySjuCxEYtteIYOAIHOhZIyND Qusx9FpDxB/iEzAyxs6pnKwpmiJb39DKYAh55LmazHrKxHk8WdgmSOXbBvotUVKWpJmfwVN9P7WUF brtjX1sg8a8mFAR8j3VR426YDqnI+rPec2ZKeKtzFN6bpewPmuEmmbnRUYF0x6LiKA/CdX58hF7gA nDn5XlqQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpAK0-00000001isF-0nEZ; Tue, 26 Mar 2024 17:10:48 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 05/10] mm: Make is_free_buddy_page() take a const argument Date: Tue, 26 Mar 2024 17:10:27 +0000 Message-ID: <20240326171045.410737-6-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240326171045.410737-1-willy@infradead.org> References: <20240326171045.410737-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 5A1E71C0009 X-Stat-Signature: soenwz4wsxah1jkatpoqy4eprezx9qun X-HE-Tag: 1711473053-257633 X-HE-Meta: U2FsdGVkX19ZwUMNM3Q4RcTvhPTXB7O3yHdB8czlGk1V5DELngvPRqtYfdWdIzcQs2s21w29h1VRHwQ8RmYN31j1as0LfnsFMdB3X+hj22QE+QzJS2eK2Jt+PEKEM1oauVvC0jJt620LXCaDSGvw9oq3a/aB8dskfzvRcsVST+OFYbYk4NzUuxTLw2/kmVMfHdsDBvh/q3cYKNicO1vlpQnhcx8lsl+lutDaUxnmork9meBKuJGLktU6yVn6ga6gvCVv63dqqWofzswcJsZuRdYk4fxju+nycHNtNPGuNl+XO2ZMb3cj018Fwi88WFClJn5lWwibV+WP5C0PsJbQryjIuSVahzQ/MR8tBr5igJ7ZZO0/TACOEULMWgtpHZAImUSRbZ+X2j4ir93FBAEcmu0GLnU1hqurrWD392leJlhdQ9hs30o94+akKDPQHBC7yCxF+5eIS3TAcpWBL3et+kWbA/tpfl8JUKwHMOJsqSsHfG3NvkDlWoK7or23AJpLkKrAcgnP8yNeMIzgre0dSfMMLTJwrXXU54vdQ1ltK3yONgtiACxKRWTzRBL+VEaYCBZV/mrqDUFT/ai9/mqq125dafmwOqk08O/tz34jXjaSI7jHRcIQK2OTvybopZtroG0746As5Cqvexqt0IgHRptd/lURZY758a/LOGQpphXaoNvtRFhRf3s33Vw9KlPK4IgGm2oYQLexIbatKC2be5QHRqI4V6x2SoUnb6qrYYhazmyn3JwbFJtwEJu1D5TrlLICq1bMIp+EvVJW0on0Sj1V6z8MRraPRzraACrzZ0GJRo6ljJ/S61BggC0R/Pzcer7DHN0p8OGf/gyoiXKdWsHNAgjDX21vm6XTi1twSMK3IRLW5doqYB7Dyj+NqnpivG4sXgt3m9B4Vov+262SczWxCeoGQJMv4q5BLwqEK3rYJJDwSFc9lf1EmNcvu0GfDYBQwFTrVeEd+GIaID1 V1lZ9ZbS FwAB0WKGVsCd7RHGRlpKrRXMK9tpMgBAog7cUZs6eNRN7l0Ht1c3RPAZeidZyuIbck1cRLYq6/c0NTj1rCIpyXbS02GHTeLGOt9ThMoaeJp215A2SZwrc4g/5zWSYh0up4FO/Zlb+9e8wH/ncADWo8nTORC6Tc+i9fj3MtLmW6u6ppAV2VPiEh/sX1Px8EHIr1Ab9nlcNOjx+GuxklCBk11qsNnVAu95e9U51 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: This function does not modify its argument; let the callers know that so they can make better optimisation decisions. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/page-flags.h | 2 +- mm/page_alloc.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 0163d6da6283..eaecf544039f 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -1088,7 +1088,7 @@ static inline bool is_page_hwpoison(const struct page *page) return folio_test_hugetlb(folio) && PageHWPoison(&folio->page); } -extern bool is_free_buddy_page(struct page *page); +bool is_free_buddy_page(const struct page *page); PAGEFLAG(Isolated, isolated, PF_ANY); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 370ea1711828..a00a2d7d8d9f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6786,16 +6786,16 @@ void __offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn) /* * This function returns a stable result only if called under zone lock. */ -bool is_free_buddy_page(struct page *page) +bool is_free_buddy_page(const struct page *page) { unsigned long pfn = page_to_pfn(page); unsigned int order; for (order = 0; order < NR_PAGE_ORDERS; order++) { - struct page *page_head = page - (pfn & ((1 << order) - 1)); + const struct page *head = page - (pfn & ((1 << order) - 1)); - if (PageBuddy(page_head) && - buddy_order_unsafe(page_head) >= order) + if (PageBuddy(head) && + buddy_order_unsafe(head) >= order) break; } From patchwork Tue Mar 26 17:10:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13604742 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 5386BC54E67 for ; Tue, 26 Mar 2024 17:11:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A5386B009F; Tue, 26 Mar 2024 13:10:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5984B6B00A3; Tue, 26 Mar 2024 13:10:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F70D6B009F; Tue, 26 Mar 2024 13:10:54 -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 E942E6B009B for ; Tue, 26 Mar 2024 13:10:53 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id ACC22A0420 for ; Tue, 26 Mar 2024 17:10:53 +0000 (UTC) X-FDA: 81939829986.25.AD8A23E Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP id 8578C180005 for ; Tue, 26 Mar 2024 17:10:51 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=NabuFMxU; dmarc=none; spf=none (imf24.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=1711473051; 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=4rsav8danrviXsQqOhqsj+Cnv5iqAQuNlq8PIWYIZQ0=; b=bgLbvRMHrlS3FJopb6BZAVWN8fJim67pNtEO9Llpr49v0qH+zvN27tAp3o7uSn/63uMju3 RxC8LcSuNcyxjEyDGcJSnsLxGfESOU2zbtw2537vmr9yixb/AZlbaea8D47uINKsKiAMtP UbUCkKKVmw/GOtDhNc7EYZ4QG8pLmDY= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=NabuFMxU; dmarc=none; spf=none (imf24.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=1711473051; a=rsa-sha256; cv=none; b=LGVAgJ1A1MCwBz+QM+kKjdDGZD87AMFlOQT4SBSCeU0uiJFJuWHuBMcabok1jw+C0xTviD Id4CQ/I6RY49itLoIpindYKFM5gYolxRlNOPXI3Jhr6JP9yPIsrPdTMrDDakkg37yE+9e0 TRNMfbqd7Djcl0zRT+cxcs9UvpgL7dk= 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=4rsav8danrviXsQqOhqsj+Cnv5iqAQuNlq8PIWYIZQ0=; b=NabuFMxUr9N12Q+IT4RcMSyJjt fePrd43vUYAPbwNtUMUGCdgCeOoVk8Lh1eQ8iKMOcFpTnQEEDLcxNkJpVZfP5RH63LzyPFuUqDIo2 zFlslJit2L9KPIVDzKyljnWdSmt6qdBWBojrFReviq0XJToPxUs922raT7AGb+rWgLy4oB4vBGAqP t3eesXRHkfJlWEC21jgrOQyWobwy7kiYP/LcKDsc++GX66+vCPKA3q1ifG7MK3aXH8unfzKBLZmo7 dVZlrlB1q0lrVdNCXtSpwSodrwKCFPwoC8OQpXpTINfgw5qf9Cl8IROC9l0ilC+axhnI/zXZVAq3o sd1XP04A==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpAK0-00000001isL-19qZ; Tue, 26 Mar 2024 17:10:48 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 06/10] mm: Make page_mapped() take a const argument Date: Tue, 26 Mar 2024 17:10:28 +0000 Message-ID: <20240326171045.410737-7-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240326171045.410737-1-willy@infradead.org> References: <20240326171045.410737-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8578C180005 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: fa15gfgyhyffwto7ge1jphtcr97f7fkk X-HE-Tag: 1711473051-165031 X-HE-Meta: U2FsdGVkX1+hWLAJp2tNaKenLezvzIQLnjG4Gs1VaAb19HgeoNLm4gOwv0kkC6449WirhafacGDk4UTcfc5AbIOWGJr+qKtsl878ktI7VtP6jHxgRq0T40IZXWfYibJxcremAffEU8TywRgPIzxG8MwYFex7KULuWSFYrLPXeaiMQ1zEiQ92TsxAtyLHg1EqutpjBAdyYsTuKE/o9ZTKb7Z0w7tFqoJOxc41Fd/N/ln7XET5Sb2oUQYR8QDkOpqzekH/CEz1CrEDQDdfCsQ39b0Yte8DMcEgF24U4ta9pqSvK0q3d4nnLQVY5bbPCwxlVHr8/tsX9EI/dUsjm+YPutabJLR34LlFEMiOd+KpdC26dFGuc/riOkUBPU0zgoBo2+Xx95TDhD6GlvaYndpDZkRYeF8s+NiVtf+IySHRz3wXlk3bt9+ls/QSPvX61VB+s6XZwAboPbHVsOph3TaQWN0eqYjTaKsVTM8rmNt/Bnh/p2LJTWNFuPRfOu/EndMgW/tmZdcK6lO7y06Qj/XRBFUp5ti9EnpMPMdgtd0zOE04HX0opB7BiUcE0895dOdtWk54zTeQ7PPwqep1ZqUI7xpfKNZDLy72BWvBYUOPQriYqRAy/zYeahEFngkQ4R5cSlFwg4QzM3Tj1kvLSKZY/Qq+P0uG6UwFBVqRKRtAp1gdIkuRTDc4NR1hy5i2LzLT0z0JFQqXgnIJlZgTN7C3cVGqaugeISmTsOVEdI7/+8pEbrPte8Siyv/rSDe9x+qkdXfpCoNF0kstTnwtTC/1IkVgQWwtU4k2YupiOtQ2S9LWd5k4Z6YOisUBqe1OFaWt4dLa+zlGqimkcIAYuMX9tGsASHoGqqF/SRMhuGz3l9Hin27p8aelhE/O7eXXSKqB0h5j/jzVkY3oPt5zJwZIh2qx7czge6Gj7j87aDDuP2yvzLSmWYFYyRrTCMCtw4SD5VAS7pnqjK/CVb7Jcvy 8z0dLbRd ZV0ITfscbQ7teAjlJOjCvpV0gGj6986xpNsmVk2I3CrtzcijMa/+7WgY670YjKVe8ZbbqjsGzYgd4jlFdz2WwNzEK9kuK1/qrYPxyl6/KzukJT0jai/hOm1vIx51Ae4cj1avmtx6bquDjZEr3ay00bjN0jbyVqc0fie+OT5eaFBnhjEmIXwi1xaOvEsKqZpBcAc50mRSrNXka1zIfYworMIAfdGyCFQLoQ6Gp 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: None of the functions called by page_mapped() modify the page or folio, so mark them all as const. Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/mm.h | 12 ++++++------ mm/internal.h | 7 ++++--- mm/rmap.c | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index e329f09fbb9c..d226c1929f98 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1200,7 +1200,7 @@ static inline int is_vmalloc_or_module_addr(const void *x) * debugging purposes - it does not include PTE-mapped sub-pages; look * at folio_mapcount() or page_mapcount() instead. */ -static inline int folio_entire_mapcount(struct folio *folio) +static inline int folio_entire_mapcount(const struct folio *folio) { VM_BUG_ON_FOLIO(!folio_test_large(folio), folio); return atomic_read(&folio->_entire_mapcount) + 1; @@ -1240,7 +1240,7 @@ static inline int page_mapcount(struct page *page) return mapcount; } -int folio_total_mapcount(struct folio *folio); +int folio_total_mapcount(const struct folio *folio); /** * folio_mapcount() - Calculate the number of mappings of this folio. @@ -1253,14 +1253,14 @@ int folio_total_mapcount(struct folio *folio); * * Return: The number of times this folio is mapped. */ -static inline int folio_mapcount(struct folio *folio) +static inline int folio_mapcount(const struct folio *folio) { if (likely(!folio_test_large(folio))) return atomic_read(&folio->_mapcount) + 1; return folio_total_mapcount(folio); } -static inline bool folio_large_is_mapped(struct folio *folio) +static inline bool folio_large_is_mapped(const struct folio *folio) { /* * Reading _entire_mapcount below could be omitted if hugetlb @@ -1288,7 +1288,7 @@ static inline bool folio_mapped(struct folio *folio) * For compound page it returns true if any sub-page of compound page is mapped, * even if this particular sub-page is not itself mapped by any PTE or PMD. */ -static inline bool page_mapped(struct page *page) +static inline bool page_mapped(const struct page *page) { if (likely(!PageCompound(page))) return atomic_read(&page->_mapcount) >= 0; @@ -2070,7 +2070,7 @@ static inline void set_page_links(struct page *page, enum zone_type zone, * * Return: A positive power of two. */ -static inline long folio_nr_pages(struct folio *folio) +static inline long folio_nr_pages(const struct folio *folio) { if (!folio_test_large(folio)) return 1; diff --git a/mm/internal.h b/mm/internal.h index 5dbfa1c12e89..8e11f7b2da21 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -71,7 +71,7 @@ void page_writeback_init(void); * How many individual pages have an elevated _mapcount. Excludes * the folio's entire_mapcount. */ -static inline int folio_nr_pages_mapped(struct folio *folio) +static inline int folio_nr_pages_mapped(const struct folio *folio) { return atomic_read(&folio->_nr_pages_mapped) & FOLIO_PAGES_MAPPED; } @@ -81,7 +81,8 @@ static inline int folio_nr_pages_mapped(struct folio *folio) * folio. We cannot rely on folio->swap as there is no guarantee that it has * been initialized. Used for calling arch_swap_restore() */ -static inline swp_entry_t folio_swap(swp_entry_t entry, struct folio *folio) +static inline swp_entry_t folio_swap(swp_entry_t entry, + const struct folio *folio) { swp_entry_t swap = { .val = ALIGN_DOWN(entry.val, folio_nr_pages(folio)), @@ -90,7 +91,7 @@ static inline swp_entry_t folio_swap(swp_entry_t entry, struct folio *folio) return swap; } -static inline void *folio_raw_mapping(struct folio *folio) +static inline void *folio_raw_mapping(const struct folio *folio) { unsigned long mapping = (unsigned long)folio->mapping; diff --git a/mm/rmap.c b/mm/rmap.c index 3746a5531018..d52759aa3ff7 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1134,7 +1134,7 @@ int pfn_mkclean_range(unsigned long pfn, unsigned long nr_pages, pgoff_t pgoff, return page_vma_mkclean_one(&pvmw); } -int folio_total_mapcount(struct folio *folio) +int folio_total_mapcount(const struct folio *folio) { int mapcount = folio_entire_mapcount(folio); int nr_pages; From patchwork Tue Mar 26 17:10:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13604743 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 1ED47CD11DF for ; Tue, 26 Mar 2024 17:11:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A4C646B009E; Tue, 26 Mar 2024 13:10:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9FC676B00A1; Tue, 26 Mar 2024 13:10:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A18C6B009E; Tue, 26 Mar 2024 13:10:54 -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 0B1A96B00A0 for ; Tue, 26 Mar 2024 13:10:54 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id CBDDC140D15 for ; Tue, 26 Mar 2024 17:10:53 +0000 (UTC) X-FDA: 81939829986.06.FBDD9F7 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf13.hostedemail.com (Postfix) with ESMTP id 2D37920019 for ; Tue, 26 Mar 2024 17:10:51 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=DlxXV5hE; dmarc=none; spf=none (imf13.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=1711473052; 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=tq8Kbf2LVfQ4EQcIhLM3s4gNREM5wXn60iV7YjjnHsY=; b=IvXZSVunS74sZJpcpNc5dIilqmITLvjK4V3qna0+E+kHNX4GuiuLP6wPerBT1QLeUoS9di CFr+aUSyJEH0SOw6WmOYNA5NK/LyuEKHSPZncRr4fL9rjvsep6KtwerwSagSQ5HeQTZFVn PQB0j8+CReqwLSgzOlyaGHNhmdOIkc0= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=DlxXV5hE; dmarc=none; spf=none (imf13.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=1711473052; a=rsa-sha256; cv=none; b=BUzbv6kt8eshYsTjinbWzNjJkH5dQ+ePl5ySwwfTpbsFhIFwGOvxlok5bCnziEuNQwrIue 0C0izcB2xr8bhbdp9xyeFJbBCwWBtU4/eFQk8BNfVmoFnC939qYyQWJmgZVM0xLZAKygUg /6zFbh4l/l4xjLFrGM1t5KKW3eScUBo= 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=tq8Kbf2LVfQ4EQcIhLM3s4gNREM5wXn60iV7YjjnHsY=; b=DlxXV5hEJBuW+sG4JENs2HKDu9 S/uWdvU4KYWJ2RufJO7o8FzyJ/hRUqs10hMaFf1qG57lmYiLhDYlwYrIKHsq5pRrl1smJDxAeKzdL 43fhgRgtpsMdLGQqV9lfXyyUQ+5tGDMiaFdC6Z7yZn9CZT78DOUnv9bhFVaPSa34b8U7XpyW+ZCvB I5NxbDpvdeh9Civ93FnHpCxXMyiAjBlsdGKf19KLCN6Csxr2KVRxj4oYStb4GpysRSFMn7IbtML8E 4iUpGIjNwKdVsQxUhE1/uQgUNLl3rQUn5xPirAxHSwyNeowpjJm/kCsdkNCA1twc30WoEwVK6qH+J yhgmV13A==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpAK0-00000001isS-1gdj; Tue, 26 Mar 2024 17:10:48 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 07/10] mm: Convert arch_clear_hugepage_flags to take a folio Date: Tue, 26 Mar 2024 17:10:29 +0000 Message-ID: <20240326171045.410737-8-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240326171045.410737-1-willy@infradead.org> References: <20240326171045.410737-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: wwpx9xg3hsx38y1fajpmm5p95j64t518 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2D37920019 X-HE-Tag: 1711473051-769864 X-HE-Meta: U2FsdGVkX1+eagcMstsesFmKeoS5KEhP2wDA+fdWU7homukfqbtdJE0KaBtBwsbUIK+2S0HkbEdYHE6Ca+JabN4udT23CyaQ5CG0dJkwWwVEIJVtaFQ1219Pbgct3ovd3Cn0i09mqWIxxEv0v3tG7lwgBbJl4ouMEeW/AzniCkEJwbIjTrF3zPMDHmCeibuUDecW2JCEdKUs9yWJHG53f1ov1EwVf6+meqsLq5hBewFymE/oLun67FoSCoy4L1x9laQcPwF/tmE9JZIOadyoY3eHsbaYgAQPXdQ56IlQKQpYXBLJSkXa3VQ7esnnGC0M05k6YO6R5Q/0x3ZhHLKnsyp+OvMihO4uyHg/8aiJaB4Wccdd3E6gosIZ1MsB9QXZpc5ktOiQBsfaAltPKqMmJQnS49rbRduH8ii3XZXl32BfPb1x85kjlYM4EFPmsq3myhHm1rpq90Z7DIhI0oaigflk3JYPq6M9av/cQbSvHujL8suACpmW0P3JdSGcoBGJRHV3BuwSOud5RngPv/X8/+qcBRkFRp4VET779THbgREcecv45kKbMxdClSUV5rOdmm/9/RmyR+xvYsEZHoOPuUxB1DqF9JnIKPGd+WXLvmXle2zS4pg02KoRCzsSj4DpSlrJWho8OzQw+b7W9ojQcieGygGK+Jmnq/AirfekFqsPhprV07efw/whU5NfHcxzBlW5PAcK/4egwVlata7AMsO2Y8cW5vy0paSIpoIF4z+Z34RlZuXngA1ILNrCbeVsn6G20Cee7SWe1GqSg+8zoqFmS36HSQMKsqTaHZWW+PpWlMBtcWVb4CQAewkAxHSfhnKp9QZfxUt6sx9sVA1Uncj9VbgTWqChcHsdgukzvsmUAlgpiA+yPOMJ/gCXMiQw04qy9yKnfD/Y7UnpybGKCY2krlakRIqoWBuPp1FusdoGEo7OB0s9vRERsa59dwbMeO1HalZHDzJwCijo6at BS/un7Bx YZ6BHdLXD7H+ROlA5iszAedPdgibwogVS1htVgSfCx6Frizc22aScZ70Pe1Q4R7W7wr9+aNNlsR2Se6RyAizuGtJ+nhFs0VeP6Y3hUDj135JzhhWQfpgJPm0cTpw1NT7ON9MFCZxiQK44h9XiLXf7n6BPcZh5F+DzrPY/ZER3PSPX23FlhJkOlK+LMhftJ/LB/SVEh86+cEp9W6UmDbxcpCiRehv4Ui6uh8sUWWgZj++h1C/NPIKmocbMrL1M0Ky1lMGsl4X7ECiv8a8= 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 implementations that aren't no-ops just set a bit in the flags, and we want to use the folio flags rather than the page flags for that. Rename it to arch_clear_hugetlb_flags() while we're touching it so nobody thinks it's used for THP. Signed-off-by: Matthew Wilcox (Oracle) --- arch/arm/include/asm/hugetlb.h | 6 +++--- arch/arm64/include/asm/hugetlb.h | 6 +++--- arch/riscv/include/asm/hugetlb.h | 6 +++--- arch/s390/include/asm/hugetlb.h | 6 +++--- arch/sh/include/asm/hugetlb.h | 6 +++--- include/linux/hugetlb.h | 4 ++-- mm/hugetlb.c | 4 ++-- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/arch/arm/include/asm/hugetlb.h b/arch/arm/include/asm/hugetlb.h index a3a82b7158d4..b766c4b373f6 100644 --- a/arch/arm/include/asm/hugetlb.h +++ b/arch/arm/include/asm/hugetlb.h @@ -15,10 +15,10 @@ #include #include -static inline void arch_clear_hugepage_flags(struct page *page) +static inline void arch_clear_hugetlb_flags(struct folio *folio) { - clear_bit(PG_dcache_clean, &page->flags); + clear_bit(PG_dcache_clean, &folio->flags); } -#define arch_clear_hugepage_flags arch_clear_hugepage_flags +#define arch_clear_hugetlb_flags arch_clear_hugetlb_flags #endif /* _ASM_ARM_HUGETLB_H */ diff --git a/arch/arm64/include/asm/hugetlb.h b/arch/arm64/include/asm/hugetlb.h index 2ddc33d93b13..3954cbd2ff56 100644 --- a/arch/arm64/include/asm/hugetlb.h +++ b/arch/arm64/include/asm/hugetlb.h @@ -18,11 +18,11 @@ extern bool arch_hugetlb_migration_supported(struct hstate *h); #endif -static inline void arch_clear_hugepage_flags(struct page *page) +static inline void arch_clear_hugetlb_flags(struct folio *folio) { - clear_bit(PG_dcache_clean, &page->flags); + clear_bit(PG_dcache_clean, &folio->flags); } -#define arch_clear_hugepage_flags arch_clear_hugepage_flags +#define arch_clear_hugetlb_flags arch_clear_hugetlb_flags pte_t arch_make_huge_pte(pte_t entry, unsigned int shift, vm_flags_t flags); #define arch_make_huge_pte arch_make_huge_pte diff --git a/arch/riscv/include/asm/hugetlb.h b/arch/riscv/include/asm/hugetlb.h index 22deb7a2a6ec..b1ce97a9dbfc 100644 --- a/arch/riscv/include/asm/hugetlb.h +++ b/arch/riscv/include/asm/hugetlb.h @@ -5,11 +5,11 @@ #include #include -static inline void arch_clear_hugepage_flags(struct page *page) +static inline void arch_clear_hugetlb_flags(struct folio *folio) { - clear_bit(PG_dcache_clean, &page->flags); + clear_bit(PG_dcache_clean, &folio->flags); } -#define arch_clear_hugepage_flags arch_clear_hugepage_flags +#define arch_clear_hugetlb_flags arch_clear_hugetlb_flags #ifdef CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION bool arch_hugetlb_migration_supported(struct hstate *h); diff --git a/arch/s390/include/asm/hugetlb.h b/arch/s390/include/asm/hugetlb.h index deb198a61039..ce5f4fe8be4d 100644 --- a/arch/s390/include/asm/hugetlb.h +++ b/arch/s390/include/asm/hugetlb.h @@ -39,11 +39,11 @@ static inline int prepare_hugepage_range(struct file *file, return 0; } -static inline void arch_clear_hugepage_flags(struct page *page) +static inline void arch_clear_hugetlb_flags(struct folio *folio) { - clear_bit(PG_arch_1, &page->flags); + clear_bit(PG_arch_1, &folio->flags); } -#define arch_clear_hugepage_flags arch_clear_hugepage_flags +#define arch_clear_hugetlb_flags arch_clear_hugetlb_flags static inline void huge_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep, unsigned long sz) diff --git a/arch/sh/include/asm/hugetlb.h b/arch/sh/include/asm/hugetlb.h index 4d3ba39e681c..75028bd568ba 100644 --- a/arch/sh/include/asm/hugetlb.h +++ b/arch/sh/include/asm/hugetlb.h @@ -27,11 +27,11 @@ static inline pte_t huge_ptep_clear_flush(struct vm_area_struct *vma, return *ptep; } -static inline void arch_clear_hugepage_flags(struct page *page) +static inline void arch_clear_hugetlb_flags(struct folio *folio) { - clear_bit(PG_dcache_clean, &page->flags); + clear_bit(PG_dcache_clean, &folio->flags); } -#define arch_clear_hugepage_flags arch_clear_hugepage_flags +#define arch_clear_hugetlb_flags arch_clear_hugetlb_flags #include diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index d748628efc5e..cc420c42a773 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -837,8 +837,8 @@ static inline int is_hugepage_only_range(struct mm_struct *mm, #endif #ifndef arch_clear_hugepage_flags -static inline void arch_clear_hugepage_flags(struct page *page) { } -#define arch_clear_hugepage_flags arch_clear_hugepage_flags +static inline void arch_clear_hugetlb_flags(struct folio *folio) { } +#define arch_clear_hugetlb_flags arch_clear_hugetlb_flags #endif #ifndef arch_make_huge_pte diff --git a/mm/hugetlb.c b/mm/hugetlb.c index f9640a81226e..0fdbd1f6c575 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1726,7 +1726,7 @@ static void add_hugetlb_folio(struct hstate *h, struct folio *folio, */ return; - arch_clear_hugepage_flags(&folio->page); + arch_clear_hugetlb_flags(folio); enqueue_hugetlb_folio(h, folio); } @@ -2024,7 +2024,7 @@ void free_huge_folio(struct folio *folio) spin_unlock_irqrestore(&hugetlb_lock, flags); update_and_free_hugetlb_folio(h, folio, true); } else { - arch_clear_hugepage_flags(&folio->page); + arch_clear_hugetlb_flags(folio); enqueue_hugetlb_folio(h, folio); spin_unlock_irqrestore(&hugetlb_lock, flags); } From patchwork Tue Mar 26 17:10:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13604745 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 45611C54E67 for ; Tue, 26 Mar 2024 17:11:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 966FF6B00A1; Tue, 26 Mar 2024 13:10:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E85A6B00A2; Tue, 26 Mar 2024 13:10:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 624226B00A5; Tue, 26 Mar 2024 13:10:55 -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 461016B00A2 for ; Tue, 26 Mar 2024 13:10:55 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1EBCEC0B7F for ; Tue, 26 Mar 2024 17:10:55 +0000 (UTC) X-FDA: 81939830070.11.32A4E28 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP id 7289218002C for ; Tue, 26 Mar 2024 17:10:53 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=TkO0yvdG; dmarc=none; spf=none (imf24.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=1711473053; 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=/TxhYLHQ0xyjPD4SrsNY9DePy2Ipz06eYkWddMgp4fA=; b=LJIqHWl/f5xInHVEKGz8kyxlX+uQcAR0Hy80KT24c5+Vp8sXM8ddpaMcTiyAqNbR4hCg51 bbS6lqbrSnnSokhtJDX4iVXix9mjPProKCUGDPsqPmYa4d3cw9G89UsNj+ib5mYArDj1yh kU/u21ITDY7UK1kdFtutGJ6dWxaPClU= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=TkO0yvdG; dmarc=none; spf=none (imf24.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=1711473053; a=rsa-sha256; cv=none; b=z99vK4AHcS1XkWLUVlQ3snNWfHKoQK2VjXrt+DQAyqJEqp8ZEKTZGUzNJzSsvFCSCob7Wb oepFN+P6Xz3PcqkOow2MHXTP3U3ItEA45wsUmdK9cMWyLGGGHILEiXYloG6Jwv/XwWZpUJ Ck8/FJAVDtDuO8/OtZ73y0OyuwrMcKY= 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=/TxhYLHQ0xyjPD4SrsNY9DePy2Ipz06eYkWddMgp4fA=; b=TkO0yvdGR8s/S19WIsCvKIQWnh fgUYH56x4sdQhzXGXiVE5iZsRsRJ2bs9ZTwIb0WZx6sXfaZy7jjZjdiNbdju8Nc0mrJ0V0s3E9C2i iCa5fG5Bnb9VyAGuRdig96JwH3vYqRF7B5mPPrWsJ6qk6hNVTvzd1zKr8zoK7oqadY76SkTTI0/tj Tw1gsBVVFq/YcG4CCmjrXL+h6yFMm0z97S4pJGBAOqIJ3BzXp1qLNfLHBv37hy/AZXCX52g+5hpn1 b4xkHAxKPr0GPlR2EgXP/CKc5gyxAexVOmRjNXoZrKQehCAkggjhH6rMBCwRDo1MJwZqdgLzgsjXc V5T7Y7+Q==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpAK0-00000001isZ-2JlW; Tue, 26 Mar 2024 17:10:48 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 08/10] slub: Remove use of page->flags Date: Tue, 26 Mar 2024 17:10:30 +0000 Message-ID: <20240326171045.410737-9-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240326171045.410737-1-willy@infradead.org> References: <20240326171045.410737-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7289218002C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: mua3bzf95akibxsxfto68jpudicb7pon X-HE-Tag: 1711473053-872807 X-HE-Meta: U2FsdGVkX1/xzv19KTK1CqNH6SB5M6PWku6vtO3F6pUQeooCXBfPzfVPgVLPzOKd8Nca4SJ1oZKFdVnihS9WbH6TgKRcSmhviJhZB1y0MHH3EVu1UXnfUNhw078Eshi+Xm1zEAMK8tIFu507oxUn58Lp6dKrQmPxW6IsKB/MYmzu+Ipa55XKnKMIewutsSuuTpFSQAtevhgqkfHccl6OShEx+KG6eGBndRhyt3LUupzYn1+wrVcod/bxBs2e2YTuIsu1VcjlWyXY6tQjrm0GYrEdQwoXwNqR1vUCBkPrbsEL05qrFwfrkq8E5x86KgJ8EIPjJdyjV7N9emL1uAMmlOB8C+Mv0QwIt++pmjgU79BUtaL2Jg2rxe3uuYUR/u7YpuSGkZ3wsX9r5rT6klpuf/W1RKKFL0oaWJJ0iD2MuQcVSlj4+wsVk/LQXegKeDY20lql/QqnkHaQtD1EDvw1xFpj+uLI/qjrELjyw9PM2PUhwZgOJacBuejxTHpCswEB4BGKLFmGpi7+iOTOQ5hR35C4vkKpOkGLvf+l3H3g1Sa37h17c0c/C5uSlmt2K1jNsI5F/Vj0A+eDUiD84VOPEOp4Wr/Qejd15jjU58XUPNWs7dNBnLtIpB56v2C7dWxsfEOG48+I/xh1hLIUg6XWTVVYqPCKjCTeOhQFTPpJIhKQzXzyA9BMEX5ZLAsqkf1E75T+q8plMLonWNwJwNyeT6UErpeHCMvd9lsNUQNzo6cKILrjAKMi8beysKdnIY6oIZ5jVF9+13u744yhAzt4qWJXc4qT2Te4/WcqwkVYWdV8sHh9z08+fprXXaSDa/QWCBk4NlZf4/faF9rv/ux8vJWkSEPJM46N+m3truPI+qb7pumiko2W0zBxG2JExN5HGrcizZTeaSuAMTgbyF+G2jrTvEXs/BMmA4bAEpq062f69V53hd4zNs8ECdE955aeaVFWiUboIhgNQKoKk2S gRYJKSZT RGU6Us509cwpb+OM7lvWZtluRbXpbbzbn7QTKqBuIGm13/dx7W8F3CJZI5lG8MArmkB+aiwgeWaKI+yU7wKLa/Ike/SfbTglhazZlEZKdgg/b3Bc5kv5s46JaKbPnr5RPl4gHhOraAS4ErrtDvbnSgNE0YNkioQ18HLS4/P/GLzyiZuoa5xKzEjalXw== 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: Use slub->__page_flags instead. We can also remove the assertion that it's not a tail page as struct slab never points to a tail page. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: David Hildenbrand --- mm/slub.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index ceee8d76e1a9..1500546a9b68 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -616,18 +616,12 @@ slub_set_cpu_partial(struct kmem_cache *s, unsigned int nr_objects) */ static __always_inline void slab_lock(struct slab *slab) { - struct page *page = slab_page(slab); - - VM_BUG_ON_PAGE(PageTail(page), page); - bit_spin_lock(PG_locked, &page->flags); + bit_spin_lock(PG_locked, &slab->__page_flags); } static __always_inline void slab_unlock(struct slab *slab) { - struct page *page = slab_page(slab); - - VM_BUG_ON_PAGE(PageTail(page), page); - bit_spin_unlock(PG_locked, &page->flags); + bit_spin_unlock(PG_locked, &slab->__page_flags); } static inline bool From patchwork Tue Mar 26 17:10:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13604738 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 E9DD4C6FD1F for ; Tue, 26 Mar 2024 17:10:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A19A6B0099; Tue, 26 Mar 2024 13:10:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 652866B009B; Tue, 26 Mar 2024 13:10:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 51A706B009C; Tue, 26 Mar 2024 13:10:53 -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 3E9686B0099 for ; Tue, 26 Mar 2024 13:10:53 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 138E1A100C for ; Tue, 26 Mar 2024 17:10:53 +0000 (UTC) X-FDA: 81939829986.26.25687AE Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf23.hostedemail.com (Postfix) with ESMTP id 25AAC14000C for ; Tue, 26 Mar 2024 17:10:49 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=maGghM32; spf=none (imf23.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=1711473051; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Uhj4LFxY9aLFI+gEf50yKVE/27RxcTXFlPgFk6W5CKM=; b=IeqgCGGmarxpsVebgMC3c6am9f6g36jmz2WT3pml5/Q7iLnyS7GzA1q0z3uZoiuvD+KQAa zNle7AYoDyZClkteinh/uTYdrgUkBmekkgp07XQVEvq45LhqC8SWc4Pwe/b13NE4vXJLmO 5PnpVYmwbXNJI/tXy+GgYj9ebpJ9MMg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711473051; a=rsa-sha256; cv=none; b=CTCtI8NGiUWQPSfRuAhYUbLfDWfJmiEdrLjOwTCQg/FWtwcdPpgDhc8/cQNVzDvd4XblDA pIKHWPw+RroWNmekhQvQdn/NNmWRbZixeH5PNEUxg3VImJzSejeIh/hpvx2/wNJ5jdr860 snFUPKsTEGNEA+qQFLcacnEUUFzO6g8= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=maGghM32; spf=none (imf23.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:Content-Type: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description; bh=Uhj4LFxY9aLFI+gEf50yKVE/27RxcTXFlPgFk6W5CKM=; b=maGghM32kuTdWeRz7vCjxKXeP7 8xo77I5/IXnwsep64qauhcUWU7GBeqJ63Y/LflMm1AO0ko1+BPE7tR1ao7R+RNNgcugcormMozmEW Hcbfg4Ew0QUqnB8pC0fnlDnCmQ2gffMmfGJ1bOwjdIq+vRZtMIfrABSEMHBOnpNuTm5/mXb6EohLv 9EGoX0tbLocD5wC7QReHA7d/lLDrzH0AQvVmkvSK9MFLAQslrxqCOZUh+DR8wkpborTvi0kbqmZ0J Ogf2I4RQPH7+82QnsR26sGx2ZtmYP65vyJw8a3dOGuHM3WpaeOY3uRBz5FImClNflVamuETDcOyOM c92P/MWw==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpAK0-00000001isf-2t4X; Tue, 26 Mar 2024 17:10:48 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 09/10] Remove references to page->flags in documentation Date: Tue, 26 Mar 2024 17:10:31 +0000 Message-ID: <20240326171045.410737-10-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240326171045.410737-1-willy@infradead.org> References: <20240326171045.410737-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 25AAC14000C X-Rspam-User: X-Stat-Signature: 5g1nouyg8srna5cyza5a3xj5r8qtxfu5 X-Rspamd-Server: rspam03 X-HE-Tag: 1711473049-524024 X-HE-Meta: U2FsdGVkX19zIqLh1NRwCxEW5gl7gKfD/6Zu8zMMOWx7IdlOQaCW4zOQh7g0/p9Qe0MlMxOYwXqxaYe5zwzmPsJdJWe9plz55YPjKPFRykRcEyGwxdeSpAVGI1fcf+LpoFmZGW5RbZqWK6Huw9xYnyWAgAv7il1CAofr7r5cHtiWmIQFbr8L4a7VBeFlaRHNF5SeZUGbqhdv3CuhBrAo9VYXFSmtJKiEBAk1kVOqopijJ7EbhJ5Kp+g/9NA/uy95akwgWvh3qyr7edLnsehWg+s9AjXP3OE4NrOoyANUH7m62jJ0ZMeo2sO2qHgMBxPaBSqGPrLMwONWUM51pXREADW12uMZiZB+HH2sgeWqy13bqVr4LkhXIzlLg+gxNTO3OlJj2uuxn/vxQVvEQvGYmlFO9kVLKqkGW83IcT1zoczTbB3LfLo4+jziVimpDSvsjTGR/okAy4eJl3PanxDEb4VdWhaHvJ7ENDTrgmv6hov9yPod/nv5pZ2VrXOyPo5E5XoGn5McbduWx/PQtrJsxwrJaCvkWKaGDc8fg7bnyre32XVPTHIMUrNRtJldo7lwIogXaXCjOc3BhwUeBtyPjm1ho40tLR3FYCl/dvpMp+N7Fkuf6EOnyVP45KkLf8MUsyaKh8xZP8KKR4K2w51dWDdGnmd+k+6xuzAJGgC3ucPnbe5IXc0+fvytCZdL16LP8cCg2EuI23lsrSG23YzGg05VrnezzdE1nopjWLoGSY0PDNhr/RF8Ru/IsWX3Rdwzx/U5lRZk1MFEWxPZ5qVgDPlozsWL7Xfcrv/cmCC9tY41bvcgtwO96G1qk65AvKVB40/fBpAipZ11Q23ibMQV65i63rGZkmpo5gaj2KycrHzZK8JAqTemPw/IfP6w4fR5rYuIIYO9qvyIQmR95xiLBfminWKp3uvxWu5LRf2ObPs8FWBt7fxWAPOjk6OREc5S35lACh2AsCnFnoaiVVS puIE1z+U CMZFSZXyr9gr1r1PEZusO3MbtQ7O1ZVyAHaIxJIC5NKfQ1sLjK9wHwLA8HAlaHM01DgQjKB+ziopI6URsMXxxizMUYXPVYvUpB2SS5+sxymdFcgPcG/GIudBofFocXB2ruk/EcZ5sWPpi5jnvKRxmui3VIzuqONxXITi1LO16dMrbyRFwcuRqbs1dJTopmsJJQuZ9+vh9dVpsF2+8MRF1mGhcsw== 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: Mostly rewording, but remove entirely the copy of page_fixed_fake_head() in the documentation; we can refer people to the actual source if necessary. Signed-off-by: Matthew Wilcox (Oracle) --- .../admin-guide/cgroup-v1/memory.rst | 4 ++-- Documentation/mm/vmemmap_dedup.rst | 22 +------------------ .../translations/zh_CN/core-api/cachetlb.rst | 2 +- mm/migrate.c | 2 +- mm/rmap.c | 4 ++-- 5 files changed, 7 insertions(+), 27 deletions(-) diff --git a/Documentation/admin-guide/cgroup-v1/memory.rst b/Documentation/admin-guide/cgroup-v1/memory.rst index ca7d9402f6be..46110e6a31bb 100644 --- a/Documentation/admin-guide/cgroup-v1/memory.rst +++ b/Documentation/admin-guide/cgroup-v1/memory.rst @@ -300,14 +300,14 @@ When oom event notifier is registered, event will be delivered. Lock order is as follows:: - Page lock (PG_locked bit of page->flags) + folio_lock mm->page_table_lock or split pte_lock folio_memcg_lock (memcg->move_lock) mapping->i_pages lock lruvec->lru_lock. Per-node-per-memcgroup LRU (cgroup's private LRU) is guarded by -lruvec->lru_lock; PG_lru bit of page->flags is cleared before +lruvec->lru_lock; the folio LRU flag is cleared before isolating a page from its LRU under lruvec->lru_lock. .. _cgroup-v1-memory-kernel-extension: diff --git a/Documentation/mm/vmemmap_dedup.rst b/Documentation/mm/vmemmap_dedup.rst index 593ede6d314b..b4a55b6569fa 100644 --- a/Documentation/mm/vmemmap_dedup.rst +++ b/Documentation/mm/vmemmap_dedup.rst @@ -180,27 +180,7 @@ this correctly. There is only **one** head ``struct page``, the tail ``struct page`` with ``PG_head`` are fake head ``struct page``. We need an approach to distinguish between those two different types of ``struct page`` so that ``compound_head()`` can return the real head ``struct page`` when the -parameter is the tail ``struct page`` but with ``PG_head``. The following code -snippet describes how to distinguish between real and fake head ``struct page``. - -.. code-block:: c - - if (test_bit(PG_head, &page->flags)) { - unsigned long head = READ_ONCE(page[1].compound_head); - - if (head & 1) { - if (head == (unsigned long)page + 1) - /* head struct page */ - else - /* tail struct page */ - } else { - /* head struct page */ - } - } - -We can safely access the field of the **page[1]** with ``PG_head`` because the -page is a compound page composed with at least two contiguous pages. -The implementation refers to ``page_fixed_fake_head()``. +parameter is the tail ``struct page`` but with ``PG_head``. Device DAX ========== diff --git a/Documentation/translations/zh_CN/core-api/cachetlb.rst b/Documentation/translations/zh_CN/core-api/cachetlb.rst index b4a76ec75daa..64295c61d1c1 100644 --- a/Documentation/translations/zh_CN/core-api/cachetlb.rst +++ b/Documentation/translations/zh_CN/core-api/cachetlb.rst @@ -260,7 +260,7 @@ HyperSparc cpu就是这样一个具有这种属性的cpu。 如果D-cache别名不是一个问题,这个程序可以简单地定义为该架构上 的nop。 - 在page->flags (PG_arch_1)中有一个位是“架构私有”。内核保证, + 在folio->flags (PG_arch_1)中有一个位是“架构私有”。内核保证, 对于分页缓存的页面,当这样的页面第一次进入分页缓存时,它将清除 这个位。 diff --git a/mm/migrate.c b/mm/migrate.c index 6dc73c438717..5c546583594d 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -113,7 +113,7 @@ bool isolate_movable_page(struct page *page, isolate_mode_t mode) if (!mops->isolate_page(&folio->page, mode)) goto out_no_isolated; - /* Driver shouldn't use PG_isolated bit of page->flags */ + /* Driver shouldn't use the isolated flag */ WARN_ON_ONCE(folio_test_isolated(folio)); folio_set_isolated(folio); folio_unlock(folio); diff --git a/mm/rmap.c b/mm/rmap.c index d52759aa3ff7..5ee9e338d09b 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -23,7 +23,7 @@ * inode->i_rwsem (while writing or truncating, not reading or faulting) * mm->mmap_lock * mapping->invalidate_lock (in filemap_fault) - * page->flags PG_locked (lock_page) + * folio_lock * hugetlbfs_i_mmap_rwsem_key (in huge_pmd_share, see hugetlbfs below) * vma_start_write * mapping->i_mmap_rwsem @@ -50,7 +50,7 @@ * hugetlb_fault_mutex (hugetlbfs specific page fault mutex) * vma_lock (hugetlb specific lock for pmd_sharing) * mapping->i_mmap_rwsem (also used for hugetlb pmd sharing) - * page->flags PG_locked (lock_page) + * folio_lock */ #include From patchwork Tue Mar 26 17:10:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13604747 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 C54B5C6FD1F for ; Tue, 26 Mar 2024 17:11:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1E73B6B0083; Tue, 26 Mar 2024 13:11:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 172D76B0087; Tue, 26 Mar 2024 13:11:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F2E636B00A4; Tue, 26 Mar 2024 13:11: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 DDB856B0087 for ; Tue, 26 Mar 2024 13:11:15 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 7A677A0CFB for ; Tue, 26 Mar 2024 17:11:15 +0000 (UTC) X-FDA: 81939830910.06.722173F Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id C519F16001B for ; Tue, 26 Mar 2024 17:11:13 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=DnCFgmEu; 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=1711473073; 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=s6CgZRK52RSScg8qoFY1i6MSuCAvafAEyBPlFSpqJ60=; b=mlfh56p+YP7UwGUxh3I9BpplPwDbVgPVi5YIRE4qeWhxC1j45T3MHbwAUSSVr8oofWr9lN s5ytYKQCEtVaqRrzPsFq6j33Bgc+fsGXHzV55nQUuwDNb5+Oiu5eL9PAWl9R2TAmrYpKJB n89Xi26FqTtWdEA5bkHzePQYKTeIOcU= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=DnCFgmEu; 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=1711473073; a=rsa-sha256; cv=none; b=dkqVoWqPpP4HbzC0Gv7V6RwKa7oC+lvntPO/1Z0WO497BLZfp3uRYoNSLT+/cs3NWzbpRc cOAJQ0xCXjqrAgdvcb/DYYpf4F96dC0Uvg/yU24cI2QJqLIOYs6a5FLnjXLwnShtmUdsjY R1fxBBFeXxlO2oapaIw5XdyflIjdho0= 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=s6CgZRK52RSScg8qoFY1i6MSuCAvafAEyBPlFSpqJ60=; b=DnCFgmEuxe3nMqLrQTU3xgs0By QZiQKXyzItHcRJcOLfwjcXEYOQ4jr0nBOzZIgb0L6fnEZY4exXFODwUERzgwM+3ItGTwjAyHEpTXA Z+lyyr4XIzwLfUz5MF1wAmq+qX4lyBkby+pfKVNpOd68FrCZqItszKGX011oK1cBnxCuLdXU2pzay KQHhLtDJiH1UfRaslBGUfbXQVu57Y1QbprwhqYHtF4FdDN/pkrkrFooRL5RaioKw017krRwOhknNy k4S4KO6nQajvWATjnl5C0ztBWp9vARpJ+oVQ0/WTUn9rBaRHQDWPYxAG7CI5hSkOFMPT9xPRZ1+cd 5KidapWw==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rpAK0-00000001isl-3U6Y; Tue, 26 Mar 2024 17:10:48 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Svetly Todorov Subject: [PATCH 10/10] proc: Rewrite stable_page_flags() Date: Tue, 26 Mar 2024 17:10:32 +0000 Message-ID: <20240326171045.410737-11-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240326171045.410737-1-willy@infradead.org> References: <20240326171045.410737-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: C519F16001B X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: zwkgzy4bzaa4eg59qojbutngdkxq6xqc X-HE-Tag: 1711473073-40382 X-HE-Meta: U2FsdGVkX19A65O4FPA6DnOqZfxGfGg4pjjSIVuoCgkoFJvtbFZ1Q6CXRTdasWxsxLHnNm/OB1jqdG+BKXvN4eJ2b+ibzsQiHgetkELCvLLkSP1v4H6zQAvfW/S08rXqIsRygXtri4LdOmKfP5SY+eQq4QfDdZ0ag+51ocALiqoVO7jepYayZtr85du7duSX8xBLdXEUbNXbg/815j5UFxpCdnuAjRg361IK8Wg/GCxzBu0uzbKLQkADAFzy3wCq7QRZFGJla6NmKlFMaDdI0QeYByMEuSNdgMRZW3R9AkX8y9NkCXvXUf6S5UDTvrzYA8Vp0jdh2Ox3DaKpTd5JH/oGdGUatuehdz894DBYa7wiC6gIhFQ95w91/TRXDfreiSo2b/gx/uLXjYNpqmwnZm7yR3IP3+snlj7JUSYHxsN7xMwsK+o0waqieOKqI2eGZcnNKfXg6nhMsq6hj+sSft6SNfIl1lkWFS9oA7bY5OcOFtrUAl7I7SZRa4CQ8+/tnxT/vmaEKequzX3hI7SGuFrB1znU0gOaUghxx9mYB99h1IRFOaw1cnHpdpjKVd/ypuO7jjnln3VKM65DxmhN92HqZDO+ob6fwMV9f9J08sTXx0sv9qK0Wq4bLaJlWKJZYDSJtxuWGTZ4pcDPiOSUN9a9ohRT+JZXog0QfKT5mWZqjRV4c/qXUfBMpyGdGSrjE+az9j3Id12rQq1DDpmu7pdUmgXSHc6JtXPgxxzpCLB/nB0iUaB2Wmyh5Ws7AYW1uZmGmhKC9OefmQ1i2apKsUY4L6cqcR+2ge9pGAdkgW81WGxhwuG2aH+Mr44vBKtVHplQcSn9bkVHjuEd2gluMoFD30/465olB1gNYpLWdF1+RSh/4NUniqIE2Iua77CpeJMoe5YBSz53pEZPF1O8kX+pt8BOtPL+mBIDHNNbzLP7/HxkP0doiMbLZw5xRGL7Nn72xGSxyjejTvrMhsH 8mPggy1j 2ms6HORwyIEGO1+fZEhGkNBaq5GbPHJcie7F/WZCUxxzLodhTU5kP9G/e8IGAQ/NRxv2eyxIba77JzxAIvIOV5l58ynTf24UXNxh8m0Nw9ACOPcMhBxPPvOyX7/zfw18PzHuhr+YpFLn/5h54oVPUzDbtNf63VoeMCeCkYFeWNp2XqiDzdMfK2HuUo1hAlA/KRjpQugiohRINcCf2MdZ4fDy9dxQ8+rJskS9BQw0UFMkCRGcNrmNWZitinbkPScRjA3hucjiTSWPwh51qN/6VN51Vk3CwEpSzNXIw 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: Reduce the usage of PageFlag tests and reduce the number of compound_head() calls. For multi-page folios, we'll now show all pages as having the flags that apply to them, e.g. if it's dirty, all pages will have the dirty flag set instead of just the head page. The mapped flag is still per page, as is the hwpoison flag. Signed-off-by: Matthew Wilcox (Oracle) Cc: Svetly Todorov --- fs/proc/page.c | 66 ++++++++++++++++++++------------------ include/linux/huge_mm.h | 4 +-- include/linux/page-flags.h | 2 +- 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/fs/proc/page.c b/fs/proc/page.c index 9223856c934b..d6953f95e3b4 100644 --- a/fs/proc/page.c +++ b/fs/proc/page.c @@ -107,10 +107,13 @@ static inline u64 kpf_copy_bit(u64 kflags, int ubit, int kbit) return ((kflags >> kbit) & 1) << ubit; } -u64 stable_page_flags(struct page *page) +u64 stable_page_flags(const struct page *page) { - u64 k; - u64 u; + const struct folio *folio; + unsigned long k; + unsigned long mapping; + bool is_anon; + u64 u = 0; /* * pseudo flag: KPF_NOPAGE @@ -118,49 +121,47 @@ u64 stable_page_flags(struct page *page) */ if (!page) return 1 << KPF_NOPAGE; + folio = page_folio(page); - k = page->flags; - u = 0; + k = folio->flags; + mapping = (unsigned long)folio->mapping; + is_anon = mapping & PAGE_MAPPING_ANON; /* * pseudo flags for the well known (anonymous) memory mapped pages */ if (page_mapped(page)) u |= 1 << KPF_MMAP; - if (PageAnon(page)) + if (is_anon) { u |= 1 << KPF_ANON; - if (PageKsm(page)) - u |= 1 << KPF_KSM; + if (mapping & PAGE_MAPPING_KSM) + u |= 1 << KPF_KSM; + } /* * compound pages: export both head/tail info * they together define a compound page's start/end pos and order */ - if (PageHead(page)) - u |= 1 << KPF_COMPOUND_HEAD; - if (PageTail(page)) + if (page == &folio->page) + u |= kpf_copy_bit(k, KPF_COMPOUND_HEAD, PG_head); + else u |= 1 << KPF_COMPOUND_TAIL; - if (PageHuge(page)) + if (folio_test_hugetlb(folio)) u |= 1 << KPF_HUGE; /* - * PageTransCompound can be true for non-huge compound pages (slab - * pages or pages allocated by drivers with __GFP_COMP) because it - * just checks PG_head/PG_tail, so we need to check PageLRU/PageAnon + * We need to check PageLRU/PageAnon * to make sure a given page is a thp, not a non-huge compound page. */ - else if (PageTransCompound(page)) { - struct page *head = compound_head(page); - - if (PageLRU(head) || PageAnon(head)) + else if (folio_test_large(folio)) { + if ((k & PG_lru) || is_anon) u |= 1 << KPF_THP; - else if (is_huge_zero_page(head)) { + else if (is_huge_zero_page(&folio->page)) { u |= 1 << KPF_ZERO_PAGE; u |= 1 << KPF_THP; } } else if (is_zero_pfn(page_to_pfn(page))) u |= 1 << KPF_ZERO_PAGE; - /* * Caveats on high order pages: PG_buddy and PG_slab will only be set * on the head page. @@ -175,15 +176,15 @@ u64 stable_page_flags(struct page *page) if (PageTable(page)) u |= 1 << KPF_PGTABLE; - if (page_is_idle(page)) +#if defined(CONFIG_PAGE_IDLE_FLAG) && defined(CONFIG_64BIT) + u |= kpf_copy_bit(k, KPF_IDLE, PG_idle); +#else + if (folio_test_idle(folio)) u |= 1 << KPF_IDLE; +#endif u |= kpf_copy_bit(k, KPF_LOCKED, PG_locked); - u |= kpf_copy_bit(k, KPF_SLAB, PG_slab); - if (PageTail(page) && PageSlab(page)) - u |= 1 << KPF_SLAB; - u |= kpf_copy_bit(k, KPF_ERROR, PG_error); u |= kpf_copy_bit(k, KPF_DIRTY, PG_dirty); u |= kpf_copy_bit(k, KPF_UPTODATE, PG_uptodate); @@ -194,7 +195,8 @@ u64 stable_page_flags(struct page *page) u |= kpf_copy_bit(k, KPF_ACTIVE, PG_active); u |= kpf_copy_bit(k, KPF_RECLAIM, PG_reclaim); - if (PageSwapCache(page)) +#define SWAPCACHE ((1 << PG_swapbacked) | (1 << PG_swapcache)) + if ((k & SWAPCACHE) == SWAPCACHE) u |= 1 << KPF_SWAPCACHE; u |= kpf_copy_bit(k, KPF_SWAPBACKED, PG_swapbacked); @@ -202,7 +204,10 @@ u64 stable_page_flags(struct page *page) u |= kpf_copy_bit(k, KPF_MLOCKED, PG_mlocked); #ifdef CONFIG_MEMORY_FAILURE - u |= kpf_copy_bit(k, KPF_HWPOISON, PG_hwpoison); + if (u & KPF_HUGE) + u |= kpf_copy_bit(k, KPF_HWPOISON, PG_hwpoison); + else + u |= kpf_copy_bit(page->flags, KPF_HWPOISON, PG_hwpoison); #endif #ifdef CONFIG_ARCH_USES_PG_UNCACHED @@ -228,7 +233,6 @@ static ssize_t kpageflags_read(struct file *file, char __user *buf, { const unsigned long max_dump_pfn = get_max_dump_pfn(); u64 __user *out = (u64 __user *)buf; - struct page *ppage; unsigned long src = *ppos; unsigned long pfn; ssize_t ret = 0; @@ -245,9 +249,9 @@ static ssize_t kpageflags_read(struct file *file, char __user *buf, * TODO: ZONE_DEVICE support requires to identify * memmaps that were actually initialized. */ - ppage = pfn_to_online_page(pfn); + struct page *page = pfn_to_online_page(pfn); - if (put_user(stable_page_flags(ppage), out)) { + if (put_user(stable_page_flags(page), out)) { ret = -EFAULT; break; } diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 7576025db55d..1540a1481daf 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -351,7 +351,7 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf); extern struct page *huge_zero_page; extern unsigned long huge_zero_pfn; -static inline bool is_huge_zero_page(struct page *page) +static inline bool is_huge_zero_page(const struct page *page) { return READ_ONCE(huge_zero_page) == page; } @@ -480,7 +480,7 @@ static inline vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf) return 0; } -static inline bool is_huge_zero_page(struct page *page) +static inline bool is_huge_zero_page(const struct page *page) { return false; } diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index eaecf544039f..888353c209c0 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -734,7 +734,7 @@ static __always_inline bool PageKsm(const struct page *page) TESTPAGEFLAG_FALSE(Ksm, ksm) #endif -u64 stable_page_flags(struct page *page); +u64 stable_page_flags(const struct page *page); /** * folio_xor_flags_has_waiters - Change some folio flags.