History

Merge branch 'akpm' (patches from Andrew)

Merge yet more updates from Andrew Morton: "The rest of MM and a kernel-wide procfs cleanup. Summary of the more significant patches: - Patch series "mm/memory_hotplug: Factor out memory block devicehandling", v3. David Hildenbrand. Some spring-cleaning of the memory hotplug code, notably in drivers/base/memory.c - "mm: thp: fix false negative of shmem vma's THP eligibility". Yang Shi. Fix /proc/pid/smaps output for THP pages used in shmem. - "resource: fix locking in find_next_iomem_res()" + 1. Nadav Amit. Bugfix and speedup for kernel/resource.c - Patch series "mm: Further memory block device cleanups", David Hildenbrand. More spring-cleaning of the memory hotplug code. - Patch series "mm: Sub-section memory hotplug support". Dan Williams. Generalise the memory hotplug code so that pmem can use it more completely. Then remove the hacks from the libnvdimm code which were there to work around the memory-hotplug code's constraints. - "proc/sysctl: add shared variables for range check", Matteo Croce. We have about 250 instances of int zero; ... .extra1 = &zero, in the tree. This is a tree-wide sweep to make all those private "zero"s and "one"s use global variables. Alas, it isn't practical to make those two global integers const" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (38 commits) proc/sysctl: add shared variables for range check mm: migrate: remove unused mode argument mm/sparsemem: cleanup 'section number' data types libnvdimm/pfn: stop padding pmem namespaces to section alignment libnvdimm/pfn: fix fsdax-mode namespace info-block zero-fields mm/devm_memremap_pages: enable sub-section remap mm: document ZONE_DEVICE memory-model implications mm/sparsemem: support sub-section hotplug mm/sparsemem: prepare for sub-section ranges mm: kill is_dev_zone() helper mm/hotplug: kill is_dev_zone() usage in __remove_pages() mm/sparsemem: convert kmalloc_section_memmap() to populate_section_memmap() mm/hotplug: prepare shrink_{zone, pgdat}_span for sub-section removal mm/sparsemem: add helpers track active portions of a section at boot mm/sparsemem: introduce a SECTION_IS_EARLY flag mm/sparsemem: introduce struct mem_section_usage drivers/base/memory.c: get rid of find_memory_block_hinted() mm/memory_hotplug: move and simplify walk_memory_blocks() mm/memory_hotplug: rename walk_memory_range() and pass start+size instead of pfns mm: make register_mem_sect_under_node() static ...

Linus Torvalds committed 7 years ago

Commit 249be852 parents 3bfe1fc eec484471 files · +1087 −1020Browse files

Showing the changes to include/linux (8 of 71 files). Show all

Unified · Split

8 files
  1. include/linux/huge_mm.h +23 −0
  2. include/linux/memory.h +5 −6
  3. include/linux/memory_hotplug.h +4 −15
  4. include/linux/migrate.h +1 −2
  5. include/linux/mm.h +19 −19
  6. include/linux/mmzone.h +69 −19
  7. include/linux/node.h +2 −12
  8. include/linux/sysctl.h +7 −0
