Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp489008pxb; Tue, 9 Feb 2021 05:39:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxCOLshJMnxgtxi2+/GAQ9fgA87EyYYep9kTi1fbKxq1u0Sm/4oHq+oz1fjiPp1axUNEL1I X-Received: by 2002:a17:906:15c7:: with SMTP id l7mr22464074ejd.226.1612877956280; Tue, 09 Feb 2021 05:39:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612877956; cv=none; d=google.com; s=arc-20160816; b=oOSpZ7Bh85Z5WIQUu2lTqOt3qLcby1qJnWzONtX5ROeJmUA2Q2ONgUcyqJyffm7sto 6FE4+KmadbtvduhpZHa0ulGQ2bWFRIpwmn/0OXMYjObiThwdIfQbFtEoUJvLYEbH71xC 2uMQx5mjTHYwky0OQvAVFbbQJ4oHemnaqzdWnNuSvENW6tSXe7hWQMbCzrPv5/tgRLVA 65R6/Ch4VR2sqEfB6F6i+zGUe5pkDHPD7Tv14okgUHv2ML0lOKqVrcljiGJrwU2p19EP iAgwOw6OGaJ1K86f8qrrsKlECn2XI+BGx9D2a2YUU8FQYqEdCy4888SisLzdZ2KkAvLb 8Weg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=25WUiLOJuw+GE+OUcQPIenFzwQPp8UMH3H3KE2iMm0w=; b=xep0Dt2fMOzr8mJ3oeMMdY9dMGKVWbtriKpn4CTHNxqTxIF6mOjtBy0BVZ49EUcccG 3NOax3QNUZRsZXo+wKEkFiqbERSQ8YBrQj5x3/8qxZox9XuvgeLC55tltVYxJMDVOPsy m/7JGMrVPYIRS9yqNGIFXhNAD0dtF/fxlUnSK7VvvWhjxP/Jv+w0qVnOJpxJbXb9VJ30 Lpfto8YmU1aG5EUGwh57XowTUUz0vHgTNSylvjUPQcoygx7QRHUpux5aCuoTzGOQhjqt VeOZ3rlIquneMCt2uCJReEaAgqyK0p3GmPf7UBMCskuMD0vFGTgOsJjX/GO25mRC9z6V CG8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=mzalXTaS; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p12si12952231ejx.70.2021.02.09.05.38.52; Tue, 09 Feb 2021 05:39:16 -0800 (PST) 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=@ziepe.ca header.s=google header.b=mzalXTaS; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230299AbhBINgd (ORCPT + 99 others); Tue, 9 Feb 2021 08:36:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230295AbhBINgG (ORCPT ); Tue, 9 Feb 2021 08:36:06 -0500 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F355C06178A for ; Tue, 9 Feb 2021 05:35:25 -0800 (PST) Received: by mail-qk1-x72b.google.com with SMTP id h8so7632133qkk.6 for ; Tue, 09 Feb 2021 05:35:25 -0800 (PST) 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; bh=25WUiLOJuw+GE+OUcQPIenFzwQPp8UMH3H3KE2iMm0w=; b=mzalXTaSQvqsMyTlcg2ocFEUjvAp99/a77nvoAG+uBoekFj7jweXCNHWlDPY2podsm yk9Mj1F2cz110lWiEY7yQblSp7LnblfxSgv5BUgT9Flc4ccAx72uC8Y2THXcbcbD6kGD MyoZYCBgQenxcNlyO8fljyQ6Jq2M8pigmK0+JOjqZBy3biXjyoLm+p+yERZ9wYNk+Bnn o52J19oTF3wLoOgSdYnYV1qzXs2BuOw4ltcx4+q08fA7o9lTx2BseR4h0neV0CMUVA5F HAUa4RtablrEiHfxqQTuyRNKLDapPyjHXbP+MKYcA1EGo2CxvAnP3VaRLHFNrbDuXCkv efLw== 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; bh=25WUiLOJuw+GE+OUcQPIenFzwQPp8UMH3H3KE2iMm0w=; b=lMQmEmpy2KqUn30bunq7NpkLtQbeWX1DsoVY8dpDgCOv+DXAFKYKOgCn4+6DdscxZA zNW7PiA3TNunLbikcnDC+VN+giXS2WYNHDyZKjF0TDZpw9pDh3NYe1ZP7c2/0/SROIL3 iwDmXnLI5/2nKvlieBUJIVuV18zgi1SvkkPflhGW2GNK4rI8OffzIBXEFv8uMpXlXPri sqc631Gbugn/zjV0Scn+zR24KJou7J35NQry73f7wRN1QKQ7V0epF3cfv3hg7Rxlyt9Z dXrPqHBSk0d9io+XCfryVp7m22tB4lRGpVcwJhFrvnc1pfqg2yYQBoxxjyGseWF8d66r zDMw== X-Gm-Message-State: AOAM530S3rxGENxcW6bTD3RaTWF17l38oLQ4Veqb/nxc94xGotqWDLCO /L7e0xoXjNQau+iLspGByb4OCS0tgmY2qkBf X-Received: by 2002:a05:620a:6d7:: with SMTP id 23mr8251839qky.460.1612877721350; Tue, 09 Feb 2021 05:35:21 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-115-133.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.115.133]) by smtp.gmail.com with ESMTPSA id e66sm6901615qkd.82.2021.02.09.05.35.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Feb 2021 05:35:20 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1l9TAm-005RH4-8s; Tue, 09 Feb 2021 09:35:20 -0400 Date: Tue, 9 Feb 2021 09:35:20 -0400 From: Jason Gunthorpe To: Alistair Popple Cc: Daniel Vetter , Linux MM , Nouveau Dev , Ben Skeggs , Andrew Morton , Linux Doc Mailing List , Linux Kernel Mailing List , kvm-ppc@vger.kernel.org, dri-devel , John Hubbard , Ralph Campbell , Jerome Glisse Subject: Re: [PATCH 0/9] Add support for SVM atomics in Nouveau Message-ID: <20210209133520.GB4718@ziepe.ca> References: <20210209010722.13839-1-apopple@nvidia.com> <3426910.QXTomnrpqD@nvdebian> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3426910.QXTomnrpqD@nvdebian> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 09, 2021 at 11:57:28PM +1100, Alistair Popple wrote: > On Tuesday, 9 February 2021 9:27:05 PM AEDT Daniel Vetter wrote: > > > > > > Recent changes to pin_user_pages() prevent the creation of pinned pages in > > > ZONE_MOVABLE. This series allows pinned pages to be created in > ZONE_MOVABLE > > > as attempts to migrate may fail which would be fatal to userspace. > > > > > > In this case migration of the pinned page is unnecessary as the page can > be > > > unpinned at anytime by having the driver revoke atomic permission as it > > > does for the migrate_to_ram() callback. However a method of calling this > > > when memory needs to be moved has yet to be resolved so any discussion is > > > welcome. > > > > Why do we need to pin for gpu atomics? You still have the callback for > > cpu faults, so you > > can move the page as needed, and hence a long-term pin sounds like the > > wrong approach. > > Technically a real long term unmoveable pin isn't required, because as you say > the page can be moved as needed at any time. However I needed some way of > stopping the CPU page from being freed once the userspace mappings for it had > been removed. The issue is you took the page out of the PTE it belongs to, which makes it orphaned and unlocatable by the rest of the mm? Ideally this would leave the PTE in place so everything continues to work, just disable CPU access to it. Maybe some kind of special swap entry? I also don't much like the use of ZONE_DEVICE here, that should only be used for actual device memory, not as a temporary proxy for CPU pages.. Having two struct pages refer to the same physical memory is pretty ugly. > The normal solution of registering an MMU notifier to unpin the page when it > needs to be moved also doesn't work as the CPU page tables now point to the > device-private page and hence the migration code won't call any invalidate > notifiers for the CPU page. The fact the page is lost from the MM seems to be the main issue here. > Yes, I would like to avoid the long term pin constraints as well if possible I > just haven't found a solution yet. Are you suggesting it might be possible to > add a callback in the page migration logic to specially deal with moving these > pages? How would migration even find the page? Jason