From patchwork Wed Sep 13 09:51:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 138730 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp973750vqx; Wed, 13 Sep 2023 03:05:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IElDySFv9ZGC5FDyS5c/lGBDtJu+TZIUlzgliI7Hr9jNp4f+aL6oyOgXu0TzrBKCPK5yrP/ X-Received: by 2002:a05:6a00:1487:b0:68f:c057:b54c with SMTP id v7-20020a056a00148700b0068fc057b54cmr2152565pfu.1.1694599512760; Wed, 13 Sep 2023 03:05:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694599512; cv=none; d=google.com; s=arc-20160816; b=PMg5eFuSmrB1PTl4RjcqVkgqoQ06xdHQzuqLCh82t2yxKAKy0Zc+71G0RdU1ekm0Jv XC7Ql7sHMLjqw4sDxzRD+I4rse8nNEEt+zgbFh7Ae6N9Qd4CbL+8wWgglkm3PvKJ8Py5 v8220apnvcxqogW3vdOOR9zBeetZhCFyZS6TCk/pffJ1bu87Q9PN7E54EgW0c/VLVhsb BHUmEflKTJJIG37r16PDWcl3qfdBGLz92rgKOR1pU/ganRgsSwjS+9DJmztPh55qBo7t 4tsMKEtklxLm7djXjcEQtQXmnawkTKOh1YRWkFiPZzJnOBizlTsl7F3P9fFIFTGr/q4v NZcA== 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=eGLAyF1TWl//bjKqzzehCYbHflfiv7bBK6GV2K9YRXA=; fh=Je6qNyAM729b1goCtB6PkBk+yQrlQCIjJMRY6BFgKTo=; b=TAlaqVT/WlzzeX4Dhc7src+iAwAp2hUqkRLEruJlSvEHc0WhsJkxgOnTSkgU+KAs1/ D+xYJQxIIuIwKgJnym4tH0NfBD0M1YgVelnGMLPHT3+CJeRyOPSkf78NCXvrIOmgcloQ Y4Rhz7ZB0E2X+TNISk3Ank9lUdQUmtD0SFRig2jBQ+opiLxSFcjROmnGKYgYIRFkJ/kG ua7PAerx3gvW3mTFoExdyV/XLxTER61QDHro0Dg6D9tCgHi9TFRFpAzEAhgvKewY++lL vGpTaRXCxJSFMC7S/TbTrAyEU0QZ19mMY767+B+rCSG1r83PQBoVqVXbWkApiFwEflKa XMfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id v202-20020a6361d3000000b0057777451a91si5204512pgb.581.2023.09.13.03.05.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 03:05:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 2F25E81B8941; Wed, 13 Sep 2023 02:52:23 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239478AbjIMJwM (ORCPT + 36 others); Wed, 13 Sep 2023 05:52:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239482AbjIMJwG (ORCPT ); Wed, 13 Sep 2023 05:52:06 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AB7819A9 for ; Wed, 13 Sep 2023 02:52:00 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Rlwcb4nlyzNnRl; Wed, 13 Sep 2023 17:48: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_128_GCM_SHA256) id 15.1.2507.31; Wed, 13 Sep 2023 17:51:58 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v3 1/8] mm: migrate: remove PageTransHuge check in numamigrate_isolate_page() Date: Wed, 13 Sep 2023 17:51:24 +0800 Message-ID: <20230913095131.2426871-2-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> References: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 02:52:23 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776916378628180363 X-GMAIL-MSGID: 1776916378628180363 The assert VM_BUG_ON_PAGE(order && !PageTransHuge(page), page) is not very useful, 1) for a tail/base page, order = 0, for a head page, the order > 0 && PageTransHuge() is true 2) there is a PageCompound() check and only base page is handled in do_numa_page(), and do_huge_pmd_numa_page() only handle PMD-mapped THP 3) even though the page is a tail page, isolate_lru_page() will post a warning, and fail to isolate the page 4) if large folio/pte-mapped THP migration supported in the future, we could migrate the entire folio if numa fault on a tail page so just remove the check. Suggested-by: Matthew Wilcox (Oracle) Signed-off-by: Kefeng Wang --- mm/migrate.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index b7fa020003f3..646d8ee7f102 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2483,8 +2483,6 @@ static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) int nr_pages = thp_nr_pages(page); int order = compound_order(page); - VM_BUG_ON_PAGE(order && !PageTransHuge(page), page); - /* Do not migrate THP mapped by multiple processes */ if (PageTransHuge(page) && total_mapcount(page) > 1) return 0; From patchwork Wed Sep 13 09:51:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 138732 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp974531vqx; Wed, 13 Sep 2023 03:06:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFoGDJsAyDLyROLMeCCL+db59TNDcwOUl/tmXp2PTRUKH17vHzSLL4KLkv6Agox+q5oJkCG X-Received: by 2002:a17:903:2308:b0:1c2:36a:52a5 with SMTP id d8-20020a170903230800b001c2036a52a5mr2295900plh.57.1694599600787; Wed, 13 Sep 2023 03:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694599600; cv=none; d=google.com; s=arc-20160816; b=FRk4tGptTmBIK98PkbgzuF0XAFuEz/nZ0jJK2KpNwTTrzl7kPbGtD0uYMEcDqP/YAK N9wYBtbTPWVhLv4bN2tgN23oEzZefaaL1xzj+wRbb3+/CPkNDKh0J2ouUjDQEBae9oE6 5vezcfpqbxuT3hEYqNVnoKi2yQC7zWBV48+M1RyKtpdMQvlalSOiIF790/Fs11d/8JnW b1OVSG4WdJ7OKGI+nA28mo5J7vnGuGdSxTf58/eAQQqwnmahiB+qA9j4WXI9dWJoep4y mMDxXtm6URUyGg7SNBjBnm96szv3IfELy6Y+Nl8W2lMb6DO+Us+KJdmwxjGHc8Up+YfD EDnQ== 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=CWyPKwL02nbvAgHk+hv8KgCviWU/Da8QA7ydynsElH8=; fh=Je6qNyAM729b1goCtB6PkBk+yQrlQCIjJMRY6BFgKTo=; b=n6Yzs19UvX7AxrCWW+D7XtyWDHerj6gKsH9cQ+x/Xm2exY9BfasfchPkQNSk6lyxgH ogWzJVL/1Xu733r2dHtI/FezDtWO04JZn5y8hga4/cuv/I9IOrDYAqu/E55P1CdfexV0 MkD5wZK7KXkbkRn/MbRAbx2vmhqo1YmkuUk4JhO1Ic9ggWoqoNvEWP394AUyQptCZMNb 7vas9MeDfMqlRaJIgRr+nE6EGyZrHNVVVCSsqgFkbjc0vGixtnoUVGcDEmxD+vV6Hzq2 Cdv4Pz9V2iNqW8wQVgL4rkNMwgv6MvmhR03NWmdl05KVp2Ux8cG8bqDyEzW9DkwYi6Iw /bFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id z11-20020a170903018b00b001b89b63b877si10407936plg.446.2023.09.13.03.06.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 03:06:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 0AF3180257B8; Wed, 13 Sep 2023 02:52:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239513AbjIMJwN (ORCPT + 36 others); Wed, 13 Sep 2023 05:52:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236400AbjIMJwG (ORCPT ); Wed, 13 Sep 2023 05:52:06 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B13501BC7 for ; Wed, 13 Sep 2023 02:52:01 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Rlwcw06PkzMlGs; Wed, 13 Sep 2023 17:48:32 +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_128_GCM_SHA256) id 15.1.2507.31; Wed, 13 Sep 2023 17:51:59 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v3 2/8] mm: migrate: remove THP mapcount check in numamigrate_isolate_page() Date: Wed, 13 Sep 2023 17:51:25 +0800 Message-ID: <20230913095131.2426871-3-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> References: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 02:52:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776916470940207481 X-GMAIL-MSGID: 1776916470940207481 The check of THP mapped by multiple processes was introduced by commit 04fa5d6a6547 ("mm: migrate: check page_count of THP before migrating") and refactor by commit 340ef3902cf2 ("mm: numa: cleanup flow of transhuge page migration"), which is out of date, since migrate_misplaced_page() is now using the standard migrate_pages() for small pages and THPs, the reference count checking is in folio_migrate_mapping(), so let's remove the special check for THP. Suggested-by: Matthew Wilcox (Oracle) Reviewed-by: "Huang, Ying" Signed-off-by: Kefeng Wang --- mm/migrate.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 646d8ee7f102..f2d86dfd8423 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2483,10 +2483,6 @@ static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) int nr_pages = thp_nr_pages(page); int order = compound_order(page); - /* Do not migrate THP mapped by multiple processes */ - if (PageTransHuge(page) && total_mapcount(page) > 1) - return 0; - /* Avoid migrating to a node that is nearly full */ if (!migrate_balanced_pgdat(pgdat, nr_pages)) { int z; From patchwork Wed Sep 13 09:51:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 138731 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp974438vqx; Wed, 13 Sep 2023 03:06:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGfBN96WSTAMLJcZH+5maOtMYIeA0bMw2MK4O2vN0L6iLkACgftgEQvMG0oprwIiMJo/SV8 X-Received: by 2002:a17:903:278e:b0:1c3:3c91:61cc with SMTP id jw14-20020a170903278e00b001c33c9161ccmr1960721plb.13.1694599591087; Wed, 13 Sep 2023 03:06:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694599591; cv=none; d=google.com; s=arc-20160816; b=w2V6CEupS5tNQM6TqqEA2z1iJo0lA9Fef2EKTG0mvfuE2S3K5I9DAlrJ1Wv4UkAYqJ z1pXLpFrwLCwfnDtp7riM34BH+lGLuhJoq0StO3GaD3lyDmx/DN3HMZlaERxscWzF/TR DZgGKWfnIrHrVBI2th3EdmD33CB/kM7HfLJ2oF9vvUcW+7QPmYbe3hbtSwf2v18SzkXe bOaRGAQxtV0bhcgziQozBsu4UVth6qlkVAe/IYvvMxFzoyxob4/+ftISUXE70vU21L2g SlNHyvNvr6ehFl+pvKePePh98M7eTaJuN0uPb+VNxLvlo7CCImbh4vq6g7rDbMXrOzD0 5fkA== 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=XimLV5Z1rXezPIZu6awNd81iU32QlWiaxWWjX2F1Naw=; fh=Je6qNyAM729b1goCtB6PkBk+yQrlQCIjJMRY6BFgKTo=; b=GOrhfHcARcio6xGj/UN0Go5GYFq7MQIe/CzyaxatZ8FTavXuaXx8ZDR8JUTU+5Cbte Gtj99+XspN070Vh+w53cO1uPgIYiGNPUmFk5iUGrBGzysiR4KoKm0a8g+wjf6RgD1BCl b3HM3mxIT0ywvgOdWre8tjht2M8yUn2yZR2MrjH6roKlmi0TS5sONuIj5E6AdVoJ0Mb3 kVksXWpoLjlPWF2NEUptFyXj5cVnZv17T1M77MurHMn1VmNT52+UYJByVhkeJotodNDH b3VHG+tQxE2hriAQrGrHxl2SgJAwjdcmgrJzyQshSvca8UrTfklpMr0AT7IYY9eVWhMg 2tsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id r9-20020a170902be0900b001b9d9b01303si3313205pls.628.2023.09.13.03.06.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 03:06:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 2766C823FAEE; Wed, 13 Sep 2023 02:52:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239492AbjIMJwP (ORCPT + 36 others); Wed, 13 Sep 2023 05:52:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239464AbjIMJwH (ORCPT ); Wed, 13 Sep 2023 05:52:07 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C38251BCC for ; Wed, 13 Sep 2023 02:52:01 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Rlwcw44lpzMlHJ; Wed, 13 Sep 2023 17:48:32 +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_128_GCM_SHA256) id 15.1.2507.31; Wed, 13 Sep 2023 17:51:59 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v3 3/8] mm: migrate: convert numamigrate_isolate_page() to numamigrate_isolate_folio() Date: Wed, 13 Sep 2023 17:51:26 +0800 Message-ID: <20230913095131.2426871-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> References: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 02:52:21 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776916460673478061 X-GMAIL-MSGID: 1776916460673478061 Rename numamigrate_isolate_page() to numamigrate_isolate_folio(), then make it takes a folio and use folio API to save compound_head() calls. Reviewed-by: Zi Yan Signed-off-by: Kefeng Wang --- mm/migrate.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index f2d86dfd8423..281eafdf8e63 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2478,10 +2478,9 @@ 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); /* Avoid migrating to a node that is nearly full */ if (!migrate_balanced_pgdat(pgdat, nr_pages)) { @@ -2493,22 +2492,23 @@ static int numamigrate_isolate_page(pg_data_t *pgdat, struct page *page) if (managed_zone(pgdat->node_zones + z)) break; } - wakeup_kswapd(pgdat->node_zones + z, 0, order, ZONE_MOVABLE); + wakeup_kswapd(pgdat->node_zones + z, 0, + folio_order(folio), ZONE_MOVABLE); 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; } @@ -2542,7 +2542,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 Sep 13 09:51:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 138726 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp969524vqx; Wed, 13 Sep 2023 02:57:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFk6s5KRre8PRaF+lHel4/p9UdABMIjTUjW1Cw6hHsVuzdjQXFJntkEJjJ+3gQAueVGtp+v X-Received: by 2002:a05:6a00:b85:b0:68f:bb16:d16a with SMTP id g5-20020a056a000b8500b0068fbb16d16amr2956367pfj.5.1694599026002; Wed, 13 Sep 2023 02:57:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694599025; cv=none; d=google.com; s=arc-20160816; b=do0MdvpDscX00BDdn8ON+vuFiQDvGR71BsCmqHZCeislmjjJKiMY179FHvkte0stDW y+g5G17MW/QEwK9KiQ3gWdxou4fsINEWy574JkQ17i3KlhS7j+Z1d79uaxHwY5o346RC 5sEe7wGetBUvsk1kv7s9Q56Rshx9C6tLzzPc1GuzEadYJ/kstMJaZsHi1uLQwil3WGMe VVVrjaqd1pQeIW+PjrS5y7NmqP95AJnYhLuw2iYHZalTUy4jRVWt6VgGG4yMMW2NMwTk GkkEuUcYTr/TlMDOpNoQBOSq5yB/4fYL3UJmoumazKusIilFDiXImwMQw8y2FCp6cTL3 Og5w== 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=qs+4Pob6hE6VoMIGoj7d8hZIC1kd6o6kgmZoesDjY7M=; fh=Je6qNyAM729b1goCtB6PkBk+yQrlQCIjJMRY6BFgKTo=; b=KoH0apumnGHKHGxzovrVdSpR3p1ntye/PUP4yOAdXjZs5O4dvhPy8X6T8iZ+KkPTB0 WjNfBfo93i5TXyOuEF3Z6nH8HZpddst3HqiI5jtEzulS0vS4Srr6+N9HKZLGuE8Q7yEj 2H06E7qweU6o4ETofEBCNa/FPEZ+w0PzXnhdDemqZUALnrGSkpZTJ/MlHGSLqi1djxVo uhKG7aFXbEZNqIL/KlYModP5ACIYsZ5nPD0PHB6bMxrtToQg5g8LTpmiQX1NhHcVikqf osR1Vw4JCONeov8TcT2FsmUmBTWweOxfdXagiUYLp1TPgeHHgK1DRKuAGntViaTNFUuZ ihVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id cg19-20020a056a00291300b0068e35157c22si9701361pfb.119.2023.09.13.02.57.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 02:57:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 4C26D81829F8; Wed, 13 Sep 2023 02:52:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239561AbjIMJwR (ORCPT + 36 others); Wed, 13 Sep 2023 05:52:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239504AbjIMJwI (ORCPT ); Wed, 13 Sep 2023 05:52:08 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DF301BCF for ; Wed, 13 Sep 2023 02:52:02 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Rlwdj18sgzVkgC; Wed, 13 Sep 2023 17:49:13 +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_128_GCM_SHA256) id 15.1.2507.31; Wed, 13 Sep 2023 17:52:00 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v3 4/8] mm: migrate: convert migrate_misplaced_page() to migrate_misplaced_folio() Date: Wed, 13 Sep 2023 17:51:27 +0800 Message-ID: <20230913095131.2426871-5-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> References: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 13 Sep 2023 02:52:28 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776915868204878154 X-GMAIL-MSGID: 1776915868204878154 At present, numa balance only support base page and PMD-mapped THP, but we will expand to support to migrate large folio/pte-mapped THP in the future, it is better to make migrate_misplaced_page() to take a folio instead of a page, and rename it to migrate_misplaced_folio(), it is a preparation, also this remove several compound_head() calls. Reviewed-by: Zi Yan Signed-off-by: Kefeng Wang --- include/linux/migrate.h | 4 ++-- mm/huge_memory.c | 2 +- mm/memory.c | 2 +- mm/migrate.c | 39 +++++++++++++++++++++------------------ 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/include/linux/migrate.h b/include/linux/migrate.h index 711dd9412561..2ce13e8a309b 100644 --- a/include/linux/migrate.h +++ b/include/linux/migrate.h @@ -142,10 +142,10 @@ const struct movable_operations *page_movable_ops(struct page *page) } #ifdef CONFIG_NUMA_BALANCING -int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, +int migrate_misplaced_folio(struct folio *folio, struct vm_area_struct *vma, int node); #else -static inline int migrate_misplaced_page(struct page *page, +static inline int migrate_misplaced_folio(struct folio *folio, struct vm_area_struct *vma, int node) { return -EAGAIN; /* can't migrate now */ diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 3e9443082035..36075e428a37 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1540,7 +1540,7 @@ vm_fault_t do_huge_pmd_numa_page(struct vm_fault *vmf) spin_unlock(vmf->ptl); writable = false; - migrated = migrate_misplaced_page(page, vma, target_nid); + migrated = migrate_misplaced_folio(page_folio(page), vma, target_nid); if (migrated) { flags |= TNF_MIGRATED; page_nid = target_nid; diff --git a/mm/memory.c b/mm/memory.c index 4c9e6fc2dcf7..983a40f8ee62 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -4815,7 +4815,7 @@ static vm_fault_t do_numa_page(struct vm_fault *vmf) writable = false; /* Migrate to the requested node */ - if (migrate_misplaced_page(page, vma, target_nid)) { + if (migrate_misplaced_folio(page_folio(page), vma, target_nid)) { page_nid = target_nid; flags |= TNF_MIGRATED; } else { diff --git a/mm/migrate.c b/mm/migrate.c index 281eafdf8e63..caf60b58b44c 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2513,55 +2513,58 @@ static int numamigrate_isolate_folio(pg_data_t *pgdat, struct folio *folio) } /* - * Attempt to migrate a misplaced page to the specified destination + * Attempt to migrate a misplaced folio to the specified destination * node. Caller is expected to have an elevated reference count on - * the page that will be dropped by this function before returning. + * the folio that will be dropped by this function before returning. */ -int migrate_misplaced_page(struct page *page, struct vm_area_struct *vma, - int node) +int migrate_misplaced_folio(struct folio *folio, struct vm_area_struct *vma, + int node) { pg_data_t *pgdat = NODE_DATA(node); 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 + * Don't migrate file folios that are mapped in multiple processes * with execute permissions as they are probably shared libraries. + * To check if the folio is shared, ideally we want to make sure + * every page is mapped to the same process. Doing that is very + * expensive, so check the estimated mapcount of the folio instead. */ - 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; /* - * Also do not migrate dirty pages as not all filesystems can move - * dirty pages in MIGRATE_ASYNC mode which is a waste of cycles. + * Also do not migrate dirty folios as not all filesystems can move + * dirty folios 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 +2572,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 Sep 13 09:51:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 138733 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp974538vqx; Wed, 13 Sep 2023 03:06:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IENTpmhziaFzKqRhs8oCeEHTJjgoPzN1uf6OzkXhPvpdKz00r1CIfuTxF5+8ujeIHMqtVWi X-Received: by 2002:a05:6e02:1d93:b0:34b:aa34:a5c4 with SMTP id h19-20020a056e021d9300b0034baa34a5c4mr2178595ila.30.1694599601347; Wed, 13 Sep 2023 03:06:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694599601; cv=none; d=google.com; s=arc-20160816; b=u6zQlJCluyhtlueV8pJfDXNAky09lLecu+x6FE/EPrKR7gzipKYbkOjamlsfbfz0i8 DKgCsGGpL8DogsektCQjwFa2xdI6ED/S/4kiL8inQsFZcUGpk2ZrDjgpFpMtcUcmQdbn FsSAK8aez5pKBW6KRjqVfX09/60GlHMLwrgUVmulO7uLC/qtyZXKlwPUpNUe0lvktfX1 /sfqMun+F407Y8CvkGhlEUg8tBZhguFjM67d/Lt5MM6zTS3izYUYjWejHoo+cKG6ncpE 849WNu7KfsETXciiRoDAkdCayzxH4nypuy2GldgXzYaZd9KNbNeEyvz9B/2qvv0+rKDH aqdQ== 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=tynzkeTlgRE0TnuNJwLboivyiix4m9++Sswl3Rc9Qjw=; fh=Je6qNyAM729b1goCtB6PkBk+yQrlQCIjJMRY6BFgKTo=; b=QMHgS5bZtpuNw5sgRQN8SZMRTohemtjGqwywMOdGRDvzUr4jkhBkWohTesX07urVDq MpYqpmeYvwxtdzDtMWbU7MLf19eG5KtfA4NB6a+x93LD+7HptTww2h5KNAG2B+nghw91 dIJJZrustCDsm0NSuSJ7zwMONMjFVBRfj8NNG2lm66ZjD4FiLbgihQneS/CLQY+B9T6z pMV9v3g+E8n84rkuu1LezGOSsvExl44Qz6TIbb08LeQTHxYLRiWHOmHQwaJu9wEFnhDw BSU2791Yemkg+moOP8Kfa8pVkSIABuIs2HDwwFGc13zXleFYudRPxYRUT8BjsIRRdfGT NXSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id r24-20020a635158000000b0056950006fd5si9796623pgl.885.2023.09.13.03.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 03:06:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 387D482CFA7D; Wed, 13 Sep 2023 02:52:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239593AbjIMJwU (ORCPT + 36 others); Wed, 13 Sep 2023 05:52:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239489AbjIMJwI (ORCPT ); Wed, 13 Sep 2023 05:52:08 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B246A19BD for ; Wed, 13 Sep 2023 02:52:04 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Rlwfh3mXTz1N7wJ; Wed, 13 Sep 2023 17:50:04 +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_128_GCM_SHA256) id 15.1.2507.31; Wed, 13 Sep 2023 17:52:00 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v3 5/8] mm: migrate: use __folio_test_movable() Date: Wed, 13 Sep 2023 17:51:28 +0800 Message-ID: <20230913095131.2426871-6-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> References: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 02:52:29 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776916471661826481 X-GMAIL-MSGID: 1776916471661826481 Use __folio_test_movable(), no need to convert from folio to page again. Reviewed-by: Matthew Wilcox (Oracle) Reviewed-by: David Hildenbrand Reviewed-by: Zi Yan Signed-off-by: Kefeng Wang --- mm/migrate.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index caf60b58b44c..264923aac04e 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); From patchwork Wed Sep 13 09:51:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 138727 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp969607vqx; Wed, 13 Sep 2023 02:57:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0aogcUnDb/gDpwuqlbVfJ+7YkT2D9gDabcv9z0dPBx0W1Vf46KoFHg3Qvm+rtoZwK/4IM X-Received: by 2002:a05:6a20:7f93:b0:122:10f9:f635 with SMTP id d19-20020a056a207f9300b0012210f9f635mr2148035pzj.19.1694599038202; Wed, 13 Sep 2023 02:57:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694599038; cv=none; d=google.com; s=arc-20160816; b=N4S3261kAaxGKh3pelQmiMJAWKnaCeaMv+N26pwIDD+T069aKI/WP0eHAsMTB4yT9j h3IhhoUKUyIfX5WNsYyUcrgoNw1hIKEWhi1dy7CJoQgXGNGCh05uiN7T5orLD1+3S4TY Rld7ry6tCCh7y0zYsmf/GVcm3nTf+NLXQxV02Mkt1QKGjSqo2ubffCKqAqNqCUWnl7FN Sa83E7FzePYPkKIXSZt7B/YQNYA8FSLFGpSsYPfkVeYq10XrYgJTMiHFCPYjxOdXZeNl JkfsTDZXkorQfrgPBF2AHouh3pQMFJbD7qSBnhvEBjWLYPZFKQ8aOVBxAAqXg/cy95wQ LMRA== 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=RK3S6ofLX88DWyIyY123P5aohf1PFWYOerflINyiNM4=; fh=Je6qNyAM729b1goCtB6PkBk+yQrlQCIjJMRY6BFgKTo=; b=KDatg9E1DrFjeSKeUnQxxpAsQCzQxFTsVo1nlGx6msZtqRa2dr1jWiletp9S/Bc0s2 A4T7+vtQKmBjykN15tQR9LbMKmP0G2VIG3PjkjU0MXsIsAgyOkwp6WuyPdaj4qLyALGI Ad/d53UzVJQuUjxVpMuFnvVml/M4DXzgxTrefeHITiQTUq0Zva/4F7M8wqI2Jy9fwrgJ IWvgrJ098V53NCF3/rm1WNFmClBKqX3wgs4XQyiXpWkQxlW/fz43fbjElA4gOQDOZznI wwbTIvFa4XKa2AatyaTC6jzgf+OQ/4zrMOpzdIbmXzmIrGK4q8sGijF5yyPCU1bga+6x 3cQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id cl7-20020a17090af68700b0026b56ee767esi1181508pjb.106.2023.09.13.02.57.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 02:57:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 64E768228808; Wed, 13 Sep 2023 02:52:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239574AbjIMJwT (ORCPT + 36 others); Wed, 13 Sep 2023 05:52:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239506AbjIMJwI (ORCPT ); Wed, 13 Sep 2023 05:52:08 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A674199D for ; Wed, 13 Sep 2023 02:52:03 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Rlwdk1Y6FzVkfH; Wed, 13 Sep 2023 17:49:14 +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_128_GCM_SHA256) id 15.1.2507.31; Wed, 13 Sep 2023 17:52:01 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v3 6/8] mm: migrate: use a folio in add_page_for_migration() Date: Wed, 13 Sep 2023 17:51:29 +0800 Message-ID: <20230913095131.2426871-7-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> References: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 13 Sep 2023 02:52:55 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776915880838501496 X-GMAIL-MSGID: 1776915880838501496 Use a folio in add_page_for_migration() to save compound_head() calls. Reviewed-by: Zi Yan 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 264923aac04e..cf5c9254fdad 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 Wed Sep 13 09:51:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 138729 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp973731vqx; Wed, 13 Sep 2023 03:05:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2Yifwti1i8TYWq0aVJ1Bhf/DVB87sbpzpLViAESRp0BNG9zxA1JyPS9UXbsL6sDQfciQR X-Received: by 2002:a05:6a00:2d9e:b0:68b:4e07:133f with SMTP id fb30-20020a056a002d9e00b0068b4e07133fmr2178615pfb.7.1694599511134; Wed, 13 Sep 2023 03:05:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694599511; cv=none; d=google.com; s=arc-20160816; b=m0AEyzOZbXaG+lod3S8CkLO3wD9YnKDFFQuMw3FshE8kinA95wLZFWYsrMtOhWz9Il vjYy5JwfX2mRt6vrCJ1G+LILRkV2YWJA+eRWs8d+003YYIOgvOhG93Ehgivu8KNHuNzn rOo8r1WfrwzDJaCxiWGbrftB0dnSUrLOouLvGhIHUfgFa7ai4nvza1duvjzYf08+cZa3 TbQl8pdB3zWMb+D5/ZINeuLGTmCRv2bQmkpqJ/L4TKGVNW+zd19ZJtpzMOw0TvKF2n9S RFPueYREh6aIdZ6By3c8m0t+xkpSyjfHyRc78gjgs1N6ol9pRb6SIvZxtxeEiHfuYELt Ovew== 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=edCISLjT6+ZkLMLK7dCnKkIlBAZTUznn0Sy9MjDom88=; fh=Je6qNyAM729b1goCtB6PkBk+yQrlQCIjJMRY6BFgKTo=; b=ixn6Q0qJp2+RwtSviNTjh+/jfxkty6FE6PmqMw0WooAQGaPWESWSRFzsY/itmS9PX+ ebmEYp3IedVh2wamzy4qdrmoPSqunq8luPZMt31mCzt90gL+bzvNscWD7cCzwR5A2ZkW wirCIQOvZNZ+juwreZUWYRvRdzdrFrcqaMjmFZBnHKKHrSwD+s4URTZlX2bQvihgcNqF k2JTsWZS9BilNV4D5n5zNzPJIn/eAgDM3/AwRNqtPl35aJ302FgdpxLVqIM+rQx78iEr ZY42gZK2sRIe/ZyLUdRRKVVlkRRJFBnn84ufqu8S9WygN1oLFrJQR5/TcmsXRUHdWTgW QvGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id q140-20020a632a92000000b0056532a83c64si9473058pgq.516.2023.09.13.03.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 03:05:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 451C381B8958; Wed, 13 Sep 2023 02:52:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239584AbjIMJwU (ORCPT + 36 others); Wed, 13 Sep 2023 05:52:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239486AbjIMJwI (ORCPT ); Wed, 13 Sep 2023 05:52:08 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6272019BE for ; Wed, 13 Sep 2023 02:52:04 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Rlwcy4tMkzMlLX; Wed, 13 Sep 2023 17:48:34 +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_128_GCM_SHA256) id 15.1.2507.31; Wed, 13 Sep 2023 17:52:01 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v3 7/8] mm: migrate: remove PageHead() check for HugeTLB in add_page_for_migration() Date: Wed, 13 Sep 2023 17:51:30 +0800 Message-ID: <20230913095131.2426871-8-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> References: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 02:52:35 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776916377408652858 X-GMAIL-MSGID: 1776916377408652858 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 Acked-by: Zi Yan 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 cf5c9254fdad..7b07c97f5a6f 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) { From patchwork Wed Sep 13 09:51:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 138725 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp968604vqx; Wed, 13 Sep 2023 02:54:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDDCwAb2NrhSjWHU/+MjpK0kNrkxyEGloDtCH9bRfGJ2Cid73HF4/NREDSx2A2EXg8QZsv X-Received: by 2002:a05:6a00:230b:b0:68e:30db:ee43 with SMTP id h11-20020a056a00230b00b0068e30dbee43mr2595333pfh.21.1694598883857; Wed, 13 Sep 2023 02:54:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694598883; cv=none; d=google.com; s=arc-20160816; b=Eg6QTIbs1R2AivwCFcvCwFUcowD7bWwubXV4F/Syvtb32SVs9fg89uTv3wGh5EG/dk RivZT8MQnVHGFiokm+Wmdg/QUwmm6F3rau1CbZgiZ2cSCKvzmHx6+eTQuD+JwfQYg6Vt zDGxA2jfMoHxNxnTfy6iUYxIyx4mzb/+fckl81dv2FxsfzrX60auFDvpD11YPkKEnoUX uc3IAEz0T/Z47BdJDf+WQ6YxYdPFkSr3c8dHW/wNr5ukD05cMIuoYudtqLoz0K8OzsHH EApDqbF24ic9eXhZD2pjutmO4bfAUNv7mhZtKmG0AjZwt3FuzCsDKoiblzTnXj1RB0FN Nnmg== 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=DCfJIYv9BZvAD508DaHGVzJ85GuKmA46MB8WO109kEY=; fh=Je6qNyAM729b1goCtB6PkBk+yQrlQCIjJMRY6BFgKTo=; b=XvRoOH7WITTxzlSLmztH+0dVQ23R//Gk9hCrKdPzM3TWjhueQVmRbrTGEKLeTPM+lJ GekYlJHOnzhrZ46mMH/HtbVCCqbCpMN8ztcauDmOxzlksnDtOm80pFcrHf9zfvZpD92M 9sQdkWRSRn06CEAaNnxLidIXG5767cIENTS9Ls3eCC7vuu9AWPj8krPorTttmf2nozWP r/U2mSbjXhKGZ/wZSEVki7upG8Pbx1lle9HsgsIMLb5s/U+kETOtrmYCKJrzl5qTiuZB wofC0JjAoKuC+CqEyVSIW5EHppao0C9mabm431rkiPDCl2Xdl4HR9L3Re3A+6Cm6dV4M 0ZSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id bd34-20020a056a0027a200b0068e3958a139si4802998pfb.186.2023.09.13.02.54.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 02:54:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 0606581BAA5B; Wed, 13 Sep 2023 02:52:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239599AbjIMJwX (ORCPT + 36 others); Wed, 13 Sep 2023 05:52:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239516AbjIMJwI (ORCPT ); Wed, 13 Sep 2023 05:52:08 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55B3219BB for ; Wed, 13 Sep 2023 02:52:04 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Rlwdl20fPzVkfZ; Wed, 13 Sep 2023 17:49: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_128_GCM_SHA256) id 15.1.2507.31; Wed, 13 Sep 2023 17:52:02 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Mike Kravetz , , Kefeng Wang Subject: [PATCH v3 8/8] mm: migrate: remove isolated variable in add_page_for_migration() Date: Wed, 13 Sep 2023 17:51:31 +0800 Message-ID: <20230913095131.2426871-9-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> References: <20230913095131.2426871-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 13 Sep 2023 02:52:57 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776915718905205201 X-GMAIL-MSGID: 1776915718905205201 Directly check the return of isolate_hugetlb() and folio_isolate_lru() to remove isolated variable, also setup err = -EBUSY in advance before isolation, and update err only when successfully queued for migration, which could help us to unify and simplify code a bit. Reviewed-by: Zi Yan Signed-off-by: Kefeng Wang --- mm/migrate.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 7b07c97f5a6f..a5d739603458 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2059,7 +2059,6 @@ static int add_page_for_migration(struct mm_struct *mm, const void __user *p, struct page *page; struct folio *folio; int err; - bool isolated; mmap_read_lock(mm); addr = (unsigned long)untagged_addr_remote(mm, p); @@ -2092,15 +2091,13 @@ static int add_page_for_migration(struct mm_struct *mm, const void __user *p, if (page_mapcount(page) > 1 && !migrate_all) goto out_putfolio; + err = -EBUSY; if (folio_test_hugetlb(folio)) { - isolated = isolate_hugetlb(folio, pagelist); - err = isolated ? 1 : -EBUSY; + if (isolate_hugetlb(folio, pagelist)) + err = 1; } else { - isolated = folio_isolate_lru(folio); - if (!isolated) { - err = -EBUSY; + if (!folio_isolate_lru(folio)) goto out_putfolio; - } err = 1; list_add_tail(&folio->lru, pagelist);