From patchwork Mon Aug 21 11:56:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 136394 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp2996595vqi; Mon, 21 Aug 2023 06:15:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzvDAO3hj0CMdCDdevPJy0TDrxB+HdndboiSC3Ioaablv4dX154mjO4gO9E90Hqyql0qvR X-Received: by 2002:a2e:9658:0:b0:2ba:8127:a2c3 with SMTP id z24-20020a2e9658000000b002ba8127a2c3mr4893942ljh.34.1692623738371; Mon, 21 Aug 2023 06:15:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692623738; cv=none; d=google.com; s=arc-20160816; b=ukpK0TqGZ9pOi+am9eDIqmgCQR4wPwcYjit+HzkwaGu1X+mEEcxmhBZgZjD1vzaTWJ JWHoCKnnTBuV1sfQJVO7TEdRA2cYVnHHrq7POFqeYFInoSI3rJ4ldKo1eVtAVKoh8uQx kGUIZQyF0UUGNzLKT/F89G+jyeDWWSAsNBQ7TzYSKa6JTl3oy1a3y8J3SK4gmxxB2aIK G3GEvc1LE4jSwFJ4VCU+DbpgmebdhNJMpSDhySVL1C192yc7yNWT1fwmveFP3vEM6RHT LXN9pySeECVmlOKWSSh4cvdF2V1sYg7EVG6zfXxN/rVzFGuTNscOJwYAEq10fczDX9/M kMuQ== 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=b6a5Lr7QxakE11InEGULrgvVA3wroipO65uNIXOCIbY=; fh=DVvJTBiVFbttu4Lo4kJqW9uQ6WV1aWAR2MVr11q/QiQ=; b=VC5GFXfMIwGbPs5hFv2BpO8QjXuqkVKVx4HO5m7EI4IPVl785lnhFUUooX2cnIvqE1 +EF/9CA7USwQNmcRCoXK94ymkjEbP6jA73cZajb3BV3gdKMwn1xz0VImqo4Wv69V2NaZ tAum9Tpief5JrrhE8sbWaflKo47LrEvEv5YXOki4Of4kQHVT47H5ojFObns3wcfsXvEr 465SQ8wvCArJ5kXL18C/8EuUhvS/lQnptvFNJpAqY/OwBcWN92S9CrsWPXW0oLOdOMg7 tsrF+yyQrMFAs/9JXPsyAF4LMPtr4HHW3ZJW6taQ9mpBKGY2rG5sGF4TZ1O9eapn+PRn lU7w== 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 bg5-20020a170906a04500b009a196ce3530si1603081ejb.932.2023.08.21.06.15.07; Mon, 21 Aug 2023 06:15:38 -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 S233473AbjHULp5 (ORCPT + 99 others); Mon, 21 Aug 2023 07:45:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233288AbjHULpv (ORCPT ); Mon, 21 Aug 2023 07:45:51 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C6E5F0 for ; Mon, 21 Aug 2023 04:45:37 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RTrGw2d0Lz1L9R0; Mon, 21 Aug 2023 19:44:08 +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.31; Mon, 21 Aug 2023 19:45:34 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v2 4/8] mm: migrate: use a folio in migrate_misplaced_page() Date: Mon, 21 Aug 2023 19:56:20 +0800 Message-ID: <20230821115624.158759-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230821115624.158759-1-wangkefeng.wang@huawei.com> References: <20230821115624.158759-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) 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 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: 1774844628862566308 X-GMAIL-MSGID: 1774844628862566308 Use a folio in migrate_misplaced_page() 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 281eafdf8e63..fc728f9a383f 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2521,17 +2521,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 (page_mapcount(page) != 1 && folio_is_file_lru(folio) && (vma->vm_flags & VM_EXEC)) goto out; @@ -2539,29 +2540,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); } @@ -2569,7 +2570,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 Mon Aug 21 11:56:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 136397 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp3023304vqi; Mon, 21 Aug 2023 07:00:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFiCN9Z2S4ndMGRqLjIWGlO2edK3y71R0NPHVGRtMnnpcuZwj1HHb14lber5FtzyquOOAO1 X-Received: by 2002:a05:6a00:180e:b0:67a:a906:9edb with SMTP id y14-20020a056a00180e00b0067aa9069edbmr9184781pfa.30.1692626444024; Mon, 21 Aug 2023 07:00:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692626443; cv=none; d=google.com; s=arc-20160816; b=YF1iGEb3gLo+9guW8Rk/O8W471XxezkToWJW/P6dfcQSNCHOb/bVrTjdtxqoyJL4RH l4ljYYaJHhxJ7+wqzd+YgCz+XQXrLv5wxixl0BLd9iIt6vT4SzwlF/jl45rQP1iRmGZD +kifr9B1xs/a/43nDnqaOUb1EOgKG52/e6niNkojsHrFScKQGBCT4KJ/KZpRM6xqU806 8bgTe0rQUQjndAMR6A/Q9oGPl8em1ogk/vjnZax65fCUsfyZ/ss9Vg8648hQPo3mgVK/ AsoNSiUWzGHo4OLL90qD3Jnbzreie7RyESJ/Gc4WkBg5MRWBRUZ9YD75ml0Fc6W0D1G6 yqTw== 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=gYRQXXuBTVIE5GzI3ExSiDKN/ek1HbmSw0AD4SoCzLw=; fh=DVvJTBiVFbttu4Lo4kJqW9uQ6WV1aWAR2MVr11q/QiQ=; b=JwzMQzyM0/6gTwW/A5zBEXMPK7V2zJjRW1COgOb/AZ/0qcA+AdhPmhVGQOH1vMAaEF 8vjBOBXiwsSFwkQUIgfhAyWz5zsx7/wB14OSSxzCoT7AO/WIruR0gfWTef3QSGuZHb7v LAfwUISuuRJtedhhFv1Mua2AiZdyz5VBf0L8yGqMSaHX7CBSjb/9icUzGUtjkMiiVnfe AeBK6ZUll6RHXwFz9+m6nxGYERxSOp1UxU3Qgz5pVxbRkPqFXnJLD5ZFt2hwLTWyjSvt 3qy4Y878AkDEwXQEhPV5GB7+O5yLZgSo9d+iGa1G7W1D/7TJR1/wyxu5IKlvsTM2pZzr 6+AA== 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 o71-20020a62cd4a000000b0068a3edcf295si3290438pfg.60.2023.08.21.07.00.27; Mon, 21 Aug 2023 07:00:43 -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 S233360AbjHULpx (ORCPT + 99 others); Mon, 21 Aug 2023 07:45:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233267AbjHULps (ORCPT ); Mon, 21 Aug 2023 07:45:48 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AAFDF3 for ; Mon, 21 Aug 2023 04:45:38 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RTrDV3ZNWzNnSY; Mon, 21 Aug 2023 19:42:02 +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.31; Mon, 21 Aug 2023 19:45:35 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v2 6/8] mm: migrate: use a folio in add_page_for_migration() Date: Mon, 21 Aug 2023 19:56:22 +0800 Message-ID: <20230821115624.158759-7-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230821115624.158759-1-wangkefeng.wang@huawei.com> References: <20230821115624.158759-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) 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 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: 1774847466339332286 X-GMAIL-MSGID: 1774847466339332286 Use a folio in add_page_for_migration() to save compound_head() calls. Signed-off-by: Kefeng Wang --- mm/migrate.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index b715cd59bdec..73572d5a5cd4 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; + goto out_putfolio; - if (PageHuge(page)) { + if (folio_test_hugetlb(folio)) { if (PageHead(page)) { - isolated = isolate_hugetlb(page_folio(page), pagelist); + 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 Mon Aug 21 11:56:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 136381 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp2950612vqi; Mon, 21 Aug 2023 05:02:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IERki0t6t0PZOOspxSszPmEMyrSTC8vaG6IbOsOWioZIGCcxcUnRMZ6HsBKBR84pX5if2+q X-Received: by 2002:a17:906:249:b0:99e:aeb:8656 with SMTP id 9-20020a170906024900b0099e0aeb8656mr4457622ejl.57.1692619330399; Mon, 21 Aug 2023 05:02:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692619330; cv=none; d=google.com; s=arc-20160816; b=VkzH1BgadezGciimYV5BgyLuWaZ3FT024Nz955MbgJtJzco736mEawnZBBJra/+ALX Iras+TMR0SmsqcQMHGfCiiEwcqD46sG0BNUpnPMExxDiRVx9tnml9gJ8U1fj0OpnM7VI rc9sp+XW49NCqXlqRuCyGiMNtgcPnP3Ml36uSBqzQfeVj0CNhQscRw532ZZlx3XZ3DFG v7V11BqtatAisV2vsWmYcdWtQ5dpB1cuLrNJH5kZiILmX/eao1f1OlC3+x05MTXKNTB9 Bko+ZHnXCTAarmddePsYZrnB/Hp6CXh6q9nTvrXVzCIWlDTwl0CFMNcJwMuAGAT0CnjZ SK8A== 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=HnLaJls1IH72MtR6jX/8bAnP1g/8utXa1KLvGbePzRo=; fh=DVvJTBiVFbttu4Lo4kJqW9uQ6WV1aWAR2MVr11q/QiQ=; b=sP2i1N6xg1rXpQNRewppLH/S2JpDdZ5VcQiSl0Dr/Svwxg1k5gaO9oLf9zkORJgZoi kM//hZBFidjgDAIcemGdEB6zOMWlSCPslJ2XOL6xvgQvZvIJc/tqRKGoD94/gJnDAvBJ RcakXmuMygQyvDBebCHamQdzVhbinmTRUykie2WXygP9Q5i9v3WcAAQQwjC4b0YMSBoG lFk1lIqZY7a+1fwZpz0MPTl33g0cRrh7sUNCY6bN0XKqBkIfHam6vAamIWC7rwhLfIuO q48e4dNoz4DsW1/JM731A/6KJBa8bYT4sP0IRMyooQMZ8uQdxAuvAac89hvBrCS2lsls ys/g== 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 p10-20020a170906a00a00b009945658c5b9si5599424ejy.811.2023.08.21.05.01.44; Mon, 21 Aug 2023 05:02:10 -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 S233411AbjHULpz (ORCPT + 99 others); Mon, 21 Aug 2023 07:45:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233173AbjHULpt (ORCPT ); Mon, 21 Aug 2023 07:45:49 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB4EDE2 for ; Mon, 21 Aug 2023 04:45:38 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RTrDW04YzzNnSZ; Mon, 21 Aug 2023 19:42:03 +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.31; Mon, 21 Aug 2023 19:45:36 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v2 7/8] mm: migrate: remove PageHead() check for HugeTLB in add_page_for_migration() Date: Mon, 21 Aug 2023 19:56:23 +0800 Message-ID: <20230821115624.158759-8-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230821115624.158759-1-wangkefeng.wang@huawei.com> References: <20230821115624.158759-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) 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 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: 1774840006858161295 X-GMAIL-MSGID: 1774840006858161295 There is some different between hugeTLB and THP behave when passed the address of a tail page, for THP, it will migrate the entire THP page, but for HugeTLB, it will return -EACCES, or -ENOENT before commit e66f17ff7177 ("mm/hugetlb: take page table lock in follow_huge_pmd()"), -EACCES The page is mapped by multiple processes and can be moved only if MPOL_MF_MOVE_ALL is specified. -ENOENT The page is not present. But when check manual[1], both of the two errnos are not suitable, it is better to keep the same behave between hugetlb and THP when passed the address of a tail page, so let's just remove the PageHead() check for HugeTLB. [1] https://man7.org/linux/man-pages/man2/move_pages.2.html Suggested-by: Mike Kravetz Signed-off-by: Kefeng Wang --- mm/migrate.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 73572d5a5cd4..e8c3fb8974f9 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2093,10 +2093,8 @@ static int add_page_for_migration(struct mm_struct *mm, const void __user *p, goto out_putfolio; if (folio_test_hugetlb(folio)) { - if (PageHead(page)) { - isolated = isolate_hugetlb(folio, pagelist); - err = isolated ? 1 : -EBUSY; - } + isolated = isolate_hugetlb(folio, pagelist); + err = isolated ? 1 : -EBUSY; } else { isolated = folio_isolate_lru(folio); if (!isolated) {