From nobody Wed Dec 17 14:22:06 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03ECBEE49AA for ; Mon, 21 Aug 2023 11:45:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233451AbjHULp4 (ORCPT ); Mon, 21 Aug 2023 07:45:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233300AbjHULpv (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 D251CF9 for ; Mon, 21 Aug 2023 04:45:39 -0700 (PDT) Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4RTrGy70myz1L9Rn; Mon, 21 Aug 2023 19:44:10 +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 8/8] mm: migrate: remove isolated variable in add_page_for_migration() Date: Mon, 21 Aug 2023 19:56:24 +0800 Message-ID: <20230821115624.158759-9-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 Content-Transfer-Encoding: quoted-printable 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Directly check the return of isolate_hugetlb() and folio_isolate_lru() to remove isolated variable, also setup err =3D -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. 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 e8c3fb8974f9..9bbd9018ece7 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2059,7 +2059,6 @@ static int add_page_for_migration(struct mm_struct *m= m, const void __user *p, struct page *page; struct folio *folio; int err; - bool isolated; =20 mmap_read_lock(mm); addr =3D (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; =20 + err =3D -EBUSY; if (folio_test_hugetlb(folio)) { - isolated =3D isolate_hugetlb(folio, pagelist); - err =3D isolated ? 1 : -EBUSY; + if (isolate_hugetlb(folio, pagelist)) + err =3D 1; } else { - isolated =3D folio_isolate_lru(folio); - if (!isolated) { - err =3D -EBUSY; + if (!folio_isolate_lru(folio)) goto out_putfolio; - } =20 err =3D 1; list_add_tail(&folio->lru, pagelist); --=20 2.41.0