Skip to content

Commit 25b2995

Browse files
Christoph Hellwigjgunthorpe
authored andcommitted
mm: remove MEMORY_DEVICE_PUBLIC support
The code hasn't been used since it was added to the tree, and doesn't appear to actually be usable. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Acked-by: Michal Hocko <[email protected]> Reviewed-by: Dan Williams <[email protected]> Tested-by: Dan Williams <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 07ec389 commit 25b2995

File tree

14 files changed

+22
-186
lines changed

14 files changed

+22
-186
lines changed

fs/proc/task_mmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ static pagemap_entry_t pte_to_pagemap_entry(struct pagemapread *pm,
12791279
if (pm->show_pfn)
12801280
frame = pte_pfn(pte);
12811281
flags |= PM_PRESENT;
1282-
page = _vm_normal_page(vma, addr, pte, true);
1282+
page = vm_normal_page(vma, addr, pte);
12831283
if (pte_soft_dirty(pte))
12841284
flags |= PM_SOFT_DIRTY;
12851285
} else if (is_swap_pte(pte)) {

include/linux/hmm.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ static inline void hmm_mm_destroy(struct mm_struct *mm) {}
584584
static inline void hmm_mm_init(struct mm_struct *mm) {}
585585
#endif /* IS_ENABLED(CONFIG_HMM_MIRROR) */
586586

587-
#if IS_ENABLED(CONFIG_DEVICE_PRIVATE) || IS_ENABLED(CONFIG_DEVICE_PUBLIC)
587+
#if IS_ENABLED(CONFIG_DEVICE_PRIVATE)
588588
struct hmm_devmem;
589589

590590
struct page *hmm_vma_alloc_locked_page(struct vm_area_struct *vma,
@@ -722,9 +722,6 @@ struct hmm_devmem {
722722
struct hmm_devmem *hmm_devmem_add(const struct hmm_devmem_ops *ops,
723723
struct device *device,
724724
unsigned long size);
725-
struct hmm_devmem *hmm_devmem_add_resource(const struct hmm_devmem_ops *ops,
726-
struct device *device,
727-
struct resource *res);
728725

729726
/*
730727
* hmm_devmem_page_set_drvdata - set per-page driver data field
@@ -751,7 +748,7 @@ static inline unsigned long hmm_devmem_page_get_drvdata(const struct page *page)
751748
{
752749
return page->hmm_data;
753750
}
754-
#endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */
751+
#endif /* CONFIG_DEVICE_PRIVATE */
755752
#else /* IS_ENABLED(CONFIG_HMM) */
756753
static inline void hmm_mm_destroy(struct mm_struct *mm) {}
757754
static inline void hmm_mm_init(struct mm_struct *mm) {}

include/linux/ioport.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ enum {
132132
IORES_DESC_PERSISTENT_MEMORY = 4,
133133
IORES_DESC_PERSISTENT_MEMORY_LEGACY = 5,
134134
IORES_DESC_DEVICE_PRIVATE_MEMORY = 6,
135-
IORES_DESC_DEVICE_PUBLIC_MEMORY = 7,
136135
};
137136

138137
/* helpers to define resources */

include/linux/memremap.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ struct vmem_altmap {
3737
* A more complete discussion of unaddressable memory may be found in
3838
* include/linux/hmm.h and Documentation/vm/hmm.rst.
3939
*
40-
* MEMORY_DEVICE_PUBLIC:
41-
* Device memory that is cache coherent from device and CPU point of view. This
42-
* is use on platform that have an advance system bus (like CAPI or CCIX). A
43-
* driver can hotplug the device memory using ZONE_DEVICE and with that memory
44-
* type. Any page of a process can be migrated to such memory. However no one
45-
* should be allow to pin such memory so that it can always be evicted.
46-
*
4740
* MEMORY_DEVICE_FS_DAX:
4841
* Host memory that has similar access semantics as System RAM i.e. DMA
4942
* coherent and supports page pinning. In support of coordinating page
@@ -58,7 +51,6 @@ struct vmem_altmap {
5851
*/
5952
enum memory_type {
6053
MEMORY_DEVICE_PRIVATE = 1,
61-
MEMORY_DEVICE_PUBLIC,
6254
MEMORY_DEVICE_FS_DAX,
6355
MEMORY_DEVICE_PCI_P2PDMA,
6456
};

include/linux/mm.h

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,6 @@ static inline bool put_devmap_managed_page(struct page *page)
944944
return false;
945945
switch (page->pgmap->type) {
946946
case MEMORY_DEVICE_PRIVATE:
947-
case MEMORY_DEVICE_PUBLIC:
948947
case MEMORY_DEVICE_FS_DAX:
949948
__put_devmap_managed_page(page);
950949
return true;
@@ -960,12 +959,6 @@ static inline bool is_device_private_page(const struct page *page)
960959
page->pgmap->type == MEMORY_DEVICE_PRIVATE;
961960
}
962961

963-
static inline bool is_device_public_page(const struct page *page)
964-
{
965-
return is_zone_device_page(page) &&
966-
page->pgmap->type == MEMORY_DEVICE_PUBLIC;
967-
}
968-
969962
#ifdef CONFIG_PCI_P2PDMA
970963
static inline bool is_pci_p2pdma_page(const struct page *page)
971964
{
@@ -998,11 +991,6 @@ static inline bool is_device_private_page(const struct page *page)
998991
return false;
999992
}
1000993

1001-
static inline bool is_device_public_page(const struct page *page)
1002-
{
1003-
return false;
1004-
}
1005-
1006994
static inline bool is_pci_p2pdma_page(const struct page *page)
1007995
{
1008996
return false;
@@ -1431,10 +1419,8 @@ struct zap_details {
14311419
pgoff_t last_index; /* Highest page->index to unmap */
14321420
};
14331421

1434-
struct page *_vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
1435-
pte_t pte, bool with_public_device);
1436-
#define vm_normal_page(vma, addr, pte) _vm_normal_page(vma, addr, pte, false)
1437-
1422+
struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
1423+
pte_t pte);
14381424
struct page *vm_normal_page_pmd(struct vm_area_struct *vma, unsigned long addr,
14391425
pmd_t pmd);
14401426

mm/Kconfig

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -718,17 +718,6 @@ config DEVICE_PRIVATE
718718
memory; i.e., memory that is only accessible from the device (or
719719
group of devices). You likely also want to select HMM_MIRROR.
720720

721-
config DEVICE_PUBLIC
722-
bool "Addressable device memory (like GPU memory)"
723-
depends on ARCH_HAS_HMM
724-
select HMM
725-
select DEV_PAGEMAP_OPS
726-
727-
help
728-
Allows creation of struct pages to represent addressable device
729-
memory; i.e., memory that is accessible from both the device and
730-
the CPU
731-
732721
config FRAME_VECTOR
733722
bool
734723

mm/gup.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -605,13 +605,6 @@ static int get_gate_page(struct mm_struct *mm, unsigned long address,
605605
if ((gup_flags & FOLL_DUMP) || !is_zero_pfn(pte_pfn(*pte)))
606606
goto unmap;
607607
*page = pte_page(*pte);
608-
609-
/*
610-
* This should never happen (a device public page in the gate
611-
* area).
612-
*/
613-
if (is_device_public_page(*page))
614-
goto unmap;
615608
}
616609
if (unlikely(!try_get_page(*page))) {
617610
ret = -ENOMEM;

mm/hmm.c

Lines changed: 2 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ EXPORT_SYMBOL(hmm_range_dma_unmap);
13311331
#endif /* IS_ENABLED(CONFIG_HMM_MIRROR) */
13321332

13331333

1334-
#if IS_ENABLED(CONFIG_DEVICE_PRIVATE) || IS_ENABLED(CONFIG_DEVICE_PUBLIC)
1334+
#if IS_ENABLED(CONFIG_DEVICE_PRIVATE)
13351335
struct page *hmm_vma_alloc_locked_page(struct vm_area_struct *vma,
13361336
unsigned long addr)
13371337
{
@@ -1478,54 +1478,4 @@ struct hmm_devmem *hmm_devmem_add(const struct hmm_devmem_ops *ops,
14781478
return devmem;
14791479
}
14801480
EXPORT_SYMBOL_GPL(hmm_devmem_add);
1481-
1482-
struct hmm_devmem *hmm_devmem_add_resource(const struct hmm_devmem_ops *ops,
1483-
struct device *device,
1484-
struct resource *res)
1485-
{
1486-
struct hmm_devmem *devmem;
1487-
void *result;
1488-
int ret;
1489-
1490-
if (res->desc != IORES_DESC_DEVICE_PUBLIC_MEMORY)
1491-
return ERR_PTR(-EINVAL);
1492-
1493-
dev_pagemap_get_ops();
1494-
1495-
devmem = devm_kzalloc(device, sizeof(*devmem), GFP_KERNEL);
1496-
if (!devmem)
1497-
return ERR_PTR(-ENOMEM);
1498-
1499-
init_completion(&devmem->completion);
1500-
devmem->pfn_first = -1UL;
1501-
devmem->pfn_last = -1UL;
1502-
devmem->resource = res;
1503-
devmem->device = device;
1504-
devmem->ops = ops;
1505-
1506-
ret = percpu_ref_init(&devmem->ref, &hmm_devmem_ref_release,
1507-
0, GFP_KERNEL);
1508-
if (ret)
1509-
return ERR_PTR(ret);
1510-
1511-
devmem->pfn_first = devmem->resource->start >> PAGE_SHIFT;
1512-
devmem->pfn_last = devmem->pfn_first +
1513-
(resource_size(devmem->resource) >> PAGE_SHIFT);
1514-
devmem->page_fault = hmm_devmem_fault;
1515-
1516-
devmem->pagemap.type = MEMORY_DEVICE_PUBLIC;
1517-
devmem->pagemap.res = *devmem->resource;
1518-
devmem->pagemap.page_free = hmm_devmem_free;
1519-
devmem->pagemap.altmap_valid = false;
1520-
devmem->pagemap.ref = &devmem->ref;
1521-
devmem->pagemap.data = devmem;
1522-
devmem->pagemap.kill = hmm_devmem_ref_kill;
1523-
devmem->pagemap.cleanup = hmm_devmem_ref_exit;
1524-
1525-
result = devm_memremap_pages(devmem->device, &devmem->pagemap);
1526-
if (IS_ERR(result))
1527-
return result;
1528-
return devmem;
1529-
}
1530-
EXPORT_SYMBOL_GPL(hmm_devmem_add_resource);
1531-
#endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */
1481+
#endif /* CONFIG_DEVICE_PRIVATE */

mm/madvise.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr,
354354
continue;
355355
}
356356

357-
page = _vm_normal_page(vma, addr, ptent, true);
357+
page = vm_normal_page(vma, addr, ptent);
358358
if (!page)
359359
continue;
360360

mm/memcontrol.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4793,7 +4793,7 @@ enum mc_target_type {
47934793
static struct page *mc_handle_present_pte(struct vm_area_struct *vma,
47944794
unsigned long addr, pte_t ptent)
47954795
{
4796-
struct page *page = _vm_normal_page(vma, addr, ptent, true);
4796+
struct page *page = vm_normal_page(vma, addr, ptent);
47974797

47984798
if (!page || !page_mapped(page))
47994799
return NULL;
@@ -4994,8 +4994,8 @@ static int mem_cgroup_move_account(struct page *page,
49944994
* 2(MC_TARGET_SWAP): if the swap entry corresponding to this pte is a
49954995
* target for charge migration. if @target is not NULL, the entry is stored
49964996
* in target->ent.
4997-
* 3(MC_TARGET_DEVICE): like MC_TARGET_PAGE but page is MEMORY_DEVICE_PUBLIC
4998-
* or MEMORY_DEVICE_PRIVATE (so ZONE_DEVICE page and thus not on the lru).
4997+
* 3(MC_TARGET_DEVICE): like MC_TARGET_PAGE but page is MEMORY_DEVICE_PRIVATE
4998+
* (so ZONE_DEVICE page and thus not on the lru).
49994999
* For now we such page is charge like a regular page would be as for all
50005000
* intent and purposes it is just special memory taking the place of a
50015001
* regular page.
@@ -5029,8 +5029,7 @@ static enum mc_target_type get_mctgt_type(struct vm_area_struct *vma,
50295029
*/
50305030
if (page->mem_cgroup == mc.from) {
50315031
ret = MC_TARGET_PAGE;
5032-
if (is_device_private_page(page) ||
5033-
is_device_public_page(page))
5032+
if (is_device_private_page(page))
50345033
ret = MC_TARGET_DEVICE;
50355034
if (target)
50365035
target->page = page;
@@ -5101,8 +5100,8 @@ static int mem_cgroup_count_precharge_pte_range(pmd_t *pmd,
51015100
if (ptl) {
51025101
/*
51035102
* Note their can not be MC_TARGET_DEVICE for now as we do not
5104-
* support transparent huge page with MEMORY_DEVICE_PUBLIC or
5105-
* MEMORY_DEVICE_PRIVATE but this might change.
5103+
* support transparent huge page with MEMORY_DEVICE_PRIVATE but
5104+
* this might change.
51065105
*/
51075106
if (get_mctgt_type_thp(vma, addr, *pmd, NULL) == MC_TARGET_PAGE)
51085107
mc.precharge += HPAGE_PMD_NR;

mm/memory-failure.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,16 +1177,12 @@ static int memory_failure_dev_pagemap(unsigned long pfn, int flags,
11771177
goto unlock;
11781178
}
11791179

1180-
switch (pgmap->type) {
1181-
case MEMORY_DEVICE_PRIVATE:
1182-
case MEMORY_DEVICE_PUBLIC:
1180+
if (pgmap->type == MEMORY_DEVICE_PRIVATE) {
11831181
/*
11841182
* TODO: Handle HMM pages which may need coordination
11851183
* with device-side memory.
11861184
*/
11871185
goto unlock;
1188-
default:
1189-
break;
11901186
}
11911187

11921188
/*

mm/memory.c

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,8 @@ static void print_bad_pte(struct vm_area_struct *vma, unsigned long addr,
571571
* PFNMAP mappings in order to support COWable mappings.
572572
*
573573
*/
574-
struct page *_vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
575-
pte_t pte, bool with_public_device)
574+
struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
575+
pte_t pte)
576576
{
577577
unsigned long pfn = pte_pfn(pte);
578578

@@ -585,29 +585,6 @@ struct page *_vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
585585
return NULL;
586586
if (is_zero_pfn(pfn))
587587
return NULL;
588-
589-
/*
590-
* Device public pages are special pages (they are ZONE_DEVICE
591-
* pages but different from persistent memory). They behave
592-
* allmost like normal pages. The difference is that they are
593-
* not on the lru and thus should never be involve with any-
594-
* thing that involve lru manipulation (mlock, numa balancing,
595-
* ...).
596-
*
597-
* This is why we still want to return NULL for such page from
598-
* vm_normal_page() so that we do not have to special case all
599-
* call site of vm_normal_page().
600-
*/
601-
if (likely(pfn <= highest_memmap_pfn)) {
602-
struct page *page = pfn_to_page(pfn);
603-
604-
if (is_device_public_page(page)) {
605-
if (with_public_device)
606-
return page;
607-
return NULL;
608-
}
609-
}
610-
611588
if (pte_devmap(pte))
612589
return NULL;
613590

@@ -797,17 +774,6 @@ copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm,
797774
rss[mm_counter(page)]++;
798775
} else if (pte_devmap(pte)) {
799776
page = pte_page(pte);
800-
801-
/*
802-
* Cache coherent device memory behave like regular page and
803-
* not like persistent memory page. For more informations see
804-
* MEMORY_DEVICE_CACHE_COHERENT in memory_hotplug.h
805-
*/
806-
if (is_device_public_page(page)) {
807-
get_page(page);
808-
page_dup_rmap(page, false);
809-
rss[mm_counter(page)]++;
810-
}
811777
}
812778

813779
out_set_pte:
@@ -1063,7 +1029,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb,
10631029
if (pte_present(ptent)) {
10641030
struct page *page;
10651031

1066-
page = _vm_normal_page(vma, addr, ptent, true);
1032+
page = vm_normal_page(vma, addr, ptent);
10671033
if (unlikely(details) && page) {
10681034
/*
10691035
* unmap_shared_mapping_pages() wants to

0 commit comments

Comments
 (0)