History

memremap: replace the altmap_valid field with a PGMAP_ALTMAP_VALID flag

Add a flags field to struct dev_pagemap to replace the altmap_valid boolean to be a little more extensible. Also add a pgmap_altmap() helper to find the optional altmap and clean up the code using the altmap using it.

Christoph Hellwig committed 7 years ago

Commit 514caf21 parent 80a72d09 files · +29 −43Browse files

Showing the changes to include/linux (1 of 9 files). Show all

Unified · Split

include/linux/memremap.h+11−1
@@ -88,6 +88,8 @@ struct dev_pagemap_ops { · 87 unmodified lines
88 vm_fault_t (*migrate_to_ram)(struct vm_fault *vmf);88 vm_fault_t (*migrate_to_ram)(struct vm_fault *vmf);
89};89};
90 90
91#define PGMAP_ALTMAP_VALID (1 << 0)
92
91/**93/**
92 * struct dev_pagemap - metadata for ZONE_DEVICE mappings94 * struct dev_pagemap - metadata for ZONE_DEVICE mappings
93 * @altmap: pre-allocated/reserved memory for vmemmap allocations95 * @altmap: pre-allocated/reserved memory for vmemmap allocations
@@ -96,19 +98,27 @@ struct dev_pagemap_ops { · 2 unmodified lines
96 * @dev: host device of the mapping for debug98 * @dev: host device of the mapping for debug
97 * @data: private data pointer for page_free()99 * @data: private data pointer for page_free()
98 * @type: memory type: see MEMORY_* in memory_hotplug.h100 * @type: memory type: see MEMORY_* in memory_hotplug.h
101 * @flags: PGMAP_* flags to specify defailed behavior
99 * @ops: method table102 * @ops: method table
100 */103 */
101struct dev_pagemap {104struct dev_pagemap {
102 struct vmem_altmap altmap;105 struct vmem_altmap altmap;
103 bool altmap_valid;
104 struct resource res;106 struct resource res;
105 struct percpu_ref *ref;107 struct percpu_ref *ref;
106 struct device *dev;108 struct device *dev;
107 enum memory_type type;109 enum memory_type type;
110 unsigned int flags;
108 u64 pci_p2pdma_bus_offset;111 u64 pci_p2pdma_bus_offset;
109 const struct dev_pagemap_ops *ops;112 const struct dev_pagemap_ops *ops;
110};113};
111 114
115static inline struct vmem_altmap *pgmap_altmap(struct dev_pagemap *pgmap)
116{
117 if (pgmap->flags & PGMAP_ALTMAP_VALID)
118 return &pgmap->altmap;
119 return NULL;
120}
121
112#ifdef CONFIG_ZONE_DEVICE122#ifdef CONFIG_ZONE_DEVICE
113void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap);123void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap);
114void devm_memunmap_pages(struct device *dev, struct dev_pagemap *pgmap);124void devm_memunmap_pages(struct device *dev, struct dev_pagemap *pgmap);

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