History

mm: simplify ZONE_DEVICE page private data

Remove the clumsy hmm_devmem_page_{get,set}_drvdata helpers, and instead just access the page directly. Also make the page data a void pointer, and thus much easier to use.

Christoph Hellwig committed 7 years ago

Commit 8a164fe1 parent eee3ae44 files · +12 −48Browse files

Unified · Split

4 files
  1. drivers/gpu/drm/nouveau/nouveau_dmem.c +7 −11
  2. include/linux/hmm.h +0 −32
  3. include/linux/mm_types.h +1 −1
  4. mm/page_alloc.c +4 −4
drivers/gpu/drm/nouveau/nouveau_dmem.c+7−11
@@ -104,11 +104,8 @@ struct nouveau_migrate { · 103 unmodified lines
104104
105105 static void nouveau_dmem_page_free(struct page *page)
106106 {
107− struct nouveau_dmem_chunk *chunk;
108− unsigned long idx;
109−
110− chunk = (void *)hmm_devmem_page_get_drvdata(page);
111− idx = page_to_pfn(page) - chunk->pfn_first;
107+ struct nouveau_dmem_chunk *chunk = page->zone_device_data;
108+ unsigned long idx = page_to_pfn(page) - chunk->pfn_first;
112109
113110 /*
114111 * FIXME:
@@ -200,7 +197,7 @@ nouveau_dmem_fault_alloc_and_copy(struct vm_area_struct *vma, · 85 unmodified lines
200197
201198 dst_addr = fault->dma[fault->npages++];
202199
203− chunk = (void *)hmm_devmem_page_get_drvdata(spage);
200+ chunk = spage->zone_device_data;
204201 src_addr = page_to_pfn(spage) - chunk->pfn_first;
205202 src_addr = (src_addr << PAGE_SHIFT) + chunk->bo->bo.offset;
206203
@@ -633,9 +630,8 @@ nouveau_dmem_init(struct nouveau_drm *drm) · 426 unmodified lines
633630 list_add_tail(&chunk->list, &drm->dmem->chunk_empty);
634631
635632 page = pfn_to_page(chunk->pfn_first);
636− for (j = 0; j < DMEM_CHUNK_NPAGES; ++j, ++page) {
637− hmm_devmem_page_set_drvdata(page, (long)chunk);
638− }
633+ for (j = 0; j < DMEM_CHUNK_NPAGES; ++j, ++page)
634+ page->zone_device_data = chunk;
639635 }
640636
641637 NV_INFO(drm, "DMEM: registered %ldMB of device memory\n", size >> 20);
@@ -698,7 +694,7 @@ nouveau_dmem_migrate_alloc_and_copy(struct vm_area_struct *vma, · 56 unmodified lines
698694 if (!dpage || dst_pfns[i] == MIGRATE_PFN_ERROR)
699695 continue;
700696
701− chunk = (void *)hmm_devmem_page_get_drvdata(dpage);
697+ chunk = dpage->zone_device_data;
702698 dst_addr = page_to_pfn(dpage) - chunk->pfn_first;
703699 dst_addr = (dst_addr << PAGE_SHIFT) + chunk->bo->bo.offset;
704700
@@ -862,7 +858,7 @@ nouveau_dmem_convert_pfn(struct nouveau_drm *drm, · 157 unmodified lines
862858 continue;
863859 }
864860
865− chunk = (void *)hmm_devmem_page_get_drvdata(page);
861+ chunk = page->zone_device_data;
866862 addr = page_to_pfn(page) - chunk->pfn_first;
867863 addr = (addr + chunk->bo->bo.mem.start) << PAGE_SHIFT;
868864
include/linux/hmm.h+0−32
@@ -584,36 +584,4 @@ static inline void hmm_mm_destroy(struct mm_struct *mm) {} · 583 unmodified lines
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)
588−/*
589− * hmm_devmem_page_set_drvdata - set per-page driver data field
590− *
591− * @page: pointer to struct page
592− * @data: driver data value to set
593− *
594− * Because page can not be on lru we have an unsigned long that driver can use
595− * to store a per page field. This just a simple helper to do that.
596− */
597−static inline void hmm_devmem_page_set_drvdata(struct page *page,
598− unsigned long data)
599−{
600− page->hmm_data = data;
601−}
602−
603−/*
604− * hmm_devmem_page_get_drvdata - get per page driver data field
605− *
606− * @page: pointer to struct page
607− * Return: driver data value
608− */
609−static inline unsigned long hmm_devmem_page_get_drvdata(const struct page *page)
610−{
611− return page->hmm_data;
612−}
613−#endif /* CONFIG_DEVICE_PRIVATE */
614−#else /* IS_ENABLED(CONFIG_HMM) */
615−static inline void hmm_mm_destroy(struct mm_struct *mm) {}
616−static inline void hmm_mm_init(struct mm_struct *mm) {}
617−#endif /* IS_ENABLED(CONFIG_HMM) */
618−
619587 #endif /* LINUX_HMM_H */
include/linux/mm_types.h+1−1
@@ -158,7 +158,7 @@ struct page { · 157 unmodified lines
158158 struct { /* ZONE_DEVICE pages */
159159 /** @pgmap: Points to the hosting device page map. */
160160 struct dev_pagemap *pgmap;
161− unsigned long hmm_data;
161+ void *zone_device_data;
162162 unsigned long _zd_pad_1; /* uses mapping */
163163 };
164164
mm/page_alloc.c+4−4
@@ -5886,12 +5886,12 @@ void __ref memmap_init_zone_device(struct zone *zone, · 5885 unmodified lines
58865886 __SetPageReserved(page);
58875887
58885888 /*
5889− * ZONE_DEVICE pages union ->lru with a ->pgmap back
5890− * pointer and hmm_data. It is a bug if a ZONE_DEVICE
5891− * page is ever freed or placed on a driver-private list.
5889+ * ZONE_DEVICE pages union ->lru with a ->pgmap back pointer
5890+ * and zone_device_data. It is a bug if a ZONE_DEVICE page is
5891+ * ever freed or placed on a driver-private list.
58925892 */
58935893 page->pgmap = pgmap;
5894− page->hmm_data = 0;
5894+ page->zone_device_data = NULL;
58955895
58965896 /*
58975897 * Mark the block movable so that blocks are reserved for

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t