Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp427197ybl; Thu, 15 Aug 2019 20:56:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqyM4zVantphvOrzD8Svesv++1W6vmeecoE9Fmudfncw3dzOOXrcDv/iscZHkJWtpG6R24t0 X-Received: by 2002:a63:1743:: with SMTP id 3mr5859226pgx.435.1565927761674; Thu, 15 Aug 2019 20:56:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565927761; cv=none; d=google.com; s=arc-20160816; b=QgyoJl6T0oL6rUrxhmU4dgKf9e9I2HzSjUSd3BjYlQwmvXZYFBidsEJAs5uK2TCI1D OVpgaGSl794Rmxx/yaYWTal8JuwLJbq0NEAO4kMn9rFAe68qte9RJdCPSGxFrGyt3HQd sw2sOmEq5g4SBnlBLsGLF61jK9JDDSFXVlKp39QkIvrx6H6atBhpEC0rxtLPZPg46HQn 1iUqeze6qZphus32Hy5gBKrp+6o9EME4qGD0PjdQcW2oJqYfvanCUUxmIpiWvjLYmBST o5SpX/ciaVJmk0IButrM5K8UoYYvz17IShLDAnYdq10zoP4eNgu0wzVGnekXMEt4wgar xhJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=9WkJUtJNJm1DYJ7j8k6+uYXDk5DFrU4ee4of/nPzT1s=; b=h3Xb5Mx0ZEiliMbfpitqBpOCVDhX6TO/zlIcKGfRvS404V/7Kt5D1yUuk/+WerkYyR FR+CXlKA3YE0vSDIInbmCiE8FWj3bYnRjxmT9Yzmmi7gnmGJhgzcQrGu8FEyDfbhMr5h YY754WxFeQyJSoGWRLZ7BzD+7mxJADE5LhVU7ktzwEWmUtruOi/BOwuF9sPtTrYrBHyw pbQgKEgkMoC0Rbw0c159/1n0hV/SeekC4U3xTlDlea2Np4gk33lp4gK1Vqwg2jI3OyXu e52X4fMIBpmolBTaP/fHMWCmT+QrEsolsviObgxenO0Jc9nlGvFZyvqZn6uK2UZ4qAzS 3KBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=UuG8eAXm; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g12si2191526pje.88.2019.08.15.20.55.46; Thu, 15 Aug 2019 20:56:01 -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=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=UuG8eAXm; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726594AbfHPDy7 (ORCPT + 99 others); Thu, 15 Aug 2019 23:54:59 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:42318 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726139AbfHPDy7 (ORCPT ); Thu, 15 Aug 2019 23:54:59 -0400 Received: by mail-oi1-f194.google.com with SMTP id o6so3850796oic.9 for ; Thu, 15 Aug 2019 20:54:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9WkJUtJNJm1DYJ7j8k6+uYXDk5DFrU4ee4of/nPzT1s=; b=UuG8eAXmgl5Ru6cZIUQval2jXosANzNztFowRGWtct0jh7nOw1RR8555FMU+nuNAIP hmNhO7WbphDv2TTdAW10rg5waTsTbjLcnYhBRfr41484IBkk2zzz7p9gLfQtEo8k3k8m D+7tNjsByy4DJfUxtdhaoGs8AvT+4s1lX1R/mEHDukPk8BI8cXzKSG1fEF6eZggnI3P9 plDLFIrc97OcWruXoxlanf1L/2EonM9E/kePByjuPM4mI2WrapZLGn0IUw/ARkxljJQC NvoZCpeoatjh6hV+PeNEIdEkVlMp/Ery6H3K0EazoowLKweCQYqY52AWrRnf6LANfgT1 2WbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9WkJUtJNJm1DYJ7j8k6+uYXDk5DFrU4ee4of/nPzT1s=; b=T/0yow69egK0aHZWfkVulmz50uA3ycftliRL7QWgg1TPHH/eqgB4XG9vcQfV7ygLqF VivIUsrTZc1b+nZD4zxx+/tYQmFv964EzmMvVkv/rAR+93VH9+TspjYAgPHP9GPJeNd0 G4h5HphV5y2WY6tgQzymyfJqYKWeAIb6NgBM3QgsJ+ZJuTVPzOywrXc3+zKOQzGzb5Z7 bLRYCFq6KBfpk7YqMRtnN3yioa1FehWfa0I/rXx3/HMPnruhhVdg281g5deQSOQQc2sI ReNl9jSzTJ+W6yjgv/T2TdBqd/ls1+vK4rswOb7Wq/YGVOVVZUj9Hc6rFaSZdTqTK/Q8 vFIA== X-Gm-Message-State: APjAAAW5lksKSkRAfAAf5TrXeLazNJdqu7aj2an7QTYNcOiVLLRQi4oN uyCQFxfjNO81RngN2NVnutu44dj35A2GcwN5qqKO6A== X-Received: by 2002:aca:be43:: with SMTP id o64mr3905357oif.149.1565927698048; Thu, 15 Aug 2019 20:54:58 -0700 (PDT) MIME-Version: 1.0 References: <20190814073854.GA27249@lst.de> <20190814132746.GE13756@mellanox.com> <20190815180325.GA4920@redhat.com> <20190815194339.GC9253@redhat.com> <20190815203306.GB25517@redhat.com> <20190815204128.GI22970@mellanox.com> <20190816004053.GB9929@mellanox.com> In-Reply-To: <20190816004053.GB9929@mellanox.com> From: Dan Williams Date: Thu, 15 Aug 2019 20:54:46 -0700 Message-ID: Subject: Re: [PATCH 04/15] mm: remove the pgmap field from struct hmm_vma_walk To: Jason Gunthorpe Cc: Jerome Glisse , Christoph Hellwig , Ben Skeggs , Felix Kuehling , Ralph Campbell , "linux-mm@kvack.org" , "nouveau@lists.freedesktop.org" , "dri-devel@lists.freedesktop.org" , "amd-gfx@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 15, 2019 at 5:41 PM Jason Gunthorpe wrote: > > On Thu, Aug 15, 2019 at 01:47:12PM -0700, Dan Williams wrote: > > On Thu, Aug 15, 2019 at 1:41 PM Jason Gunthorpe wrote: > > > > > > On Thu, Aug 15, 2019 at 04:33:06PM -0400, Jerome Glisse wrote: > > > > > > > So nor HMM nor driver should dereference the struct page (i do not > > > > think any iommu driver would either), > > > > > > Er, they do technically deref the struct page: > > > > > > nouveau_dmem_convert_pfn(struct nouveau_drm *drm, > > > struct hmm_range *range) > > > struct page *page; > > > page = hmm_pfn_to_page(range, range->pfns[i]); > > > if (!nouveau_dmem_page(drm, page)) { > > > > > > > > > nouveau_dmem_page(struct nouveau_drm *drm, struct page *page) > > > { > > > return is_device_private_page(page) && drm->dmem == page_to_dmem(page) > > > > > > > > > Which does touch 'page->pgmap' > > > > > > Is this OK without having a get_dev_pagemap() ? > > > > > > Noting that the collision-retry scheme doesn't protect anything here > > > as we can have a concurrent invalidation while doing the above deref. > > > > As long take_driver_page_table_lock() in Jerome's flow can replace > > percpu_ref_tryget_live() on the pagemap reference. It seems > > nouveau_dmem_convert_pfn() happens after: > > > > mutex_lock(&svmm->mutex); > > if (!nouveau_range_done(&range)) { > > > > ...so I would expect that to be functionally equivalent to validating > > the reference count. > > Yes, OK, that makes sense, I was mostly surprised by the statement the > driver doesn't touch the struct page.. > > I suppose "doesn't touch the struct page out of the driver lock" is > the case. > > However, this means we cannot do any processing of ZONE_DEVICE pages > outside the driver lock, so eg, doing any DMA map that might rely on > MEMORY_DEVICE_PCI_P2PDMA has to be done in the driver lock, which is > a bit unfortunate. Wouldn't P2PDMA use page pins? Not needing to hold a lock over ZONE_DEVICE page operations was one of the motivations for plumbing get_dev_pagemap() with a percpu-ref.