Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1241854ybz; Fri, 1 May 2020 17:57:58 -0700 (PDT) X-Google-Smtp-Source: APiQypLM+ek6IVs2x13ZP5R/BzvDkbCU4sD9mtiE7B/ByXQILXMg07fu641K/LcKqyhrGG56pAAc X-Received: by 2002:aa7:d311:: with SMTP id p17mr5750797edq.73.1588381078652; Fri, 01 May 2020 17:57:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588381078; cv=none; d=google.com; s=arc-20160816; b=znJH0OHxK0opCoCtoVuNsM6ETwGePYUlrzUML03S18G3LyGzwdffSWhKM7fUDjL7dE oSxTJjWWvbhXE1dKI8ihk9BUu84LUi8PY6PlgoXo1PM44I/LAG3vr2y8Wa9Ph61g57/A MMlXRdVdPa3fA5pk79eIJTzbHrmRXl8kguBFTPoA41pmZdcN7R4Il73h5Cm/rBNW5XS3 PrJCfHlIM0q2i6zycy5HyqI+PVRdPD3wYiMyy4t1UyN9abvi986zXkvVXdqd3AvTk55I d9djJYpj06pTAI83SR1v6njfxkxn9UkDYGuVlYDj1+OfuBOCNNM3smqwMxnw3H0OFIDe aokA== 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=EV3nm763BNlVbz3132Rm5ScZ/T6SWXq2x/ZiKuEfuP8=; b=B6fxtdPtGVQKlkXhTwLWSmtdaVcKtESGgGdib+q1Ob7YdN7lyJIih6pcHuXR64bGMN E9ZtGukEqVMVNvQHkFzkpKdl3Ty8Tw7QjCSc6oelcYdP30TpfSuARNEtU09M6AbfKL9i qsUzs4Hu3sP/ZU+4fg7XRJWafE1KCvGzw3TF0kk3cXEtmJNlVoG2XL3OMnthJ1se9f2S YhrShJdsV55a/O+cW/ZOjyQbwHzZRwio0gnAyq+whrIftWaASaEnyx2q137XPsp4ASG9 aO2n15k5JVWI19z9ayO5kFnH7/Yey/E1f5n2eSqvLeSOQ35lNh0KRuwgV5/u0rdVWVkZ 3ltg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=nh1pY9Fz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id o20si2684258edr.279.2020.05.01.17.57.24; Fri, 01 May 2020 17:57:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=nh1pY9Fz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726565AbgEBAx1 (ORCPT + 99 others); Fri, 1 May 2020 20:53:27 -0400 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:18427 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726437AbgEBAx1 (ORCPT ); Fri, 1 May 2020 20:53:27 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Fri, 01 May 2020 17:52:19 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Fri, 01 May 2020 17:53:27 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Fri, 01 May 2020 17:53:27 -0700 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Sat, 2 May 2020 00:53:27 +0000 Received: from rcampbell-dev.nvidia.com (10.124.1.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Sat, 2 May 2020 00:53:26 +0000 Subject: Re: [PATCH hmm v2 5/5] mm/hmm: remove the customizable pfn format from hmm_range_fault To: Jason Gunthorpe , CC: Alex Deucher , , Ben Skeggs , =?UTF-8?Q?Christian_K=c3=b6nig?= , "David (ChunMing) Zhou" , , Felix Kuehling , Christoph Hellwig , , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , John Hubbard , , "Niranjana Vishwanathapura" , , "Yang, Philip" References: <5-v2-b4e84f444c7d+24f57-hmm_no_flags_jgg@mellanox.com> From: Ralph Campbell X-Nvconfidentiality: public Message-ID: <3c06a94c-c17f-dc31-537e-f3f6e1ace9a2@nvidia.com> Date: Fri, 1 May 2020 17:53:26 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <5-v2-b4e84f444c7d+24f57-hmm_no_flags_jgg@mellanox.com> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To DRHQMAIL107.nvidia.com (10.27.9.16) 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=1588380739; bh=EV3nm763BNlVbz3132Rm5ScZ/T6SWXq2x/ZiKuEfuP8=; h=X-PGP-Universal:Subject:To:CC:References:From:X-Nvconfidentiality: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=nh1pY9Fz7u8s1vJpgRxLXu08giXCQDP363xmg6l0tAXktkX3k7JoYV9gKXZk8ciil SsUuIaFfjBxg5B2mGb0w6MYWHWVDSBFSOtvOJA4iKUWDR+lt/J5OTKRwsPFmkGiB2p KWQ21HmxXBvfqDQSqQP6ezOvrHGsyqrA94xl/oK9cAXsp7wfeJ4axVyFAWoGkFtyRZ 74F/UacwzaZaSglpWi4zAE3eIiU+E+80I57OOsg05kYPRSD7GKDMp+tkSbIK6Dy1QA ibQfUJa5jPZvKQfDqst9zXF+/N3IiDcejcNSN7m9HKNOHjmzXFxQdHg1RNqoA6EH6G vipRDrDiXDJSg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/1/20 11:20 AM, Jason Gunthorpe wrote: > From: Jason Gunthorpe > > Presumably the intent here was that hmm_range_fault() could put the data > into some HW specific format and thus avoid some work. However, nothing > actually does that, and it isn't clear how anything actually could do that > as hmm_range_fault() provides CPU addresses which must be DMA mapped. > > Perhaps there is some special HW that does not need DMA mapping, but we > don't have any examples of this, and the theoretical performance win of > avoiding an extra scan over the pfns array doesn't seem worth the > complexity. Plus pfns needs to be scanned anyhow to sort out any > DEVICE_PRIVATE pages. > > This version replaces the uint64_t with an usigned long containing a pfn > and fixed flags. On input flags is filled with the HMM_PFN_REQ_* values, > on successful output it is filled with HMM_PFN_* values, describing the > state of the pages. > > amdgpu is simple to convert, it doesn't use snapshot and doesn't use > per-page flags. > > nouveau uses only 16 hmm_pte entries at most (ie fits in a few cache > lines), and it sweeps over its pfns array a couple of times anyhow. It > also has a nasty call chain before it reaches the dma map and hardware > suggesting performance isn't important: > > nouveau_svm_fault(): > args.i.m.method = NVIF_VMM_V0_PFNMAP > nouveau_range_fault() > nvif_object_ioctl() > client->driver->ioctl() > struct nvif_driver nvif_driver_nvkm: > .ioctl = nvkm_client_ioctl > nvkm_ioctl() > nvkm_ioctl_path() > nvkm_ioctl_v0[type].func(..) > nvkm_ioctl_mthd() > nvkm_object_mthd() > struct nvkm_object_func nvkm_uvmm: > .mthd = nvkm_uvmm_mthd > nvkm_uvmm_mthd() > nvkm_uvmm_mthd_pfnmap() > nvkm_vmm_pfn_map() > nvkm_vmm_ptes_get_map() > func == gp100_vmm_pgt_pfn > struct nvkm_vmm_desc_func gp100_vmm_desc_spt: > .pfn = gp100_vmm_pgt_pfn > nvkm_vmm_iter() > REF_PTES == func == gp100_vmm_pgt_pfn() > dma_map_page() > > Acked-by: Felix Kuehling > Tested-by: Ralph Campbell > Signed-off-by: Jason Gunthorpe > Signed-off-by: Christoph Hellwig > --- > Documentation/vm/hmm.rst | 26 ++-- > drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 35 ++---- > drivers/gpu/drm/nouveau/nouveau_dmem.c | 27 +--- > drivers/gpu/drm/nouveau/nouveau_dmem.h | 3 +- > drivers/gpu/drm/nouveau/nouveau_svm.c | 87 ++++++++----- > include/linux/hmm.h | 99 ++++++--------- > mm/hmm.c | 160 +++++++++++------------- > 7 files changed, 192 insertions(+), 245 deletions(-) > ...snip... > > +static void nouveau_hmm_convert_pfn(struct nouveau_drm *drm, > + struct hmm_range *range, u64 *ioctl_addr) > +{ > + unsigned long i, npages; > + > + /* > + * The ioctl_addr prepared here is passed through nvif_object_ioctl() > + * to an eventual DMA map in something like gp100_vmm_pgt_pfn() > + * > + * This is all just encoding the internal hmm reprensetation into a s/reprensetation/representation/ Looks good and still tests OK with nouveau.