From patchwork Mon Aug 21 11:56: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: 13359348 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 B4F77EE49AC for ; Mon, 21 Aug 2023 11:45:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35FCD8E0009; Mon, 21 Aug 2023 07:45:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C3058E0007; Mon, 21 Aug 2023 07:45:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1148D8E0009; Mon, 21 Aug 2023 07:45:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id EE4758E0007 for ; Mon, 21 Aug 2023 07:45:45 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CE8081C9163 for ; Mon, 21 Aug 2023 11:45:45 +0000 (UTC) X-FDA: 81147932250.05.074C644 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf07.hostedemail.com (Postfix) with ESMTP id 955A840016 for ; Mon, 21 Aug 2023 11:45:42 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1692618344; 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=n7Yv3QZv9dekqlhiF7Y8pWzu8r2nsq4XL3K8G+3wW/E=; b=V74MtPcxLrIT0XFmO+/l7atZl4mnOxmj1o5XPnJANGZb3PijIEL6HAF4okODtEjfwMdRHU jRdlH4IMDyCbl+R8jeERNkecpRCQ0XNBxbfMywcgz+2T+A4528JZeGuykx48SJc6TOTaaJ XfG84JSb4VRN0PtRN6SsjzVv6CgTd8A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692618344; a=rsa-sha256; cv=none; b=GvADGTbvOni69XpLeSx9/rLoiknlwNLoDeNExkmppxmIBBf8f1KiiYApttTuLrl/ruQG/W IDgVHxlSqEKmbsED1idgyg7TIg7Ebb2lPgkOdBrnVasMQZgKsnz57n8N3XYmGXEQOxwAkZ VUjSCV6j+bZh+rQLa8pRHtmIJmB4xQU= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com 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 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-Stat-Signature: 73bzpkqyeaxpkes1yrb9f1zz7k3m9i3j X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 955A840016 X-Rspam-User: X-HE-Tag: 1692618342-541499 X-HE-Meta: U2FsdGVkX19q5QZj42psnoa29OaTE5D/Yn7RKO/DnnQHAOOqfjVU1UZYoupYpZa+uqKotpWu9CewLIe07Uzo6tALFCw4UqGOeihVpZT/Aktr8D+G5sxJY8rpOdNglbIRM4qkL0qmQgs1YqhiQdnoBI208gDwPwh+KTZG7yjOuNd6TBLsvB27zEFrBDYLGTGBkHU5psOt2o+eNb2ZaMMWZ27HhmB/Sa0LiUTg9AX2uG23AyOAbc4yUBDgRFyDZP6sZqMxOGvtQ8KAL89Pj4BRvYNtnmdCzZuQ/UV8vWDli7EhyuckM9JunPHWM7c5mOVuxN+jxVAVrwfytF0lToRupLYpLZTjueB1No8GaRmKbaWoYRgq0kutkXEL0ippo1JimksYp4Nt+OwFNQZzD7Cz1ZOP9WqUdPsp5l9qVtB3qd09N9jfSpL6oYZHG8KIh1em0zXvNkHXyaaEnddooLSJi7402WtYEa74Olq9bRhGp6VkSJB0KsqRUMZN67rVZIsnuNofv8sHw2yteYSXIFRa0agHm40NdGCZ467NulTrdqfCQCrRn/rYlXaao4daEoJ26r4P0ZWnF1vVkdis1IuZZzLVyfyMBVOZ4Ive/YMegFKGmort7i6MySbJULxi5IOQj2TAynSbSnv1DjTysyxpzTl6yU+SNU+7rE3lyXXel3HzIWYE7StOzZAnkUH+/Yj+F3g7ywgLmtI571sGXo8sgWMVUzaAmr3wQtONMgtrCDWXF8huoKpYcp2k571n1n0O3IGEK7Lj/Pb0hHt7f9KREnw4/5FzkdI+rrtfLpR8XftuXuzHik9AcVx55Rbvjw8uav0V/QgS5KjA4U9kVP4Zt7RQq3nL8zOJ8UncEYr0iy1Lfh4fnlZr5lPezL+B0fZzpPgDlWK4YzHdJieMzsvgxeQdtQ0ieNIzfTyJ/gXtYGtXnlNicDF2I3gxw7bU+hs7+MlwdbPdBqa6Czesm3d ONmJzpRu AFFQ+ngPniBBw/Dyzp+Qhg0btJ2JAqiKeCQ6H9Yc6o7PVTW+Mt348j5wrilZEeobezDQNj6bjVBBRZ5N8KNvX3kGCEcEiwNxV8V4czHX1FsxOxKGxSV2tNgH15nZEleBWmmm5AWHUUerb/Uin33BH25MNzt6B6WAn74DFI6eTaxxrPp+lOenD0CYtLM8r/ENKE3Fm 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. 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 *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);