From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.4 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A687C0044D for ; Mon, 16 Mar 2020 19:04:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2B14720658 for ; Mon, 16 Mar 2020 19:04:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="b4PO6Gx4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B14720658 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C4E826B0003; Mon, 16 Mar 2020 15:04:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BFF3E6B0005; Mon, 16 Mar 2020 15:04:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEF006B0007; Mon, 16 Mar 2020 15:04:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0068.hostedemail.com [216.40.44.68]) by kanga.kvack.org (Postfix) with ESMTP id 950726B0003 for ; Mon, 16 Mar 2020 15:04:45 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 36FAE180AD806 for ; Mon, 16 Mar 2020 19:04:45 +0000 (UTC) X-FDA: 76602152130.18.crook84_468e24eb54649 X-HE-Tag: crook84_468e24eb54649 X-Filterd-Recvd-Size: 5343 Received: from mail-qv1-f66.google.com (mail-qv1-f66.google.com [209.85.219.66]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Mon, 16 Mar 2020 19:04:44 +0000 (UTC) Received: by mail-qv1-f66.google.com with SMTP id m2so9457418qvu.13 for ; Mon, 16 Mar 2020 12:04:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=BWUlD7DMxUCjadcoWlHWZLSyInqh6sPVvbrJFhGcEXw=; b=b4PO6Gx41wgIvNR75/iEEHqP7YeAWOo5I4vM1hYEixFuze+GD6DaYqoq6TC5z6ZmrJ Ay/5Z5n3+GxgulTlewop2xKyUtwkOsk/3xSb3Dci9QGrROQg0xNI4SUrd6gZB6+izdNe N1pEZM8nEhG8cFaafaI7oaJVEsr/RZaSPAOGp/dvEqzcI/FlL1EmhGf5oLnxpn5fsFMX 0vDAhrju1L63wESfxt4lt2sv7hw8jBZVFlY4uyOJvCMiAZXPlnY61hAjM+L2/9omI9RE eSIpwURT9g78RsWcH396M8bdPtPAtYe5mLGXoaunFXluYfTsfHTzArNAe1Kq2Vj3zALv DJlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=BWUlD7DMxUCjadcoWlHWZLSyInqh6sPVvbrJFhGcEXw=; b=ip8cK4c+oLfNv6iosw+kF+MvYVZ+skGwlw/Fj/0M3jREuP/gMxxMQjJvXwGX1E3nKR rWNqR4iZaBPnsoTxxRp8qW+MAsKio97wTv6QuQDhUTBTTI6QEpCs6mefiu4+X2tcSjek RF9tpUhv8ani6dxvkMK4UA1tCmP1FL9VG6aMOsrjIfrbTHMDnfL3Pln946ZrUr5J1w+o TVQYXnmXlanTrdv79HahlOzO6ovxCRXW2ucJ7DhfBm77m/R4o7s82K8RRMtjopPktebU FAz03s/Hn4hmJBiK3inSXgauqIRfdAMFrv9oTfQRtO0hpQ3pZLQKHGlTjCNjp6WwAsod zJxQ== X-Gm-Message-State: ANhLgQ3WqzsA9LNp+9l0N08Aei/urrZ3WKFNgcu0CjKE8QnuH1Of+GLg +Au/bEGPPD4XZYKA0HsD7lg+Xg== X-Google-Smtp-Source: ADFU+vupCuGjSfz+zG9xNUf8/b9EmEfqnAO4l1aoYhG7XjmfvRH/QvbrSw7U+oPGZcF3Uap4STtBfQ== X-Received: by 2002:ad4:4847:: with SMTP id t7mr1236975qvy.237.1584385484358; Mon, 16 Mar 2020 12:04:44 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-57-212.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.57.212]) by smtp.gmail.com with ESMTPSA id x19sm407776qtm.47.2020.03.16.12.04.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Mar 2020 12:04:43 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1jDv2Z-0006k6-7W; Mon, 16 Mar 2020 16:04:43 -0300 Date: Mon, 16 Mar 2020 16:04:43 -0300 From: Jason Gunthorpe To: Ralph Campbell Cc: Christoph Hellwig , Dan Williams , Bharata B Rao , Christian =?utf-8?B?S8O2bmln?= , Ben Skeggs , Jerome Glisse , kvm-ppc@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-mm@kvack.org Subject: Re: [PATCH 2/2] mm: remove device private page support from hmm_range_fault Message-ID: <20200316190443.GM20941@ziepe.ca> References: <20200316175259.908713-1-hch@lst.de> <20200316175259.908713-3-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Mar 16, 2020 at 11:42:19AM -0700, Ralph Campbell wrote: > > On 3/16/20 10:52 AM, Christoph Hellwig wrote: > > No driver has actually used properly wire up and support this feature. > > There is various code related to it in nouveau, but as far as I can tell > > it never actually got turned on, and the only changes since the initial > > commit are global cleanups. > > This is not actually true. OpenCL 2.x does support SVM with nouveau and > device private memory via clEnqueueSVMMigrateMem(). > Also, Ben Skeggs has accepted a set of patches to map GPU memory after being > migrated and this change would conflict with that. Other than the page_to_dmem() possibly doing container_of on the wrong type pgmap, are there other bugs here to fix? Something like this is probably close to the right thing to fix that and work with Christoph's 1/2 patch - Ralph can you check, test, etc? diff --git a/mm/hmm.c b/mm/hmm.c index 9e8f68eb83287a..9fa4748da1b779 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -300,6 +300,20 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, unsigned long addr, range->flags[HMM_PFN_DEVICE_PRIVATE]; cpu_flags |= is_write_device_private_entry(entry) ? range->flags[HMM_PFN_WRITE] : 0; + + /* + * If the caller understands this kind of device_private + * page, then leave it as is, otherwise fault it. + */ + hmm_vma_walk->pgmap = get_dev_pagemap( + device_private_entry_to_pfn(entry), + hmm_vma_walk->pgmap); + if (!unlikely(!pgmap)) + return -EBUSY; + if (hmm_vma_walk->pgmap->owner != + hmm_vma_walk->dev_private_owner) + cpu_flags = 0; + hmm_pte_need_fault(hmm_vma_walk, orig_pfn, cpu_flags, &fault, &write_fault); if (fault || write_fault) Jason