Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1389691ybl; Fri, 16 Aug 2019 14:12:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqyjh8HEmK4Txi8UslkZeoj4okZDs7JVmKPqDGNeMUR+Fnbg7j5f6UpfefjJgkFTTFPSopa9 X-Received: by 2002:a62:b60e:: with SMTP id j14mr12854702pff.54.1565989978289; Fri, 16 Aug 2019 14:12:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565989978; cv=none; d=google.com; s=arc-20160816; b=wT6NBNcHe6n1E9RzWB9+TzwDT/TDL9XJL5yy9RsEMsnpULzxCeapSr8L66PTGrTKoz ZltLIYpQ8kRce06fr3cSYcmNsosm7KOGfisAh1S94uXGnyDj7r66qcbe9FYKEDsmH3Mx 3k8ufdDDYLTZHfLa7kool4IL706klQ+ufaFMMukQ721Jp+jQAWLLQBaipDbIIb6nq4X3 RsccbyWNwzISxxnGUL8+PZmm1UJU5Xgh1z0mJwULqMschIFjsC3KC6mfw47x03Qu0VSq laybL69Usz8bGqTc/vb2kcgEzjMTCg5uD591N9Slgxl62SDt1T4lIaz7O7WTFTHrTTk4 reNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=PJd/tDuHjDQeAiJVFqvLpPZ32U3ebbqcCpFuKHXBESc=; b=X4GFerswpr5XkmB1fO1LeRLtlqPNh4vPL0mdJo9L88SUXXOhCCA1ckdoP/yvU/hnB2 sXcDIpY0jWVXRJDDejNV1WXPECGWDepJEzTmzRegbEBSzXrNJud5qklEs2UmRvna6KDP Kvjp01fWEBUUiHC4lf/D+ObwBIrIzZJ3uAxUwDtuUeSmEMVlO5VBzMquh4Z8B5Q0GW9F rEKdhBKIZecxlmlnaJuaNeA9Uxk0i9Js+vaDK9brXqrU5GkNCnGkZe5UJI7cR3ZU27MS niJo8hgD4wxo9UjOuLZmxPogxEZ4ekrw1a2Z4o9t6APPwwNhp87apXw2BkGrEHHpOWYA 2VRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=eE4pqTBh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c11si4497951pga.118.2019.08.16.14.12.37; Fri, 16 Aug 2019 14:12:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=eE4pqTBh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727686AbfHPVKt (ORCPT + 99 others); Fri, 16 Aug 2019 17:10:49 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:19894 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727548AbfHPVKt (ORCPT ); Fri, 16 Aug 2019 17:10:49 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 16 Aug 2019 14:11:00 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 16 Aug 2019 14:10:48 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 16 Aug 2019 14:10:48 -0700 Received: from rcampbell-dev.nvidia.com (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 16 Aug 2019 21:10:48 +0000 Subject: Re: [PATCH 04/15] mm: remove the pgmap field from struct hmm_vma_walk To: Jason Gunthorpe , Dan Williams CC: Jerome Glisse , Christoph Hellwig , Ben Skeggs , Felix Kuehling , "linux-mm@kvack.org" , "nouveau@lists.freedesktop.org" , "dri-devel@lists.freedesktop.org" , "amd-gfx@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" References: <20190815194339.GC9253@redhat.com> <20190815203306.GB25517@redhat.com> <20190815204128.GI22970@mellanox.com> <20190816004053.GB9929@mellanox.com> <20190816122414.GC5412@mellanox.com> <20190816172846.GJ5398@ziepe.ca> X-Nvconfidentiality: public From: Ralph Campbell Message-ID: Date: Fri, 16 Aug 2019 14:10:47 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190816172846.GJ5398@ziepe.ca> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1565989860; bh=PJd/tDuHjDQeAiJVFqvLpPZ32U3ebbqcCpFuKHXBESc=; h=X-PGP-Universal:Subject:To:CC:References:X-Nvconfidentiality:From: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=eE4pqTBhvF6Jo8/onIHf7UdJEMa+f38IaiV8IGyr6VH7sjC6/U7NDUidvZNZrPxGi IWqO/9fzHXHdrzVt8mWRqyLtMRcwigQV5w8yH7jqzlnp/q4jIk+1eFwNzlZBsNe1NB oPhq4ZrJ8F3y8HabI5/23apg9QjOZvNlVAY4CtZWixb7IRHsZJPoCiKvJXP/lQxFz2 wdzux9+eXoGrD7TafNg4FaiE1QOgPnlD97QPQs0F0HaZzmUKDI4WRI9CpmvKshvUrP ddi04plRaD3gWIBjv3Ah3JRRCsNodqPudA276IOtp9tVqGFsfBROvB1prYQhrsbnah NYPaeCyBQzF8w== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/16/19 10:28 AM, Jason Gunthorpe wrote: > On Fri, Aug 16, 2019 at 10:21:41AM -0700, Dan Williams wrote: > >>> We can do a get_dev_pagemap inside the page_walk and touch the pgmap, >>> or we can do the 'device mutex && retry' pattern and touch the pgmap >>> in the driver, under that lock. >>> >>> However in all cases the current get_dev_pagemap()'s in the page walk >>> are not necessary, and we can delete them. >> >> Yes, as long as 'struct page' instances resulting from that lookup are >> not passed outside of that lock. > > Indeed. > > Also, I was reflecting over lunch that the hmm_range_fault should only > return DEVICE_PRIVATE pages for the caller's device (see other thread > with HCH), and in this case, the caller should also be responsible to > ensure that the driver is not calling hmm_range_fault at the same time > it is deleting it's own DEVICE_PRIVATE mapping - ie by fencing its > page fault handler. Yes, that would make it a one step process to access another device's migrated memory pages. Right now, it has to be a two step process where the caller calls hmm_range_fault, check the struct page to see if it is device private and not owned, then call hmm_range_fault again with range->pfns[i] |= range->flags[HMM_PFN_DEVICE_PRIVATE] to cause the other device to migrate the page back to system memory.