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
8888 vm_fault_t (*migrate_to_ram)(struct vm_fault *vmf);
8989 };
9090
91+#define PGMAP_ALTMAP_VALID (1 << 0)
92+
9193 /**
9294 * struct dev_pagemap - metadata for ZONE_DEVICE mappings
9395 * @altmap: pre-allocated/reserved memory for vmemmap allocations
@@ -96,19 +98,27 @@ struct dev_pagemap_ops { · 2 unmodified lines
9698 * @dev: host device of the mapping for debug
9799 * @data: private data pointer for page_free()
98100 * @type: memory type: see MEMORY_* in memory_hotplug.h
101+ * @flags: PGMAP_* flags to specify defailed behavior
99102 * @ops: method table
100103 */
101104 struct dev_pagemap {
102105 struct vmem_altmap altmap;
103− bool altmap_valid;
104106 struct resource res;
105107 struct percpu_ref *ref;
106108 struct device *dev;
107109 enum memory_type type;
110+ unsigned int flags;
108111 u64 pci_p2pdma_bus_offset;
109112 const struct dev_pagemap_ops *ops;
110113 };
111114
115+static 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+
112122 #ifdef CONFIG_ZONE_DEVICE
113123 void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap);
114124 void 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