include/linux/huge_mm.h+23−0
@@ -121,6 +121,23 @@ static inline bool __transparent_hugepage_enabled(struct vm_area_struct *vma) · 120 unmodified lines
121121
122122 bool transparent_hugepage_enabled(struct vm_area_struct *vma);
123123
124+#define HPAGE_CACHE_INDEX_MASK (HPAGE_PMD_NR - 1)
125+
126+static inline bool transhuge_vma_suitable(struct vm_area_struct *vma,
127+ unsigned long haddr)
128+{
129+ /* Don't have to check pgoff for anonymous vma */
130+ if (!vma_is_anonymous(vma)) {
131+ if (((vma->vm_start >> PAGE_SHIFT) & HPAGE_CACHE_INDEX_MASK) !=
132+ (vma->vm_pgoff & HPAGE_CACHE_INDEX_MASK))
133+ return false;
134+ }
135+
136+ if (haddr < vma->vm_start || haddr + HPAGE_PMD_SIZE > vma->vm_end)
137+ return false;
138+ return true;
139+}
140+
124141 #define transparent_hugepage_use_zero_page() \
125142 (transparent_hugepage_flags & \
126143 (1<<TRANSPARENT_HUGEPAGE_USE_ZERO_PAGE_FLAG))
@@ -271,6 +288,12 @@ static inline bool transparent_hugepage_enabled(struct vm_area_struct *vma) · 144 unmodified lines
271288 return false;
272289 }
273290
291+static inline bool transhuge_vma_suitable(struct vm_area_struct *vma,
292+ unsigned long haddr)
293+{
294+ return false;
295+}
296+
274297 static inline void prep_transhuge_page(struct page *page) {}
275298
276299 #define transparent_hugepage_flags 0UL
include/linux/memory.h+5−6
@@ -111,16 +111,15 @@ extern int register_memory_notifier(struct notifier_block *nb); · 110 unmodified lines
111111 extern void unregister_memory_notifier(struct notifier_block *nb);
112112 extern int register_memory_isolate_notifier(struct notifier_block *nb);
113113 extern void unregister_memory_isolate_notifier(struct notifier_block *nb);
114−int hotplug_memory_register(int nid, struct mem_section *section);
115−#ifdef CONFIG_MEMORY_HOTREMOVE
116−extern void unregister_memory_section(struct mem_section *);
117−#endif
114+int create_memory_block_devices(unsigned long start, unsigned long size);
115+void remove_memory_block_devices(unsigned long start, unsigned long size);
118116 extern int memory_dev_init(void);
119117 extern int memory_notify(unsigned long val, void *v);
120118 extern int memory_isolate_notify(unsigned long val, void *v);
121−extern struct memory_block *find_memory_block_hinted(struct mem_section *,
122− struct memory_block *);
123119 extern struct memory_block *find_memory_block(struct mem_section *);
120+typedef int (*walk_memory_blocks_func_t)(struct memory_block *, void *);
121+extern int walk_memory_blocks(unsigned long start, unsigned long size,
122+ void *arg, walk_memory_blocks_func_t func);
124123 #define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION<<PAGE_SHIFT)
125124 #endif /* CONFIG_MEMORY_HOTPLUG_SPARSE */
126125
include/linux/memory_hotplug.h+4−15
@@ -123,20 +123,10 @@ static inline bool movable_node_is_enabled(void) · 122 unmodified lines
123123 return movable_node_enabled;
124124 }
125125
126−#ifdef CONFIG_MEMORY_HOTREMOVE
127126 extern void arch_remove_memory(int nid, u64 start, u64 size,
128127 struct vmem_altmap *altmap);
129128 extern void __remove_pages(struct zone *zone, unsigned long start_pfn,
130129 unsigned long nr_pages, struct vmem_altmap *altmap);
131−#endif /* CONFIG_MEMORY_HOTREMOVE */
132−
133−/*
134− * Do we want sysfs memblock files created. This will allow userspace to online
135− * and offline memory explicitly. Lack of this bit means that the caller has to
136− * call move_pfn_range_to_zone to finish the initialization.
137− */
138−
139−#define MHP_MEMBLOCK_API (1<<0)
140130
141131 /* reasonably generic interface to expand the physical pages */
142132 extern int __add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages,
@@ -350,17 +340,16 @@ static inline void __remove_memory(int nid, u64 start, u64 size) {} · 207 unmodified lines
350340 #endif /* CONFIG_MEMORY_HOTREMOVE */
351341
352342 extern void __ref free_area_init_core_hotplug(int nid);
353−extern int walk_memory_range(unsigned long start_pfn, unsigned long end_pfn,
354− void *arg, int (*func)(struct memory_block *, void *));
355343 extern int __add_memory(int nid, u64 start, u64 size);
356344 extern int add_memory(int nid, u64 start, u64 size);
357345 extern int add_memory_resource(int nid, struct resource *resource);
358346 extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn,
359347 unsigned long nr_pages, struct vmem_altmap *altmap);
360348 extern bool is_memblock_offlined(struct memory_block *mem);
361−extern int sparse_add_one_section(int nid, unsigned long start_pfn,
362− struct vmem_altmap *altmap);
363−extern void sparse_remove_one_section(struct zone *zone, struct mem_section *ms,
349+extern int sparse_add_section(int nid, unsigned long pfn,
350+ unsigned long nr_pages, struct vmem_altmap *altmap);
351+extern void sparse_remove_section(struct mem_section *ms,
352+ unsigned long pfn, unsigned long nr_pages,
364353 unsigned long map_offset, struct vmem_altmap *altmap);
365354 extern struct page *sparse_decode_mem_map(unsigned long coded_mem_map,
366355 unsigned long pnum);
include/linux/migrate.h+1−2
@@ -77,8 +77,7 @@ extern void migrate_page_copy(struct page *newpage, struct page *page); · 76 unmodified lines
7777 extern int migrate_huge_page_move_mapping(struct address_space *mapping,
7878 struct page *newpage, struct page *page);
7979 extern int migrate_page_move_mapping(struct address_space *mapping,
80− struct page *newpage, struct page *page, enum migrate_mode mode,
81− int extra_count);
80+ struct page *newpage, struct page *page, int extra_count);
8281 #else
8382
8483 static inline void putback_movable_pages(struct list_head *l) {}
include/linux/mm.h+19−19
@@ -541,6 +541,23 @@ static inline void vma_set_anonymous(struct vm_area_struct *vma) · 540 unmodified lines
541541 vma->vm_ops = NULL;
542542 }
543543
544+static inline bool vma_is_anonymous(struct vm_area_struct *vma)
545+{
546+ return !vma->vm_ops;
547+}
548+
549+#ifdef CONFIG_SHMEM
550+/*
551+ * The vma_is_shmem is not inline because it is used only by slow
552+ * paths in userfault.
553+ */
554+bool vma_is_shmem(struct vm_area_struct *vma);
555+#else
556+static inline bool vma_is_shmem(struct vm_area_struct *vma) { return false; }
557+#endif
558+
559+int vma_is_stack_for_current(struct vm_area_struct *vma);
560+
544561 /* flush_tlb_range() takes a vma, not a mm, and can care about flags */
545562 #define TLB_FLUSH_VMA(mm,flags) { .vm_mm = (mm), .vm_flags = (flags) }
546563
@@ -1620,23 +1637,6 @@ int clear_page_dirty_for_io(struct page *page); · 1073 unmodified lines
16201637
16211638 int get_cmdline(struct task_struct *task, char *buffer, int buflen);
16221639
1623−static inline bool vma_is_anonymous(struct vm_area_struct *vma)
1624−{
1625− return !vma->vm_ops;
1626−}
1627−
1628−#ifdef CONFIG_SHMEM
1629−/*
1630− * The vma_is_shmem is not inline because it is used only by slow
1631− * paths in userfault.
1632− */
1633−bool vma_is_shmem(struct vm_area_struct *vma);
1634−#else
1635−static inline bool vma_is_shmem(struct vm_area_struct *vma) { return false; }
1636−#endif
1637−
1638−int vma_is_stack_for_current(struct vm_area_struct *vma);
1639−
16401640 extern unsigned long move_page_tables(struct vm_area_struct *vma,
16411641 unsigned long old_addr, struct vm_area_struct *new_vma,
16421642 unsigned long new_addr, unsigned long len,
@@ -2767,8 +2767,8 @@ static inline void print_vma_addr(char *prefix, unsigned long rip) · 1124 unmodified lines
27672767 #endif
27682768
27692769 void *sparse_buffer_alloc(unsigned long size);
2770−struct page *sparse_mem_map_populate(unsigned long pnum, int nid,
2771− struct vmem_altmap *altmap);
2770+struct page * __populate_section_memmap(unsigned long pfn,
2771+ unsigned long nr_pages, int nid, struct vmem_altmap *altmap);
27722772 pgd_t *vmemmap_pgd_populate(unsigned long addr, int node);
27732773 p4d_t *vmemmap_p4d_populate(pgd_t *pgd, unsigned long addr, int node);
27742774 pud_t *vmemmap_pud_populate(p4d_t *p4d, unsigned long addr, int node);
include/linux/mmzone.h+69−19
@@ -855,18 +855,6 @@ static inline int local_memory_node(int node_id) { return node_id; }; · 854 unmodified lines
855855 */
856856 #define zone_idx(zone) ((zone) - (zone)->zone_pgdat->node_zones)
857857
858−#ifdef CONFIG_ZONE_DEVICE
859−static inline bool is_dev_zone(const struct zone *zone)
860−{
861− return zone_idx(zone) == ZONE_DEVICE;
862−}
863−#else
864−static inline bool is_dev_zone(const struct zone *zone)
865−{
866− return false;
867−}
868−#endif
869−
870858 /*
871859 * Returns true if a zone has pages managed by the buddy allocator.
872860 * All the reclaim decisions have to use this function rather than
@@ -1160,6 +1148,29 @@ static inline unsigned long section_nr_to_pfn(unsigned long sec) · 287 unmodified lines
11601148 #define SECTION_ALIGN_UP(pfn) (((pfn) + PAGES_PER_SECTION - 1) & PAGE_SECTION_MASK)
11611149 #define SECTION_ALIGN_DOWN(pfn) ((pfn) & PAGE_SECTION_MASK)
11621150
1151+#define SUBSECTION_SHIFT 21
1152+
1153+#define PFN_SUBSECTION_SHIFT (SUBSECTION_SHIFT - PAGE_SHIFT)
1154+#define PAGES_PER_SUBSECTION (1UL << PFN_SUBSECTION_SHIFT)
1155+#define PAGE_SUBSECTION_MASK (~(PAGES_PER_SUBSECTION-1))
1156+
1157+#if SUBSECTION_SHIFT > SECTION_SIZE_BITS
1158+#error Subsection size exceeds section size
1159+#else
1160+#define SUBSECTIONS_PER_SECTION (1UL << (SECTION_SIZE_BITS - SUBSECTION_SHIFT))
1161+#endif
1162+
1163+#define SUBSECTION_ALIGN_UP(pfn) ALIGN((pfn), PAGES_PER_SUBSECTION)
1164+#define SUBSECTION_ALIGN_DOWN(pfn) ((pfn) & PAGE_SUBSECTION_MASK)
1165+
1166+struct mem_section_usage {
1167+ DECLARE_BITMAP(subsection_map, SUBSECTIONS_PER_SECTION);
1168+ /* See declaration of similar field in struct zone */
1169+ unsigned long pageblock_flags[0];
1170+};
1171+
1172+void subsection_map_init(unsigned long pfn, unsigned long nr_pages);
1173+
11631174 struct page;
11641175 struct page_ext;
11651176 struct mem_section {
@@ -1177,8 +1188,7 @@ struct mem_section { · 11 unmodified lines
11771188 */
11781189 unsigned long section_mem_map;
11791190
1180− /* See declaration of similar field in struct zone */
1181− unsigned long *pageblock_flags;
1191+ struct mem_section_usage *usage;
11821192 #ifdef CONFIG_PAGE_EXTENSION
11831193 /*
11841194 * If SPARSEMEM, pgdat doesn't have page_ext pointer. We use
@@ -1209,6 +1219,11 @@ extern struct mem_section **mem_section; · 24 unmodified lines
12091219 extern struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT];
12101220 #endif
12111221
1222+static inline unsigned long *section_to_usemap(struct mem_section *ms)
1223+{
1224+ return ms->usage->pageblock_flags;
1225+}
1226+
12121227 static inline struct mem_section *__nr_to_section(unsigned long nr)
12131228 {
12141229 #ifdef CONFIG_SPARSEMEM_EXTREME
@@ -1219,8 +1234,8 @@ static inline struct mem_section *__nr_to_section(unsigned long nr) · 4 unmodified lines
12191234 return NULL;
12201235 return &mem_section[SECTION_NR_TO_ROOT(nr)][nr & SECTION_ROOT_MASK];
12211236 }
1222−extern int __section_nr(struct mem_section* ms);
1223−extern unsigned long usemap_size(void);
1237+extern unsigned long __section_nr(struct mem_section *ms);
1238+extern size_t mem_section_usage_size(void);
12241239
12251240 /*
12261241 * We use the lower bits of the mem_map pointer to store
@@ -1238,7 +1253,8 @@ extern unsigned long usemap_size(void); · 11 unmodified lines
12381253 #define SECTION_MARKED_PRESENT (1UL<<0)
12391254 #define SECTION_HAS_MEM_MAP (1UL<<1)
12401255 #define SECTION_IS_ONLINE (1UL<<2)
1241−#define SECTION_MAP_LAST_BIT (1UL<<3)
1256+#define SECTION_IS_EARLY (1UL<<3)
1257+#define SECTION_MAP_LAST_BIT (1UL<<4)
12421258 #define SECTION_MAP_MASK (~(SECTION_MAP_LAST_BIT-1))
12431259 #define SECTION_NID_SHIFT 3
12441260
@@ -1264,6 +1280,11 @@ static inline int valid_section(struct mem_section *section) · 19 unmodified lines
12641280 return (section && (section->section_mem_map & SECTION_HAS_MEM_MAP));
12651281 }
12661282
1283+static inline int early_section(struct mem_section *section)
1284+{
1285+ return (section && (section->section_mem_map & SECTION_IS_EARLY));
1286+}
1287+
12671288 static inline int valid_section_nr(unsigned long nr)
12681289 {
12691290 return valid_section(__nr_to_section(nr));
@@ -1291,14 +1312,42 @@ static inline struct mem_section *__pfn_to_section(unsigned long pfn) · 21 unmodified lines
12911312 return __nr_to_section(pfn_to_section_nr(pfn));
12921313 }
12931314
1294−extern int __highest_present_section_nr;
1315+extern unsigned long __highest_present_section_nr;
1316+
1317+static inline int subsection_map_index(unsigned long pfn)
1318+{
1319+ return (pfn & ~(PAGE_SECTION_MASK)) / PAGES_PER_SUBSECTION;
1320+}
1321+
1322+#ifdef CONFIG_SPARSEMEM_VMEMMAP
1323+static inline int pfn_section_valid(struct mem_section *ms, unsigned long pfn)
1324+{
1325+ int idx = subsection_map_index(pfn);
1326+
1327+ return test_bit(idx, ms->usage->subsection_map);
1328+}
1329+#else
1330+static inline int pfn_section_valid(struct mem_section *ms, unsigned long pfn)
1331+{
1332+ return 1;
1333+}
1334+#endif
12951335
12961336 #ifndef CONFIG_HAVE_ARCH_PFN_VALID
12971337 static inline int pfn_valid(unsigned long pfn)
12981338 {
1339+ struct mem_section *ms;
1340+
12991341 if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
13001342 return 0;
1301− return valid_section(__nr_to_section(pfn_to_section_nr(pfn)));
1343+ ms = __nr_to_section(pfn_to_section_nr(pfn));
1344+ if (!valid_section(ms))
1345+ return 0;
1346+ /*
1347+ * Traditionally early sections always returned pfn_valid() for
1348+ * the entire section-sized span.
1349+ */
1350+ return early_section(ms) || pfn_section_valid(ms, pfn);
13021351 }
13031352 #endif
13041353
@@ -1330,6 +1379,7 @@ void sparse_init(void); · 25 unmodified lines
13301379 #define sparse_init() do {} while (0)
13311380 #define sparse_index_init(_sec, _nid) do {} while (0)
13321381 #define pfn_present pfn_valid
1382+#define subsection_map_init(_pfn, _nr_pages) do {} while (0)
13331383 #endif /* CONFIG_SPARSEMEM */
13341384
13351385 /*
include/linux/node.h+2−12
@@ -137,10 +137,7 @@ static inline int register_one_node(int nid) · 136 unmodified lines
137137 extern void unregister_one_node(int nid);
138138 extern int register_cpu_under_node(unsigned int cpu, unsigned int nid);
139139 extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid);
140−extern int register_mem_sect_under_node(struct memory_block *mem_blk,
141− void *arg);
142−extern int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
143− unsigned long phys_index);
140+extern void unregister_memory_block_under_nodes(struct memory_block *mem_blk);
144141
145142 extern int register_memory_node_under_compute_node(unsigned int mem_nid,
146143 unsigned int cpu_nid,
@@ -171,15 +168,8 @@ static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid) · 24 unmodified lines
171168 {
172169 return 0;
173170 }
174−static inline int register_mem_sect_under_node(struct memory_block *mem_blk,
175− void *arg)
171+static inline void unregister_memory_block_under_nodes(struct memory_block *mem_blk)
176172 {
177− return 0;
178−}
179−static inline int unregister_mem_sect_under_nodes(struct memory_block *mem_blk,
180− unsigned long phys_index)
181−{
182− return 0;
183173 }
184174
185175 static inline void register_hugetlbfs_with_node(node_registration_func_t reg,
include/linux/sysctl.h+7−0
@@ -37,6 +37,13 @@ struct ctl_table_root; · 36 unmodified lines
3737 struct ctl_table_header;
3838 struct ctl_dir;
3939
40+/* Keep the same order as in fs/proc/proc_sysctl.c */
41+#define SYSCTL_ZERO ((void *)&sysctl_vals[0])
42+#define SYSCTL_ONE ((void *)&sysctl_vals[1])
43+#define SYSCTL_INT_MAX ((void *)&sysctl_vals[2])
44+
45+extern const int sysctl_vals[];
46+
4047 typedef int proc_handler (struct ctl_table *ctl, int write,
4148 void __user *buffer, size_t *lenp, loff_t *ppos);
4249

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