Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp244224ybl; Thu, 15 Aug 2019 16:32:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTDgO/w65yDqZHhBI+VglXnV1aGjhYj/ePdFnC/JqEmhdPQkYV/CdoaaafwYnUl64SyIBF X-Received: by 2002:a65:4304:: with SMTP id j4mr5485706pgq.419.1565911961922; Thu, 15 Aug 2019 16:32:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565911961; cv=none; d=google.com; s=arc-20160816; b=OI6femGYThCqoP1aIP7mFcEyypdrsQqaTrI3dVSHLODKQf8jm9D22dvg/viKZpQ39c 130Ha1xN2AfvQDKrGyh3wqvwLkHIso4VNxL86eXgv2yjcrR9VSqtEuEWew9Z1dkuS+FJ HocsIFWwr6Zw0gl6IUZBjzhQaLrhttvdwb8MyxInwXhOx09f7Mcmv7a1KVQYk4852g8i 2/Anp3TTozHWNxouT+e2dJhmNnV/QfuVwj/ugf+lm+n6GPe7OmG/lDf5dos25jZO0mb1 1ViaJ9msRg6SexvBgL5rTh3/aYeCJjLs3ftJmU4S1eph0ZuTEkzVnSK7dUzsosRlHG5/ /xrA== 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=iGCSUcgObYGVRCAzYsit2AWDPyDTFFk4jtMiYAkxFvg=; b=vlcZc+eq29ZxY3oINnFXdLdzLC7gGUOyDyKjecEumr+li3py8fLp0ZNfFHhojWlRgf JRG8GocM/a6BckTyoMBP8eybxvK1KmpbEO9UMTsZmG65e+X5BfLmEIMKXvC5Aibjmj3J 5AHXCnqUffUtNHGD+p8n4d9aVg+6NcNWpmoVZhOtUFpnOm+YOmXN7N3E4T+Ers/4lr9Y zQbe1ozpmkAc1vpF4J8M0TJpch2vyIb+AOHvPPm3mhUfFyNnLTCu6IgWd/tAVdF23z6b YmIAzkOHfn9vFZeCBtyJDl7SxmUqgYRcIUhuLMmuZGaNuEhGa378DbdaWPaUELvsbuqO zBSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=Xs91eNvC; 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 z20si2800320plo.159.2019.08.15.16.32.25; Thu, 15 Aug 2019 16:32:41 -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=Xs91eNvC; 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 S1732516AbfHOUrZ (ORCPT + 99 others); Thu, 15 Aug 2019 16:47:25 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:35732 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728728AbfHOUrZ (ORCPT ); Thu, 15 Aug 2019 16:47:25 -0400 Received: by mail-ot1-f66.google.com with SMTP id g17so6874194otl.2 for ; Thu, 15 Aug 2019 13:47:24 -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=iGCSUcgObYGVRCAzYsit2AWDPyDTFFk4jtMiYAkxFvg=; b=Xs91eNvCSOxAfiys1ppgNPaq0ALSevQ/T2i3xlUF6I+d0oNYGWm/kcLiWw3+Xl4qnf JmRKMGDSydou9/I7nXt437o0JX4dmiF7jPGXc+pjZbnEFC2zEZTdc2kHWzkAn3V1gSAl Hu9FCTmyAtKxs8tWdI2G6Y/dh0Bvh+WzLoLzAyJ2QnYpWxC6zKV9cpe1sVsIEPWKNT7E iVYV5R/+pyflylvOahsY4t5XbCQibs6REFPZ0SdxGqNvL9GniE7dpOmgRXMxzo5dWcEd ZEmrJY5OG1t7TpFlJrOJdClXDU4QGKNZ3i/T4vOTVaMLxf8C2MQbB2F1vE0fQMBNsoGm GEng== 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=iGCSUcgObYGVRCAzYsit2AWDPyDTFFk4jtMiYAkxFvg=; b=Bn9V7h6YWdxt0NhFpDPRJoHU2EP1zXJuYONhC3Q9/9ZE1nfEZJiXj3MtRvpS7G35po Y6Qvo+M7rrUcLTteHk1hlhkaNgywM375uMVo8YjdztS2XtubDXALNPfUWf46C1oXk2RM naKzLwUtLKEW4fSUsjskyY7fDzjcm0m2IukVen5cI1uh38LhdwoyuHHyzgreIliKR/eR Ovz0xccwPxhUfKQhuPYHC5cdVvWfYWYhqc2vPHQ6CzSS8I8hBTOm85RipNP2bnFd+Ldj vmIFxtWdRBRbwiOIGpX/Flaj17n4DQL2+LdN5QoDvZPuceiwXEKjz+A98OYTvPfeaX4l LGFg== X-Gm-Message-State: APjAAAX4BQMfP8LIgLWM2x3+hoxXmJZJts4+KgVjGXDHEzsc8i+xO4br ImnPCUpqy6N7HKhQmWfJJmubx7V+vxVCD0KvoPhwjg== X-Received: by 2002:a05:6830:458:: with SMTP id d24mr4706447otc.126.1565902044326; Thu, 15 Aug 2019 13:47:24 -0700 (PDT) MIME-Version: 1.0 References: <20190808065933.GA29382@lst.de> <20190814073854.GA27249@lst.de> <20190814132746.GE13756@mellanox.com> <20190815180325.GA4920@redhat.com> <20190815194339.GC9253@redhat.com> <20190815203306.GB25517@redhat.com> <20190815204128.GI22970@mellanox.com> In-Reply-To: <20190815204128.GI22970@mellanox.com> From: Dan Williams Date: Thu, 15 Aug 2019 13:47:12 -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 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.