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; }