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) {