From patchwork Mon Aug 26 06:58:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13777226 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 549C4C5472F for ; Mon, 26 Aug 2024 06:58:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1B086B0248; Mon, 26 Aug 2024 02:58:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C7E0E6B03DF; Mon, 26 Aug 2024 02:58:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A0DF76B03D6; Mon, 26 Aug 2024 02:58:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6FC8F6B03D3 for ; Mon, 26 Aug 2024 02:58:38 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 255AAC0C6E for ; Mon, 26 Aug 2024 06:58:38 +0000 (UTC) X-FDA: 82493493516.24.4902274 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf29.hostedemail.com (Postfix) with ESMTP id 0483B12000B for ; Mon, 26 Aug 2024 06:58:35 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 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=1724655432; 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=UQLQHJIl4ePQ9CVMJZVMiSf3ev3ADjmuz57PPMeUC98=; b=Ur/zPEdiwCIlfloBXkAgDSW5t09L0Kn5Oqc85rBW8lssIsU3HrVJcMKOL87DFa0GbtiQUp xVfVRcOE9mF6BCTfIQsBIUdqUoytYVU06DO62LDdgujx3aMG6vVR9DOKf0uaTSPtZTwiCn GtGK1AcCup6yQB7a1B7lx2uYa12m6fo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724655432; a=rsa-sha256; cv=none; b=PLBxbp4ObsH0AquzF9MCJe9+SKreBhvLSi1e/uIWHBlehceNzHgRBhBQdWo6hgYLLxcsO5 dH158WgIuiV/5jaXvQzTk833lkpUJ5kLHB9Q78poOehpU9UuZUpXU7rXyEk40HWBCpneIu 3WzoWzZ24Hh3d3lLsz2UCWJPjYXFP68= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf29.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WshMz3qTWz2CnZp; Mon, 26 Aug 2024 14:58:23 +0800 (CST) Received: from dggpemf100008.china.huawei.com (unknown [7.185.36.138]) by mail.maildlp.com (Postfix) with ESMTPS id 16A24140120; Mon, 26 Aug 2024 14:58:32 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemf100008.china.huawei.com (7.185.36.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 26 Aug 2024 14:58:31 +0800 From: Kefeng Wang To: Andrew Morton CC: David Hildenbrand , Matthew Wilcox , Baolin Wang , Zi Yan , Alistair Popple , Jonathan Corbet , , Kefeng Wang Subject: [PATCH 3/6] mm: migrate_device: use more folio in migrate_device_unmap() Date: Mon, 26 Aug 2024 14:58:11 +0800 Message-ID: <20240826065814.1336616-4-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20240826065814.1336616-1-wangkefeng.wang@huawei.com> References: <20240826065814.1336616-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemf100008.china.huawei.com (7.185.36.138) X-Rspamd-Queue-Id: 0483B12000B X-Stat-Signature: oaarn95s6guxdkqwuaqk1wq7um95ebr6 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1724655515-259499 X-HE-Meta: U2FsdGVkX1/5FCIuL9COTdw4ciD9mQqLjyPhyqlmtUmoka8m57iGFffDaWBCOZaeZUELIfaCPgJ/UHPWOxNu5qbdpqwswrSRioONg4IY00MrIWnHvJmZHHcZr2I1mjlgjg72kvAAuOR4Ni2w0CQVpf+nOWhvKMpROZD2fZsD0yeDDMUQe0X06oEx6km1gvYHYugeedpjLUkV7lMJQu7usf8pHBkXe+z/EzF1YKGvj6Qnc0mAuoFiYyWB7aqs4Ta+v0kYatWfdW+OAiVBMQMzRzGpxCjpcOMsXbxcFWkKSMqSwOzRxN159vrenH92yPiyofGRekuBMyOSky2YjnnXy15GFA+nEImGabXMrg1Fl6CQ2xIVRBwIpTHC42h5OSPanch7uKLNzZlafFYqfoHcPRpp5DbPJx66ubosS+BKU+9Ygj4omvSLZPQyrVyj/AQsTuGvpMAivws9HmbOPmKDXiX/1QcEjJPFwrQGgP5XwLg8eRvKUHsDo/zMWwyn9CrqPOak4Sl/zvntnQoKA3hQ7+mkN9PdMdEja0u7LTNWiwdiIqPbWDvN6vrdftCllfWZhwJNh4Gc7Qa/8/UcZ+N2Tec5dB9GmDwz2fpL/afGvOP2xJWlT1Y8FwHpNpDy8p/XRPJ27qMpl+ZxLExu8KB/5T7+HuZN6PITUbnWcF6rgBbYya5ZXiDKCAsHwW1KGl3beQj3Fb7v8CsNH2Pcn5416VLmmsa7pSLTrviCuTLZifFlbL2RzB4VWWWZdkov9NMbzY41BGukBdM3opxC5xuVlN53kJtIMHHhYjuHrThzqib1nZ2JTu5ImELc1gjQYyT17QLJT03SaUZ5oWj9eG+eJUJVZFTdlKmlaCl7KI4fY7jrkl6p2ZiLApT+QRiF2LZ8a8CH8zoYiS85+Ms0+D9r6bic8OHuf4GTIToHiLXAZG3DSenXTcau90qYcwQ8jABEuwrTLzm9xYANosMfm8J 9Bl3AJdD vqUfiKsd3UPPIiO5jTSURvER4rt0OAjZ3YQdokwyDNcWBn1NcbxDgtxUtMflehjN+MAy1hlh99sym0kZ/+vfsFB0NHLV3pQgyOWhsk1P5zq0/tD54lsNYcUAigVBCGXwZ6LClqHRo4w86TrZePkH3r7KvHUcBAYG78KNv5tu3E0PpjB86Hnp8ZZb1f/UUzewfNDHymniN1mJH64tWjlqwBiOII3OeQZldF8oCRTg45yEYy7VEL4i91uhMFa0P/epj5P92eavOLfP6NNfmKRPNTEk2OfNgeWjKxUTs9Jgg1rHqXrugOJHiMRi6SA== 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 Acked-by: David Hildenbrand Reviewed-by: Vishal Moola (Oracle) Reviewed-by: Alistair Popple --- mm/migrate_device.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index 66db28b89f9b..b49f4956617a 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; } - /* ZONE_DEVICE pages are not on LRU */ - if (!is_zone_device_page(page)) { - if (!PageLRU(page) && allow_drain) { + folio = page_folio(page); + /* ZONE_DEVICE folios are not on LRU */ + 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) || + if (folio_mapped(folio) || !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;