From mboxrd@z Thu Jan 1 00:00:00 1970 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 3C1EFC433EF for ; Mon, 11 Jul 2022 13:53:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8DFFE6B00E7; Mon, 11 Jul 2022 09:53:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 88FE66B00E8; Mon, 11 Jul 2022 09:53:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 730276B00E9; Mon, 11 Jul 2022 09:53:03 -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 60B2C6B00E7 for ; Mon, 11 Jul 2022 09:53:03 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 319D720CEE for ; Mon, 11 Jul 2022 13:53:03 +0000 (UTC) X-FDA: 79674960246.25.999C892 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf29.hostedemail.com (Postfix) with ESMTP id BC29C12006B for ; Mon, 11 Jul 2022 13:53:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657547582; h=from:from: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=TiDFw+H9wQAOoFgenmknWW5ulkS2E0Ovm/60i012Tps=; b=bty9a/+z0po9y951Q9OaFfA4QOPqe//PWk8MD1gR4J0tKzF3NylJ2ikslSpTq9YG4OvP7i xooGpKzVJfRxbNJ5eZrWgD2cqsH9lt06u43E8EC7+ZAaRx9+vN2625MUD/SQzsAHzOiWUI wCo6BpOdZR4E9TR57FWW76ri8KkSSUc= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-275-vBleIR8pM3Cvovq89RTIJw-1; Mon, 11 Jul 2022 09:53:00 -0400 X-MC-Unique: vBleIR8pM3Cvovq89RTIJw-1 Received: by mail-wm1-f69.google.com with SMTP id c126-20020a1c3584000000b003a02fa133ceso2765930wma.2 for ; Mon, 11 Jul 2022 06:53:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:organization:subject :in-reply-to:content-transfer-encoding; bh=TiDFw+H9wQAOoFgenmknWW5ulkS2E0Ovm/60i012Tps=; b=sJIA5DypxvhaZ/L6ZkoLdHLKv+6qLrMND0eQTup4ZGKgbILwzpbfOjDhFkTYPeAs6f DFaGoiVuGjaf7nCLrTT42U+R7RhnS/ahltT6LVIt2NPVpJSe42VMRTNLI0+/GtlwptL5 DSREFo4ZcAY6ddlXQRVERYTGfgMuqTVotjRJ6NPfY/hf8D+1PwWiMRsIP2HKFs37kM/t q6hUXUPRc6d+3x8V9o3BxEaEXRMw+Q/tzN8CLEuzamGWnKjgtB4YFslSt7W4bWNBZAdn Q67zzcPz7oCLDtPdrb5lEDdQPMOdhtnm8TJr18hVrfGbI7FAy7aL2CgnkDU1jrzcNKdX vmiw== X-Gm-Message-State: AJIora+sAGDXL8lb+OplB0opx3RW9q3+7G3kLTpPMLuclJpvVAFequtU 3jdkjJqWbXwm8oURsuZrB21DTF+8WU766WnIFXXe5poh4VJXJtUIPFgjQJ/Plc3eS7g62ojhQ8W Q21EB1pGHghQ= X-Received: by 2002:adf:f151:0:b0:21d:76a7:76d3 with SMTP id y17-20020adff151000000b0021d76a776d3mr16557680wro.702.1657547579796; Mon, 11 Jul 2022 06:52:59 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tVRhLI1q2NxvdCqXB46XQEdcekPaWp69NFcGLqv0djixdSMTe1BzXGsV30YFN4gPC0osccbA== X-Received: by 2002:adf:f151:0:b0:21d:76a7:76d3 with SMTP id y17-20020adff151000000b0021d76a776d3mr16557660wro.702.1657547579573; Mon, 11 Jul 2022 06:52:59 -0700 (PDT) Received: from ?IPV6:2003:cb:c702:1400:c3:4ae0:6d5c:1ab2? (p200300cbc702140000c34ae06d5c1ab2.dip0.t-ipconnect.de. [2003:cb:c702:1400:c3:4ae0:6d5c:1ab2]) by smtp.gmail.com with ESMTPSA id z15-20020a056000110f00b0021d6c7a9f50sm6200486wrw.41.2022.07.11.06.52.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 Jul 2022 06:52:58 -0700 (PDT) Message-ID: <7a772ca0-0c82-2251-dd54-8ad466774e99@redhat.com> Date: Mon, 11 Jul 2022 15:52:58 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 To: Alex Sierra , jgg@nvidia.com Cc: Felix.Kuehling@amd.com, linux-mm@kvack.org, rcampbell@nvidia.com, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, hch@lst.de, jglisse@redhat.com, apopple@nvidia.com, willy@infradead.org, akpm@linux-foundation.org References: <20220707190349.9778-1-alex.sierra@amd.com> <20220707190349.9778-7-alex.sierra@amd.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v8 06/15] mm: remove the vma check in migrate_vma_setup() In-Reply-To: <20220707190349.9778-7-alex.sierra@amd.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657547582; a=rsa-sha256; cv=none; b=ATIHEOLRq65EHHW8wM/5b2JkmFZmWjKteNd4EyT2rrsEqmDrLOGcNDqkAJzReeqe6eBwPe cPNNbzh13Zfj3Yl88gCqMBsaA5jPljxAP16ehqhliuBWuao+iELlQOjltoJrVSVFrTGyMh YezIwxc7AmMP1FXPs2WCZh+AYPsIDrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657547582; 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:dkim-signature; bh=TiDFw+H9wQAOoFgenmknWW5ulkS2E0Ovm/60i012Tps=; b=4UK0Yk477O4hyJtrMH45AFLIxjC7tktl1bGwnx/gU72nk1xZMc5bfXnNykq8LVkcMeYUlm eL4E34BUc7aV5xpVoTwQ3J77vhqP2VOx4q8wGF915jwyeWGlov57hp5QBjr4162xZZ8sXQ fcBbW5/w4bKU+EtIXGVfuNvIZgc0ycI= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="bty9a/+z"; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf29.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="bty9a/+z"; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf29.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com X-Rspamd-Server: rspam03 X-Stat-Signature: 8w64tk1wi1oon9eog1w9nky3oxfrtwut X-Rspamd-Queue-Id: BC29C12006B X-Rspam-User: X-HE-Tag: 1657547582-84629 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: On 07.07.22 21:03, Alex Sierra wrote: > 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. As raised in my other reply, without a VMA ... it feels odd to use a "migrate_vma" API. For an internal (mm/migrate_device.c) use case it is ok I guess, but it certainly adds a bit of confusion. For example, because migrate_vma_setup() will undo ref+lock not obtained by it. I guess the interesting point is that a) Besides migrate_vma_pages() and migrate_vma_setup(), the ->vma is unused. b) migrate_vma_setup() does collect+unmap+cleanup if unmap failed. c) With our source page in our hands, we cannot be processing a hole in a VMA. Not sure if it's better. but I would a) Enforce in migrate_vma_setup() that there is a VMA. Code outside of mm/migrate_device.c shouldn't be doing some hacks like this. b) Don't call migrate_vma_setup() from migrate_device_page(), but directly migrate_vma_unmap() and add a comment. That will leave a single change to this patch (migrate_vma_pages()). But is that even required? Because .... > @@ -685,7 +685,7 @@ void migrate_vma_pages(struct migrate_vma *migrate) > continue; > } > > - if (!page) { > + if (!page && migrate->vma) { How could we ever have !page in case of migrate_device_page()? Instead, I think a VM_BUG_ON(migrate->vma); should hold and you can just simplify. > if (!(migrate->src[i] & MIGRATE_PFN_MIGRATE)) > continue; > if (!notified) { -- Thanks, David / dhildenb