Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp796593img; Mon, 18 Mar 2019 14:33:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwf2RGn50XpAm6wE9myYSWdLXr1mRBPY+sR9RZWeuLPRIrJVvXr5ReTBZLvKx2eV2a0aDTN X-Received: by 2002:a65:4341:: with SMTP id k1mr17879002pgq.175.1552944794007; Mon, 18 Mar 2019 14:33:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552944793; cv=none; d=google.com; s=arc-20160816; b=M9AVyctseQ17Rlrt4PkBRns2Res6qDuu0kD2I0Qfrt0ZdYX2I6L2K2IacY809St6Xn ttu6T0+PNNQMYfe5tSbxGfJZrZewg5hhTSybxFp8wAFYlUCPew7QIzXLjtKNTOa91yrD taAFSufEmQf8MqNZ6k6/3YS5D+p+tNQlOiUVVHIpOI4eJgmZ8qdk/03TPzlqHPOvn9oQ JdfTxSjXF0tb/VgrVghjy+qhf9GnvhN+Y2IkpVNoY4LHmB53pKnVhGC/pnI5JHF0d+rN lsdDuc45A+WWme6az8C2Wky9Q1a50gOB0bMhIHYPxhHSHCFrwM4GzMJxiHoy1Fz7Gub+ 5hXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Y8YsUQ1pdHWqexK7sIz4qXDZCsJt+yDdueh4JXEzClU=; b=Kkg02KdyhtXL9UJBpQINkCUc1OhBPEmYQ85v8xr0F6RdCO/xWO8N1wviS3dbAETdJW WDHZJltVFfi5bXp3WOE5j3pjfx4hrSJrgBrFZgv29XAWlYRZh1aPAWwnrKzWzjeAi2U2 A1tTZ+zI1pv4fBmVXu/yhtyotJPdMQA4lAzZF2rTtz9rL0MU6Ie12LU2MvpwyHNoGqwX +q6OTilXo/zNZl0vbTJOTyzcFedCS6S1FJSdHmsSrg8j8mgj9Yi9TTrS/nVmkTWcmwab neHwTsadJEGol9TBu/CAjVEjSycPHefD4ddi5shrWwQlZUwaJnIIeLnCGceQHTnjEwV3 CD8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b="KCUGuNY/"; 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 k25si5948221pfo.254.2019.03.18.14.32.58; Mon, 18 Mar 2019 14:33:13 -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="KCUGuNY/"; 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 S1727202AbfCRVab (ORCPT + 99 others); Mon, 18 Mar 2019 17:30:31 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:40275 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726832AbfCRVaa (ORCPT ); Mon, 18 Mar 2019 17:30:30 -0400 Received: by mail-ot1-f66.google.com with SMTP id x8so15802528otg.7 for ; Mon, 18 Mar 2019 14:30:29 -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:content-transfer-encoding; bh=Y8YsUQ1pdHWqexK7sIz4qXDZCsJt+yDdueh4JXEzClU=; b=KCUGuNY/mUzIWa+2Uv9mcBG4QykEPnd1Ea57GYtl5VlUucexWFnnu4flLt6LSUwd60 6fQV+8rsTSWWt1sIWhQhnPdNWb4O7N2dy4+wXIRjpBMJaZBkYm5nCqsTn1Y5iyk3U5gm VrUN+mtjYc8zJ9H2L2zqW9n69wy6yCuFQvxBXG99eHShKdq0TFc3tYcO5F8Tk4FKout2 pzZ5pZm+Wu6pd4AWmFsp5ixT14IC46H4VI+zo5zDZeR2ZkH4jSx8p4dGwK08q9DzlG8M ibCuyVusvAvOntZCrjp4LjdhCiaAxtsz3ccecU6A+WRlIR9yKXMdrZQEM7bAddHHegeL TJiw== 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:content-transfer-encoding; bh=Y8YsUQ1pdHWqexK7sIz4qXDZCsJt+yDdueh4JXEzClU=; b=tABuIEoCEuuUReh60hghGQqw3ruzw3ZrCSXmxxvsncLuX1bLdGgFpbkgU+RZEjQmEz PY2soVz74/LH042yog509aQXn7wyN+jV1HeqcmECDOb9g+OtqsEWaUQnSJ7/wmcRYb24 xAKNTu3paK6p5T9LWvygxE4zWKBH7Ckwnu6JhMkhsHxZBou6Y/R7pRuEA5y6JIaPBXik HMtjTacjsnxDuPKNuqsEkLDKgaB09tiUfB0fvbstVFmA88JG5zQaz6zAYUgcy4ar3My6 S3N3HqKl8ViQUAAjRM9fUbcz1GG15rfM9JccG3bdQ3TuRylnsjcB/ogPimUvWunkDtJk p0FA== X-Gm-Message-State: APjAAAWppE+E1YoeCRMdvwEjwis4/HzGUiwzLmmRMgXn/9PX6+0NUOvR ldwbsi/sM6B0FAhao8JRdExVZZJ3BgOUXiviGAwmHg== X-Received: by 2002:a9d:2c23:: with SMTP id f32mr8388695otb.353.1552944626498; Mon, 18 Mar 2019 14:30:26 -0700 (PDT) MIME-Version: 1.0 References: <20190129165428.3931-1-jglisse@redhat.com> <20190129165428.3931-8-jglisse@redhat.com> <20190318204134.GD6786@redhat.com> In-Reply-To: <20190318204134.GD6786@redhat.com> From: Dan Williams Date: Mon, 18 Mar 2019 14:30:15 -0700 Message-ID: Subject: Re: [PATCH 07/10] mm/hmm: add an helper function that fault pages and map them to a device To: Jerome Glisse Cc: linux-mm , Linux Kernel Mailing List , Andrew Morton , Ralph Campbell , John Hubbard Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 18, 2019 at 1:41 PM Jerome Glisse wrote: > > On Mon, Mar 18, 2019 at 01:21:00PM -0700, Dan Williams wrote: > > On Tue, Jan 29, 2019 at 8:55 AM wrote: > > > > > > From: J=C3=A9r=C3=B4me Glisse > > > > > > This is a all in one helper that fault pages in a range and map them = to > > > a device so that every single device driver do not have to re-impleme= nt > > > this common pattern. > > > > Ok, correct me if I am wrong but these seem effectively be the typical > > "get_user_pages() + dma_map_page()" pattern that non-HMM drivers would > > follow. Could we just teach get_user_pages() to take an HMM shortcut > > based on the range? > > > > I'm interested in being able to share code across drivers and not have > > to worry about the HMM special case at the api level. > > > > And to be clear this isn't an anti-HMM critique this is a "yes, let's > > do this, but how about a more fundamental change". > > It is a yes and no, HMM have the synchronization with mmu notifier > which is not common to all device driver ie you have device driver > that do not synchronize with mmu notifier and use GUP. For instance > see the range->valid test in below code this is HMM specific and it > would not apply to GUP user. > > Nonetheless i want to remove more HMM code and grow GUP to do some > of this too so that HMM and non HMM driver can share the common part > (under GUP). But right now updating GUP is a too big endeavor. I'm open to that argument, but that statement then seems to indicate that these apis are indeed temporary. If the end game is common api between HMM and non-HMM drivers then I think these should at least come with /* TODO: */ comments about what might change in the future, and then should be EXPORT_SYMBOL_GPL since they're already planning to be deprecated. They are a point in time export for a work-in-progress interface. > I need > to make progress on more driver with HMM before thinking of messing > with GUP code. Making that code HMM only for now will make the GUP > factorization easier and smaller down the road (should only need to > update HMM helper and not each individual driver which use HMM). > > FYI here is my todo list: > - this patchset > - HMM ODP > - mmu notifier changes for optimization and device range binding > - device range binding (amdgpu/nouveau/...) > - factor out some nouveau deep inner-layer code to outer-layer for > more code sharing > - page->mapping endeavor for generic page protection for instance > KSM with file back page > - grow GUP to remove HMM code and consolidate with GUP code Sounds workable as a plan.