Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1666464pxb; Fri, 6 Nov 2020 16:17:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJyzPnTP1/TyEQLCgF4oJwMDgdjs/PkZdYtqesLyoZB16IjmLLzfUaAH5eO4ksNriaW2ho2y X-Received: by 2002:a17:906:2697:: with SMTP id t23mr4786277ejc.292.1604708249790; Fri, 06 Nov 2020 16:17:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604708249; cv=none; d=google.com; s=arc-20160816; b=vlkabjreiAeCWBaX2ixKeZspJXEACIVofcJrqX/Vu+DFkdK9mBl/BgjWXllW25juxa HKY/j54RDo5mua9pdSU605J4lseFb4DspPjpOPMm/0jxOjHOPzzqu9EXy8Hno44M/XUZ FzWzUzQpuqZODYxjTScqYvJiNC11nHHYiFKNd9FM4WckhWibKOghRGdcYorUkzDdcisu yBizcH+BCGCp9+cXxyurV5/YR63hpJd99dvci66ndRl5KJQM1k+wRs2kC5gjC2Rflaho X8J8nBcHf0fJl5zdJ1dntAy86NDMwLxL+T4o785wkTncxEqvY+yOadQGOMkaei7orQ41 gKHg== 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=2xP+5n8avN9R0PMRHtfY/hU7jf10h4hT8Klf4TvQEgQ=; b=n3BD/CFOJUBxErysMjI9ldi6kEFejGgAHslTnIu8toHRLAe8aWsyIx3/uC8mw0KxhD 2fV2aXUyCL2lxG5M+iovDGzQmf5WBF7latZdbHPgwIIARtX+lbivqYz2yEIC5G0NW0BH w/nvTqr5vEh2qmqQwfUn+hySUoBQGkxeSAQpixkah/K8S2YSQjExy8ev2cXNUaYR9hbk 3KulaV7fKdVKjkpQg4BU5Voa2kHDtEQcUmr1kIEj3+WiaQf2oq6/jAfNwEYueUmqgMPT 5IAsJB0r4X4nbMkFBIfykXpI2XdRuGhjr4CsXD4KiaJy5V1pCAaskeeicpWCWMtrp4/F PQfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=aokkElWM; 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 d10si1995721ejh.20.2020.11.06.16.17.06; Fri, 06 Nov 2020 16:17:29 -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=aokkElWM; 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 S1727569AbgKGAO7 (ORCPT + 99 others); Fri, 6 Nov 2020 19:14:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726987AbgKGAO7 (ORCPT ); Fri, 6 Nov 2020 19:14:59 -0500 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38A8CC0613D3 for ; Fri, 6 Nov 2020 16:14:59 -0800 (PST) Received: by mail-qt1-x843.google.com with SMTP id m65so2078929qte.11 for ; Fri, 06 Nov 2020 16:14:59 -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=2xP+5n8avN9R0PMRHtfY/hU7jf10h4hT8Klf4TvQEgQ=; b=aokkElWMyWDPsBa6alzqFjXX6Ty/GtCdSx9WukymLV2/BbaYYEQkA6h6NtXkVdapG2 f4KRlQs9Y+5DAc9+pE/HHKpJIyuCn91sXpwCSZ+08lhM8dAiFiLN7V2xrbpk6hfNSKic ieoBgAnzjzjw2iZmefkEtA4fme7kItwUr5LmWc4Urv+NDQjlRSC80EXdjXFB3UnTz0qc xUHsKwFfqKXXKxkjKflCvn5HeQw2iywmUCXpbij/QRJ/D8iwlPNvI/Ibqockn0S2v+qQ EoTvzw1G3AJLPsWVsVolt0ALyaAOomLE+whBhiXSdjlB8hbwuoItdTWe41htAX37ZvKD VHSA== 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=2xP+5n8avN9R0PMRHtfY/hU7jf10h4hT8Klf4TvQEgQ=; b=lZQfm9lIS6Az607AWKcOucfBi7pBsLSeJae8hc7ooVJtic1F1gDcvv6M/y3ELeIn0L 8yxuAEiRtDvNZ9wybwHhY5QUpCdweYR7nzwkMWa7po2W105tZt1w/Av5etupjTzTYz0f pE2bFserKA7/ApYRfnx4/2HamUgrhmCIrfkWIOixBUx8OGu5eb+6ZRb/JgJ4XCjerWDs 83pASMPD2nTMaFqHwIY8ispdOoAT1kg4VS/riW79j/jXImWD75Bzcqbl1JJCWUzjuUxD EDD/mSNbOuQuxRKt/fiGBr9xkc8AydSo001pa5YLvG4c2oDbI08PO/FdYtyb6QoBtrd/ cP/w== X-Gm-Message-State: AOAM531/YLlzPj2OV8e8a4zs9ws21fRFNMG501H9SrvdByoFfkpWBBcJ iL0rL78+jQqzqULY2rL/2x/abg== X-Received: by 2002:aed:2c02:: with SMTP id f2mr4176029qtd.48.1604708098335; Fri, 06 Nov 2020 16:14:58 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-156-34-48-30.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.48.30]) by smtp.gmail.com with ESMTPSA id u5sm1592838qtg.57.2020.11.06.16.14.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2020 16:14:57 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kbBsf-0015Rr-2V; Fri, 06 Nov 2020 20:14:57 -0400 Date: Fri, 6 Nov 2020 20:14:57 -0400 From: Jason Gunthorpe To: Logan Gunthorpe Cc: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, linux-pci@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Stephen Bates , Christoph Hellwig , Dan Williams , Christian =?utf-8?B?S8O2bmln?= , Ira Weiny , John Hubbard , Don Dutile , Matthew Wilcox , Daniel Vetter Subject: Re: [RFC PATCH 14/15] PCI/P2PDMA: Introduce pci_mmap_p2pmem() Message-ID: <20201107001457.GB244516@ziepe.ca> References: <20201106172206.GS36674@ziepe.ca> <20201106174223.GU36674@ziepe.ca> <2c2d2815-165e-2ef9-60d6-3ace7ff3aaa5@deltatee.com> <20201106180922.GV36674@ziepe.ca> <09885400-36f8-bc1d-27f0-a8adcf6104d4@deltatee.com> <20201106193024.GW36674@ziepe.ca> <03032637-0826-da76-aec2-121902b1c166@deltatee.com> <20201106195341.GA244516@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 06, 2020 at 01:03:26PM -0700, Logan Gunthorpe wrote: > I don't think a function like that will work for the p2pmem use case. In > order to implement proper page freeing I expect I'll need a loop around > the allocator and vm_insert_mixed()... Something roughly like: > > for (addr = vma->vm_start; addr < vma->vm_end; addr += PAGE_SIZE) { > vaddr = pci_alloc_p2pmem(pdev, PAGE_SIZE); > ret = vmf_insert_mixed(vma, addr, > __pfn_to_pfn_t(virt_to_pfn(vaddr), PFN_DEV | PFN_MAP)); > } > > That way we can call pci_free_p2pmem() when a page's ref count goes to > zero. I suspect your use case will need to do something similar. Yes, but I would say the pci_alloc_p2pmem() layer should be able to free pages on a page-by-page basis so you don't have to do stuff like the above. There is often a lot of value in having physical contiguous addresses, so allocating page by page as well seems poor. Jason