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: 13382707 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40D76CA5534 for ; Wed, 13 Sep 2023 09:52:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CCB066B015F; Wed, 13 Sep 2023 05:52:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C7B2B6B0170; Wed, 13 Sep 2023 05:52:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B6A266B0173; Wed, 13 Sep 2023 05:52:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A467C6B015F for ; Wed, 13 Sep 2023 05:52:53 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 720C8B3C90 for ; Wed, 13 Sep 2023 09:52:53 +0000 (UTC) X-FDA: 81231110226.07.04A86AE Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf18.hostedemail.com (Postfix) with ESMTP id 1E97C1C0030 for ; Wed, 13 Sep 2023 09:52:50 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694598771; a=rsa-sha256; cv=none; b=lN5PSfPu47F8fXF6sZKVMEGv79/NuWiIDifJD1K8yRkd9se6TceUQBc9vZXvopln8K+QJD UGVEMQeuGwhbPNSlAmo+86GEg2cSTSPq4Tli0W/onkiGFxF7+JV1AlfDZD2fAoAyQ4eJQl fzwOMYqDnW6u96KLOI6HaFWmaLRhc4w= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; spf=pass (imf18.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694598771; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DCfJIYv9BZvAD508DaHGVzJ85GuKmA46MB8WO109kEY=; b=z6W5TCP9ObgWYvWpJdbLUhB98tRlJtHSvAopBgFRdJHiFRDGwBDl27I0b3fGzG9aUtBQVW JNGibDomB5+E7xuSvbDptFZep76XQ5JX5BVx9zb5+Lg0Q9P7Mz0wQnk01o5uEM7LSbAGc1 ED18Biuyb9mnzJfFkcKa0AgrbDGKpyQ= 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 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1E97C1C0030 X-Stat-Signature: dxnfknehdg4hir4sd3apy8ao7kox35g8 X-HE-Tag: 1694598770-185631 X-HE-Meta: U2FsdGVkX189hArBSP9rxycoJgGgdtxXbwgcuaHi+ZBocot5BoFzL8u4FVLoWT4BkF+NbT+2ZJl+74RY9az1hbSDIzD9wD69XLS3Arnx+P7hTi4/OWC2RiXYLOl04ZvyQL0UOxJoU7wkZegetMTnDEmIHOMTIpNp+vs9oreJEU3aV9uJYuKhomvWF9sJXWJjobZtuh3IdW+jZFqBT1vWrRPaNHlYfxEY3rp6Dm4I9rCyV+5ZZZuDiN7Qkw6kdOZ2XYQoyt0QYnXgancsPRYTo3bMxuWhT2/4nrwYbpVoLKqABLnEegM8zAbNF79jyXnC5gcG/FUkPHo4crxVElQoPVf5q8zCW9ge8PK7ErrEf0zMpcZzBiw7ug7tmtx14EEpyEqXX/KDrQZXkYTjavG5E01bskwg2sKuOE3M6Hz7opPdwNbjfLRFsHoMUeyvNVioPypbEwJOSfry2kwtV3VuuahBJS9jEj36dt86cCpDszvHRpK70/g//ODq0EuL8bYvdwiF7yyXjrv+Jys+hvYWP0UZvW8sxiXLQkC3HPxyEj6wZNsF29bS+KjOwqWFJB/kYzW3F3DiuJlwRAlObRO/x68NPxs0TQAT0dFRN61YCp4gmw0NRvL5uFpJTCgZuCx6vneEZS8Tr/0iIdJkg4/Qy6QS+DtDJlMEnE4+0KG3WSWXfar6UCF5zgQaHOJAkcdF8cxb/QQ0eNfjpPMjl6hncqHJ/fp/iEDWg+0RUesRC5Y6wlmnz0nqZ2kA7p85Bz9efCZXmTPgYNWfkVXdtryHvyYUiCqLmWTc6vymutCqi/p51sJ2e5+WrlXZpW53Df0+KHK5h+7pN7YsiswQ5Q0hYHRj5Fr8fUK0auOp8jT9ldPxmFsZ06AzKrFKEqjMDZdMAqvDmDHuPqov/quyCXXTyWf+NutqFBH6BaACNAfNlCPFKSZ0oG07JwuE+LftZZa0rr7hsE5h2ZHlB1Uxrv3 Sz8RMUha XHKKVJI6o8aQ51Rd5Ig1gaJAO4rVqWVha7RZnJG143M+sKWErj5//079o7nxieQkFotK5UxokUMk85GtZCVrQImZmyoVVCQJPlH2fAH0DSeqLNYirgHZKJApcnSH6ZATwi47VyHDLuLAxEVpnwZ9ei5QUONpSFcNCXzEYbT3nT3EHvjjrH9br9lSU7G+qi4mh6IsWuPRDOs7ev7jCbDmtR8zFjxgmbDe7DC8v X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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);