From patchwork Wed Aug 2 09:53:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 129740 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp347452vqx; Wed, 2 Aug 2023 03:14:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlGWbpjY+EjhrA5ls/MWV2MQmUsToPcLlFZQkBUeIt5G9af18+4nbx0kLonK/Pgvv0VzuKfg X-Received: by 2002:a17:906:518a:b0:99b:fdbb:31f1 with SMTP id y10-20020a170906518a00b0099bfdbb31f1mr4858386ejk.16.1690971268623; Wed, 02 Aug 2023 03:14:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690971268; cv=none; d=google.com; s=arc-20160816; b=u7kQUcsZt/xFdklpeBwIBARtjeeT8Xs7M4RDZ5p8926MOqJwPxcS7s4y5PKcBitY/H 8KIaaGq9fV1vjKMb4I/1GUvuKJOvc6wT3+0nnaVE3zgQEZirNl/Y7Pa5FwMj+nTkRyDa zGKVUeL7rnzyKOi42hcpp+dI73+uBOdEEi1LRtiNavuBXpcUGiPyVGOM7BUcwdk62ZKD f1x6hyUElKLMoCUIPbIiP5NXV6Ny/oDv1DZ+KO1qjpaxjoiuKt4QiD7XP3sUqZf7+VlB LCB7J0VuvbgNyjwDWDwZDFFki0G8qBU4BNnybzVaWxF9Sw/z+SQshssXT5kvPHfH6evX v3Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=sKA63lWYPN2MF+P3BEUtg/sR22zgj0WfA+RU7kxoC38=; fh=frTJ5b0OruHscvMLDfKfibXYJSJ4/6aFlw/4ZMUelj0=; b=CvA/hyHxFxZ93BT/ZdeV9ABOBXiOo5X4yD0NZrFgwiL0oB1nXqUJow7vPHEINMMq1a cJSKk1ArH6iTl0nhuYevH4pODzQejTTmD9xiqg8XJp/Es20kQ1cwRSBxCw8tN6gylZaA p6rGBTx2rpDF2oTOQWgUqRvEZeQ1Pjdb4CjIXOciEG3vlarynm7DtE9cG3QtDkXsjwZh EFiac8xbal//hZbCM5U+ySHupp1bGeVzFEFky77jSBEToZrYEPiVxGdOfwBE04C4mr7m +Rp6RChF8hxrWIeCwwc06V0kN/E3Xdg1Ntpn5JjRCm7txpvgeFMaPYKWBWjeVoCx/Vhr z7rA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f16-20020a1709067f9000b009893fe84e74si10427757ejr.484.2023.08.02.03.14.04; Wed, 02 Aug 2023 03:14:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233857AbjHBJpf (ORCPT + 99 others); Wed, 2 Aug 2023 05:45:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230494AbjHBJpc (ORCPT ); Wed, 2 Aug 2023 05:45:32 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 902512D53 for ; Wed, 2 Aug 2023 02:45:21 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4RG6TT1cQ1zLnxK; Wed, 2 Aug 2023 17:42:37 +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 1/4] mm: migrate: use a folio in add_page_for_migration() Date: Wed, 2 Aug 2023 17:53:43 +0800 Message-ID: <20230802095346.87449-2-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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773111888484406168 X-GMAIL-MSGID: 1773111888484406168 Use a folio in add_page_for_migration() to save compound_head() calls. Signed-off-by: Kefeng Wang --- mm/migrate.c | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index e21d5a7e7447..b0c318bc531c 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2057,6 +2057,7 @@ static int add_page_for_migration(struct mm_struct *mm, const void __user *p, struct vm_area_struct *vma; unsigned long addr; struct page *page; + struct folio *folio; int err; bool isolated; @@ -2079,45 +2080,42 @@ static int add_page_for_migration(struct mm_struct *mm, const void __user *p, if (!page) goto out; - if (is_zone_device_page(page)) - goto out_putpage; + folio = page_folio(page); + if (folio_is_zone_device(folio)) + goto out_putfolio; err = 0; - if (page_to_nid(page) == node) - goto out_putpage; + if (folio_nid(folio) == node) + goto out_putfolio; err = -EACCES; - if (page_mapcount(page) > 1 && !migrate_all) - goto out_putpage; + if (folio_estimated_sharers(folio) > 1 && !migrate_all) + goto out_putfolio; - if (PageHuge(page)) { - if (PageHead(page)) { - isolated = isolate_hugetlb(page_folio(page), pagelist); + if (folio_test_hugetlb(folio)) { + if (folio_test_large(folio)) { + isolated = isolate_hugetlb(folio, pagelist); err = isolated ? 1 : -EBUSY; } } else { - struct page *head; - - head = compound_head(page); - isolated = isolate_lru_page(head); + isolated = folio_isolate_lru(folio); if (!isolated) { err = -EBUSY; - goto out_putpage; + goto out_putfolio; } err = 1; - list_add_tail(&head->lru, pagelist); - mod_node_page_state(page_pgdat(head), - NR_ISOLATED_ANON + page_is_file_lru(head), - thp_nr_pages(head)); + list_add_tail(&folio->lru, pagelist); + node_stat_mod_folio(folio, + NR_ISOLATED_ANON + folio_is_file_lru(folio), + folio_nr_pages(folio)); } -out_putpage: +out_putfolio: /* - * Either remove the duplicate refcount from - * isolate_lru_page() or drop the page ref if it was - * not isolated. + * Either remove the duplicate refcount from folio_isolate_lru() + * or drop the folio ref if it was not isolated. */ - put_page(page); + folio_put(folio); out: mmap_read_unlock(mm); return err; 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: 129733 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp338975vqx; Wed, 2 Aug 2023 02:59:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlEPX7Q7N/pR5FbhPmD8C5alBtsFK/gZ7w0eeSqxEVftEgVgCRincUvI2z0UYqsbx5pZ0Oeu X-Received: by 2002:a05:6a20:7daa:b0:12c:2956:564 with SMTP id v42-20020a056a207daa00b0012c29560564mr15901417pzj.45.1690970373187; Wed, 02 Aug 2023 02:59:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690970373; cv=none; d=google.com; s=arc-20160816; b=fJKycQINJpe9AHY71OQwhjprUluyf7t0OpRTtY12xNpq4Pc8F4qbJ3u1bLy9cfgGvs bPlUaDEJhA7T0lXPwK3m0QvhNQyGWOIklbCsizGgDmAImkHozQ8wNteArAqCezj0NddH 5PDndW5c+a4D3hhXb0PuvuqFI+KGYKy9AR22Ro1P5XmAASTLeoghtse27wNV0JVjkmtK kYUSFhN9W55ywOj5SuLFer4Jqks/pSFSIh8Eee8SQ/p3vUgjgt81KtutUOqL/m5LLSSy kcPmLfYe/3VlTgxtAR24MryHVjrY2nPF+tXvsMuSktl/5WaihDUhKUW0H27VYckfDqlA xn7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=f7DiKVRoTUN5O+c/eQv/0iW0L2QwEutWFkDqyujwY4o=; fh=frTJ5b0OruHscvMLDfKfibXYJSJ4/6aFlw/4ZMUelj0=; b=irOrwC3Cxi/IrEqb+ldJRKoIMpXsZGVxJAjnkRzAZ8O5c4EqzETvk1DD8GUqn8tWQb JpZYFdfGNXgx8y149siNqAN0xsusqMdfMrAN/qa69HqYAGirUzbJWWXfEsNBjD4WoPiP /Clp9zbg2O56hU4lyQgw4z7AfjAFPnGGnKRlrcRRMM3zFe30L4cydiPaO5Zwg+BF0Km5 N1GevUCR4ej4eBR3r3jXb/0MRBRjLVxZgniv+zXFM21c1Y1NWpZdiFfejIFIIwJJwQJ7 Z+1kV5YxSH8VFvTbb3otZdwDr4EY4Q4dalmj+dSZEe+F9T28wFESkh0Irt4M4Y1aQ67m bv4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k13-20020aa788cd000000b00686627e7e9esi5995027pff.120.2023.08.02.02.59.19; Wed, 02 Aug 2023 02:59:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234166AbjHBJpl (ORCPT + 99 others); Wed, 2 Aug 2023 05:45:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230372AbjHBJpe (ORCPT ); Wed, 2 Aug 2023 05:45:34 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44C312D5B for ; Wed, 2 Aug 2023 02:45:22 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773110950011006123 X-GMAIL-MSGID: 1773110950011006123 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; From patchwork Wed Aug 2 09:53:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 129748 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp352332vqx; Wed, 2 Aug 2023 03:24:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlGE4mZBv73KI31naJyYW/w2c9kVL2Ag2HIr+Ks6HxtWDc8vJ6OAAg3FkRfK/8Vz1U7RSiHP X-Received: by 2002:a17:906:3cb1:b0:99b:f08d:a390 with SMTP id b17-20020a1709063cb100b0099bf08da390mr4288350ejh.26.1690971876648; Wed, 02 Aug 2023 03:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690971876; cv=none; d=google.com; s=arc-20160816; b=eUJwG/5HpC5CQWYxtmw4VO/v7mDKmexANoWNOImsc75bk0L3IcwOg3WXUMLeyxcO91 VC6GooUhAnBs10RLymS9baIWJSru/kiYpO9BLdU/c3kdE6g/KsUgxrMyGVtOkHEMvXl0 l89fA+rnfND3bpSrkYsEWotJUzaREAJyFlch9oxaRQuBkIXCKQOOXua6W/ry1S/6jWsG r1FHO569lY7r+WkrYR6zCKsHod96zMXTMCbO60TlcrJ0H1LJV4JJk/Z1O5T/UTcISllU savENr4XQlXleP9CmJau2IYxjC4VJcJp7AHAhy1r3F+J+kOeCiiE+8UQcmAuZsMH+8eI UQmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=1+Xi+YSKqKVg8IVlzQ0fkNKnjeMm7NKG82xUkYU+qiA=; fh=frTJ5b0OruHscvMLDfKfibXYJSJ4/6aFlw/4ZMUelj0=; b=PuuZJlnn27D5fEANmv+kUCR2Bwy58wrNlF2BQUWpJ4XEtGf4fEX+eONP0/oWQwwhzH Ipzdrv72rn07hrfXe5Q1qkVu6u5AO4UTKR9wz+yhYehmty8ayJgLjB//9cPDGM0eFvqC yqzfzmAOGws1C/NqM8eEhfV/FBrCuIPBczPWf6lisEM6CLAT1foIJlK3h8O0J8bj+4WR B+5mQFFOUnmKspmkSGRFFhEzj4BQNia7beADWQKAY1xXt9Jups40jFlFx+rToy1Rri4+ GkEPSjSJbmDMr0NsXmY2HpMdde6ypz9BvxnnK4Tuo+Jre97kGhqEC/9/62Oj3+gxIcXE abdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rs5-20020a170907036500b0099b921de2fasi10136379ejb.964.2023.08.02.03.24.11; Wed, 02 Aug 2023 03:24:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234122AbjHBJpu (ORCPT + 99 others); Wed, 2 Aug 2023 05:45:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233802AbjHBJpe (ORCPT ); Wed, 2 Aug 2023 05:45:34 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 841682D5F for ; Wed, 2 Aug 2023 02:45:22 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RG6WQ4xLDz1GDP2; Wed, 2 Aug 2023 17:44:18 +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:20 +0800 From: Kefeng Wang To: Andrew Morton , , CC: Huang Ying , David Hildenbrand , Matthew Wilcox , Kefeng Wang Subject: [PATCH 3/4] mm: migrate: make migrate_misplaced_page() to take a folio Date: Wed, 2 Aug 2023 17:53:45 +0800 Message-ID: <20230802095346.87449-4-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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773112526743981714 X-GMAIL-MSGID: 1773112526743981714 Make migrate_misplaced_page() to take a folio and use folio API to save compound_head() calls. Signed-off-by: Kefeng Wang --- mm/migrate.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 39e0d35bccb3..4be61f944cac 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2525,17 +2525,18 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, int node) { pg_data_t *pgdat = NODE_DATA(node); + struct folio *folio = page_folio(page); int isolated; int nr_remaining; unsigned int nr_succeeded; LIST_HEAD(migratepages); - int nr_pages = thp_nr_pages(page); + int nr_pages = folio_nr_pages(folio); /* * Don't migrate file pages that are mapped in multiple processes * with execute permissions as they are probably shared libraries. */ - if (page_mapcount(page) != 1 && page_is_file_lru(page) && + if (folio_estimated_sharers(folio) != 1 && folio_is_file_lru(folio) && (vma->vm_flags & VM_EXEC)) goto out; @@ -2543,29 +2544,29 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, * Also do not migrate dirty pages as not all filesystems can move * dirty pages in MIGRATE_ASYNC mode which is a waste of cycles. */ - if (page_is_file_lru(page) && PageDirty(page)) + if (folio_is_file_lru(folio) && folio_test_dirty(folio)) goto out; - isolated = numamigrate_isolate_folio(pgdat, page_folio(page)); + isolated = numamigrate_isolate_folio(pgdat, folio); if (!isolated) goto out; - list_add(&page->lru, &migratepages); + list_add(&folio->lru, &migratepages); nr_remaining = migrate_pages(&migratepages, alloc_misplaced_dst_folio, NULL, node, MIGRATE_ASYNC, MR_NUMA_MISPLACED, &nr_succeeded); if (nr_remaining) { if (!list_empty(&migratepages)) { - list_del(&page->lru); - mod_node_page_state(page_pgdat(page), NR_ISOLATED_ANON + - page_is_file_lru(page), -nr_pages); - putback_lru_page(page); + list_del(&folio->lru); + node_stat_mod_folio(folio, NR_ISOLATED_ANON + + folio_is_file_lru(folio), -nr_pages); + folio_putback_lru(folio); } isolated = 0; } if (nr_succeeded) { count_vm_numa_events(NUMA_PAGE_MIGRATE, nr_succeeded); - if (!node_is_toptier(page_to_nid(page)) && node_is_toptier(node)) + if (!node_is_toptier(folio_nid(folio)) && node_is_toptier(node)) mod_node_page_state(pgdat, PGPROMOTE_SUCCESS, nr_succeeded); } @@ -2573,7 +2574,7 @@ int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, return isolated; out: - put_page(page); + folio_put(folio); return 0; } #endif /* CONFIG_NUMA_BALANCING */ From patchwork Wed Aug 2 09:53:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 129734 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f41:0:b0:3e4:2afc:c1 with SMTP id v1csp338990vqx; Wed, 2 Aug 2023 02:59:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlECNrm128oL0JYenfYwUsVgVJGcPoiMtwNr9QG6NerziIOrVXaQlxO5dVX+nwS+oQKMNpqH X-Received: by 2002:a05:6a20:8e0f:b0:126:42ce:bd44 with SMTP id y15-20020a056a208e0f00b0012642cebd44mr18129364pzj.17.1690970374732; Wed, 02 Aug 2023 02:59:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690970374; cv=none; d=google.com; s=arc-20160816; b=TdopTeALDW7SON/0C2CqhUTrfAolIxvT/w0XmDVf5y1NAZo0HM7GKG5bR3EF1Em7W3 l6a7/tWLYMDDgzUDV51QmDzylObrW/Lt1Sg0xbL8eQIb+QB+KGaCju8+rsysYhPKZp5r QMKDRf/YczdAN7b7pNRRPQAk3YNMB7dkJ+YxFHJetk7DeALAUMtglagsv/tQXgUWuX3i WlQW19tPYFuRRZoHwosirRUsuzSTcFsGD7wBqzBnXfnUrwOgaVu8zXBZj0HIdVcBImXE GZI+IecRttzLs8q1147zsEGqMxdP3mv6xU3wgBN5/AiexCfciq13x601CQCvNy8dERlT M3fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=C9SLzI1jBQxZ3MenzIaKU+m294r5B3MM6jSUBENnZOM=; fh=frTJ5b0OruHscvMLDfKfibXYJSJ4/6aFlw/4ZMUelj0=; b=wcN7pez2ciFc3N96TXMdkn3PGddfswoEzBymTgr8QhbtcHKOsLXZFjV0PG4qbrbp5n IUFpD+R/6LmQtui8LIIqbMf7jbEKALKLptvYso4xdKGK1xc/tZPrQwxSzuWoszbcFVvy Ywd7VEBFJbLPfGBgLbduRbmMkKQ/NdSzp6rMK7M1r1o5KGA5YoAHBUa7oPkKXf8Bo3sh 62ZCILSStWozu5dvsNsvDXlTSoRaWPZc8O8n/gwJmwwcvDCaOfqTw1tOuV3JSE6QZe13 /fak2OHQ/FbfeKN9Nux79qghdTAfRf2IjRGmHLTDBiWCtJOgxjv4n7FRfqRxv3qe4cv2 Gdjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m27-20020a63711b000000b00564364d198fsi6262370pgc.361.2023.08.02.02.59.21; Wed, 02 Aug 2023 02:59:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229948AbjHBJpo (ORCPT + 99 others); Wed, 2 Aug 2023 05:45:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233451AbjHBJpe (ORCPT ); Wed, 2 Aug 2023 05:45:34 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DD732D62 for ; Wed, 2 Aug 2023 02:45:22 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RG6WQ2pXczrS1v; Wed, 2 Aug 2023 17:44:18 +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:20 +0800 From: Kefeng Wang To: Andrew Morton , , CC: Huang Ying , David Hildenbrand , Matthew Wilcox , Kefeng Wang Subject: [PATCH 4/4] mm: migrate: use __folio_test_movable() Date: Wed, 2 Aug 2023 17:53:46 +0800 Message-ID: <20230802095346.87449-5-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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773110951857860367 X-GMAIL-MSGID: 1773110951857860367 Use __folio_test_movable(), no need to convert from folio to page. Signed-off-by: Kefeng Wang Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: David Hildenbrand --- mm/migrate.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 4be61f944cac..8590e6f68cf3 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -157,8 +157,8 @@ void putback_movable_pages(struct list_head *l) list_del(&folio->lru); /* * We isolated non-lru movable folio so here we can use - * __PageMovable because LRU folio's mapping cannot have - * PAGE_MAPPING_MOVABLE. + * __folio_test_movable because LRU folio's mapping cannot + * have PAGE_MAPPING_MOVABLE. */ if (unlikely(__folio_test_movable(folio))) { VM_BUG_ON_FOLIO(!folio_test_isolated(folio), folio); @@ -943,7 +943,7 @@ static int move_to_new_folio(struct folio *dst, struct folio *src, enum migrate_mode mode) { int rc = -EAGAIN; - bool is_lru = !__PageMovable(&src->page); + bool is_lru = !__folio_test_movable(src); VM_BUG_ON_FOLIO(!folio_test_locked(src), src); VM_BUG_ON_FOLIO(!folio_test_locked(dst), dst); @@ -990,7 +990,7 @@ static int move_to_new_folio(struct folio *dst, struct folio *src, * src is freed; but stats require that PageAnon be left as PageAnon. */ if (rc == MIGRATEPAGE_SUCCESS) { - if (__PageMovable(&src->page)) { + if (__folio_test_movable(src)) { VM_BUG_ON_FOLIO(!folio_test_isolated(src), src); /* @@ -1082,7 +1082,7 @@ static void migrate_folio_done(struct folio *src, /* * Compaction can migrate also non-LRU pages which are * not accounted to NR_ISOLATED_*. They can be recognized - * as __PageMovable + * as __folio_test_movable */ if (likely(!__folio_test_movable(src))) mod_node_page_state(folio_pgdat(src), NR_ISOLATED_ANON + @@ -1103,7 +1103,7 @@ static int migrate_folio_unmap(new_folio_t get_new_folio, int rc = -EAGAIN; int page_was_mapped = 0; struct anon_vma *anon_vma = NULL; - bool is_lru = !__PageMovable(&src->page); + bool is_lru = !__folio_test_movable(src); bool locked = false; bool dst_locked = false; @@ -1261,7 +1261,7 @@ static int migrate_folio_move(free_folio_t put_new_folio, unsigned long private, int rc; int page_was_mapped = 0; struct anon_vma *anon_vma = NULL; - bool is_lru = !__PageMovable(&src->page); + bool is_lru = !__folio_test_movable(src); struct list_head *prev; __migrate_folio_extract(dst, &page_was_mapped, &anon_vma);