From patchwork Wed Aug 2 09:53:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13337929 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 C2F69C04A94 for ; Wed, 2 Aug 2023 09:45:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 67D84280141; Wed, 2 Aug 2023 05:45:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 62DA6280112; Wed, 2 Aug 2023 05:45:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D4E0280143; Wed, 2 Aug 2023 05:45:28 -0400 (EDT) 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 284DB280141 for ; Wed, 2 Aug 2023 05:45:28 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E2F171C951A for ; Wed, 2 Aug 2023 09:45:27 +0000 (UTC) X-FDA: 81078681894.03.E3C3E9E Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf02.hostedemail.com (Postfix) with ESMTP id 312158001F for ; Wed, 2 Aug 2023 09:45:24 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf02.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 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=1690969526; 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=f7DiKVRoTUN5O+c/eQv/0iW0L2QwEutWFkDqyujwY4o=; b=btKOJqVhn+tP/QwhePCwxQ303IE9ML96a3LTSbd0Q99B3SKqf93zDSEinbFehUZVu+bjfW hBmKx+CPjLQHRj2GqRgfxl+zCCyd1rGZgcKegNqP5alKwcBjIC+FFNxDg5L7iCmrgKet3z LMVr64Z2FeJeIOD1+G4ZUqt4JQms16c= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf02.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690969526; a=rsa-sha256; cv=none; b=UJ+f6cWap7PE9NMORwAzokI1L8GpA1LY1/COeJnP4g7DbPpmriJN9b7vJjJdg8jMlCgLp7 1xyzHjiAmfzF2HRiq5eGknoOtSYUd5C8Jf+k2gaIkof2moPNLpJaiTTAzrrijqLNvN5pVm zXFHK91zSHNIrHiwXJAbOu7d326G7NU= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RG6Vb57BczVk0q; Wed, 2 Aug 2023 17:43:35 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 2 Aug 2023 17:45:19 +0800 From: Kefeng Wang To: Andrew Morton , , CC: Huang Ying , David Hildenbrand , Matthew Wilcox , Kefeng Wang Subject: [PATCH 2/4] mm: migrate: convert numamigrate_isolate_page() to numamigrate_isolate_folio() Date: Wed, 2 Aug 2023 17:53:44 +0800 Message-ID: <20230802095346.87449-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230802095346.87449-1-wangkefeng.wang@huawei.com> References: <20230802095346.87449-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 312158001F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: cz8jmapxz94g358q4oameq464p4fk5a1 X-HE-Tag: 1690969524-565787 X-HE-Meta: U2FsdGVkX18vJqHDUKCywIUibfyGmtzYeLqF0EfJ0axhgVEzrLTsNCjCCqv2MVb4tLV5lWM4lDK91PxW48tso9TfIpI+pH/d5LKvX7Nyie8FQSNDsedDgjxgmjKryFE/XDF2M7g4VYxuCT3O0JUv9UmbPuuV2BnBrdWcxeNWYmN3hPhzRL164kuTObkKrPxpC+qJCp1JNhsjgbAkYWbdLDxpREHk2d6bx+4wwyAYGFjMFuZWqSon71oXEn8zE/LXwz4s5xxWFYJq3UWnPoq2o3OwllgyX85qlhF3iPZhSC4IqTxCa9J7FGSzGxr+p/GC593uO0K/rhZ+D8gn8lU4vU0CBrPKdkWSnsn9AijgG20jZvd8ESSn6ubZJhVXDD8vcdunnK+uOiQRjYHS6MEFFqKchR0QsjvkpmKeGVlVjNYlzqdtH9Dka5l/eOTcbzpC7TBVGOgyIOJEOVEKzXPpzgWXIwxVG729+FGwh12AmJJ9fta20C0lvrd2qxGfrI0L3cB2/6z9UW9YFBB9KX4DSAEwA4rw3hGU/KskbVStdDhF66rJdBK07FZJ+j2+MPaDy7PHtDox5V+IOqXiFHC3WMwgbsjyDIisK+8rDM9m3tz83wLntwhdVEnapxlBoQxiSqUyRYVmXrEvjgv2dd+5UD4oflU6n42Ktrc1Jm4EEcZBVOYo/r2yrWhu4dfsf3XwrI3EdShwKSTg9ywbYVTa1f1PwH+isfyVwTCgOxXG0ztqFZi1TZnUpS298IjKRebx79kmNPrMxaIdLhaqaVWd772hRncLh6pzgnSAy22YZRsA4lBdvPDm/fmcFIctvzf4B4cFv3K16FDkuvltXHF7wu+ZqkZsjLLL7IA1hUlhXIg3HeDrTgWLvWGiYoxlrdjDEM+P/4S1oCifxeTrA0wjIdE7Qo8ZDTJ1mo34VmEtifPjTWK8RjXHi7F9O5VcGChJa/IY+C5/SPLMHjE8EXv wGq8aKl7 0vwsqfWkd4jN8h3EMg32uJZVM5bfvYCvLXHTRSzvwvrn8mbe2qGq5Z/q377EyX60Br6OyRyJSjTI/bbCsDx+yrCjICCf2su07neIy7fN2htc43HCI9VgugnzFDMlR5K7MQQ4ByvOLoAflk5Ar6S4BljcXdx5yEwt4+sKvuBXwAyoYe2Z8Rul5Wg4hPywBnVe0PQ3P 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: Rename numamigrate_isolate_page() to numamigrate_isolate_folio(), then make it takes a folio and use folio API to save compound_head() calls. Signed-off-by: Kefeng Wang --- mm/migrate.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index b0c318bc531c..39e0d35bccb3 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2476,15 +2476,15 @@ static struct folio *alloc_misplaced_dst_folio(struct folio *src, return __folio_alloc_node(gfp, order, nid); } -static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) +static int numamigrate_isolate_folio(pg_data_t *pgdat, struct folio *folio) { - int nr_pages = thp_nr_pages(page); - int order = compound_order(page); + int nr_pages = folio_nr_pages(folio); + int order = folio_order(folio); - VM_BUG_ON_PAGE(order && !PageTransHuge(page), page); + VM_BUG_ON_FOLIO(order && !folio_test_pmd_mappable(folio), folio); /* Do not migrate THP mapped by multiple processes */ - if (PageTransHuge(page) && total_mapcount(page) > 1) + if (folio_test_pmd_mappable(folio) && folio_estimated_sharers(folio) > 1) return 0; /* Avoid migrating to a node that is nearly full */ @@ -2501,18 +2501,18 @@ static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) return 0; } - if (!isolate_lru_page(page)) + if (!folio_isolate_lru(folio)) return 0; - mod_node_page_state(page_pgdat(page), NR_ISOLATED_ANON + page_is_file_lru(page), + node_stat_mod_folio(folio, NR_ISOLATED_ANON + folio_is_file_lru(folio), nr_pages); /* - * Isolating the page has taken another reference, so the - * caller's reference can be safely dropped without the page + * Isolating the folio has taken another reference, so the + * caller's reference can be safely dropped without the folio * disappearing underneath us during migration. */ - put_page(page); + folio_put(folio); return 1; } @@ -2546,7 +2546,7 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, if (page_is_file_lru(page) && PageDirty(page)) goto out; - isolated = numamigrate_isolate_page(pgdat, page); + isolated = numamigrate_isolate_folio(pgdat, page_folio(page)); if (!isolated) goto out;