From patchwork Fri Nov 17 16:14:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13459125 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 6EA9DC072A2 for ; Fri, 17 Nov 2023 16:15:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B5FDF6B04EE; Fri, 17 Nov 2023 11:15:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ABE326B04F1; Fri, 17 Nov 2023 11:15:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 938536B04F2; Fri, 17 Nov 2023 11:15:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8095B6B04EE for ; Fri, 17 Nov 2023 11:15:08 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 57AD91401DA for ; Fri, 17 Nov 2023 16:15:08 +0000 (UTC) X-FDA: 81467945496.15.C1499E6 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id B2EF516002A for ; Fri, 17 Nov 2023 16:15:06 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=N8WgV35M; 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=1700237706; 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=8gvR0hfnArLw42hOz7sYaHZFkVWRhDjUXlO4vAmkjQw=; b=VflGCguDb8pTF8wsdQU0rmnVzpiKm9PWP9gudzLSu8cpxdHvASHKLhfJWnY2LXbcQmDK64 6aLbBoiKtLtXdyyLRHOwWZ451mbN97yVQ4JnjBjezBW07snRxbVNsITjdOwjDq1RmwYG1t Z0Z62klngvr9kUTq8M3iGV75/2zR5I4= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=N8WgV35M; 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=1700237706; a=rsa-sha256; cv=none; b=KDEPjO4blh7O0ef3ZfItYvj66wepzvHfLqsX/aESLI/NYVVzDRlLveIyO4+Bhb0rqKSUag 9O0Z4a+j5rWNK21bQMLI38Gv5KXmKK9QidrYETA8nu4hInPNE6VaU3M6cDm37puwmNdzLT A+BrXE/s4dDWGqYzo9lolCXZVGfTY7s= 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=8gvR0hfnArLw42hOz7sYaHZFkVWRhDjUXlO4vAmkjQw=; b=N8WgV35M5s0mjyyNderE17Qmxo OJkL8RyC2nLLhMIa4daHxxYStcbBxFBTzYl8S3jkoIz5p6orZfU9FrKQAwvGkN6aTsFtlZxxAmFIA r5Kj/oTZc8CWxZKbqy3Sb+8FKsXEWExbklZZzEUjtK4T3XCuSFEEBxZj8bw7GejebeIHdyD7zU9H5 Haf1YaqvY5uVuZILuYO0OZ7t7EkW32MsGqMrRtxpB1H3vUlDY/grumRFHB7TX6eEMYJcx6uCepG9W YHAitttCXDyAfZcqSAo+d7j5o3vN3ahTw+XTkI9uBaK3xszSQYi2lajCeKpSh+MJjqL6osb9Ob7X6 vrRzipgQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r41Uc-00AKWa-GQ; Fri, 17 Nov 2023 16:14:54 +0000 From: "Matthew Wilcox (Oracle)" To: Naoya Horiguchi , Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 1/6] memory-failure: Use a folio in me_pagecache_clean() Date: Fri, 17 Nov 2023 16:14:42 +0000 Message-Id: <20231117161447.2461643-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231117161447.2461643-1-willy@infradead.org> References: <20231117161447.2461643-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: B2EF516002A X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 1prizn451o5xumxgouaokimofm7jscrq X-HE-Tag: 1700237706-862002 X-HE-Meta: U2FsdGVkX19TG45EsF4faJp3mpLFLwWRBCQZq9rFQ+Jp5T9iC3Ze7JYKHHiwTCJ1meoSxLqj9ag/s/tDBN6nSFqdC6k2JdiqD/zYjZb5fODAgJmzENXQlRrtj8BY7btI4E7gUPzeIw9FoLnoYm5nvy3UXE6QilYjFeCcGUFCth2IUF7dCc80voN0V0deA4ngn5FJyt2xfx5dP+Rds1kncFgDwAH9Ezq2PLxJKxOlP/jMIJKh8TJL+Vx8WPIAdgIT62/aV9kbMNyzc7cPxxWiETqwEEwVpFhEsM69f66hnOiIH3rls4n0TWYaspYH/kN2LhGXo7qk7R5bK7fM+BT6ZD1hbQuuQMy/GKEvq8JyXNDkjjG8lQN0i8hiEs4V4tfgj3Rik3JRLixpqwh37rc/HWYKoG+5zz1aoYeEZo/l2R/V2pOY+Kfo/pyLmeup4oFBX38hq+U3XDoK3TAMVr3m2skx8v4/l9UKJs3Lx9jRtZIDrqMZjSRjQSzQzVaV+kFBnb46lcZxdn/nB85RDKPm7O5D4L1/cvovlTSThq79sdSrcUB5ETZjBmBKnwPdunlwd7kJVZRm5Fv/8UYMX5HEIqLPR/ZRsjAWZ4Y+BL9vQHpsNEWm5oubOpjyGxmTAdLadkAwbeEDgcJwHESXOtv3Z4SpwgB50j22lI0FSpOCAfWrAedAY1S3QyITOipcHMyKObSayqxITh2jQK6gvxHSS5SK1ZcTDa4sWSIylc6mqCFQfcyxRMT+JHRa3PYyH+hlE/G1wZkJ5yQzdO/p6Liv/gIv/3JShGoTbKws+rFTVdBbNE4SPXmD/7YmoeWEfmruc6ZBSiAY0R7vhCPIhHeagFYraLPQTCNp1+EPthGOXRrkHQ1vJDtfStOAPGzp1vYuzPT/EOMYY8HHGFW4IfDaHvkpqYt3vMqHI6WSHI3WM9uMxzpz1QEhaZn3WA8P9tgSzqycE6YtNVzkGIpKvtt eiUglyng X5hKf43eimD/8qMSAEUZ9FuwJXlqbZ9ghtZA1kt/YL3NMc5SNgbyqpXp41LiDLQtopXouRBxy2TuiH+8VklEKRjW9wpdG+KIsHlTxtjR4xxV23K8N3z2jvCHFxjBsOY+W7UurJBIxExnA5xl/+HDP6g4VRwaURlcKrkaEPU/CmxOyA01GYcRGedlwjiyan+YWQI4AK95yLZwZ0afjzHj/UveGmC/uJv3789Tn 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: Replaces three hidden calls to compound_head() with one visible one. Fix up a few comments while I'm modifying this function. Signed-off-by: Matthew Wilcox (Oracle) --- mm/memory-failure.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index b601f59ed062..496e8ecd8496 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1014,6 +1014,7 @@ static int me_unknown(struct page_state *ps, struct page *p) */ static int me_pagecache_clean(struct page_state *ps, struct page *p) { + struct folio *folio = page_folio(p); int ret; struct address_space *mapping; bool extra_pins; @@ -1021,10 +1022,10 @@ static int me_pagecache_clean(struct page_state *ps, struct page *p) delete_from_lru_cache(p); /* - * For anonymous pages we're done the only reference left + * For anonymous folios the only reference left * should be the one m_f() holds. */ - if (PageAnon(p)) { + if (folio_test_anon(folio)) { ret = MF_RECOVERED; goto out; } @@ -1036,11 +1037,9 @@ static int me_pagecache_clean(struct page_state *ps, struct page *p) * has a reference, because it could be file system metadata * and that's not safe to truncate. */ - mapping = page_mapping(p); + mapping = folio_mapping(folio); if (!mapping) { - /* - * Page has been teared down in the meanwhile - */ + /* Folio has been torn down in the meantime */ ret = MF_FAILED; goto out; } @@ -1061,7 +1060,7 @@ static int me_pagecache_clean(struct page_state *ps, struct page *p) ret = MF_FAILED; out: - unlock_page(p); + folio_unlock(folio); return ret; } From patchwork Fri Nov 17 16:14:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13459123 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 EFF13C197A0 for ; Fri, 17 Nov 2023 16:15:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E20C6B04EB; Fri, 17 Nov 2023 11:15:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3933E6B04ED; Fri, 17 Nov 2023 11:15:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 25A116B04EE; Fri, 17 Nov 2023 11:15:06 -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 11FC56B04EB for ; Fri, 17 Nov 2023 11:15:06 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D44168063C for ; Fri, 17 Nov 2023 16:15:05 +0000 (UTC) X-FDA: 81467945370.28.A740FA6 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf03.hostedemail.com (Postfix) with ESMTP id 2875820010 for ; Fri, 17 Nov 2023 16:15:03 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=cP4vkMrj; dmarc=none; spf=none (imf03.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700237704; 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=zgKIMNO9SoWoamx4nfeJw6ay/xwbZPsNF5ZtmzNQz8s=; b=7nz2s+HEVNnIQLbAY6DY6/0THUuNERPscqkv3wVufQJ8XCZjfyJA7NP0yo5uLoy1nKZaQ/ L6qQa6nsTH/YsVmmDz71oOeE03yHvv/uDMbmCdTNX7uvuF9aWQ7pbw3NXrVO/TFMTzywr7 rT4UZeKoom1YNsZ9jeGE02Fb4CXhd+4= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=cP4vkMrj; dmarc=none; spf=none (imf03.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700237704; a=rsa-sha256; cv=none; b=SpxvxQXE+10u5czhSI/qX9ewzSgAArbyd+RX/lEgeChqr1g/1lzuVLsDqAttDaCajp8064 U/hPzh4t8f58W7/O569Lpt/hyURFCOKyKfJuyCFAP6Nb7ZhVv+OzWeSPpkYlqGARuf4Wqm Yc5mhI4r/ux98S1B6nQdAU5LKwShXc8= 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=zgKIMNO9SoWoamx4nfeJw6ay/xwbZPsNF5ZtmzNQz8s=; b=cP4vkMrj4ZpFOH9Q3bcgXCdmVK v7qVSAJdIVOD50Uf5a496mO7tImj5kJgldjKrv0Tq2fbmqV/M1sByRDx1dCoCvXxWLcOJ03Lh1EUB ozuILp2raG7J9TXGwKi+IYSpJOGltR0J3LlopzajD11deTId2zJl9cNtdudORtwEDgX/4DjCVvd+L QgQ0bISL9h9rL9OAq9h5Rt/Jdj7xciZsrukosx8e6sEb4mbv0vEGlNZu7aJECz1aDc8+M4UxhdhKA KdVD/Jx48zE+W3qXgwZSvHqC6drT4UJtm9xJzRsZWFZwKQaqoQHjuajoUGCS0dsQ6lo+nX5gUeEIs akTRRVmw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r41Uc-00AKXs-J5; Fri, 17 Nov 2023 16:14:54 +0000 From: "Matthew Wilcox (Oracle)" To: Naoya Horiguchi , Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 2/6] memory-failure: Use a folio in me_pagecache_dirty() Date: Fri, 17 Nov 2023 16:14:43 +0000 Message-Id: <20231117161447.2461643-3-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231117161447.2461643-1-willy@infradead.org> References: <20231117161447.2461643-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2875820010 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: cknn8rq31bdmhk4hie3x5dung9o3uyph X-HE-Tag: 1700237703-166719 X-HE-Meta: U2FsdGVkX1/pDQGxAtN+GuJ/XntDdJ72G6DW6FJ/yfbTpN0RtTUwHn6hQAlYic2L/Mz7pbP63DZT+fkKb+kOe4UdOAEQ10lB8ZfQo9e2r404xtytrYO2bHf+zsN1ySkisO6pOCvI5WFDYWG5G41Z5AbGISni1M3BEdrLINdx2aKzq7L5blCcQ23tB0Du700z5Zu0KNgReIPUeVbR8EkhEr2FRVRDZowq5kQ26LddnTHCPUImKKd4TFp5zn0w48zeA7VdXT6q6FiiFv5VStja6Iq5YVIxKBuFFW1FLodsyt4xK3ME+gSiukgu1v/vlCG/6BwyothhZOD+19XKWev+fwcvV8DqYZPKG0vNpS21onTR4PFLH1HM2fpzuQdjRz5j/ovMf/OwWMGM6/g2RycTkXx4sL4lD2AEAwsXBiFOQMKu+eL0U88yqWoakIGsIGm6rK0a3vpX5PJfFtPL5rOFJLfrnMkP+2QcPcUgtPiSNzmvHuPi/qDb877vTZQM0je/PXDA1WmwnRD8+2kharjHg53Y/n0XdLjKtfX4uHTReowpr1zgAuVUIyO0VAb4BiEH5ik6zlClx92WBGxgCgHgzvQxSUPyxLPqMA7JFDFA2Gs27KuAKk+0GELTJJxW23xTArh3KHREMiYdTb29hxHLLkB4EpBAwKK+U/d8/jIxza5dnn6b+lRah2MIsm1BuOA63zNUab6+wx8dpzOb+e9vAyNnjVjsppce9gdPF/iude7w0rQnjgQPz7SxlQcTrWm/8EUVKqG7BHKEbVu4cbFJm9YZcfQa/giCuHCoOGTAm0lgkz2pdv73AG980aKzJe9LwxoCOdsduGrKk4Wku+OjQnrvocEHbUs9TzuAgcr7NVRzA4YFEeE2RSHfZzelC0a2D1G/Ar7t7PCQVobVFZSvrpXyN4GMw6YcfEuZ3Zo+hRI/pwEqspekJu3KW924r2+syYKknTyebRm7hu20DoN hSWlBqcr 9jW3MQ6jQ5/E8l32xp6PzS7dv3odOWziS1z7RvJSe96GqKHALSL3Bi8Adnuo83AP7iljcTdFbatzvBeU9lkp6xn/jITPnXZ4tuE8DlnP0YQLPhzzlNX/zNQ/X2UtiKMNOylaQuEacgHAQuL+07Frnyl/Tw5vw+odi0mHdQNRP9ByAIQjQS1rvGe2k6lFyTUbNXl4FRO5R7cAtXooeg4h19wB5cIDDJd1zqZj4 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: Replaces three hidden calls to compound_head() with one visible one. Signed-off-by: Matthew Wilcox (Oracle) --- mm/memory-failure.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 496e8ecd8496..d2764fd3e448 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1138,15 +1138,16 @@ static int me_pagecache_dirty(struct page_state *ps, struct page *p) */ static int me_swapcache_dirty(struct page_state *ps, struct page *p) { + struct folio *folio = page_folio(p); int ret; bool extra_pins = false; - ClearPageDirty(p); + folio_clear_dirty(folio); /* Trigger EIO in shmem: */ - ClearPageUptodate(p); + folio_clear_uptodate(folio); ret = delete_from_lru_cache(p) ? MF_FAILED : MF_DELAYED; - unlock_page(p); + folio_unlock(folio); if (ret == MF_DELAYED) extra_pins = true; From patchwork Fri Nov 17 16:14:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13459124 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 6ABADC072A2 for ; Fri, 17 Nov 2023 16:15:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9143A6B04ED; Fri, 17 Nov 2023 11:15:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C19C6B04EE; Fri, 17 Nov 2023 11:15:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7146B6B04F0; Fri, 17 Nov 2023 11:15:06 -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 3FAF66B04EE for ; Fri, 17 Nov 2023 11:15:06 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 142ED160BAA for ; Fri, 17 Nov 2023 16:15:06 +0000 (UTC) X-FDA: 81467945412.20.701B5D5 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf26.hostedemail.com (Postfix) with ESMTP id BF600140030 for ; Fri, 17 Nov 2023 16:15:02 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=lBuDi0+u; spf=none (imf26.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=1700237703; 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=Vf86B2r48b06hq56Lphk6YasHUIlClzmrRVlrcnYbEU=; b=8AeMz5WdSWSEFcHtTKQDV44jUdhf1klInbd3dbqGnHdQdFgpjrBN4YLsurIvvr+edaQCtV fnePN9FANgtxM0/k9g7cXtyAvKYvjf/MNHYiFrjB63YOkwE+UtTCt7cOhLkcmGUNBbF47s 92ddqDE4JiH0bAf05MfNshviiCRq6a8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=lBuDi0+u; spf=none (imf26.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=1700237703; a=rsa-sha256; cv=none; b=sIULBA1Z6h0l/03CIvF6mUXFJya/NHLvWCq5+J1H+GxGEXpGl+tjLGtT1hLQelGHNqvgtY gnWHSf06hzTGSfsP81rYj7iB0zpUXbUqWHkMLLC9yZHl/4+wsOcQfROBt16LWZdSkHjB0U Cb4c1KNyQZ2KHf10rG6keiqYc8NMGXo= 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=Vf86B2r48b06hq56Lphk6YasHUIlClzmrRVlrcnYbEU=; b=lBuDi0+uFlBwKBKbtjXDnKKGud rX5G0hyB33CMmJ47hg3DEseAmCwagVH9GPP7WtDUCl092doyezqxJlxbydWz48xrawTeWv6CS1h6u Gqfs5ac+eCkrxHEmynbYjj9QH1BNEUEt8VtTxSxCegbRs8TQE8/L6mrZKrhuBZ8tDOq6LFnnuh2eq FdLtH0G1xGzwrnXnK2dAvTQZ2XVF8z9YiRa+qQcx9aO2aEAtlRsbZynXwSdNRn9bvBPn2+mVv5EQ3 lZCGmeyoIhijEKJdx/EA67UmxwYKaA4iox4SHDgH3PzWHVgiMrOYAMc7qv8CaQmWzEAA61Hi5zi4n kIRbFC4A==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r41Uc-00AKYn-LM; Fri, 17 Nov 2023 16:14:54 +0000 From: "Matthew Wilcox (Oracle)" To: Naoya Horiguchi , Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 3/6] memory-failure: Convert delete_from_lru_cache() to take a folio Date: Fri, 17 Nov 2023 16:14:44 +0000 Message-Id: <20231117161447.2461643-4-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231117161447.2461643-1-willy@infradead.org> References: <20231117161447.2461643-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: BF600140030 X-Rspam-User: X-Stat-Signature: 6jq81josfzzqspsx6qs3zitmt6r4aswi X-Rspamd-Server: rspam01 X-HE-Tag: 1700237702-114891 X-HE-Meta: U2FsdGVkX1+jxurRUVqYgA48M9yAX3vs6zVILYXWcRavD7PE9sQAwZciQF3EKHGmdHGz5QRb/oY+vNDu1pZou6mxME0jLdR0CTd6UFc6O17DfT9qqQsf5YDjEFCSYF63my+krerCtzUwyj6AS73oJpwOaxDxmkXhXEDJTRnfmTn+beOy8ZaeFm7xyV41G9Z1m6k8RzuE5qLZ+xIrF/SrYZSDAe1UneblCOcsnn9SXjP8ydYP2GTTeAr1V8cnIUHB+AFX2T5X6JNp5oK7VsCHoh6OeW2B7Jljzcei9qPzmmn2F3qo+oxbH8xMmokTGQ/dBjDuNT2cFdXVKWmuQ0e6+XtUm8vpP8piN0XwjT9cNzlAk9zaIkZKmgkaGdcyjT7FvRUqRfhuyaffRD7Vd7hP61jyMgHrl/Rm317dSIsTRyJ4H1oD7x+GhcNy9ExswXlA1Bfy73UkpYy05hVUqGgp+aDVpyzCi8udO1cqK7/ewi0nw3T2xeTQlJbj1IvShyCYOdcntuWWOV8KeErMeLhCao6CI1coYJTcI/EyO4p4KJr2CE4LCSkvEpsc1dTChikEANrKgh7QrOAQdEFNYVvJvCKc/yYgPsF8KE5KyVBZ9TzeGYtUfr2Q6sn+WDldqN9ecHgcSHEr6QPIu7/lx8aawtHuBwUhG8WQFb/BAbvrwLjazTg+R1QOZP+OmLqbjXSPVNYDYH6vdx5RkcWSThNy269OjY1gtbhczEh0E62cMZ+WczyPhcYapECpArobSw2eGNRn6xk1uh2Gb8x9RpbcAWk8iLEI3uSpaA3s/EtA/+76ET0OhR8ER+bM7mTAKTGom59YBnFKd62aIfxL8EPFYheq7J8cMOTqgEDOoxfx8j7IpV+A2gPyZfWn3jrqDdvnO0fuXLxUrCdfzIzweekJyAfN65SqTyFDDUNreBG6vS3VzFdjAm8zP3Rcw3g6fcR7HojjHZZpuc1+f5BwvRN C7fXiVYD M1E7v1yLq6iUOhXkWmgM8bT7Fl3FcVAI1yZvfI7XnA1XoT+CZgg4kbETHZ5uWjUKbsUlr5zM+MnUEV6/X3XMtBbv1uZpBaNX5qjuPE+2AxBZl3t3rQW8/SgxkAPepwYxwt3gCsCK+Ijdj5yH4VahdjAuKWaX5TcOhyyV6QKWTNAlJy49Oi/LahdzTyHrQgihAmdNe/TibEO9xQTB3AvtwE9znt7+HRsNnwhs8 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 three callers now have a folio; pass it in instead of the page. Saves five calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- mm/memory-failure.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index d2764fd3e448..e73f2047ffcb 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -902,26 +902,26 @@ static const char * const action_page_types[] = { * The page count will stop it from being freed by unpoison. * Stress tests should be aware of this memory leak problem. */ -static int delete_from_lru_cache(struct page *p) +static int delete_from_lru_cache(struct folio *folio) { - if (isolate_lru_page(p)) { + if (folio_isolate_lru(folio)) { /* * Clear sensible page flags, so that the buddy system won't - * complain when the page is unpoison-and-freed. + * complain when the folio is unpoison-and-freed. */ - ClearPageActive(p); - ClearPageUnevictable(p); + folio_clear_active(folio); + folio_clear_unevictable(folio); /* * Poisoned page might never drop its ref count to 0 so we have * to uncharge it manually from its memcg. */ - mem_cgroup_uncharge(page_folio(p)); + mem_cgroup_uncharge(folio); /* - * drop the page count elevated by isolate_lru_page() + * drop the refcount elevated by folio_isolate_lru() */ - put_page(p); + folio_put(folio); return 0; } return -EIO; @@ -1019,7 +1019,7 @@ static int me_pagecache_clean(struct page_state *ps, struct page *p) struct address_space *mapping; bool extra_pins; - delete_from_lru_cache(p); + delete_from_lru_cache(folio); /* * For anonymous folios the only reference left @@ -1146,7 +1146,7 @@ static int me_swapcache_dirty(struct page_state *ps, struct page *p) /* Trigger EIO in shmem: */ folio_clear_uptodate(folio); - ret = delete_from_lru_cache(p) ? MF_FAILED : MF_DELAYED; + ret = delete_from_lru_cache(folio) ? MF_FAILED : MF_DELAYED; folio_unlock(folio); if (ret == MF_DELAYED) @@ -1165,7 +1165,7 @@ static int me_swapcache_clean(struct page_state *ps, struct page *p) delete_from_swap_cache(folio); - ret = delete_from_lru_cache(p) ? MF_FAILED : MF_RECOVERED; + ret = delete_from_lru_cache(folio) ? MF_FAILED : MF_RECOVERED; folio_unlock(folio); if (has_extra_refcount(ps, p, false)) From patchwork Fri Nov 17 16:14:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13459126 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 8E236C072A2 for ; Fri, 17 Nov 2023 16:15:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 211ED6B04F1; Fri, 17 Nov 2023 11:15:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C0446B04F3; Fri, 17 Nov 2023 11:15:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 05FB66B04F4; Fri, 17 Nov 2023 11:15:14 -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 E53CF6B04F1 for ; Fri, 17 Nov 2023 11:15:14 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A5A6EA0494 for ; Fri, 17 Nov 2023 16:15:14 +0000 (UTC) X-FDA: 81467945748.20.0F42309 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf03.hostedemail.com (Postfix) with ESMTP id D1F7120003 for ; Fri, 17 Nov 2023 16:15:12 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=eajgtCer; dmarc=none; spf=none (imf03.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700237712; 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=5qnFXc1Xogmh7PAIEEQ0Shj70PekKGvUt3R6/VGwhqA=; b=ywFiROYQ10QuxfQnDOKFD7Wag8U3G5CVZ+ynrqhVAzazc8SQqFmnY0kcEADNb5pfGzrRZC kpg4Kfn4NTBVPC6l6Usd2OR9VISOgPHVifpyostC4K4RO8NFNxmpcEoS2Y7abRHyJ0hF9r V6Cb0lwZpgBBJLVcWg67XjPcKlNLqaI= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=eajgtCer; dmarc=none; spf=none (imf03.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700237712; a=rsa-sha256; cv=none; b=8lTV+Xcoq4U926BVLmGsuHpg+of2z2dzgq0xib+m1rnZzIhFq9NCUgaQRZS8/MQEMA6Evp h2GuPCoI7zrq6oq8xBePaXAaLkdugEZBhBA3kNPyvla/aJ2hdz1qXctZvXJcgz0BA6qomH SLTRPoZb49rIWwXB1BOVIuwU3QMiz7A= 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=5qnFXc1Xogmh7PAIEEQ0Shj70PekKGvUt3R6/VGwhqA=; b=eajgtCermKMU/e17PoydSMDg9r +kz5k6bnBxxa9t7In5z9eci5kjX7tVUaXqZh+9RxzYJvhLiGT60uRDBHbuA7no6VvrrnVthyJvuLV pl8i/tVkgrMfhjjfvaaEHuvF3NDpQ24zf4m9HqFihpQ3vBLF/XeFwCdxQzgjv5m5frpWsQdT5zUDa HPb1KANQtiPQum5YxUn4dme7qift/JXUa9/FMi4K2LX/2Jm5zmMt7AY6/sLWHv3umATpyaGAr/Fl3 FWf/7zyh0qZpLFdDLd5hEQ3ul1AJfw8Rt6Ix+cMsejBKKv50kztvCiYuXE8ayVRz2nOZBekrg05Dg +MngwkxA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r41Uc-00AKZj-Na; Fri, 17 Nov 2023 16:14:54 +0000 From: "Matthew Wilcox (Oracle)" To: Naoya Horiguchi , Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 4/6] memory-failure: Use a folio in me_huge_page() Date: Fri, 17 Nov 2023 16:14:45 +0000 Message-Id: <20231117161447.2461643-5-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231117161447.2461643-1-willy@infradead.org> References: <20231117161447.2461643-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: xa5xhsk1dntzw9de9fsw4jhunxawtqie X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: D1F7120003 X-HE-Tag: 1700237712-803519 X-HE-Meta: U2FsdGVkX18gcNtJ0/7SWv+HrRM2mUZHPRlxqFjebHMwuSXxkqJRzkONBw6HsSlKJsoBr2MHFOnfEspbmAp9YRdKlrp1zr7Y03+/4AO7SQOttWYaUFjLzcSj5SnXCxawRErQvtfNxp15U9uDFLVEi4hIwZaNFvCp/r0d61jxXSxQ5BLzS3Ipe7/xaAekFCfc6PLmH1mB9Js8WbmHDCOvl/Pykdt4Z2UFlRRv3NPx55AXqUWAak7lRNCg07I0XMR0G+CL3+z4HCAsp6SFMeYodwG9T8gSoTt0PKa+1DfMJHID/16bvkAOpY0RLN3DctAn92UaufNGXOkaR8uVGY+63FoOwnCPM8HXQ5UJ7HvZF2/2p/lkYh5Ob0PnSHnbLRA5o8F5mG3x3z/HOK6P37inwBdLcnAgafsI0eh7w54iiZeR9debu3FRmCO2HCeguSgk5TgJklEgMfhDIHp2N8xtzKCOygfF3sL8b+TzYyAGaHvWWuj6biHlS5zfvRBqVTjaNxKAhYUbeptvl6aHWDXks7ILlzzPcqU6wvYGs/CLUS9JBmHIeWeDtyIO+y5CwOITUZgcYzL9kvDP75OGO3lQJyYHSgUkg5wRZLLRw/QseoSYWCkFnT5XKkY2ZktGQPIzH6X+CMtjMf10vhxzcYijV5zLpYBDkkQfbY6hWJViUntPI05JBIJj8eWL/LierCDPHONMWYbt8+nMP8BeVQUqJlIktDeVRVBitXmy9dtVHDi3BH0HO1NsQHy0hU7xyBjoiFNheYnhhvfpV45J23JEeZLfqMjYrQKXJOjdbwPsZoz402Tzi2a4AY20RdPCzHvKkCgaNi1hTl9uayilRe3XdudZQS38Oz0gQgf9uddgGT6/ET/ALbKrCG0trjDHubTbbyJjNQ3rmVdkAzg1og7TWC1sTsXytwIGVoQbNP9bks5i7BZty2eBS+xR4vm1idcg9CAQ/HyuzSXj/gk4gCq 3QHybDUX EouOcbftao2zWbRtdEU0gcdBaB37uHjV4oHdNtBCrvVdguT5OqcNymBMWyeW8JnNa1rcii9nkOf4MHAcBxjfKWoWSYMq7AhmJa/uPoyoT1adNdY6TNDqJs7Hr8Yu+vRDuuOWJfiypXiskJ4tZlAGE5Dzld5HMajlCy/2vSdMiwljeR6Uy75NijDRcxfPng78yScJKe6GpPx/DCkC/kTlC0Kb53KIaKEhjhv9u 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 was already explicitly calling compound_head(); unfortunately the compiler can't know that and elide the redundant calls to compound_head() buried in page_mapping(), unlock_page(), etc. Switch to using a folio, which does let us elide these calls. Signed-off-by: Matthew Wilcox (Oracle) --- mm/memory-failure.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index e73f2047ffcb..d97d247c0224 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1182,25 +1182,25 @@ static int me_swapcache_clean(struct page_state *ps, struct page *p) */ static int me_huge_page(struct page_state *ps, struct page *p) { + struct folio *folio = page_folio(p); int res; - struct page *hpage = compound_head(p); struct address_space *mapping; bool extra_pins = false; - mapping = page_mapping(hpage); + mapping = folio_mapping(folio); if (mapping) { - res = truncate_error_page(hpage, page_to_pfn(p), mapping); + res = truncate_error_page(&folio->page, page_to_pfn(p), mapping); /* The page is kept in page cache. */ extra_pins = true; - unlock_page(hpage); + folio_unlock(folio); } else { - unlock_page(hpage); + folio_unlock(folio); /* * migration entry prevents later access on error hugepage, * so we can free and dissolve it into buddy to save healthy * subpages. */ - put_page(hpage); + folio_put(folio); if (__page_handle_poison(p) >= 0) { page_ref_inc(p); res = MF_RECOVERED; From patchwork Fri Nov 17 16:14:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13459129 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 9B739C197A0 for ; Fri, 17 Nov 2023 16:15:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E92E26B04FA; Fri, 17 Nov 2023 11:15:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E41046B04F9; Fri, 17 Nov 2023 11:15:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CBCA46B04FA; Fri, 17 Nov 2023 11:15:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id B97766B04F7 for ; Fri, 17 Nov 2023 11:15:21 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 88D39140571 for ; Fri, 17 Nov 2023 16:15:21 +0000 (UTC) X-FDA: 81467946042.13.F7EC9B8 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf24.hostedemail.com (Postfix) with ESMTP id 85F7F180014 for ; Fri, 17 Nov 2023 16:15:19 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=eXvcsDQf; 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; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700237719; 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=d2kHOzpOuXHwXRsMk1/dqyTvVthpU9cofZVkTm/4UCo=; b=tbsn6VFFS5nXGRMM2HnJ6TEcuGbfajrJtwsOJKq7na4yBpdQlXInHNCgYJQipUQrqGT52/ LziUccXwZgUgqGY0pXGq+E7z1LT/MHiRvJbBqy/8CNbpV2n0c6/xeDXggy7kTRNhOPo/FM ZJWUMcDyAVsEyd4nJEF6gMN/ttPI1N0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700237719; a=rsa-sha256; cv=none; b=bnxuXCQ5NwWA1AgRdh3BVVF4S4IA33YG9Gqv8j3/0pG6vdgx6JsizjJ10NLjUIfesmghN3 Lmi/+SuUTwUky0yuOx1DgNYFFIsNhYcSOq5Wg/e/5LAqto9/YLnV0xMYr/YVy4tnp/VB2z ajLpz/gZbLamLwRC+7TxMQyU9OGBuf0= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=eXvcsDQf; 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; 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=d2kHOzpOuXHwXRsMk1/dqyTvVthpU9cofZVkTm/4UCo=; b=eXvcsDQfEbE9m+fx+sPaMT6dVQ MU/QNu2vC2S3Mtrv/KKQxuyOHY5bQQXKyIvihXhZN9FRE5L8l+c/n/DM6QaT3iyoLVt3MYZ6ZAybo qdTOEVEkw2MrjPfZ2ltKr/jSKwRJl9LvCnzMYTN8PJXSZpUbTuGfEJyI2Oi4gV9O5WL9sLzrOUG5E s/t53XaeJp8uQGwS5j3IpKHmaVwy65XlvR+WckNOM1OVZcLkQOh3Y8/AGIb6EKTgBgW0UzJRtQs2L Hjj9sHkPaVDBYiK5Cfl9xCuPLPFwMtrj7aV0mGKzScoBPRZjbawb6L0P5v3ha3tPiQGSsdfD+Y8GJ gIRppf0w==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r41Uc-00AKbJ-RK; Fri, 17 Nov 2023 16:14:54 +0000 From: "Matthew Wilcox (Oracle)" To: Naoya Horiguchi , Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 5/6] memory-failure: Convert truncate_error_page to truncate_error_folio Date: Fri, 17 Nov 2023 16:14:46 +0000 Message-Id: <20231117161447.2461643-6-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231117161447.2461643-1-willy@infradead.org> References: <20231117161447.2461643-1-willy@infradead.org> MIME-Version: 1.0 X-Stat-Signature: r7wuuh5s1y8b5idn6zz4cw8qtpjnydps X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 85F7F180014 X-Rspam-User: X-HE-Tag: 1700237719-310799 X-HE-Meta: U2FsdGVkX18ZW9m17uXoZ94MoyJhtd4rZV/eaB7tazbJPVGU68FrqVlZWhUDe4Qy2X5JytHA7f62BvXMjanNuaYPGFLNiXu4R9qinaPWo9At3+GyGS24s7D4Ca/pXxVEaOCtIBOcbeRoYQ94gWLlH9BPLVfiXl/t2E3NqgXnh8ds/R3/5f16tZRh/FiLT9F0PYNL0XdL5p490jPqQ9XlX2+HAHWLbuWGlPjEDgCwzYL/4jgzzt64EGkA+lh6xV3ARxJgM+Sp/LZh6/VafRGIvXbZXnXnyHhoyRFM2OXo9hf0eomDUWn+EKIb7tq4780lb/tA0EoXxN4gyV18YjXXTU/+AV6P9JX/haTm/D09TAW2YQla9D3dZLnqNrsys7w9ZEFg0o12MOewMQqkCFlw7heWYJCmOPm2LUx3FRjeICSuGtIrWopqK8Flt7qZsw8TdnY82HAv/EV1XK7tWi3Bd2hepopmW9YoNvrvha2JsKel2SH63824S4dN/cgrZ8o4BBVSDOhVpebtpJghUlJO5Lwggf+wMjCiJvac+aMF0E6iubN25MpfqMAIXs/cb4EUaXKKIvsuLOVKzM8/uyWG9vjGq/MxStcacWlX1cg7EThfERMRgevt1v2oD559k9WIxG/wB798JeXCUt6W8a2WdONpApnww7sJeLEBmQwgN8RgfTJsnzhcDiJcGjTqSTcj//IyWcbEAopFrOJO8BtNy5galwzt1d6RdBbkaQZhujmTPZfm368dv5EMzTqwkO+k847GlWYVw4bE6EG+KllR6uOLlqdUn/GaZuxnDf/YxBlrvM/VK9q3in+yhKnMCU52qekWLnZ4VF11q2H5T6zS8Uj3OvV1w2EPjYK2EKqQYIxs0QFytoc7nK8mzsRgwCK+XJFDKU6uhmW0u31m+iopdy7A6Plza1oH9BWa3brw7esLVTUaCn/+zt8zOdI/ZyRXBx/BNmLYt3k1NRowVha 1s6I9W6d gC4opIWBs7nKq2wRgeiE/WwRz0wrTt6Dovsi9XgZT0Mm7ipvKC0mTeJzBi9Y53trv2Bti0ZTre0L78jFDOm55oeShwSFs5x0Edfn9SZbgsKkKYVFPsp0qNa8eiH7WWwuq+JLEpV4PLoUzDPsTL3Rj3j6vobw5w0DVRO9NNMiD3QYtsKXJF3l64uZ5gdyPArO/Met9rsNfp34t6Zz0nSqA8qj4GXfgQBqqxVz0 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: Both callers now have a folio, so pass it in. Nothing downstream was expecting a tail page; that's asserted in generic_error_remove_page(), for example. Signed-off-by: Matthew Wilcox (Oracle) --- mm/memory-failure.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index d97d247c0224..6aec94821fda 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -927,14 +927,13 @@ static int delete_from_lru_cache(struct folio *folio) return -EIO; } -static int truncate_error_page(struct page *p, unsigned long pfn, +static int truncate_error_page(struct folio *folio, unsigned long pfn, struct address_space *mapping) { - struct folio *folio = page_folio(p); int ret = MF_FAILED; if (mapping->a_ops->error_remove_page) { - int err = mapping->a_ops->error_remove_page(mapping, p); + int err = mapping->a_ops->error_remove_page(mapping, &folio->page); if (err != 0) pr_info("%#lx: Failed to punch page: %d\n", pfn, err); @@ -1055,7 +1054,7 @@ static int me_pagecache_clean(struct page_state *ps, struct page *p) * * Open: to take i_rwsem or not for this? Right now we don't. */ - ret = truncate_error_page(p, page_to_pfn(p), mapping); + ret = truncate_error_page(folio, page_to_pfn(p), mapping); if (has_extra_refcount(ps, p, extra_pins)) ret = MF_FAILED; @@ -1189,7 +1188,7 @@ static int me_huge_page(struct page_state *ps, struct page *p) mapping = folio_mapping(folio); if (mapping) { - res = truncate_error_page(&folio->page, page_to_pfn(p), mapping); + res = truncate_error_page(folio, page_to_pfn(p), mapping); /* The page is kept in page cache. */ extra_pins = true; folio_unlock(folio); From patchwork Fri Nov 17 16:14:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13459128 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 70C83C072A2 for ; Fri, 17 Nov 2023 16:15:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CE8D36B04F5; Fri, 17 Nov 2023 11:15:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C92AE6B04F7; Fri, 17 Nov 2023 11:15:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEA126B04F8; Fri, 17 Nov 2023 11:15:19 -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 93BDA6B04F5 for ; Fri, 17 Nov 2023 11:15:19 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 66BE940D3D for ; Fri, 17 Nov 2023 16:15:19 +0000 (UTC) X-FDA: 81467945958.10.43F346D Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf19.hostedemail.com (Postfix) with ESMTP id 582141A0012 for ; Fri, 17 Nov 2023 16:15:17 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=QdpB+VDV; dmarc=none; spf=none (imf19.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=1700237717; 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=3d07ubN7Lt9CAyL8HyT5gd46gkz7i8yQq9PdgneSji0=; b=kRISMpsxUDvEYeh0vY47d9pw8+TMdVvRbym3xj030t0nyHf17DG3S4oRduUdtqJQTmmcV6 zWYYND8XzRKaLE6O1znxbK4YUqW/wrysbmQwSBY+wKP1Ll+hjwYWwtJybcFzyWWS4lmqBg 5sAbxVLlCvhOOVvH7IV5sMMK2qqv01o= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=QdpB+VDV; dmarc=none; spf=none (imf19.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=1700237717; a=rsa-sha256; cv=none; b=SJ7vn8i+p/868ko9CFMa44A3m/zGwAte1hlp3sKqI4432LfllLFaulImI69CILuNuVZnwb qPLEfCDLe8hRywDnppAHECzGofr46LnDMu1DzzW2WRmFJw2TzlDeb+u5y7kDEB5lkT15ib On+KzodKmLqfK3sx6IWnMSQjHb0XNXE= 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=3d07ubN7Lt9CAyL8HyT5gd46gkz7i8yQq9PdgneSji0=; b=QdpB+VDV8/VJP1P6+8acYCvEyG zG0if7j0FYaEUIVl8GQZqYcMIXKuAr39vfMcKdSCYYhV47tuUwB0jAoGXq/8DRDGzFwNryLOHPXOW ecEvJ5m8eh1YBEYRiD5BLXe52Qb/iAfZd+oMPqvKs4JBBgUJgC7ZMVbYgPJ/Q8FxTKvlgAqrsuW9D dK1h1rDqy8RIpfD5tJJetSKVPJwVw40TN6O1DH0ZLx9Qas926Szb/rGmY2VsXQ2UcmHKzbFbCEmKG mmRt9seIdIBEVDra5mg0FwojGwHZM7kedcxNXQ07f3lYuxriZ8c187p1uGhRDFZxItLAaZLhkM6UM U0DwtgJg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r41Uc-00AKcZ-UF; Fri, 17 Nov 2023 16:14:54 +0000 From: "Matthew Wilcox (Oracle)" To: Naoya Horiguchi , Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 6/6] fs: Convert error_remove_page to error_remove_folio Date: Fri, 17 Nov 2023 16:14:47 +0000 Message-Id: <20231117161447.2461643-7-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231117161447.2461643-1-willy@infradead.org> References: <20231117161447.2461643-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 582141A0012 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: pb4kzg5k67i93qdndrfjqtodgsqobuap X-HE-Tag: 1700237717-838482 X-HE-Meta: U2FsdGVkX18JK4Q9MOY1yCYQxAL8LhcG+FfxonkAkZEKSymBHtEH8U2fCNvVvFcH7QwL0W63gTCRnPDx5mk0CVf1N0UqRMKIiLsw7VLSyiYw1hrjDB02zHAYwruRA/0iVPS0q0aW7omWW2Ry+AfOpXTWOhIm1Vv/HsXNiTb59ztSNVtW6VOBc7vC4JJchI1m36SECSZoPwjtgQAonwyVTzYa7TVdR8YJ1SRXzEVtsfEAOGsFN1iiS4kfkssgvInUXP6aOxil2TsciGZIuiaEimt25n1TwAnmSMVSGqHYtzerQt9wuVnKEIhgd9spIBlpRll9ZS+xaaIjQfcutOunI7Qjhllao1M897zoLYiCgoJ02x+K0JB11+ktYVjdyGEEQUYkMohA6eH8eWpe9rCMq4AaQ2OIgIPF15mwx5TXV5raUq+fDhPwGCiTYt8+ECAwegiX8LNUbt/W7D6oFFuK8Zo0z9PFkVMwiJlXwH65NlDTsN3dVU2RMNSMWeHICa5SA4AyvjYrt8NTKC4KJOCBkhKA3UK87SUhompMc008gYAjnuB5tZITaIAL+Ei3RxjJNWQRT4kSNJr3aan41y//jW1uvAzHPUKek34YNRvJI4mVrkkoJE1a0L+TKGJh2CyKkdBJ+dGe0ZU2ccrmyY5veNtZtNE+be9WUWcMs9K/vrOakTsotNnLsjCi6uMy/BR+93Ms0tm7ojJ+IUwObvxpo+0P2+80a8VxrPT0RliKfmPGpSKlDETZZs3UDLBLt+3F7BLroFb0igiY6jillounTQYjRLtS0pqt24D7xwsJ8/qAqjp4pCWq+garZi3rtRkIKe3Wl1k4yOJSu0qtnRV57L3r0N7085DmgmJ8Z+/nb8+JhRbYJPviufdzpAQjEFy4fCSohcqHJcRw7rsBsWPLKk/zSMOhqmgU8Bc5q7LGN/+JiAgFwMSizZTvHy+/MD7Xxpqp+3b76EyeQPl1lN0 M8dffUIW Ow9FRl7rH2rl4s7hz10Z/4tA0xjZzQ88p0bgRYfIZXRhla2JgwNgec6/oFxZMcneiN4/o+wSfCl3Dmg1aQPZkAu/W2l6M7ws4WMf5wX4tUknwCsuNuWIj+65rLRhqqmEg9puxDUaNUxBYeXn8pVoFok8JsLlr4nI46aH5qzdie/+0doTavIXizJMZYukorSdt4ifQSHWcvAbyXXiaYf3I0zLK5Nd+DjFxhBzH X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: There were already assertions that we were not passing a tail page to error_remove_page(), so make the compiler enforce that by converting everything to pass and use a folio. Signed-off-by: Matthew Wilcox (Oracle) --- Documentation/filesystems/locking.rst | 4 ++-- Documentation/filesystems/vfs.rst | 6 +++--- block/fops.c | 2 +- fs/afs/write.c | 2 +- fs/bcachefs/fs.c | 2 +- fs/btrfs/inode.c | 2 +- fs/ceph/addr.c | 4 ++-- fs/ext2/inode.c | 2 +- fs/ext4/inode.c | 6 +++--- fs/f2fs/compress.c | 2 +- fs/f2fs/inode.c | 2 +- fs/gfs2/aops.c | 4 ++-- fs/hugetlbfs/inode.c | 6 +++--- fs/nfs/file.c | 2 +- fs/ntfs/aops.c | 6 +++--- fs/ocfs2/aops.c | 2 +- fs/xfs/xfs_aops.c | 2 +- fs/zonefs/file.c | 2 +- include/linux/fs.h | 2 +- include/linux/mm.h | 3 ++- mm/memory-failure.c | 10 +++++----- mm/shmem.c | 6 +++--- mm/truncate.c | 9 ++++----- virt/kvm/guest_memfd.c | 9 +++++---- 24 files changed, 49 insertions(+), 48 deletions(-) diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst index 7be2900806c8..421daf837940 100644 --- a/Documentation/filesystems/locking.rst +++ b/Documentation/filesystems/locking.rst @@ -261,7 +261,7 @@ prototypes:: struct folio *src, enum migrate_mode); int (*launder_folio)(struct folio *); bool (*is_partially_uptodate)(struct folio *, size_t from, size_t count); - int (*error_remove_page)(struct address_space *, struct page *); + int (*error_remove_folio)(struct address_space *, struct folio *); int (*swap_activate)(struct swap_info_struct *sis, struct file *f, sector_t *span) int (*swap_deactivate)(struct file *); int (*swap_rw)(struct kiocb *iocb, struct iov_iter *iter); @@ -287,7 +287,7 @@ direct_IO: migrate_folio: yes (both) launder_folio: yes is_partially_uptodate: yes -error_remove_page: yes +error_remove_folio: yes swap_activate: no swap_deactivate: no swap_rw: yes, unlocks diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst index 99acc2e98673..dd99ce5912d8 100644 --- a/Documentation/filesystems/vfs.rst +++ b/Documentation/filesystems/vfs.rst @@ -823,7 +823,7 @@ cache in your filesystem. The following members are defined: bool (*is_partially_uptodate) (struct folio *, size_t from, size_t count); void (*is_dirty_writeback)(struct folio *, bool *, bool *); - int (*error_remove_page) (struct mapping *mapping, struct page *page); + int (*error_remove_folio)(struct mapping *mapping, struct folio *); int (*swap_activate)(struct swap_info_struct *sis, struct file *f, sector_t *span) int (*swap_deactivate)(struct file *); int (*swap_rw)(struct kiocb *iocb, struct iov_iter *iter); @@ -1034,8 +1034,8 @@ cache in your filesystem. The following members are defined: VM if a folio should be treated as dirty or writeback for the purposes of stalling. -``error_remove_page`` - normally set to generic_error_remove_page if truncation is ok +``error_remove_folio`` + normally set to generic_error_remove_folio if truncation is ok for this address space. Used for memory failure handling. Setting this implies you deal with pages going away under you, unless you have them locked or reference counts increased. diff --git a/block/fops.c b/block/fops.c index 0abaac705daf..0bdad1e8d514 100644 --- a/block/fops.c +++ b/block/fops.c @@ -500,7 +500,7 @@ const struct address_space_operations def_blk_aops = { .readahead = blkdev_readahead, .writepages = blkdev_writepages, .is_partially_uptodate = iomap_is_partially_uptodate, - .error_remove_page = generic_error_remove_page, + .error_remove_folio = generic_error_remove_folio, .migrate_folio = filemap_migrate_folio, }; #endif /* CONFIG_BUFFER_HEAD */ diff --git a/fs/afs/write.c b/fs/afs/write.c index 57d05d67f0c2..e87b52b1f34c 100644 --- a/fs/afs/write.c +++ b/fs/afs/write.c @@ -242,7 +242,7 @@ static void afs_kill_pages(struct address_space *mapping, folio_clear_uptodate(folio); folio_end_writeback(folio); folio_lock(folio); - generic_error_remove_page(mapping, &folio->page); + generic_error_remove_folio(mapping, folio); folio_unlock(folio); folio_put(folio); diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index 74cdd3d85c8a..dc3f6e75703a 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -1103,7 +1103,7 @@ static const struct address_space_operations bch_address_space_operations = { #ifdef CONFIG_MIGRATION .migrate_folio = filemap_migrate_folio, #endif - .error_remove_page = generic_error_remove_page, + .error_remove_folio = generic_error_remove_folio, }; struct bcachefs_fid { diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 9f5a9894f88f..ff7b4efca24f 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -10930,7 +10930,7 @@ static const struct address_space_operations btrfs_aops = { .release_folio = btrfs_release_folio, .migrate_folio = btrfs_migrate_folio, .dirty_folio = filemap_dirty_folio, - .error_remove_page = generic_error_remove_page, + .error_remove_folio = generic_error_remove_folio, .swap_activate = btrfs_swap_activate, .swap_deactivate = btrfs_swap_deactivate, }; diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 85be3bf18cdf..13af429ab030 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -907,8 +907,8 @@ static void writepages_finish(struct ceph_osd_request *req) doutc(cl, "unlocking %p\n", page); if (remove_page) - generic_error_remove_page(inode->i_mapping, - page); + generic_error_remove_folio(inode->i_mapping, + page_folio(page)); unlock_page(page); } diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 464faf6c217e..5a4272b2c6b0 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -969,7 +969,7 @@ const struct address_space_operations ext2_aops = { .writepages = ext2_writepages, .migrate_folio = buffer_migrate_folio, .is_partially_uptodate = block_is_partially_uptodate, - .error_remove_page = generic_error_remove_page, + .error_remove_folio = generic_error_remove_folio, }; static const struct address_space_operations ext2_dax_aops = { diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 61277f7f8722..d7729b17a66b 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3564,7 +3564,7 @@ static const struct address_space_operations ext4_aops = { .direct_IO = noop_direct_IO, .migrate_folio = buffer_migrate_folio, .is_partially_uptodate = block_is_partially_uptodate, - .error_remove_page = generic_error_remove_page, + .error_remove_folio = generic_error_remove_folio, .swap_activate = ext4_iomap_swap_activate, }; @@ -3581,7 +3581,7 @@ static const struct address_space_operations ext4_journalled_aops = { .direct_IO = noop_direct_IO, .migrate_folio = buffer_migrate_folio_norefs, .is_partially_uptodate = block_is_partially_uptodate, - .error_remove_page = generic_error_remove_page, + .error_remove_folio = generic_error_remove_folio, .swap_activate = ext4_iomap_swap_activate, }; @@ -3598,7 +3598,7 @@ static const struct address_space_operations ext4_da_aops = { .direct_IO = noop_direct_IO, .migrate_folio = buffer_migrate_folio, .is_partially_uptodate = block_is_partially_uptodate, - .error_remove_page = generic_error_remove_page, + .error_remove_folio = generic_error_remove_folio, .swap_activate = ext4_iomap_swap_activate, }; diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index 36e5dab6baae..6b2af514660d 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -1944,7 +1944,7 @@ void f2fs_invalidate_compress_pages(struct f2fs_sb_info *sbi, nid_t ino) continue; } - generic_error_remove_page(mapping, &folio->page); + generic_error_remove_folio(mapping, folio); folio_unlock(folio); } folio_batch_release(&fbatch); diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index 560bfcad1af2..a9eb3891f417 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c @@ -600,7 +600,7 @@ struct inode *f2fs_iget(struct super_block *sb, unsigned long ino) #ifdef CONFIG_F2FS_FS_COMPRESSION inode->i_mapping->a_ops = &f2fs_compress_aops; /* - * generic_error_remove_page only truncates pages of regular + * generic_error_remove_folio only truncates pages of regular * inode */ inode->i_mode |= S_IFREG; diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c index ba8742dc91f8..5cffb079b87c 100644 --- a/fs/gfs2/aops.c +++ b/fs/gfs2/aops.c @@ -745,7 +745,7 @@ static const struct address_space_operations gfs2_aops = { .bmap = gfs2_bmap, .migrate_folio = filemap_migrate_folio, .is_partially_uptodate = iomap_is_partially_uptodate, - .error_remove_page = generic_error_remove_page, + .error_remove_folio = generic_error_remove_folio, }; static const struct address_space_operations gfs2_jdata_aops = { @@ -758,7 +758,7 @@ static const struct address_space_operations gfs2_jdata_aops = { .invalidate_folio = gfs2_invalidate_folio, .release_folio = gfs2_release_folio, .is_partially_uptodate = block_is_partially_uptodate, - .error_remove_page = generic_error_remove_page, + .error_remove_folio = generic_error_remove_folio, }; void gfs2_set_aops(struct inode *inode) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index f757d4f7ad98..36132c9125f9 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1129,8 +1129,8 @@ static int hugetlbfs_migrate_folio(struct address_space *mapping, #define hugetlbfs_migrate_folio NULL #endif -static int hugetlbfs_error_remove_page(struct address_space *mapping, - struct page *page) +static int hugetlbfs_error_remove_folio(struct address_space *mapping, + struct folio *folio) { return 0; } @@ -1277,7 +1277,7 @@ static const struct address_space_operations hugetlbfs_aops = { .write_end = hugetlbfs_write_end, .dirty_folio = noop_dirty_folio, .migrate_folio = hugetlbfs_migrate_folio, - .error_remove_page = hugetlbfs_error_remove_page, + .error_remove_folio = hugetlbfs_error_remove_folio, }; diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 3f9768810427..e8cccb94b927 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -567,7 +567,7 @@ const struct address_space_operations nfs_file_aops = { .migrate_folio = nfs_migrate_folio, .launder_folio = nfs_launder_folio, .is_dirty_writeback = nfs_check_dirty_writeback, - .error_remove_page = generic_error_remove_page, + .error_remove_folio = generic_error_remove_folio, .swap_activate = nfs_swap_activate, .swap_deactivate = nfs_swap_deactivate, .swap_rw = nfs_swap_rw, diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c index 71e31e789b29..70479ce915e8 100644 --- a/fs/ntfs/aops.c +++ b/fs/ntfs/aops.c @@ -1644,7 +1644,7 @@ const struct address_space_operations ntfs_normal_aops = { .bmap = ntfs_bmap, .migrate_folio = buffer_migrate_folio, .is_partially_uptodate = block_is_partially_uptodate, - .error_remove_page = generic_error_remove_page, + .error_remove_folio = generic_error_remove_folio, }; /* @@ -1658,7 +1658,7 @@ const struct address_space_operations ntfs_compressed_aops = { #endif /* NTFS_RW */ .migrate_folio = buffer_migrate_folio, .is_partially_uptodate = block_is_partially_uptodate, - .error_remove_page = generic_error_remove_page, + .error_remove_folio = generic_error_remove_folio, }; /* @@ -1673,7 +1673,7 @@ const struct address_space_operations ntfs_mst_aops = { #endif /* NTFS_RW */ .migrate_folio = buffer_migrate_folio, .is_partially_uptodate = block_is_partially_uptodate, - .error_remove_page = generic_error_remove_page, + .error_remove_folio = generic_error_remove_folio, }; #ifdef NTFS_RW diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index ba790219d528..795997806326 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -2480,5 +2480,5 @@ const struct address_space_operations ocfs2_aops = { .release_folio = ocfs2_release_folio, .migrate_folio = buffer_migrate_folio, .is_partially_uptodate = block_is_partially_uptodate, - .error_remove_page = generic_error_remove_page, + .error_remove_folio = generic_error_remove_folio, }; diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 465d7630bb21..813f85156b0c 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -584,7 +584,7 @@ const struct address_space_operations xfs_address_space_operations = { .bmap = xfs_vm_bmap, .migrate_folio = filemap_migrate_folio, .is_partially_uptodate = iomap_is_partially_uptodate, - .error_remove_page = generic_error_remove_page, + .error_remove_folio = generic_error_remove_folio, .swap_activate = xfs_iomap_swapfile_activate, }; diff --git a/fs/zonefs/file.c b/fs/zonefs/file.c index b2c9b35df8f7..6ab2318a9c8e 100644 --- a/fs/zonefs/file.c +++ b/fs/zonefs/file.c @@ -180,7 +180,7 @@ const struct address_space_operations zonefs_file_aops = { .invalidate_folio = iomap_invalidate_folio, .migrate_folio = filemap_migrate_folio, .is_partially_uptodate = iomap_is_partially_uptodate, - .error_remove_page = generic_error_remove_page, + .error_remove_folio = generic_error_remove_folio, .swap_activate = zonefs_swap_activate, }; diff --git a/include/linux/fs.h b/include/linux/fs.h index b2a3f1c61c19..0f26cf2fbac8 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -434,7 +434,7 @@ struct address_space_operations { bool (*is_partially_uptodate) (struct folio *, size_t from, size_t count); void (*is_dirty_writeback) (struct folio *, bool *dirty, bool *wb); - int (*error_remove_page)(struct address_space *, struct page *); + int (*error_remove_folio)(struct address_space *, struct folio *); /* swapfile support */ int (*swap_activate)(struct swap_info_struct *sis, struct file *file, diff --git a/include/linux/mm.h b/include/linux/mm.h index 64cd1ee4aacc..13a090271716 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2384,7 +2384,8 @@ extern void truncate_pagecache(struct inode *inode, loff_t new); extern void truncate_setsize(struct inode *inode, loff_t newsize); void pagecache_isize_extended(struct inode *inode, loff_t from, loff_t to); void truncate_pagecache_range(struct inode *inode, loff_t offset, loff_t end); -int generic_error_remove_page(struct address_space *mapping, struct page *page); +int generic_error_remove_folio(struct address_space *mapping, + struct folio *folio); struct vm_area_struct *lock_mm_and_find_vma(struct mm_struct *mm, unsigned long address, struct pt_regs *regs); diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 6aec94821fda..d8c853b35dbb 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -927,13 +927,13 @@ static int delete_from_lru_cache(struct folio *folio) return -EIO; } -static int truncate_error_page(struct folio *folio, unsigned long pfn, +static int truncate_error_folio(struct folio *folio, unsigned long pfn, struct address_space *mapping) { int ret = MF_FAILED; - if (mapping->a_ops->error_remove_page) { - int err = mapping->a_ops->error_remove_page(mapping, &folio->page); + if (mapping->a_ops->error_remove_folio) { + int err = mapping->a_ops->error_remove_folio(mapping, folio); if (err != 0) pr_info("%#lx: Failed to punch page: %d\n", pfn, err); @@ -1054,7 +1054,7 @@ static int me_pagecache_clean(struct page_state *ps, struct page *p) * * Open: to take i_rwsem or not for this? Right now we don't. */ - ret = truncate_error_page(folio, page_to_pfn(p), mapping); + ret = truncate_error_folio(folio, page_to_pfn(p), mapping); if (has_extra_refcount(ps, p, extra_pins)) ret = MF_FAILED; @@ -1188,7 +1188,7 @@ static int me_huge_page(struct page_state *ps, struct page *p) mapping = folio_mapping(folio); if (mapping) { - res = truncate_error_page(folio, page_to_pfn(p), mapping); + res = truncate_error_folio(folio, page_to_pfn(p), mapping); /* The page is kept in page cache. */ extra_pins = true; folio_unlock(folio); diff --git a/mm/shmem.c b/mm/shmem.c index 0d1ce70bce38..c62f904ba1ca 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -4462,8 +4462,8 @@ static void __init shmem_destroy_inodecache(void) } /* Keep the page in page cache instead of truncating it */ -static int shmem_error_remove_page(struct address_space *mapping, - struct page *page) +static int shmem_error_remove_folio(struct address_space *mapping, + struct folio *folio) { return 0; } @@ -4478,7 +4478,7 @@ const struct address_space_operations shmem_aops = { #ifdef CONFIG_MIGRATION .migrate_folio = migrate_folio, #endif - .error_remove_page = shmem_error_remove_page, + .error_remove_folio = shmem_error_remove_folio, }; EXPORT_SYMBOL(shmem_aops); diff --git a/mm/truncate.c b/mm/truncate.c index 52e3a703e7b2..725b150e47ac 100644 --- a/mm/truncate.c +++ b/mm/truncate.c @@ -250,10 +250,9 @@ bool truncate_inode_partial_folio(struct folio *folio, loff_t start, loff_t end) /* * Used to get rid of pages on hardware memory corruption. */ -int generic_error_remove_page(struct address_space *mapping, struct page *page) +int generic_error_remove_folio(struct address_space *mapping, + struct folio *folio) { - VM_BUG_ON_PAGE(PageTail(page), page); - if (!mapping) return -EINVAL; /* @@ -262,9 +261,9 @@ int generic_error_remove_page(struct address_space *mapping, struct page *page) */ if (!S_ISREG(mapping->host->i_mode)) return -EIO; - return truncate_inode_folio(mapping, page_folio(page)); + return truncate_inode_folio(mapping, folio); } -EXPORT_SYMBOL(generic_error_remove_page); +EXPORT_SYMBOL(generic_error_remove_folio); /** * mapping_evict_folio() - Remove an unused folio from the page-cache. diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c index b99272396119..451435123fe7 100644 --- a/virt/kvm/guest_memfd.c +++ b/virt/kvm/guest_memfd.c @@ -267,7 +267,8 @@ static int kvm_gmem_migrate_folio(struct address_space *mapping, return -EINVAL; } -static int kvm_gmem_error_page(struct address_space *mapping, struct page *page) +static int kvm_gmem_error_folio(struct address_space *mapping, + struct folio *folio) { struct list_head *gmem_list = &mapping->private_list; struct kvm_gmem *gmem; @@ -275,8 +276,8 @@ static int kvm_gmem_error_page(struct address_space *mapping, struct page *page) filemap_invalidate_lock_shared(mapping); - start = page->index; - end = start + thp_nr_pages(page); + start = folio->index; + end = start + folio_nr_pages(folio); list_for_each_entry(gmem, gmem_list, entry) kvm_gmem_invalidate_begin(gmem, start, end); @@ -303,7 +304,7 @@ static const struct address_space_operations kvm_gmem_aops = { #ifdef CONFIG_MIGRATION .migrate_folio = kvm_gmem_migrate_folio, #endif - .error_remove_page = kvm_gmem_error_page, + .error_remove_folio = kvm_gmem_error_folio, }; static int kvm_gmem_getattr(struct mnt_idmap *idmap, const struct path *path,