From patchwork Thu Feb 10 07:28:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12741496 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 078B3C433F5 for ; Thu, 10 Feb 2022 07:29:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9BB196B0088; Thu, 10 Feb 2022 02:29:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 96B126B0089; Thu, 10 Feb 2022 02:29:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 80C056B008A; Thu, 10 Feb 2022 02:29:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 715C86B0088 for ; Thu, 10 Feb 2022 02:29:19 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 38A622369F for ; Thu, 10 Feb 2022 07:29:19 +0000 (UTC) X-FDA: 79126044438.01.11D2A9E Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf27.hostedemail.com (Postfix) with ESMTP id D7B2C40004 for ; Thu, 10 Feb 2022 07:29:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; 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=wCdTPi8sABXHaeJsId/JTSLi+c8Rwwiec5m8oAEznlg=; b=0e+HFPbe1yvFskke6QJO8jYN43 BL27P4rhMpZrOyRnm/Q2IFdFK02AdjcEHuLHbNOgqaLpJ3k/+8sdPvBcS5BMSWbYwm818f8/pHJQ9 N6oYv7ggwmp8pNG9UCE+nV9x3jkbmqJnBv5FDZzSl++H9pOEAFWok4hWRhxOgmkhE64XUtmaenhWA Lh/ETXt+Tg9Ly39G8h9Zs+lMnNyI8iCH6l06TLjGId++3ApOcROW1jra68QUFiTSPijOLQlJqTfYy PPFccOKbpQRr0/fwy/8IDnvxqIcU/bJJQOB6XJcncTYxCVdGbrUPwCTMYwjK/GOD7R6PdxZnOrdmu srX0uIbw==; Received: from [2001:4bb8:188:3efc:8014:b2f2:fdfd:57ea] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nI3t0-002ryS-8V; Thu, 10 Feb 2022 07:29:02 +0000 From: Christoph Hellwig To: Andrew Morton , Dan Williams Cc: Felix Kuehling , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , Ben Skeggs , Karol Herbst , Lyude Paul , Jason Gunthorpe , Alistair Popple , Logan Gunthorpe , Ralph Campbell , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, nvdimm@lists.linux.dev, linux-mm@kvack.org Subject: [PATCH 11/27] mm: refactor the ZONE_DEVICE handling in migrate_vma_insert_page Date: Thu, 10 Feb 2022 08:28:12 +0100 Message-Id: <20220210072828.2930359-12-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220210072828.2930359-1-hch@lst.de> References: <20220210072828.2930359-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspam-User: Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=0e+HFPbe; dmarc=none; spf=none (imf27.hostedemail.com: domain of BATV+4801fb5fa93fa27e8109+6745+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+4801fb5fa93fa27e8109+6745+infradead.org+hch@bombadil.srs.infradead.org X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: D7B2C40004 X-Stat-Signature: gbaihcnuurk5htemee1tx1de5rbisfsb X-HE-Tag: 1644478158-987055 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: Make the flow a little more clear and prepare for adding a new ZONE_DEVICE memory type. Signed-off-by: Christoph Hellwig Reviewed-by: Alistair Popple --- mm/migrate.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/mm/migrate.c b/mm/migrate.c index 8e0370a73f8a43..30ecd7223656c1 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -2670,26 +2670,25 @@ static void migrate_vma_insert_page(struct migrate_vma *migrate, */ __SetPageUptodate(page); - if (is_zone_device_page(page)) { - if (is_device_private_page(page)) { - swp_entry_t swp_entry; + if (is_device_private_page(page)) { + swp_entry_t swp_entry; - if (vma->vm_flags & VM_WRITE) - swp_entry = make_writable_device_private_entry( - page_to_pfn(page)); - else - swp_entry = make_readable_device_private_entry( - page_to_pfn(page)); - entry = swp_entry_to_pte(swp_entry); - } else { - /* - * For now we only support migrating to un-addressable - * device memory. - */ + if (vma->vm_flags & VM_WRITE) + swp_entry = make_writable_device_private_entry( + page_to_pfn(page)); + else + swp_entry = make_readable_device_private_entry( + page_to_pfn(page)); + entry = swp_entry_to_pte(swp_entry); + } else { + /* + * For now we only support migrating to un-addressable device + * memory. + */ + if (is_zone_device_page(page)) { pr_warn_once("Unsupported ZONE_DEVICE page type.\n"); goto abort; } - } else { entry = mk_pte(page, vma->vm_page_prot); if (vma->vm_flags & VM_WRITE) entry = pte_mkwrite(pte_mkdirty(entry));