linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Logan Gunthorpe <logang@deltatee.com>
To: Christoph Hellwig <hch@lst.de>, Ralph Campbell <rcampbell@nvidia.com>
Cc: linux-mm@kvack.org, nouveau@lists.freedesktop.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jerome Glisse <jglisse@redhat.com>,
	John Hubbard <jhubbard@nvidia.com>,
	Alistair Popple <apopple@nvidia.com>,
	Jason Gunthorpe <jgg@nvidia.com>,
	Bharata B Rao <bharata@linux.ibm.com>, Zi Yan <ziy@nvidia.com>,
	"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
	Yang Shi <yang.shi@linux.alibaba.com>,
	Ben Skeggs <bskeggs@redhat.com>, Shuah Khan <shuah@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Dan Williams <dan.j.williams@intel.com>,
	linux-nvdimm@lists.01.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v3 3/6] mm: support THP migration to device private memory
Date: Wed, 2 Dec 2020 11:01:06 -0700	[thread overview]
Message-ID: <7229bb21-7bf7-4989-e7cf-210834190693@deltatee.com> (raw)
In-Reply-To: <20201202101426.GC7597@lst.de>



On 2020-12-02 3:14 a.m., Christoph Hellwig wrote:>>
MEMORY_DEVICE_PCI_P2PDMA:
>> Struct pages are created in pci_p2pdma_add_resource() and represent device
>> memory accessible by PCIe bar address space. Memory is allocated with
>> pci_alloc_p2pmem() based on a byte length but the gen_pool_alloc_owner()
>> call will allocate memory in a minimum of PAGE_SIZE units.
>> Reference counting is +1 per *allocation* on the pgmap->ref reference count.
>> Note that this is not +1 per page which is what put_page() expects. So
>> currently, a get_page()/put_page() works OK because the page reference count
>> only goes 1->2 and 2->1. If it went to zero, the pgmap->ref reference count
>> would be incorrect if the allocation size was greater than one page.
>>
>> I see pci_alloc_p2pmem() is called by nvme_alloc_sq_cmds() and
>> pci_p2pmem_alloc_sgl() to create a command queue and a struct scatterlist *.
>> Looks like sg_page(sg) returns the ZONE_DEVICE struct page of the scatterlist.
>> There are a huge number of places sg_page() is called so it is hard to tell
>> whether or not get_page()/put_page() is ever called on MEMORY_DEVICE_PCI_P2PDMA
>> pages.
> 
> Nothing should call get_page/put_page on them, as they are not treated
> as refcountable memory.  More importantly nothing is allowed to keep
> a reference longer than the time of the I/O.

Yes, right now this is safe, as Christoph notes there are no places
where these should be got/put.

But eventually we'll need to change how pci_alloc_p2pmem() works to take
references on the actual pages and allow freeing individual pages,
similar to what you suggest. This is one of the issues Jason pointed out
in my last RFC to try to pass these pages through GUP.

Logan


  reply	other threads:[~2020-12-02 18:01 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-06  0:51 [PATCH v3 0/6] mm/hmm/nouveau: add THP migration to migrate_vma_* Ralph Campbell
2020-11-06  0:51 ` [PATCH v3 1/6] mm/thp: add prep_transhuge_device_private_page() Ralph Campbell
2020-11-06  7:55   ` Christoph Hellwig
2020-11-06 20:56     ` Ralph Campbell
2020-11-06 12:14   ` Matthew Wilcox
2020-11-06 20:34     ` Ralph Campbell
2020-11-06  0:51 ` [PATCH v3 2/6] mm/migrate: move migrate_vma_collect_skip() Ralph Campbell
2020-11-06  7:56   ` Christoph Hellwig
2020-11-06  7:57   ` Christoph Hellwig
2020-11-06  0:51 ` [PATCH v3 3/6] mm: support THP migration to device private memory Ralph Campbell
2020-11-06  8:03   ` Christoph Hellwig
2020-11-06 21:26     ` Ralph Campbell
2020-11-09  9:14       ` Christoph Hellwig
2020-11-09 21:34         ` Ralph Campbell
2020-11-11 23:38         ` Ralph Campbell
2020-11-20 20:01           ` Jason Gunthorpe
2020-12-02 10:08             ` Christoph Hellwig
2020-12-05  8:22               ` Roger Pau Monné
2020-12-02 10:14           ` Christoph Hellwig
2020-12-02 18:01             ` Logan Gunthorpe [this message]
2020-11-06  0:51 ` [PATCH v3 4/6] mm/thp: add THP allocation helper Ralph Campbell
2020-11-06  8:01   ` Christoph Hellwig
2020-11-06 21:09     ` Ralph Campbell
2020-11-06  0:51 ` [PATCH v3 5/6] mm/hmm/test: add self tests for THP migration Ralph Campbell
2020-11-06  0:51 ` [PATCH v3 6/6] nouveau: support THP migration to private memory Ralph Campbell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7229bb21-7bf7-4989-e7cf-210834190693@deltatee.com \
    --to=logang@deltatee.com \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=bharata@linux.ibm.com \
    --cc=bskeggs@redhat.com \
    --cc=dan.j.williams@intel.com \
    --cc=hch@lst.de \
    --cc=jgg@nvidia.com \
    --cc=jglisse@redhat.com \
    --cc=jhubbard@nvidia.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nvdimm@lists.01.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=rcampbell@nvidia.com \
    --cc=shuah@kernel.org \
    --cc=yang.shi@linux.alibaba.com \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).