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