From patchwork Wed Mar 27 14:10:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13606715 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 0BAB6C47DD9 for ; Wed, 27 Mar 2024 14:13:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 864036B0093; Wed, 27 Mar 2024 10:13:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 811366B0095; Wed, 27 Mar 2024 10:13:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 616376B0096; Wed, 27 Mar 2024 10:13:22 -0400 (EDT) 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 3FA016B0092 for ; Wed, 27 Mar 2024 10:13:22 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0657B1A0DFF for ; Wed, 27 Mar 2024 14:13:22 +0000 (UTC) X-FDA: 81943011444.19.01EB30A Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf13.hostedemail.com (Postfix) with ESMTP id 4BBB820016 for ; Wed, 27 Mar 2024 14:13:18 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711548800; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8jdoZHQe/eabwCQajw5l4z4BSM48qUV5oi9A/k3PhpM=; b=dXA6uD3+LwZw+9iJYf6DJX6AC2CqxVJOdfylXOQMI/2DKEZ4KlQgxRhHsaqfMs+OyOTMt/ sHhC9kbQIDbSo80m4hND4by2OuEmgy3sAfOsm8dvJHdngd3xydVIY4r1SRypcqTOq6qx6t DXMtLaEZhtx9TRdhPQNPiazkgsSXeo0= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711548800; a=rsa-sha256; cv=none; b=KZHqCkmMU3JC6nwJiDU4dxRf8FBU2gPzNIiE0wYWNIxrfoPoHwVLsjN4AzxB1GEJbiVPjD vGctIQ93BU86FPrMPB1pUIEmMzyT9V77L2CeMlBrFbMEkLOGXGUDFGiM9GBMW422Q1LXSw lAyvBmm2HTiIyPP2eFaAF20EcHvHRX4= Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4V4T8q6jGWz29dPD; Wed, 27 Mar 2024 22:10:35 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 9C5C71A0172; Wed, 27 Mar 2024 22:13:15 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 27 Mar 2024 22:13:14 +0800 From: Kefeng Wang To: Andrew Morton CC: , Miaohe Lin , Naoya Horiguchi , David Hildenbrand , Oscar Salvador , Zi Yan , Hugh Dickins , Jonathan Corbet , , , Baolin Wang , Kefeng Wang Subject: [PATCH 2/6] mm: memory_hotplug: use more folio in do_migrate_range() Date: Wed, 27 Mar 2024 22:10:30 +0800 Message-ID: <20240327141034.3712697-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240327141034.3712697-1-wangkefeng.wang@huawei.com> References: <20240327141034.3712697-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100001.china.huawei.com (7.185.36.93) X-Rspamd-Queue-Id: 4BBB820016 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: wegg9zx67c4xi784en75io1pjgc1xogf X-HE-Tag: 1711548798-521187 X-HE-Meta: U2FsdGVkX1+BhTdfjEBlSVt92mERv2hJENusxv0nShxoxQ/09fGo3PKDKLoxUOxHeXsNTjzqvOMnhnTqM/dsEzK0+ta0QSQgSoaEwY6Zf4ouyw1m3wflxGyqPtKxNF9Teu75qKJz0O9maBMF4fOlirG4+RGOzVMstmaeXGqxXL/45BK2niCI2qzgBzd/O3PONzufr2K12WKdkR/qXBPq7PWQ0bjyRgKMtN81FpB71OxKUUe0dK2S436NiTRYmgPHixLB8fRvWBkv7wl6dOWnRZQVrH1rBbCNfSXRbJD7nIZ6K3C42J3Nva7s7Lsh98ZgqhueEa6IdTQQrN3zJeeGLLj4qKyWRLa0YCxDcO/HiEmOEmfrG0zmoeo/9sKDoKEoNbRN8x49mWlO76I2IqQwaUcVBBFDJv5y20vg0/h/nwU3OesYYPyPo/hMtSJSgWHpcFA7Jvk2bBpxcUBnaGw2nYzuy1lpuR6AL30YyGFd5kHCVrhR9LMRtyGR8V4JfNuezr1pd6mFMT97pDPop3N5Wz8yMb2wjbvl5JPp8r7QLuf7oV3613OmEsAPLUogUEiJfZbl6aEgRMJ0pxxMCKrE5XtkL1j7+fPWVHuakZ5jeyM+DrXBtQzTSMdKdZnvWGB5GvFPGAnKnU9/gHP47cbQQqUyM47ciwJV5vTlPMcxmT82MJzww28z72HJpbfzzVPe48KC2m1iBXqD2QMtxM9lTSColSnUAPwNRBdivSdAcJuxf+/Q7D+1LbjZWgHoRbOj/0HjBgdkiQbswTPgw+p94c5BsWH9pMFFizSvuecTQa4GXjajzEoR6zky+7TgjpXpwpW3ad3sfxGycdRFqINbXcrL3tCvf3+eDTwSphsIT2res61qLuvCPQlcBpWSlIFkxIKlq9vVbd3ryd2GSMW4rPnY9aAEsMHG27ckCMzRJKqG1G+FmQsSQvTFATiyxxVSL2CzG0qEr2b35cMH6bG 56Xz3tJG hYPUTdCAvOZSUn5+pzbhFRsvshplfNkil3qtxZ6AkOPL9lH2AhWaq/xdoBoPb1lSq/w0/DvUb6avMsvD9y7WXF/FvFxmokTS6QB+/h7ENSHPbacmLImUa+k5ZC78FVJCjFIMS04i50LOXf+fBgwvbo0kWbowOkvOH/b+qsVZqxCs9hcuLGYT+XIi1yMnWTiNcl6cK 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: With isolate_movable_folio() and folio_isolate_lru(), let's use more folio in do_migrate_range() to save compound_head() calls. Signed-off-by: Kefeng Wang --- mm/memory_hotplug.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index a444e2d7dd2b..bd207772c619 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1774,14 +1774,14 @@ static int scan_movable_pages(unsigned long start, unsigned long end, static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) { + struct folio *folio; unsigned long pfn; - struct page *page, *head; LIST_HEAD(source); static DEFINE_RATELIMIT_STATE(migrate_rs, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); for (pfn = start_pfn; pfn < end_pfn; pfn++) { - struct folio *folio; + struct page *page, *head; bool isolated; if (!pfn_valid(pfn)) @@ -1818,15 +1818,15 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) * We can skip free pages. And we can deal with pages on * LRU and non-lru movable pages. */ - if (PageLRU(page)) - isolated = isolate_lru_page(page); + if (folio_test_lru(folio)) + isolated = folio_isolate_lru(folio); else - isolated = isolate_movable_page(page, ISOLATE_UNEVICTABLE); + isolated = isolate_movable_folio(folio, ISOLATE_UNEVICTABLE); if (isolated) { - list_add_tail(&page->lru, &source); - if (!__PageMovable(page)) - inc_node_page_state(page, NR_ISOLATED_ANON + - page_is_file_lru(page)); + list_add_tail(&folio->lru, &source); + if (!__folio_test_movable(folio)) + node_stat_add_folio(folio, NR_ISOLATED_ANON + + folio_is_file_lru(folio)); } else { if (__ratelimit(&migrate_rs)) { @@ -1834,7 +1834,7 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) dump_page(page, "isolation failed"); } } - put_page(page); + folio_put(folio); } if (!list_empty(&source)) { nodemask_t nmask = node_states[N_MEMORY]; @@ -1846,9 +1846,9 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) /* * We have checked that migration range is on a single zone so - * we can use the nid of the first page to all the others. + * we can use the nid of the first folio to all the others. */ - mtc.nid = page_to_nid(list_first_entry(&source, struct page, lru)); + mtc.nid = folio_nid(list_first_entry(&source, struct folio, lru)); /* * try to allocate from a different node but reuse this node @@ -1861,11 +1861,11 @@ static void do_migrate_range(unsigned long start_pfn, unsigned long end_pfn) ret = migrate_pages(&source, alloc_migration_target, NULL, (unsigned long)&mtc, MIGRATE_SYNC, MR_MEMORY_HOTPLUG, NULL); if (ret) { - list_for_each_entry(page, &source, lru) { + list_for_each_entry(folio, &source, lru) { if (__ratelimit(&migrate_rs)) { pr_warn("migrating pfn %lx failed ret:%d\n", - page_to_pfn(page), ret); - dump_page(page, "migration failure"); + folio_pfn(folio), ret); + dump_page(&folio->page, "migration failure"); } } putback_movable_pages(&source);