Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1526447
| From | Anshuman Khandual <khandual@linux.vnet.ibm.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [HMM v13 04/18] mm/ZONE_DEVICE/free-page: callback when page is freed |
| Date | 2016-11-21 09:30 +0100 |
| Message-ID | <sFS9c-7d8-9@gated-at.bofh.it> (permalink) |
| References | <sEUZr-1B7-3@gated-at.bofh.it> <sEV98-1Es-25@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 11/18/2016 11:48 PM, Jérôme Glisse wrote:
> When a ZONE_DEVICE page refcount reach 1 it means it is free and nobody
> is holding a reference on it (only device to which the memory belong do).
> Add a callback and call it when that happen so device driver can implement
> their own free page management.
>
> Signed-off-by: Jérôme Glisse <jglisse@redhat.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
> ---
> include/linux/memremap.h | 4 ++++
> kernel/memremap.c | 8 ++++++++
> 2 files changed, 12 insertions(+)
>
> diff --git a/include/linux/memremap.h b/include/linux/memremap.h
> index fe61dca..469c88d 100644
> --- a/include/linux/memremap.h
> +++ b/include/linux/memremap.h
> @@ -37,17 +37,21 @@ static inline struct vmem_altmap *to_vmem_altmap(unsigned long memmap_start)
>
> /**
> * struct dev_pagemap - metadata for ZONE_DEVICE mappings
> + * @free_devpage: free page callback when page refcount reach 1
> * @altmap: pre-allocated/reserved memory for vmemmap allocations
> * @res: physical address range covered by @ref
> * @ref: reference count that pins the devm_memremap_pages() mapping
> * @dev: host device of the mapping for debug
> + * @data: privata data pointer for free_devpage
> * @flags: memory flags (look for MEMORY_FLAGS_NONE in memory_hotplug.h)
> */
> struct dev_pagemap {
> + void (*free_devpage)(struct page *page, void *data);
> struct vmem_altmap *altmap;
> const struct resource *res;
> struct percpu_ref *ref;
> struct device *dev;
> + void *data;
> int flags;
> };
>
> diff --git a/kernel/memremap.c b/kernel/memremap.c
> index 438a73aa2..3d28048 100644
> --- a/kernel/memremap.c
> +++ b/kernel/memremap.c
> @@ -190,6 +190,12 @@ EXPORT_SYMBOL(get_zone_device_page);
>
> void put_zone_device_page(struct page *page)
> {
> + /*
> + * If refcount is 1 then page is freed and refcount is stable as nobody
> + * holds a reference on the page.
> + */
> + if (page->pgmap->free_devpage && page_count(page) == 1)
> + page->pgmap->free_devpage(page, page->pgmap->data);
> put_dev_pagemap(page->pgmap);
> }
> EXPORT_SYMBOL(put_zone_device_page);
> @@ -326,6 +332,8 @@ void *devm_memremap_pages(struct device *dev, struct resource *res,
> pgmap->ref = ref;
> pgmap->res = &page_map->res;
> pgmap->flags = flags | MEMORY_DEVICE;
> + pgmap->free_devpage = NULL;
> + pgmap->data = NULL;
When is the driver expected to load up pgmap->free_devpage ? I thought
this function is one of the right places. Though as all the pages in
the same hotplug operation point to the same dev_pagemap structure this
loading can be done at later point of time as well.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[HMM v13 00/18] HMM (Heterogeneous Memory Management) v13 Jérôme Glisse <jglisse@redhat.com> - 2016-11-18 18:20 +0100
[HMM v13 13/18] mm/hmm/mirror: device page fault handler Jérôme Glisse <jglisse@redhat.com> - 2016-11-18 18:20 +0100
[HMM v13 12/18] mm/hmm/mirror: helper to snapshot CPU page table Jérôme Glisse <jglisse@redhat.com> - 2016-11-18 18:30 +0100
[HMM v13 02/18] mm/ZONE_DEVICE/unaddressable: add support for un-addressable device memory Jérôme Glisse <jglisse@redhat.com> - 2016-11-18 18:30 +0100
Re: [HMM v13 02/18] mm/ZONE_DEVICE/unaddressable: add support for un-addressable device memory Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2016-11-21 09:10 +0100
Re: [HMM v13 02/18] mm/ZONE_DEVICE/unaddressable: add support for un-addressable device memory Jerome Glisse <jglisse@redhat.com> - 2016-11-21 13:40 +0100
Re: [HMM v13 02/18] mm/ZONE_DEVICE/unaddressable: add support for un-addressable device memory Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2016-11-22 06:20 +0100
[HMM v13 09/18] mm/hmm/mirror: mirror process address space on device with HMM helpers Jérôme Glisse <jglisse@redhat.com> - 2016-11-18 18:30 +0100
Re: [HMM v13 09/18] mm/hmm/mirror: mirror process address space on device with HMM helpers Balbir Singh <bsingharora@gmail.com> - 2016-11-21 03:50 +0100
Re: [HMM v13 09/18] mm/hmm/mirror: mirror process address space on device with HMM helpers Jerome Glisse <jglisse@redhat.com> - 2016-11-21 06:20 +0100
[HMM v13 05/18] mm/ZONE_DEVICE/devmem_pages_remove: allow early removal of device memory Jérôme Glisse <jglisse@redhat.com> - 2016-11-18 18:30 +0100
Re: [HMM v13 05/18] mm/ZONE_DEVICE/devmem_pages_remove: allow early removal of device memory Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2016-11-21 11:40 +0100
Re: [HMM v13 05/18] mm/ZONE_DEVICE/devmem_pages_remove: allow early removal of device memory Jerome Glisse <jglisse@redhat.com> - 2016-11-21 13:40 +0100
Re: [HMM v13 05/18] mm/ZONE_DEVICE/devmem_pages_remove: allow early removal of device memory Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2016-11-22 06:00 +0100
[HMM v13 04/18] mm/ZONE_DEVICE/free-page: callback when page is freed Jérôme Glisse <jglisse@redhat.com> - 2016-11-18 18:30 +0100
Re: [HMM v13 04/18] mm/ZONE_DEVICE/free-page: callback when page is freed Balbir Singh <bsingharora@gmail.com> - 2016-11-21 03:00 +0100
Re: [HMM v13 04/18] mm/ZONE_DEVICE/free-page: callback when page is freed Jerome Glisse <jglisse@redhat.com> - 2016-11-21 06:00 +0100
Re: [HMM v13 04/18] mm/ZONE_DEVICE/free-page: callback when page is freed Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2016-11-21 09:30 +0100
Re: [HMM v13 04/18] mm/ZONE_DEVICE/free-page: callback when page is freed Jerome Glisse <jglisse@redhat.com> - 2016-11-21 13:40 +0100
Re: [HMM v13 04/18] mm/ZONE_DEVICE/free-page: callback when page is freed Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2016-11-22 06:10 +0100
[HMM v13 10/18] mm/hmm/mirror: add range lock helper, prevent CPU page table update for the range Jérôme Glisse <jglisse@redhat.com> - 2016-11-18 18:30 +0100
[HMM v13 06/18] mm/ZONE_DEVICE/unaddressable: add special swap for unaddressable Jérôme Glisse <jglisse@redhat.com> - 2016-11-18 18:30 +0100
Re: [HMM v13 06/18] mm/ZONE_DEVICE/unaddressable: add special swap for unaddressable Balbir Singh <bsingharora@gmail.com> - 2016-11-21 03:10 +0100
Re: [HMM v13 06/18] mm/ZONE_DEVICE/unaddressable: add special swap for unaddressable Jerome Glisse <jglisse@redhat.com> - 2016-11-21 06:10 +0100
Re: [HMM v13 06/18] mm/ZONE_DEVICE/unaddressable: add special swap for unaddressable Balbir Singh <bsingharora@gmail.com> - 2016-11-22 03:30 +0100
Re: [HMM v13 06/18] mm/ZONE_DEVICE/unaddressable: add special swap for unaddressable Jerome Glisse <jglisse@redhat.com> - 2016-11-22 15:00 +0100
Re: [HMM v13 06/18] mm/ZONE_DEVICE/unaddressable: add special swap for unaddressable Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2016-11-21 12:20 +0100
Re: [HMM v13 06/18] mm/ZONE_DEVICE/unaddressable: add special swap for unaddressable Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2016-11-21 12:00 +0100
Re: [HMM v13 06/18] mm/ZONE_DEVICE/unaddressable: add special swap for unaddressable Jerome Glisse <jglisse@redhat.com> - 2016-11-21 13:50 +0100
Re: [HMM v13 06/18] mm/ZONE_DEVICE/unaddressable: add special swap for unaddressable Anshuman Khandual <khandual@linux.vnet.ibm.com> - 2016-11-22 05:50 +0100
Re: [HMM v13 06/18] mm/ZONE_DEVICE/unaddressable: add special swap for unaddressable Jerome Glisse <jglisse@redhat.com> - 2016-11-24 15:00 +0100
[HMM v13 11/18] mm/hmm/mirror: add range monitor helper, to monitor CPU page table update Jérôme Glisse <jglisse@redhat.com> - 2016-11-18 18:30 +0100
Re: [HMM v13 00/18] HMM (Heterogeneous Memory Management) v13 John Hubbard <jhubbard@nvidia.com> - 2016-11-19 01:50 +0100
Re: [HMM v13 00/18] HMM (Heterogeneous Memory Management) v13 "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> - 2016-11-19 16:00 +0100
csiph-web