From patchwork Wed Nov 8 18:28:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13450387 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 E5AF9C4332F for ; Wed, 8 Nov 2023 18:28:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 310518D00C7; Wed, 8 Nov 2023 13:28:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2BFDF8D00C3; Wed, 8 Nov 2023 13:28:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 187D18D00C7; Wed, 8 Nov 2023 13:28:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0ACA88D00C3 for ; Wed, 8 Nov 2023 13:28:35 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id D68271602B5 for ; Wed, 8 Nov 2023 18:28:34 +0000 (UTC) X-FDA: 81435622548.15.D1BC022 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf29.hostedemail.com (Postfix) with ESMTP id 252C7120027 for ; Wed, 8 Nov 2023 18:28:32 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=DHCbyKu7; dmarc=none; 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699468113; 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=yzk7MZdb5d77onPKXJjjtQ/h/XdKpGzRY4if9O/N7pE=; b=RpcI404yKZahdb2jTFczUanks4rCQWa3pt1+twENGV01i9/CG3kIArsQ+5um3c9cy7ljx3 lefZQfhP7j/9hZ7AkF1rg/Sg5r4Y0/RvGZVRFMkQ1hgx+vn/5e7II+Ny9waK98B81Hb93z nOztxx1VN+ARuHDAp6alldDzPIIYORg= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=DHCbyKu7; dmarc=none; 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699468113; a=rsa-sha256; cv=none; b=Tp7kr/L68HpC4F0oYEAtxqCnCBOC/u7QuinRij+lC7o6YI4s1jOLfV68WdwNDhovikHXc6 W6I+uDCC7NDnzgDjnyrcR/+iGQO8nieknwfnq+WTISfIoKSr/DB/7PjYAZ/tISxCHNdCef VHRZsw91Dlza7VWK4f1tzyVsZ/Xg390= 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=yzk7MZdb5d77onPKXJjjtQ/h/XdKpGzRY4if9O/N7pE=; b=DHCbyKu7Ae6BaMQbftKibYWFO5 pBbpE+EfFScZKAHhwckAt8Z4pRgFzGvbF2oWTidSUKTBPBHM3SlJNk6+n8CzBkQP4SbdF/CVJM4Gy 4zbIMybu5ep6GkE8G65vmFNfwSBmxuBPOkiHL7+FvTb6K89NruHlu9N/HUuNgAo8u2oYgSVIuOdIG pjATqwhpxkuQIKILBOZQ9w2bUo213AelZx0QViifquLiOveuvTpJPITPWYnqUhw1v4Il714K90uL6 Is+tW2BPdSeVxwj7/pXX8LTJuf5WOvXhiaJ6hDfBBGQgMdKheq1P4zI4+AqcWf5950bz3N0SYwG3b XVJngHmg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r0nHe-002WdG-Ur; Wed, 08 Nov 2023 18:28:10 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , Naoya Horiguchi , linux-mm@kvack.org Subject: [PATCH 1/6] mm: Make mapping_evict_folio() the preferred way to evict clean folios Date: Wed, 8 Nov 2023 18:28:04 +0000 Message-Id: <20231108182809.602073-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231108182809.602073-1-willy@infradead.org> References: <20231108182809.602073-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 252C7120027 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: ggfggnoxrdpcuzyss8n81y33ieetfrw5 X-HE-Tag: 1699468112-740971 X-HE-Meta: U2FsdGVkX1/n5OUCB6gJElzahgQiVglYjsfGlTBWsW4jXl6Yq5hySIiNd8Zs+tw5/BNz0ecVJww+WRv2tqq1Jm5lv+139qmKDQeCO5xeSnDYN7ax+tg3t/+QJCyRT0Z5dgA5Jl8hE3seL1Qz4eAiKF3XFC0dE/qdHcUGLUk5Qtd2f0GXgbOuAzmPdueFGvzC+TK6cVJz8wm9IaGUbpVROxOftjHGYt84DTs9eJdUltCiIc/QaErz+re7N1OsvM8yfa+DMi0VZjw9wWS1ddrjXSZiisDXt+qPTEldQC2cRBzjnl++JN3Q/TYXO+FOlVAaziQkR92inrfFVQj/oaCCfe/ULmG8VTzh/G6tMpp75qMLm5jtVW2Ru15Bgd4LrIaXG55mkS239bgBUYfXj8uKpKIAUObTU6k0VVqL+T/x0eWPlC2i1GOeelyrHlzEmQhN4gnzPSqWZEmkKkmsUSZL5SSUBs0d07xjlJhw+wsfGPS3k+sPOgx4KEvz+VEn0sk3W3AUnMDhd8f4KtOx8lTisrZm2xUl5LA12ZWH4tAbB5MKCzxJWGETznNnqosGtH4V3uiqbbzQuKnR6nyOL2TcscPO36zc+KYPx1aqA9e9Xl3AndL+avzybOyZWZ7n+ZiAbBfr+ml+bk2LZhyg/kt74gXE6fZqaZajY/ooMB/Yrgc2FAPEWha6cgr7krKakfwwv1dPD/GtW/U82cNOecpbcouwf4H7cKynKZNTmwofcZTRDqXAdVRjyzp5ur8PvP9aU2rGwBCn7aMeFIitvxNZtIUvz3z9WEdP88REtVrM8+nZx5IJG3Suwy9FGuQsli2LBmu44l2JULi/aY5LzH6Ei5oIzWjdK9vcDzzyqrJLL3nejGkDtFCbXPH1u7gbYyEW+1TlYwksTCbXea6MK2mCW3AIBLCTd/WswFOVtsPpoBJIWiw2lojtkoDXPOwK1O/JVPnn0y3tZfMM5sEUFLr 8TJuY8jA vvbkZ3RrXDBWLovSyn74vOSAjc6jBckBcdvGnC1mfODGNqfpTLTDl9BLrQ7FDJ7cJiBM/XDSjhBsl2FJzEHEp3DppNuuMJjKg67gIG8xIEHZqYWWmj9iYcE7VT76N06lu4tr3p5SqcnYEWtyhvbCMgR0He5XexqpeuHrD8d/jZ4KG06RT+MFZqWP7Np+fzChbOLjm5tcW2DNu5onAiTWnRThvxPiImTNq8wJI 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: invalidate_inode_page() does very little beyond calling mapping_evict_folio(). Move the check for mapping being NULL into mapping_evict_folio() and make it available to the rest of the MM for use in the next few patches. Signed-off-by: Matthew Wilcox (Oracle) --- mm/internal.h | 1 + mm/truncate.c | 33 ++++++++++++++++----------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index b61034bd50f5..687d89d317d0 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -138,6 +138,7 @@ void filemap_free_folio(struct address_space *mapping, struct folio *folio); int truncate_inode_folio(struct address_space *mapping, struct folio *folio); bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end); +long mapping_evict_folio(struct address_space *mapping, struct folio *folio); long invalidate_inode_page(struct page *page); unsigned long mapping_try_invalidate(struct address_space *mapping, pgoff_t start, pgoff_t end, unsigned long *nr_failed); diff --git a/mm/truncate.c b/mm/truncate.c index 8e3aa9e8618e..1d516e51e29d 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -266,9 +266,22 @@ int generic_error_remove_page(struct address_space *mapping, struct page *page) } EXPORT_SYMBOL(generic_error_remove_page); -static long mapping_evict_folio(struct address_space *mapping, - struct folio *folio) +/** + * mapping_evict_folio() - Remove an unused folio from the page-cache. + * @mapping: The mapping this folio belongs to. + * @folio: The folio to remove. + * + * Safely remove one folio from the page cache. + * It only drops clean, unused folios. + * + * Context: Folio must be locked. + * Return: The number of pages successfully removed. + */ +long mapping_evict_folio(struct address_space *mapping, struct folio *folio) { + /* The page may have been truncated before it was locked */ + if (!mapping) + return 0; if (folio_test_dirty(folio) || folio_test_writeback(folio)) return 0; /* The refcount will be elevated if any page in the folio is mapped */ @@ -281,25 +294,11 @@ static long mapping_evict_folio(struct address_space *mapping, return remove_mapping(mapping, folio); } -/** - * invalidate_inode_page() - Remove an unused page from the pagecache. - * @page: The page to remove. - * - * Safely invalidate one page from its pagecache mapping. - * It only drops clean, unused pages. - * - * Context: Page must be locked. - * Return: The number of pages successfully removed. - */ long invalidate_inode_page(struct page *page) { struct folio *folio = page_folio(page); - struct address_space *mapping = folio_mapping(folio); - /* The page may have been truncated before it was locked */ - if (!mapping) - return 0; - return mapping_evict_folio(mapping, folio); + return mapping_evict_folio(folio_mapping(folio), folio); } /** From patchwork Wed Nov 8 18:28:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13450385 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 06587C4332F for ; Wed, 8 Nov 2023 18:28:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 902B78D00C5; Wed, 8 Nov 2023 13:28:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B27E8D00C3; Wed, 8 Nov 2023 13:28:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77A748D00C5; Wed, 8 Nov 2023 13:28:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 6A35E8D00C3 for ; Wed, 8 Nov 2023 13:28:28 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2243716024D for ; Wed, 8 Nov 2023 18:28:28 +0000 (UTC) X-FDA: 81435622296.19.69BE9AD Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf29.hostedemail.com (Postfix) with ESMTP id 7E505120011 for ; Wed, 8 Nov 2023 18:28:26 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=vbaruzZi; 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=1699468106; 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=Hh7iR22H/bMBGg1WTep51qz0ES5l/FVjx1m1RYU2PfQ=; b=wI80cmjYAGCpLzNdHSbVak/dSOdKRjOSI0IX4eKUlcCwYJnAGs6ZIX1pOtbpHLKEGG+JUB e4qsTKxNq9/siY3P39+99Bkm1MFU4tFZU7pLCV4D+toEmdf+V3Q9B9KtCIs7mbPmKuWjTK s4AGHmxeWaYHVDWoiJTsz3qunFI2Vns= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699468106; a=rsa-sha256; cv=none; b=P0HPMYv9BjPB/1TzIv5ynQdN+JYbei18s1GCty/vWBsXx6uGRvhpIUdegFpU7ohk7usP1e Z6s6tHvmvKuMCg2JVGwEt/poSNa6v7nurMBdYA7tty/Qx59lm4CdE0xXQys7uqFhI+GfGx ttLijerSNrvkMOsbx8eFE8hgiTjfHfk= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=vbaruzZi; 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 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=Hh7iR22H/bMBGg1WTep51qz0ES5l/FVjx1m1RYU2PfQ=; b=vbaruzZi/nRV0eD5bIifbhL48M lrsEFUNwWq7APBHxiX/omLWGhaMszAff2PpF8eYHbnXmrIvbDx1WWo5yq0yCn6qTLK0Utd+fLTWax a5Y7SkOOj83Jpdw2Ndn7xGpTVs5z+KNqqpjHV9bChnAavQP9fL/xf9DdIjgWfcgT00+LpWfkImjz1 C8jiymDHrQ8luWORDfZL9iisCP3FUwGIeXWi0kJNQjzYEOJ700dDpPNmS+53X/yfm9GfNxM+u1ZeN 8vWwmtyUZll+1thVFzvLzBLj7V1bUQtxdpECKQfXJI4VztC/c87t1OGEctUFM/Z4cNQkhCizbO1Ot ImvwbaxQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r0nHf-002WdI-1E; Wed, 08 Nov 2023 18:28:11 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , Naoya Horiguchi , linux-mm@kvack.org, stable@vger.kernel.org Subject: [PATCH 2/6] mm: Convert __do_fault() to use a folio Date: Wed, 8 Nov 2023 18:28:05 +0000 Message-Id: <20231108182809.602073-3-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231108182809.602073-1-willy@infradead.org> References: <20231108182809.602073-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7E505120011 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: iydxk91yc4p6s5awqehm6gi5xgr6k6kb X-HE-Tag: 1699468106-792278 X-HE-Meta: U2FsdGVkX19mRkplHPYEIJkOsO6qAlFRtG4ZrYZ0DuPQ7LZ0lsX1n75mqbhqeMw1rrIe6lqFvS6OD/lE/b5qjRWamsYDXD+PkYlxF0uT+9c+/95m/+tnoIgdLINdaEyjmE1LdLKl/dRlbiqem3WQwf7Gca6UiyQSfcHIkDHOtLGq26t7lCmfiG46zSGLCX8AUiSKWiTPI8xY2SvJxrnEkHDGvAQBp7HVtg4tn2HYBBU3obauVh3Efu1sF1hww+5Po5SkP0cFrnpQaoCgxMTgTZKB/m7LvvvZlbKqSomNt1/+n/CjljjrvKZC3pe106XxNha/HvldAMBwUml0Cojv71yJQiu880k3ulSlBYykKKgzw8R4DHBYED1CxCSmA9fO54Y/N7MYA2Bk39ovQiHbHGgX8/TZZrd3cpdnJyjppnmWVSwom0F1RAt/jbmoiCy1taIeqH08ofYZeDln7h7TJH6d90WNL/fyCaYPvyzx+8Z5ZE75FvyxCw4qvAcjBZ4FVCmnTmkEppYUushAG5MX2jb5kQ2+E2u9htGKkwxsFjZ7vcSG4yRWmMgkrWQzUJW/ZD9r4e+/aF8r1udEs4Qp8z/EAj75yi1UZqtAKTGwtS+RX9fKsYjR4RBFF+0ryfvpHwyhkEACn7DR/874jysNCI0ks3nVP9wakolOmOuJa91hEmaHlX4ZyBPG7x9R03Ix1Dg94wUFcH4ES59PIR6uOpmo0ha12izKvZWw/g1YfLt9gYukb0ap5NXtsVLJYbzufik0XDGU0ru75c/NkEjBGKOuACrofZQZ/xEKNpmNnhHkLDtlWWm0hJRCPo3w1EFyzjd4P6URSOyhn8BUDvkd985cY4t1AEwbXiiCa0r3ACKPJcoh+oMFVXafjTKXyZ5N9PXDBvzvVDBKrEWaOwZLixA1uJ5x6Tekuxfx8K8lc9bfjg5xJR+/mZx02i5Eg9jV7mz0zXbMbA1J42w+U76 7IO7Z5vD mcRzdUIdv21JYc7vCcktsy+lK8vNoLhvukSbrppZDjHGFgAZeub03M1lu8Ow9eO9+diiLWU1ulIEBr4Z9lqo4PVLLeyjmLB6L9IHBZ+AXEU37jh3aC8nZ2ViViuTLVQhKWcHD+rHtek/58c+oOYwvp169D0VB+Ck0JN6worUHkQDfH+Hmkv9Mjg/5riqboYNvzE1h2OZySA8cIg1u4aDgUY75YVvaTN9VXyzcadbT37i5RatLBGvMiaA9rtX5+K1lqGcsTByMlFNfTS5heV016hBHyUX4Wd2A/LXl 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: Convert vmf->page to a folio as soon as we're going to use it. This fixes a bug if the fault handler returns a tail page with hardware poison; tail pages have an invalid page->index, so we would fail to unmap the page from the page tables. We actually have to unmap the entire folio (or mapping_evict_folio() will fail), so use unmap_mapping_folio() instead. This also saves various calls to compound_head() hidden in lock_page(), put_page(), etc. Signed-off-by: Matthew Wilcox (Oracle) Fixes: 793917d997df ("mm/readahead: Add large folio readahead") Cc: stable@vger.kernel.org --- mm/memory.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 1f18ed4a5497..c2ee303ba6b3 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4239,6 +4239,7 @@ static vm_fault_t do_anonymous_page(struct vm_fault *vmf) static vm_fault_t __do_fault(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; + struct folio *folio; vm_fault_t ret; /* @@ -4267,27 +4268,26 @@ static vm_fault_t __do_fault(struct vm_fault *vmf) VM_FAULT_DONE_COW))) return ret; + folio = page_folio(vmf->page); if (unlikely(PageHWPoison(vmf->page))) { - struct page *page = vmf->page; vm_fault_t poisonret = VM_FAULT_HWPOISON; if (ret & VM_FAULT_LOCKED) { - if (page_mapped(page)) - unmap_mapping_pages(page_mapping(page), - page->index, 1, false); - /* Retry if a clean page was removed from the cache. */ - if (invalidate_inode_page(page)) + if (page_mapped(vmf->page)) + unmap_mapping_folio(folio); + /* Retry if a clean folio was removed from the cache. */ + if (mapping_evict_folio(folio->mapping, folio)) poisonret = VM_FAULT_NOPAGE; - unlock_page(page); + folio_unlock(folio); } - put_page(page); + folio_put(folio); vmf->page = NULL; return poisonret; } if (unlikely(!(ret & VM_FAULT_LOCKED))) - lock_page(vmf->page); + folio_lock(folio); else - VM_BUG_ON_PAGE(!PageLocked(vmf->page), vmf->page); + VM_BUG_ON_PAGE(!folio_test_locked(folio), vmf->page); return ret; } From patchwork Wed Nov 8 18:28:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13450382 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 4A8EEC4332F for ; Wed, 8 Nov 2023 18:28:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 817B78D00C2; Wed, 8 Nov 2023 13:28:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C7F78D0073; Wed, 8 Nov 2023 13:28:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6906A8D00C2; Wed, 8 Nov 2023 13:28:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 558508D0073 for ; Wed, 8 Nov 2023 13:28:20 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2B45D80442 for ; Wed, 8 Nov 2023 18:28:20 +0000 (UTC) X-FDA: 81435621960.28.B9A2DFE Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf30.hostedemail.com (Postfix) with ESMTP id 5D68380025 for ; Wed, 8 Nov 2023 18:28:16 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=R3yxSlyq; spf=none (imf30.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=1699468098; 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=nKQ7Bn5WXdb5w70KcBh9auGo0P3KFj8JXeXSo8T8LYs=; b=jYrSqL0NZPcxloUx5ZYAXXcpC66qH6/uIfiHVq/YNutTult7GptRp/8INUJep3+PN0StrT W8kutcPd9N5r8gyCJjhHVFnpKm+Mqvq6A4ugQ2cnSp0v6DiGVIEE40aTVLoztk0PeK/dHt iw6w0dKAM3Z6S7FsbX/d8vsdB499LFs= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=R3yxSlyq; spf=none (imf30.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=1699468098; a=rsa-sha256; cv=none; b=IlDVL6T2yOiB8qyokrAAzhoirA7Oanna529rVM6tA//FIqHvc8s+NPrCpfqEQCb+a6YDyR D6R4Hw1387F9I9lpQ3mWVaIyBRCsb1kK5dQYz7gV0QFOkTPStss6a5dSoOQPRdT2LFg6SL AECANngwd0kaYJa5WxTnNExWtAVRJLs= 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=nKQ7Bn5WXdb5w70KcBh9auGo0P3KFj8JXeXSo8T8LYs=; b=R3yxSlyqS8iNOg9n2SRGPjum9p //nxbgsGM+1HtpS1x/LFpeDo8MkqicXUNJj9yN7VRWKanozAtWurYGpn2d5rREIBm35x94z2WjXYn UuonLQo0IEJ7IUkx/cAtP+Cv419tiYde7ST1AZOO5YHXr7Bz5C12xdNqaZ4YhGXmOAvWRNVRaGtSw afNXCs9miAltzZ0Ss4vKPgu3pqp0BiglLxkLX+zUmLvhRRmlQSMZtVI1eqpR07/CthWb2V8GdgUpZ XudhdnmFRFRNMezrNBwfvkZbd9BQE5dtpXx9NDksQ3qctKkk02LZEZtwMhfbfeL3rOmR6c2lfxf1o H6E1dTHQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r0nHf-002WdK-3w; Wed, 08 Nov 2023 18:28:11 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , Naoya Horiguchi , linux-mm@kvack.org Subject: [PATCH 3/6] mm: Use mapping_evict_folio() in truncate_error_page() Date: Wed, 8 Nov 2023 18:28:06 +0000 Message-Id: <20231108182809.602073-4-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231108182809.602073-1-willy@infradead.org> References: <20231108182809.602073-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5D68380025 X-Rspam-User: X-Stat-Signature: i7wa7mr94xo7ohe1nek11yqkgtichmgc X-Rspamd-Server: rspam01 X-HE-Tag: 1699468096-18402 X-HE-Meta: U2FsdGVkX1/MVohcnavZM6s/4f5BMbg3+Q4CXki46OIy6cKs6VKOAoZCQVhCpX8ZsBTSmKpfs2iCF64Z3DqKgu2s2TOwfYLCsWN3IBOnqWllNxeA2ALUa2fjvP8WSV7Bdc8iOSRVW2H4S3mDsyNglibFeyQxV50E/XsXIEgUeBNDJl9iUyfc/k0Cxr5W61Nvk4aBTUNsdf4tD8Kf/JZOXO/mri+04OvFNROT9fN9mf4D3YaMr97d+vwcL9Xxt9/gFrjcbPDl3m80HxqCTK/qWa0Ss8z1lIVTx+lxx/nyJWJGX/7zRIHWbfu8DWKS7HEA68UGmvY394KVP0EZHvTw1V8UCDfXeNZvRC5evlX/c7UL+b1A/oIV/AkgXa02hhTu0j5bcDnoSPcQCm1Y1xpVTY8rGVE5qrJx4pQJ3F+1NZAd5eRkkJzp3n8Nlsc+vu/ha0Dq5KzKfcx3Cs1cFwHxrfqfkoou1Ao1XN3uhEp5WvdJShDZWF6QmU1xDCLDfuzEqECMYf+sGtV2kAMWdMfz2EI8vV30+yPjNea3CwScdyxLT+Hfj+zTKDUNh+gUi2TMjSrIAtSUqkYe6PfJ/ikkbWP8QRZAOcgkyv7+Mq3GhvCgBODxz8TecXs80G5v4TCuE/X0wHHWdcUPuhzyrqzZ/f/KmT6xCwYjnSghWgMENDLHsAFnu8rk7J6Lyb92rrYwFweGGL4L0qT7j6+P0I1a+vKQ87o5E65y17gIyO9JrRGu30jnYyY9J9JOKs4YrITlX3qDUf+JMsy0iUbfgnvoSWGc39gYlj5TcYTjN4E+Hre8p/JJ9EIQWYHn7sKkM7aUfgCS9sEEMLCBzU2lLG2nLCoRHL7KKg52EEeMaLoGUp1Yn5zMvpfd7s6LP4/dcWn+qWfFzdKhqkjH2nvyYfot6lICBb4sMGTIBTnuA81/22OYsad2njb6cP5qXkU97Ya9xHBt8tKKyErHRje4tif 6clV3iZm OmHdDizzowj0/0kZAOJ6xmbWSyK/zK0Or3V3uKmCqOE0gFV2CZTf6wAtlTcaidhM/Qdqe0ElEGzMkmPaIVpLEbfSUwh0u1UlYC75Au+IRwfstKQaz4rjJh9ugjLXN7lMs+eLEw9MnzE8Ke32KVikiTj5PN7nzb38tHWg4fcrW2ARn+Q7YPw4r5MrPMknOPX3mD1KBfhSzHmGNgBRRqMOTRGWKBgZJ+VykNceV 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: We already have the folio and the mapping, so replace the call to invalidate_inode_page() with mapping_evict_folio(). Signed-off-by: Matthew Wilcox (Oracle) --- mm/memory-failure.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 660c21859118..9f03952e6d38 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -930,10 +930,10 @@ static int delete_from_lru_cache(struct page *p) static int truncate_error_page(struct page *p, unsigned long pfn, struct address_space *mapping) { + struct folio *folio = page_folio(p); int ret = MF_FAILED; if (mapping->a_ops->error_remove_page) { - struct folio *folio = page_folio(p); int err = mapping->a_ops->error_remove_page(mapping, p); if (err != 0) @@ -947,7 +947,7 @@ static int truncate_error_page(struct page *p, unsigned long pfn, * If the file system doesn't support it just invalidate * This fails on dirty or anything with private pages */ - if (invalidate_inode_page(p)) + if (mapping_evict_folio(mapping, folio)) ret = MF_RECOVERED; else pr_info("%#lx: Failed to invalidate\n", pfn); From patchwork Wed Nov 8 18:28:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13450396 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 2B1CAC4332F for ; Wed, 8 Nov 2023 18:52:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B7FCD8D00C2; Wed, 8 Nov 2023 13:52:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B2EF58D0073; Wed, 8 Nov 2023 13:52:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F7018D00C2; Wed, 8 Nov 2023 13:52:48 -0500 (EST) 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 8D4258D0073 for ; Wed, 8 Nov 2023 13:52:48 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5BE7B1A024C for ; Wed, 8 Nov 2023 18:52:48 +0000 (UTC) X-FDA: 81435683616.19.E2E82CA Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf12.hostedemail.com (Postfix) with ESMTP id 7C16C40008 for ; Wed, 8 Nov 2023 18:52:46 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="lKP+/XUt"; spf=none (imf12.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=1699469566; 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=mDiDP2KsUBzpXJBl1Xti/F7ebJjZlXXgCNE5nV8XnZ0=; b=VDQ6nvfMWkLfJDaGF0HExgM6LSo4dgidVdEZNLoZtqZX3H7aXY3YA7s5oPbgWQijQt7okt oCM6cnMuVC2kL8nVVqcLf32hk3e4dKb+8XKn4Gv6WNZbD0mni+VkpvYRbfKBZD/nPmtENm CDQc0dwuF8jaKsgw/eCii2fmOqIbCj0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699469566; a=rsa-sha256; cv=none; b=tMYcOMkDLwGGauFd81p/5/UlLDKjWOQqO3pYHOk9NmTRi5BW+J8AiHfLQdlaZWSmYSAVAm ooiU1ZkXkcK90iqFwdHAhvImi9jVVbz1mc6ZC6t06NK2PlYVCx5Szrva7sEPLb7Afpuq/p wSetEFbN8HslTEOGFvvD3HIq5S1iAyc= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="lKP+/XUt"; spf=none (imf12.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=mDiDP2KsUBzpXJBl1Xti/F7ebJjZlXXgCNE5nV8XnZ0=; b=lKP+/XUt2XF46zMsGV+bu8I6Dn ZH7gXPibDXs3OhPWrX2tjRUNGv2wjMQynQhhbs/OhcBG9pHdScIXJt0sT6zul2m90KqsLjgWudezw WQNEV+2o8yXeEVGBYrOwUmqzUc5xJuTSQdkTUf/RacR4y40KS3iUkzBlC/4fpuHKkziuabKlgcQDb zxWSw8dXi9lwh3NGB6yLAIhvFJA88F1mAhjV3A44ITeu0NlGlLO4DQdb6eb8CVPO3BWZKya/oNE1V HjrU5qdCgI0g6fsSgyVceZTTR+DDu9dxahx8t9wMPwXc9h98k257okbR3mUc+eNa3W5EeBh+NwxlK Z/O8Qdwg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r0nHf-002WdM-6g; Wed, 08 Nov 2023 18:28:11 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , Naoya Horiguchi , linux-mm@kvack.org Subject: [PATCH 4/6] mm: Convert soft_offline_in_use_page() to use a folio Date: Wed, 8 Nov 2023 18:28:07 +0000 Message-Id: <20231108182809.602073-5-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231108182809.602073-1-willy@infradead.org> References: <20231108182809.602073-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7C16C40008 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 3pbwsmhb37smppfwx4sdapiniha1aczj X-HE-Tag: 1699469566-511575 X-HE-Meta: U2FsdGVkX1/UWZkw/wKsHVM8rrwS/hEUEogeWu9TgJqIReSDo6q2lF5usWiciiFyl5vlRxPdLxQinhQ6fBPDUypfDWVn9U/O8VWI5hbkOHbowPjlMWjGFgOGJVGHLATd9YwVWPSPpPUOwY4yebuFjGBUneFOCEhNvkwM8CvNaPsYOHWDscqF3YmMwMKXKVTknJ4Oqm8m3PWyWzgmsQzmhYB2kFtZiCyxu+6C23gz0Xy7G28JDKKvwHwgXj4gMLzItfyA5E2I0fNh4lSEI1Cdrxp728JPPq7lFNsY8ZI0QLISXbr6cRbnGM5aHQkfvtGX2FubzEMIbGYZ6amEo64R4o4tpgvOOtUOSZaeGrMzITnjFmIMuzp/a3d3HmyeEuAC/jM2WPRoji+tNYYxa541XgY9HXA3KGIglHC3T4Ie/edK3H/0vEkhy/WEkKHeaOsGH5fJaO51zjguKBR5mwegoIxQGYh6DFaM49frhcfrmb/PUChRy1GXUTM1oXxIciEWmZOvLksFqsaoK0b6wxnD1GWqqhcOT6fvB5BeKMvaYwSfHDD+h5afqbwOnLJ9HzcfKq28dz+ZzzEt6NEh3iCQs2wWQ/QP1ZEuP+cefRgZTbzhFevt87cInwGOTqGy+mJ45qSY/Ih3J/NT/GSesc+WbHEkxxab+Za7B1PgJ3XDEjV71IHm6Rf286NsD9HGDx2h7jDL5Jxa3S85bXLb29pSu6KvF/HeeeiOO6aPVBkwOpK3ULJSx78QLqNS6+TqtPPFgmHdfczPtaNnrBjJUcXhwGBNTQRW7Vi+gKDJ8V66ZLQoAwS9PLe43XVlfavZCr+4PMvgNcu5zDGWpeJ+sNh9yA7mMa+jBOQSemtgJbIgJlquRIKYJg4BJWQw0IBFIztmShKkxeIUx93xSEkCsrNhP/YyloJGY4YZLX2DS/qDpdKqu667gLoOTOrm7iWK9gs/pQwv5jCiT3uSUm4+o/m /kBodFdx K8GjFlwhdzi8HbiUTGtWn2tqAxDETha3T0xv9gVVsCu2Q4inkQLqgHBXSDk1FHJJY9Hq6RpN3RB3eubj0y/jWauv9sD8WEB5PMv1CKi7HKkSZAm07ih0HPLOmgi8AupnUcvtqS+4xLNkJNEyd6god6F6b8sy7GgzJVbUbSkHOcgJFAPHF9WHVKXwUIerGqkvhXGeoiPYL4ZitlkSkmEnw00Zw1tnKgBX+cM9X 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: Replace the existing head-page logic with folio logic. Signed-off-by: Matthew Wilcox (Oracle) --- mm/memory-failure.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 9f03952e6d38..075db5b5ad5e 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2645,40 +2645,40 @@ static int soft_offline_in_use_page(struct page *page) { long ret = 0; unsigned long pfn = page_to_pfn(page); - struct page *hpage = compound_head(page); + struct folio *folio = page_folio(page); char const *msg_page[] = {"page", "hugepage"}; - bool huge = PageHuge(page); + bool huge = folio_test_hugetlb(folio); LIST_HEAD(pagelist); struct migration_target_control mtc = { .nid = NUMA_NO_NODE, .gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_RETRY_MAYFAIL, }; - if (!huge && PageTransHuge(hpage)) { + if (!huge && folio_test_large(folio)) { if (try_to_split_thp_page(page)) { pr_info("soft offline: %#lx: thp split failed\n", pfn); return -EBUSY; } - hpage = page; + folio = page_folio(page); } - lock_page(page); + folio_lock(folio); if (!huge) - wait_on_page_writeback(page); + folio_wait_writeback(folio); if (PageHWPoison(page)) { - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); pr_info("soft offline: %#lx page already poisoned\n", pfn); return 0; } - if (!huge && PageLRU(page) && !PageSwapCache(page)) + if (!huge && folio_test_lru(folio) && !folio_test_swapcache(folio)) /* * Try to invalidate first. This should work for * non dirty unmapped page cache pages. */ - ret = invalidate_inode_page(page); - unlock_page(page); + ret = mapping_evict_folio(folio_mapping(folio), folio); + folio_unlock(folio); if (ret) { pr_info("soft_offline: %#lx: invalidated\n", pfn); @@ -2686,7 +2686,7 @@ static int soft_offline_in_use_page(struct page *page) return 0; } - if (isolate_page(hpage, &pagelist)) { + if (isolate_page(&folio->page, &pagelist)) { ret = migrate_pages(&pagelist, alloc_migration_target, NULL, (unsigned long)&mtc, MIGRATE_SYNC, MR_MEMORY_FAILURE, NULL); if (!ret) { From patchwork Wed Nov 8 18:28:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13450384 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 270E6C4332F for ; Wed, 8 Nov 2023 18:28:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B4D5B8D00C4; Wed, 8 Nov 2023 13:28:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AFE508D00C3; Wed, 8 Nov 2023 13:28:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9EBFD8D00C4; Wed, 8 Nov 2023 13:28:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 8B7968D00C3 for ; Wed, 8 Nov 2023 13:28:24 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 66EB2120828 for ; Wed, 8 Nov 2023 18:28:24 +0000 (UTC) X-FDA: 81435622128.22.C1342F3 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id C01A6160013 for ; Wed, 8 Nov 2023 18:28:22 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Uvtp+7HH; 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=1699468102; 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=g8GMweT2pb7sSQ9GkAahwtsiRNczuYXJqyztMvUJVOY=; b=xo9zTUh+oisGuClauR/apECEhX+mMmo1FNjy4DHr5OXWk42kgT0iCv1Ad/oK1wJmFhzB9P M4masuk4dt6DzYllOMpxeBP8evNBnB8paEbOBW44E8+8QIzHkp5mjfnv9EBLfU8pcn1BH/ sAMn1BhIiVvsndCUD5jS+QFJkwMpIE8= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Uvtp+7HH; 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=1699468102; a=rsa-sha256; cv=none; b=jKp/EO1d36msuOsLIT8rYzstb0I0J29O5p0lRTWTVtYvjER0EwQ2t9+Y57K3zoji63ujBP vl9HSbJe5ESwTjrzwotKrZ9H8Yc59ZLIR0I5hybOQCIqygbJorKdtGqbmhnT0/EneXLMsn G07+ddlMiQ0+Vrn7dQZ8Ka9q7kfjJc4= 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=g8GMweT2pb7sSQ9GkAahwtsiRNczuYXJqyztMvUJVOY=; b=Uvtp+7HHEiKQ2dFqdKeJ9zHTyi DFA91bYvj2Yz3JT0UI2x0qZrvRrHAwPGPdpOS8damwLsx2ZWnR/ZcOq4UHH8NIcTsqi0uf4HWYuYZ W9+lWhRcx2NQK5QtYSb45+GHCWLBbtqPmqw4SmHvfanQiRK1B+QIlACw5czCPpXfze0N6cY6Uc3w4 LRcItC26Z0lIf4D4c+zC5hlIm/q9HK9zqNOxLlM0Q+1vE/pJmKVFgxT2nY2VqIc9y8Ptt0LlGswpt GA7T0bDTeZfI3ou1xrsGAe0IaomoL7EvloXC6S5BsfkSBd4Kt81VwfwjPxt368o5OkVCeiArNyFZQ 699CDiJA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r0nHf-002WdO-9I; Wed, 08 Nov 2023 18:28:11 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , Naoya Horiguchi , linux-mm@kvack.org Subject: [PATCH 5/6] mm: Convert isolate_page() to mf_isolate_folio() Date: Wed, 8 Nov 2023 18:28:08 +0000 Message-Id: <20231108182809.602073-6-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231108182809.602073-1-willy@infradead.org> References: <20231108182809.602073-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: C01A6160013 X-Stat-Signature: zdkmthsemzk6jjp6h3ar6wu76yyb5zrt X-Rspam-User: X-HE-Tag: 1699468102-135383 X-HE-Meta: U2FsdGVkX199Jm4Bn//VSFYKIMd3Lba5YclHzb2K++v1WtBpniANnr+VPVhRfesQerlfSN2qggI0zZcEFzknYmcJLSUWxLD+MHu8fASMl9ao8kp4Afet/12s2oG8WZ/6pMOMKML2xEgLpvMW5Cfq4NbSru7wtlrH/LdTdNGb7Giyhu+Pz9d0+8nUpRcnu2JJWzoXmejuZ4AC2xLCezjz29Vv1vGuM3Kms9KsotnD22AvvyyoMbprPz0IM/rF0x4GmBTUF9115Cbk8ywaxjmDC0SRtXT6cAsGoAjJbPCOiTJN4t0oa1IZjPjrwm+SJwzpdWuztf4h+gm75M36Wi21FRU+r3j8wsH9zglutAYLKSbXp42n/IFGH8aKTXxTSnao+t0hBBMVJLnQVPQetHGvGbx0+f+bpTHxDfPMwhXR1k8lupMb/JjJWyeU2EAQ5emuiRwzYu90Tt39leasgkl9wNXRXd2t5aoLy6/YabO+ySTTkJJEDLKGZJWMcitpUZSEAc27/Hcaxt4X/EJr43YQ4GoHoy53DMbeI8FjfV7j73D7Ouii0Vp9rlQkXc1kldTnCOPNCFHFebXLc5C0Ae6cBdXmaw86IhXVriQuAvm0Rte8jWWIXiDB9bdFRsWM1E2xe2ppah6MTcV4CPQPFR+HqI/grjWkCuy01ROZufmNkMphSVC9EsIRo38GGqWnVb+JUrinoyT98r/dvEvLO7NxEbKJYutoz3CfnazvLupr8BAtD5hhew/gE7d0s7UgCwZ5tX7HnBfekEOQpGlK/vUZoGycOMthTSyjba318l3GdRQUWud6sehgux+RCaWf0MreN68+Uxzcf+APBO4ZsclNiXmWSkC5Syb+Xk2PBPD/LbmMmu72zzJellclWviiUGZ0RG5GZtzIpUn5CZ8LAQ3DDXgYcn2rW2BnLF3JhaPZ1PVa6pfDqaxJD+C1n+527kzXRmgU7bGEfbh9pJ7PVm8 gcsVPzpY QU77a169Regq2QQ3U2zogQv/Id7uZYOtfA9X7IYY6My/2pQ9YyTjAhE5aRnlLSqBwj7dK7qC/ZawJGd01cGqaPrDDHCbq4MI85IfdaXheOZh6Y/rnwVKch0SjrdQkuWU5Ip69tbCFT3L745urtz794Bzm6ScoGfzqEclkKKBb1Se/1vwy0PKBaNdRtCE3ilWuZBcQN8YjrATa8HafTUfJWnQIdsQgaAkCYG8z 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 caller now has a folio, so pass it in and operate on it. Saves many page->folio conversions and introduces only one folio->page conversion when calling isolate_movable_page(). Signed-off-by: Matthew Wilcox (Oracle) --- mm/memory-failure.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 075db5b5ad5e..b601f59ed062 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2602,37 +2602,37 @@ int unpoison_memory(unsigned long pfn) } EXPORT_SYMBOL(unpoison_memory); -static bool isolate_page(struct page *page, struct list_head *pagelist) +static bool mf_isolate_folio(struct folio *folio, struct list_head *pagelist) { bool isolated = false; - if (PageHuge(page)) { - isolated = isolate_hugetlb(page_folio(page), pagelist); + if (folio_test_hugetlb(folio)) { + isolated = isolate_hugetlb(folio, pagelist); } else { - bool lru = !__PageMovable(page); + bool lru = !__folio_test_movable(folio); if (lru) - isolated = isolate_lru_page(page); + isolated = folio_isolate_lru(folio); else - isolated = isolate_movable_page(page, + isolated = isolate_movable_page(&folio->page, ISOLATE_UNEVICTABLE); if (isolated) { - list_add(&page->lru, pagelist); + list_add(&folio->lru, pagelist); if (lru) - inc_node_page_state(page, NR_ISOLATED_ANON + - page_is_file_lru(page)); + node_stat_add_folio(folio, NR_ISOLATED_ANON + + folio_is_file_lru(folio)); } } /* - * If we succeed to isolate the page, we grabbed another refcount on - * the page, so we can safely drop the one we got from get_any_page(). - * If we failed to isolate the page, it means that we cannot go further + * If we succeed to isolate the folio, we grabbed another refcount on + * the folio, so we can safely drop the one we got from get_any_page(). + * If we failed to isolate the folio, it means that we cannot go further * and we will return an error, so drop the reference we got from * get_any_page() as well. */ - put_page(page); + folio_put(folio); return isolated; } @@ -2686,7 +2686,7 @@ static int soft_offline_in_use_page(struct page *page) return 0; } - if (isolate_page(&folio->page, &pagelist)) { + if (mf_isolate_folio(folio, &pagelist)) { ret = migrate_pages(&pagelist, alloc_migration_target, NULL, (unsigned long)&mtc, MIGRATE_SYNC, MR_MEMORY_FAILURE, NULL); if (!ret) { From patchwork Wed Nov 8 18:28:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13450386 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 0B725C4167D for ; Wed, 8 Nov 2023 18:28:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 99E778D00C6; Wed, 8 Nov 2023 13:28:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 94ECF8D00C3; Wed, 8 Nov 2023 13:28:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EFA48D00C6; Wed, 8 Nov 2023 13:28:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 7126C8D00C3 for ; Wed, 8 Nov 2023 13:28:33 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4C461804BF for ; Wed, 8 Nov 2023 18:28:33 +0000 (UTC) X-FDA: 81435622506.04.86E8E31 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf29.hostedemail.com (Postfix) with ESMTP id 3382512001B for ; Wed, 8 Nov 2023 18:28:30 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=aDoiH7YL; dmarc=none; 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699468111; 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=ge2YEmHJGHGEQpMO5GGjXgZSkkH9dVGDapYpajDMgdw=; b=mMqfEpbKHEtajeVfJqnTCtBPl5tSUHkRjfTuhgH6ow5mf1r5Q0BzJ9wg14bWEIb1YUu9LS fqk4ojj1pV5Eg9Pn33tvwitG1fWsQNjftTz+sL6gl9aLiHx6Vl64ATDynre6ISHdxggjkQ h6LGRNwkI7iNX/U7fYFaiVCY6aaFeb0= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=aDoiH7YL; dmarc=none; 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699468111; a=rsa-sha256; cv=none; b=slFJeVcA8eN5Lupm4kfHGdkCvuuWbkKOyl4MiNwcQY0n0k3XKotbiKWj/GcgPr7AQ8G1FG Kw03VYljuFYiYK210pMnCCl11L7gJlqum1t880MvPcq0hynG+CB1SOBKk2p7zne91Hf/XU Nzm7ZiV5wk1S5+t6EGJY41VwmFN+bik= 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=ge2YEmHJGHGEQpMO5GGjXgZSkkH9dVGDapYpajDMgdw=; b=aDoiH7YLhue1Nexe31uEEZyfyo EetNsAeMZd+0zQWLt9CU0+7UOQpKbvm+bGiM+hEHNoMcyBW67xaiUhhP5L4rz0jCYbh1ghbVJja48 b/a6HyvzGsth+7grDkj6Q9FPnc/D8ayDpbrt90+WbEI3fZE4Fc5aasKUqQMfdrsSnstQ/94z/+X5A 6yeRDk5pGHYPFmMNpgo9marnrmAvwn+YO47uXeK024NJoaAXN5y1Toc9PGa148Ky4WcXd6SfRIBVi vuNj/KlJMQpgrjby2aSPnQEyFLpg405UmUtdjdQPhvsO/W0lWm/rs/F7E+NtmjdFJFqrlrLxjpsGy 7bSEV4Pg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r0nHf-002WdQ-C3; Wed, 08 Nov 2023 18:28:11 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , Naoya Horiguchi , linux-mm@kvack.org Subject: [PATCH 6/6] mm: Remove invalidate_inode_page() Date: Wed, 8 Nov 2023 18:28:09 +0000 Message-Id: <20231108182809.602073-7-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231108182809.602073-1-willy@infradead.org> References: <20231108182809.602073-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 3382512001B X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: wwrh5icixfhjq66hqfkkbiwe3zonxigk X-HE-Tag: 1699468110-294953 X-HE-Meta: U2FsdGVkX19H3eiX2fRNkf6ztLAtl3jMMhOWEWFA6OFnFXXBi8ihJyNGPspiRN6QFKnxXPdgfxuCzTPJsgJ7ZrmIjWckNvZODTcuOq4droSl9dYaHul5MLbVG5HueJ1nl0wToyMZ1AtOemCNUcEmUD+P68DPM7YdVEEaWDArc7Ra+sq9m0XiEyeO0lr+nYH6YHxLnhO+mJGqPzdEk+r3q5+gi1QoOUoBn6A9xKGkfTk/xpFRVwOd+zRahl5j9swo/gY0pAxr4ECTy9xZpECHjVnWPXphNB49URdcmqq9edOvGIwsBZLNGHqOxzegk0bG0HQpYe6v/cCWFXuzF/5TVeQTOlG10oTWoQVE8kOEw3QzbATPXwoRxuuBe2b8056D+2r9YO7H3R/syRnsEon+9kRbh5psYuYRfSo9J7dvq3/hVxuOS96RCI3EUtg+cJgrPm423jM57Bz/x2c9u2iL29o6ZWw72cIuy2pJnIlEeV3k4PejlrcWeTyEb20wvwftwWMW7SGOGzw3anPcRRbgyCEvTFSHOgjbpbaNzkIgrdLvPHbSoCo4WmxLUbvvsHJztn3detX9Sr3ULGgQ7Cs73XIlTbQBZFoGmtuX2sERdj3sdcvyao26kSDoT3qR+Ma2q3pMICWmMqMSyRgxbG0huJN2gmY3+yQErQn3c1Iu1Ot7um6D+BtQNrtacsC9ReUlIPsqs7bgg4rhr78/D8RA85f7+NqVjjJxpjxnlOBPhMjPYswz9h1tN06YXxSYaCLN1MD6JNu9Z7NROR+K57M9JQliMN63rVNivUuB8pMpIM3m8UoabAUgxU8FkCouLSRDCyV0OTZinmUftadPshYfsIxHtnXAB6njvVf0fqcOUSl0OO/kf+P2aUun7Lw28y6NHEqD2XOHdWz10/0rAik9mEXumz1uSXOl9amFNXsjGgDSWQRz2ZonSZKSEBrwyv4dsNldcYvT89LBvgomUrg 7MCwah9t qCiOoX8WMKpGoRGyhVPhvpI4D+6egvdlxOWpu4z1cwQjMOSN4FBlmEDBaGHAi0yyVMRELWcgrFFPAvKjilANzBHs/K5LRtWv5mscX9sE2Mmw0ZY6W8BIlEub79HyC84Om66tOek+Ostit7v6FB1EV+qVOAaCvdjSanjs7Pkkz6mCNVU5IBrJnAa2pYS4W1inJg9FHzfIQCmr3PBPXhjvL0hpvCJrpWpjqkh2g 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 callers are now converted to call mapping_evict_folio(). Signed-off-by: Matthew Wilcox (Oracle) --- mm/internal.h | 1 - mm/truncate.c | 11 ++--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 687d89d317d0..7e84ec0219b1 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -139,7 +139,6 @@ int truncate_inode_folio(struct address_space *mapping, struct folio *folio); bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end); long mapping_evict_folio(struct address_space *mapping, struct folio *folio); -long invalidate_inode_page(struct page *page); unsigned long mapping_try_invalidate(struct address_space *mapping, pgoff_t start, pgoff_t end, unsigned long *nr_failed); diff --git a/mm/truncate.c b/mm/truncate.c index 1d516e51e29d..52e3a703e7b2 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -294,13 +294,6 @@ long mapping_evict_folio(struct address_space *mapping, struct folio *folio) return remove_mapping(mapping, folio); } -long invalidate_inode_page(struct page *page) -{ - struct folio *folio = page_folio(page); - - return mapping_evict_folio(folio_mapping(folio), folio); -} - /** * truncate_inode_pages_range - truncate range of pages specified by start & end byte offsets * @mapping: mapping to truncate @@ -559,9 +552,9 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping, EXPORT_SYMBOL(invalidate_mapping_pages); /* - * This is like invalidate_inode_page(), except it ignores the page's + * This is like mapping_evict_folio(), except it ignores the folio's * refcount. We do this because invalidate_inode_pages2() needs stronger - * invalidation guarantees, and cannot afford to leave pages behind because + * invalidation guarantees, and cannot afford to leave folios behind because * shrink_page_list() has a temp ref on them, or because they're transiently * sitting in the folio_add_lru() caches. */