From patchwork Mon Dec 11 16:22:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13487534 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 47BC7C4167B for ; Mon, 11 Dec 2023 16:22:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 668146B015A; Mon, 11 Dec 2023 11:22:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 619226B015C; Mon, 11 Dec 2023 11:22:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4199C6B015D; Mon, 11 Dec 2023 11:22:32 -0500 (EST) 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 26FE96B015A for ; Mon, 11 Dec 2023 11:22:32 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 09DD4A1BCF for ; Mon, 11 Dec 2023 16:22:32 +0000 (UTC) X-FDA: 81555055344.09.D8C81A3 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf28.hostedemail.com (Postfix) with ESMTP id 5BA06C001C for ; Mon, 11 Dec 2023 16:22:30 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=lqFIwyUs; spf=none (imf28.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702311750; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=p/4ibDc02LREHfNKAqGjcw8GKUvCcq1xLtUCwg/63T8=; b=i3tjrAXYiqWlJsgPl55nfO0AZJjGJPc0h/rd4FymDuYcVaY3uufc+7Vp/ra83CyKYLVT2b +8Ov5Qz6GlkVWmkralKHdRW5otGwXibEbG9M32Fpcg8eAY8L5H+oNNtM8AEhamYEMK2BPz WOVnOeAMy0YCECmUvuUDWD145N8YAFM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702311750; a=rsa-sha256; cv=none; b=XL5lo0ZGTmq5eFF8Q7aED0drazZrYT8WcAtiBbLI7n9EPQX6/pddTS7wZrPmzXAgdoGG0t FcyxRMXSB3d3LHVVLDf7WqapncFs0Q3Kc6d8Y4sLql7FgspgkZH++hHU4pVFbpE3BtQEA0 A5Nx51WXTV7RpL8+npNTDJLb75lhV/o= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=lqFIwyUs; spf=none (imf28.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=p/4ibDc02LREHfNKAqGjcw8GKUvCcq1xLtUCwg/63T8=; b=lqFIwyUsA0071p54wMX7oajykx vob5x7B7L/HyhEtuFnXlDLfkh58NFnIkCM5M9yyXCW0Pcr/fzHy7hnfO0l6azluOa8ki0sT4CBxyh KhWS/v3N8s9mSgqG88pP3+oSGpxeBeWD/GlOkiN4OZnLEZCjWZUMggXaoZOhwMNCdfxbgHe5sxsGz EFU+/632GvbU7vAhQUF9exXFeasmCbVcLN1jn89N6p9OXMWPCSLo3vSkbTvluzDNr7/SiauZLlFcu jWbuVtd14xuvk3LbsFXoqeWUu2yk1q61gHWA5813glM+TBm1VDYzwO0c3PP7+qZEVRN9mbA0fEyv0 gSvi+RoQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rCj2u-0090JV-HA; Mon, 11 Dec 2023 16:22:16 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 7/9] mm: Convert migrate_vma_insert_page() to use a folio Date: Mon, 11 Dec 2023 16:22:12 +0000 Message-Id: <20231211162214.2146080-8-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231211162214.2146080-1-willy@infradead.org> References: <20231211162214.2146080-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5BA06C001C X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 3nzsfriy66e61kbzstrds8dx4pi8nqh9 X-HE-Tag: 1702311750-374492 X-HE-Meta: U2FsdGVkX1+vWNPW0y7hyUhFmRRpRMbXlzoVo8W2lGBRvtD7u49qx118p5h8nPwDay0qhRq8eabsqoe4JKjbpF+4qYxILELXVOExu5zLx7WRYBrZheOTL2AdkDHP6cNCCyMa0at5DpKTj2B9Zg/yprBmm40DwwpFGYRQe14Zi33CrUoHJjgCH+AolxjYypU/8o+Es087d8SxOkwPAuMQc82HMGtrHaVz9QhrVQRo+p/DlhPosq4tA9Jm5ECtGS5HVTJJ583cP7W+KVFo/0Vnzu16rayZQSlTs4rw6+7kPBTNZfHJgEoJD1fG+wFuAE0iAa54y2+ZXwKMpjs6FBWL3atYgWlAQsqnM3X+MF3DYHeEek3FiONRQoQmhFMLYjYcWPt+5IMWwtCvwJjlHMN2y0Qls95y45HnXZ1bZupc4o0Ip3N14KBUy06dhTv2Mz5GVDTtbJ3RnD+wJcwv71uEErVgU9176kBgtWKZga/sbtHTJnDFl2a7ODqVZ++QtETAiZbtC7X7ukz0IbJRS9gEUjhP8K+5egXMivYmuKvBcRY53eUQeazGx7TGh8LLGmv+3+a22FRJEPmzDZ6yYXjpjFR1x6KwTatIkDYEyLma71nBO4Bhw+L+hzDIZbGn2Bo3kb3WVx5jbXkRfDG3Y0UkLMlUs/JKp++R1l74PtYoG7a4LsseJO3CHOk6qUZWybaktZwcTjVlOfUbAGP3vqZNvx6c5gBh4hSSUBukuWenM533e7CGLMhfouYncIlNPeoPbVuVz82U6L4p8Q50xnlw/u1WAZHRm90ywZyRoC+mwVfD3QLipNG2G6FjK6XwgFvufjFvmV9d9NPjz7cwSVtVZcmDfGF9EaJxS0YS60LNqV1j6SyWpL9pFtM+QXFpGMYthNTUzOtrUjOdDU8A5WL8S8Pr9hh73EK0uEZcG6jEhnuNCD5bciDQy3v6PQ5WTBrD7LhCdgO7T7jYXRylqRW /sbnt/Pt sLsedqF7Ta66N+7NQ9RJadBRZP/b6LHivpdnx718dRrJhwO8818DNIhB9nVq4MQ35BRYyIYxbFCqlGEV6SnCvzW7xMTWuQwPL8OTCop0dy0O3b008394T1S3jTwhdjPb+N3qg//Am8FOrQqZa2SSQRrC55GsKaJFeG2Lmud/8ClKJ7WMn7mtVO0t4YLwS7X6NY5mMk2SPAmJcPeXrKu+XBD2AtK9pm4NGgqoV 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: Replaces five calls to compound_head() with one. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Alistair Popple Reviewed-by: David Hildenbrand --- mm/migrate_device.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index 8ac1f79f754a..81193363f8cd 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -564,6 +564,7 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate, struct page *page, unsigned long *src) { + struct folio *folio = page_folio(page); struct vm_area_struct *vma = migrate->vma; struct mm_struct *mm = vma->vm_mm; bool flush = false; @@ -596,17 +597,17 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate, goto abort; if (unlikely(anon_vma_prepare(vma))) goto abort; - if (mem_cgroup_charge(page_folio(page), vma->vm_mm, GFP_KERNEL)) + if (mem_cgroup_charge(folio, vma->vm_mm, GFP_KERNEL)) goto abort; /* - * The memory barrier inside __SetPageUptodate makes sure that - * preceding stores to the page contents become visible before + * The memory barrier inside __folio_mark_uptodate makes sure that + * preceding stores to the folio contents become visible before * the set_pte_at() write. */ - __SetPageUptodate(page); + __folio_mark_uptodate(folio); - if (is_device_private_page(page)) { + if (folio_is_device_private(folio)) { swp_entry_t swp_entry; if (vma->vm_flags & VM_WRITE) @@ -617,8 +618,8 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate, page_to_pfn(page)); entry = swp_entry_to_pte(swp_entry); } else { - if (is_zone_device_page(page) && - !is_device_coherent_page(page)) { + if (folio_is_zone_device(folio) && + !folio_is_device_coherent(folio)) { pr_warn_once("Unsupported ZONE_DEVICE page type.\n"); goto abort; } @@ -652,10 +653,10 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate, goto unlock_abort; inc_mm_counter(mm, MM_ANONPAGES); - page_add_new_anon_rmap(page, vma, addr); - if (!is_zone_device_page(page)) - lru_cache_add_inactive_or_unevictable(page, vma); - get_page(page); + folio_add_new_anon_rmap(folio, vma, addr); + if (!folio_is_zone_device(folio)) + folio_add_lru_vma(folio, vma); + folio_get(folio); if (flush) { flush_cache_page(vma, addr, pte_pfn(orig_pte));