From patchwork Thu Apr 25 08:40:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13642972 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 94FB5C10F15 for ; Thu, 25 Apr 2024 08:41:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77DEE6B0095; Thu, 25 Apr 2024 04:40:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 72C3B6B0096; Thu, 25 Apr 2024 04:40:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CB506B0098; Thu, 25 Apr 2024 04:40:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 376166B0095 for ; Thu, 25 Apr 2024 04:40:59 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DF89EA048B for ; Thu, 25 Apr 2024 08:40:58 +0000 (UTC) X-FDA: 82047408996.13.B0623AC Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf09.hostedemail.com (Postfix) with ESMTP id D8E16140026 for ; Thu, 25 Apr 2024 08:40:56 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714034457; 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=8g/fjf5Bp9zMfUTVcdih2n/RGFhdyeL3pfeXntoscmc=; b=SDTx7fOtzjO/EanaaJyK5IpYBULtheb12VNNnf68KpyDWeJauGZCP1ypg4iBlB/ZTjnmJ7 ZTt+UyGeeyGlLeDIqxKoyYGa06DSc5QmIVz73vG7JBJVDJW+AbyDaT8/kSJTi/+xMPI8Vt UwoAy18MuZ4y6FQs1+hV2x8rINAq/e8= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf09.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714034457; a=rsa-sha256; cv=none; b=wRzpCAx3zBRx9iDkzTOmGwcmOBvECM6zHeVbZtbBmBUEzVUL2uJxWfDg0RjjJeLtRKoA1d jX00RDXhrl0lt45IAwgDjNf9d+Aj+22Dfd31f4D0rXGUXh0MGhj544EsacnxkBIMXGQwEa tRZR1R7Shvw6fOSVtRb4FoNSJSlVEcI= Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4VQ8PV44kpz1R9Kf; Thu, 25 Apr 2024 16:37:50 +0800 (CST) Received: from dggpemm100001.china.huawei.com (unknown [7.185.36.93]) by mail.maildlp.com (Postfix) with ESMTPS id 4A2C5180073; Thu, 25 Apr 2024 16:40:53 +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_256_GCM_SHA384) id 15.1.2507.35; Thu, 25 Apr 2024 16:40:52 +0800 From: Kefeng Wang To: Andrew Morton CC: , David Hildenbrand , Miaohe Lin , Naoya Horiguchi , Oscar Salvador , Zi Yan , Hugh Dickins , Jonathan Corbet , , Vishal Moola , Kefeng Wang Subject: [PATCH v2 09/10] mm: migrate_device: use more folio in migrate_device_unmap() Date: Thu, 25 Apr 2024 16:40:27 +0800 Message-ID: <20240425084028.3888403-10-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240425084028.3888403-1-wangkefeng.wang@huawei.com> References: <20240425084028.3888403-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100001.china.huawei.com (7.185.36.93) X-Stat-Signature: 6xtua4wc5qhnymqz771fj36afexqsxtp X-Rspamd-Queue-Id: D8E16140026 X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1714034456-911861 X-HE-Meta: U2FsdGVkX1/vHt1EcvWscrZHnxRoxjnpp0Xgd4HZ7Aoif8/efk94NPgAnuCEXXTAIuMJM9VynTjM4RZg1JE9mjwfAYt1DqZUNkHfO79V1tLwsqtFLgrhqgk9W2SnwKOf65oSGpHzZGTK6+SnWJNj7H80/aMriSYxsjAhvvE3gvBP1oQ3i5k8Nmo/m4C+Jsz0OlnoSuHajXpOrP0t2Wkwvey2FbbAo8kcNaUrNXsLrvYJ6oAkqB34+NmNrvZ0V1M87O9ZgR4wYhgGNSpU++Q3x5aeK6p+dBvMJ/ceJTLUN6KE33ptU62SzD3oCSw3LPgqiqqjWk1ClojyTSs+0qXRYhmoNZhvKdAJmm4YHIjHr66zgIQ3ITesriiCE2TPjsaz76Urrcl5G/NUiUb0Rdmy3VxKF4zCsAU1ceN6+zlM/WDXhdo+EjMz/dDdRwm4PYgZ9hcORZ6hYtGEEip/QIjn3RWc4WVI5Da1oJJMqFbRRifHLTptLL8UmGQ/doVetnmOKriF8NXP882vE94LGQXW1btiCFeP9p0BcJLmHSpbLP2yFeWSP8Hgx8lVzJDWCx00Th9u2GBGGnGl818k66wmCkJIP7Ezew/dfOVHIKQe6C0mQCEChpr9rV/HLym51f4Y7ehiY89w+3IA1SpW6c8odZhgleX5DoMqxSw6YakcM3FnVR9Ni6TvsWIkPwFLcr9ZSRU7GmNsoU7+aNl0J69whxsIIpdB0iAoWeT+xkHSnGELXR4IcuYPNdjjGxpXXd5VO+ulkNKs6FrViajZ2fPz9WiAQKm4yntzTaqQ7Js16lsyfmaMDiigfTS+pXgpQd4eUssIk+a0uueKiSVkDEA+Y35Hm9xO390RTfUXomtqMJVKLpQ9/yWCX1zotPyqwvlKNWNaeeM6VjCRjjTTjLFPSZK02x1+Sga7Lk9B1/ClHMVwgNBWC9yyw7GvPjNm8FsLf51Vvxci2wOkC1mLAJ6 1sg== 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: List-Subscribe: List-Unsubscribe: The page for migrate_device_unmap() already has a reference, so it is safe to convert the page to folio to save a few calls to compound_head(), which removes the last isolate_lru_page() call. Signed-off-by: Kefeng Wang --- mm/migrate_device.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index a68616c1965f..423d71ad736a 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -379,33 +379,33 @@ static unsigned long migrate_device_unmap(unsigned long *src_pfns, continue; } + folio = page_folio(page); /* ZONE_DEVICE pages are not on LRU */ - if (!is_zone_device_page(page)) { - if (!PageLRU(page) && allow_drain) { + if (!folio_is_zone_device(folio)) { + if (!folio_test_lru(folio) && allow_drain) { /* Drain CPU's lru cache */ lru_add_drain_all(); allow_drain = false; } - if (!isolate_lru_page(page)) { + if (!folio_isolate_lru(folio)) { src_pfns[i] &= ~MIGRATE_PFN_MIGRATE; restore++; continue; } /* Drop the reference we took in collect */ - put_page(page); + folio_put(folio); } - folio = page_folio(page); if (folio_mapped(folio)) try_to_migrate(folio, 0); if (page_mapped(page) || !migrate_vma_check_page(page, fault_page)) { - if (!is_zone_device_page(page)) { - get_page(page); - putback_lru_page(page); + if (!folio_is_zone_device(folio)) { + folio_get(folio); + folio_putback_lru(folio); } src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;