Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2619363pxb; Thu, 10 Feb 2022 01:29:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0aPP9BxYN/sgbh2w6PFtBsYiBdxAJRxexBk7P14NdOvwpabrNZhEwROYUpYQQtTHSH6Db X-Received: by 2002:a63:6909:: with SMTP id e9mr5495750pgc.450.1644485389378; Thu, 10 Feb 2022 01:29:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644485389; cv=none; d=google.com; s=arc-20160816; b=if7y0dQsKSr3ZbkJOLClQqznv8MutmwCCgsVBf6tSmdnR/lffDkeJAzWxv3gJNXkSK Zybi72nhEX8ogeLzhGyPJp2Qpxw45kdhJwa9FzwxVtg4rX5btGrp/DSO4EqpwR6gymWi 75UqRlPwzB0LhM2lyPal++vduz8tHL0FYfyMOviyiKiCkDbMdR/mY9mWEbtOQoi7Y6wL uL+Gand16zPt6AzZ5d6uxLGO+vQoeTNy98Nz6WUXcWNVIxCiU1vVTZync9T592Qm68ow GJgiw0ame93vV92GEJNQHsA40Qo8Gu0VEJsF0KZTYkC/PT/SI+tWaOeyVKudcDtFfR2F uhOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cT0lgQLRNyTNcmoanfoLYEuqgQBo6jG7fWqTaM2xsVI=; b=oXHHklVKwLwteQoMxbIjumYehY3TkYsE7+gmSZ7acxoDam6jhI0TKQTR0DKYC2vyjy SekfduIfHxfVbSNQyExIcqlVZd6XQ2kKfWUPfDMYjDIm/USJGtM97lWNcjGdfsgI2Ksc YbWibRWsDbzF/IvBzfIllNDDTs3vhy8G+BGXx6che7dlf+jlEkSk8ErkZgE6JhoX+IjH Npco8liB2Q3owKngN6QbZbIifLvTOBqgBc6Qg3KynDhXNj8ziuymV4461VzALMZ/Xnrs qdGgmHD0PGCKtbWhkvNA4okVERb1MRXCzxhSMLPLT6ChCs9hj5+onVNo2HmHhTi+9EDO wYxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="WtXnyR0/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c14si8511916pfl.136.2022.02.10.01.29.37; Thu, 10 Feb 2022 01:29:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="WtXnyR0/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236489AbiBJHaY (ORCPT + 99 others); Thu, 10 Feb 2022 02:30:24 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236466AbiBJH3w (ORCPT ); Thu, 10 Feb 2022 02:29:52 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC4872197 for ; Wed, 9 Feb 2022 23:29:47 -0800 (PST) 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=cT0lgQLRNyTNcmoanfoLYEuqgQBo6jG7fWqTaM2xsVI=; b=WtXnyR0/9o8Ve39JA/IAs6kxRj +T3DdMelNYqpGXzKygkC4Y4CtpCWN/6tcAC/dBsxIY5S2HAa1ONMU3A3VdEBKd8Qvvk6phUj9gw8s qf0oxMsyITvf3j0B1ovCKTLGKdB+48mCGSFd+7ATgssvTFB5v08ay/qd+SAOe1JHFUn44Io2RZMAQ oEZyC2tZhuIyk5ylZU9lCNPDL3mYOudZ6I6bFj6addurE4AP+dLanx1P0RKhpQBRIRt+KUAbiP8q6 8ffUhMXi1H/nvzHVwM+Lag8Uit/c5OfAwt6VydD4rL2duWM1tbopsEdfKuBA6Pqa7qLP0gPbcPAIJ NAo1KASw==; 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 1nI3te-002sOv-8Y; Thu, 10 Feb 2022 07:29:42 +0000 From: Christoph Hellwig To: Andrew Morton , Dan Williams Cc: Felix Kuehling , Alex Deucher , =?UTF-8?q?Christian=20K=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 25/27] mm: remove the vma check in migrate_vma_setup() Date: Thu, 10 Feb 2022 08:28:26 +0100 Message-Id: <20220210072828.2930359-26-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 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alistair Popple migrate_vma_setup() checks that a valid vma is passed so that the page tables can be walked to find the pfns associated with a given address range. However in some cases the pfns are already known, such as when migrating device coherent pages during pin_user_pages() meaning a valid vma isn't required. Signed-off-by: Alistair Popple Acked-by: Felix Kuehling Signed-off-by: Christoph Hellwig --- mm/migrate_device.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index 0b295594e7626d..03e182f9fc7865 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -462,24 +462,24 @@ int migrate_vma_setup(struct migrate_vma *args) args->start &= PAGE_MASK; args->end &= PAGE_MASK; - if (!args->vma || is_vm_hugetlb_page(args->vma) || - (args->vma->vm_flags & VM_SPECIAL) || vma_is_dax(args->vma)) - return -EINVAL; - if (nr_pages <= 0) - return -EINVAL; - if (args->start < args->vma->vm_start || - args->start >= args->vma->vm_end) - return -EINVAL; - if (args->end <= args->vma->vm_start || args->end > args->vma->vm_end) - return -EINVAL; if (!args->src || !args->dst) return -EINVAL; - - memset(args->src, 0, sizeof(*args->src) * nr_pages); - args->cpages = 0; - args->npages = 0; - - migrate_vma_collect(args); + if (args->vma) { + if (is_vm_hugetlb_page(args->vma) || + (args->vma->vm_flags & VM_SPECIAL) || vma_is_dax(args->vma)) + return -EINVAL; + if (args->start < args->vma->vm_start || + args->start >= args->vma->vm_end) + return -EINVAL; + if (args->end <= args->vma->vm_start || + args->end > args->vma->vm_end) + return -EINVAL; + memset(args->src, 0, sizeof(*args->src) * nr_pages); + args->cpages = 0; + args->npages = 0; + + migrate_vma_collect(args); + } if (args->cpages) migrate_vma_unmap(args); @@ -661,7 +661,7 @@ void migrate_vma_pages(struct migrate_vma *migrate) continue; } - if (!page) { + if (!page && migrate->vma) { if (!(migrate->src[i] & MIGRATE_PFN_MIGRATE)) continue; if (!notified) { -- 2.30.2