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=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 82503C55178 for ; Sat, 7 Nov 2020 00:15:04 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D5F5020867 for ; Sat, 7 Nov 2020 00:15:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="aokkElWM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D5F5020867 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 6F45F8757E; Sat, 7 Nov 2020 00:15:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qBU0P6zcmp-e; Sat, 7 Nov 2020 00:15:02 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id AFCF787571; Sat, 7 Nov 2020 00:15:02 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 92C62C0893; Sat, 7 Nov 2020 00:15:02 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 97BB3C0889 for ; Sat, 7 Nov 2020 00:15:00 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 72FEA20448 for ; Sat, 7 Nov 2020 00:15:00 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zawi5gBl97Ce for ; Sat, 7 Nov 2020 00:14:59 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) by silver.osuosl.org (Postfix) with ESMTPS id 56F3F20446 for ; Sat, 7 Nov 2020 00:14:59 +0000 (UTC) Received: by mail-qt1-f193.google.com with SMTP id h12so2098413qtu.1 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=dN3JpLpdBOOuxeGXpXWZXJ03n+myCHJ3KzwJKv4EJyUSf+CD3tkoNRCimcKTe5+z25 h4nniTL+W2iMmddD5ggWVDreit4UMMuhXvLlV/Mq/OXRqejwqpa7hhz+bpWbRk9wL4Qk ULTXLe7XD1LHHGHzkv15+VE4IQ2/C67rqU1APWyDEuZXnYIcmlXje4B49yVNTQVtxu1a R6xRwxTl6ZT5jJuuzPjSsjabXMra8zMyQjZTZ8fBRkWd82J+aHWECe5Aa5SuT3sjQr7H PHLUOYv3U38Y7EcyMyVry1KTruJ7aZimeDfrABjtxORIJGXkcR2RAUJS+OH+9IlnltPF urMQ== X-Gm-Message-State: AOAM532zSfua0NpOUq0rLrS3d/kXvFznmwc7qRcPKiaU6Kc6jgXxmmnT VnfSHefWiW0C41ugiNB2+ZsTtQ== X-Google-Smtp-Source: ABdhPJxMxLKgSiQ4x1Of97Fg4BcrbjDaTMOumnt9gw+omdxttGmxoTEsM80CNgLqS0LcZZvrtkPZNw== 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 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-Disposition: inline In-Reply-To: Cc: Christian =?utf-8?B?S8O2bmln?= , linux-pci@vger.kernel.org, Daniel Vetter , Ira Weiny , linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, Stephen Bates , linux-block@vger.kernel.org, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Matthew Wilcox , John Hubbard , Dan Williams , Christoph Hellwig X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" 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 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu