Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1730541pxb; Fri, 6 Nov 2020 18:52:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwbgsncDGe4chym2ws5VCSxzjbOWKPLFe2MaPqHTyrs6hNJ4z077w1I3y4tbMv5oQbHzla9 X-Received: by 2002:a17:906:5a97:: with SMTP id l23mr4992753ejq.232.1604717558552; Fri, 06 Nov 2020 18:52:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604717558; cv=none; d=google.com; s=arc-20160816; b=BB5nKAA9L7Alu82aHJhPcrRcH5urciVNBPfb8wdRzPqzrb5WFGoKJqXArKEP93K9mo QbEVNQuIZMRe6rXlElCXCnM7gLOgozDu0KB/Bl/mRW02JsB8PWMgLOBaZDiFOifHO84U 7IJzYIc527/v/QwNo78/mgvZr0nLUttut63lxaX9HsQyZhBjYWOH0NYCzFEiQhKEciM5 utY8tSVwphBFOATSKla90LUNbAW19FBynZwhGgmnCZ5Mlpq+TIBtVKi2GTs3pp2uaDS8 +uUFR2C9ul3gxBQKx+lyIpBmIaAZ+mtdAB3ip3J8N+3KOqZMUmbC1I4K9W9OZ9s8b34v gWjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:dkim-signature; bh=60km6xH0HSvahM5c30+DJ4g8BodPX7+0LmwNaM0K8BI=; b=c9V4oCYIpM5D5sR+6WdiPkopvfG3ntV9SyOFYhuogJmdgzt5RBMBFCzJQ0p7ehKSuL ZZjKXtZvpXaqt+qt/K2BfCR6xNPwwPd6L63AOiN2lIGwOsBb9DXrg2Dy0n0LlYvd6pS5 RHJ+PQ93qoEE678lJHg2aV4YOuiPE5IUU4/SmhGdMuOND+yMpXT4iC7iM5Waw2EjA5UO vHBmC+OQLeCsY4hnwdMK+6U+XDTIRbdJJCgNzwPlPgjPHuLGyGd9gm0KNG1PzhS0DEy8 VKO7u+yJiCMY7NwdgrFjw1WZBNGlHSn2JLSUKRYxXn0nnvZ5RLvBV8lGB1mR6fqQJ1xx G9ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@deltatee.com header.s=20200525 header.b=ExYwdc+D; 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 bi24si2443847edb.452.2020.11.06.18.52.15; Fri, 06 Nov 2020 18:52:38 -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=fail header.i=@deltatee.com header.s=20200525 header.b=ExYwdc+D; 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 S1728269AbgKGCuv (ORCPT + 99 others); Fri, 6 Nov 2020 21:50:51 -0500 Received: from ale.deltatee.com ([204.191.154.188]:35002 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725868AbgKGCuv (ORCPT ); Fri, 6 Nov 2020 21:50:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=60km6xH0HSvahM5c30+DJ4g8BodPX7+0LmwNaM0K8BI=; b=ExYwdc+DkS+fkDeydObiKNmENV tHOCg7o9tz01AsRah8P/Sr/9fh7XNjnnO8jUpwDGiiOtI4fzZuc6CUz0kowPjTXWC6ng/SIFsgqYN EJHOk3xQTOWZhterUYWYUuqnSOJrTgIRuwbsS0EX7HcK+HPf6oJYHWV5Bct4py7lGeNLo3+V3BDQD y5yp6ooOKpOsyzsFqaAIcs+xYoIbgqvVKxiXPkS/46cCAeQ19J2mBvZiqs9XbCzRkYaVcg210o8Hy kosgowf22Fkc7d716zpVdUVQa11HzeqnKB3bS3yoy0lNdGfuHQmF/UGjLKyQSo4URkuNgC0n1iHYd T4gVkX0w==; Received: from s01060023bee90a7d.cg.shawcable.net ([24.64.145.4] helo=[192.168.0.10]) by ale.deltatee.com with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kbEJI-00029J-SL; Fri, 06 Nov 2020 19:50:37 -0700 To: Jason 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 , =?UTF-8?Q?Christian_K=c3=b6nig?= , Ira Weiny , John Hubbard , Don Dutile , Matthew Wilcox , Daniel Vetter 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> <20201107001457.GB244516@ziepe.ca> From: Logan Gunthorpe Message-ID: <6f202b79-fa90-7cda-9ac9-457aa451530f@deltatee.com> Date: Fri, 6 Nov 2020 19:50:32 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <20201107001457.GB244516@ziepe.ca> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 24.64.145.4 X-SA-Exim-Rcpt-To: daniel.vetter@ffwll.ch, willy@infradead.org, ddutile@redhat.com, jhubbard@nvidia.com, iweiny@intel.com, christian.koenig@amd.com, dan.j.williams@intel.com, hch@lst.de, sbates@raithlin.com, iommu@lists.linux-foundation.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, jgg@ziepe.ca X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,MYRULES_FREE,NICE_REPLY_A autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [RFC PATCH 14/15] PCI/P2PDMA: Introduce pci_mmap_p2pmem() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-11-06 5:14 p.m., Jason Gunthorpe wrote: > 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. Agreed. But I'll have to dig to see if genalloc supports freeing blocks in different sizes than the allocations. Logan