Lines Matching +full:non +full:- +full:overlap +full:- +full:time
1 // SPDX-License-Identifier: GPL-2.0-or-later
26 for (i = 0; i < ARRAY_SIZE(mi->blk); i++) in numa_nodemask_from_meminfo()
27 if (mi->blk[i].start != mi->blk[i].end && in numa_nodemask_from_meminfo()
28 mi->blk[i].nid != NUMA_NO_NODE) in numa_nodemask_from_meminfo()
29 node_set(mi->blk[i].nid, *nodemask); in numa_nodemask_from_meminfo()
33 * numa_reset_distance - Reset NUMA distance table
69 return -ENOMEM; in numa_alloc_distance()
85 * numa_set_distance - Set NUMA distance from one NUMA to another
99 * at the time of table creation or @distance doesn't make sense, the call
142 pr_warn("Warning: invalid memblk node %d [mem %#010Lx-%#010Lx]\n", in numa_add_memblk_to()
143 nid, start, end - 1); in numa_add_memblk_to()
147 if (mi->nr_blks >= NR_NODE_MEMBLKS) { in numa_add_memblk_to()
149 return -EINVAL; in numa_add_memblk_to()
152 mi->blk[mi->nr_blks].start = start; in numa_add_memblk_to()
153 mi->blk[mi->nr_blks].end = end; in numa_add_memblk_to()
154 mi->blk[mi->nr_blks].nid = nid; in numa_add_memblk_to()
155 mi->nr_blks++; in numa_add_memblk_to()
160 * numa_remove_memblk_from - Remove one numa_memblk from a numa_meminfo
164 * Remove @idx'th numa_memblk from @mi by shifting @mi->blk[] and
165 * decrementing @mi->nr_blks.
169 mi->nr_blks--; in numa_remove_memblk_from()
170 memmove(&mi->blk[idx], &mi->blk[idx + 1], in numa_remove_memblk_from()
171 (mi->nr_blks - idx) * sizeof(mi->blk[0])); in numa_remove_memblk_from()
175 * numa_move_tail_memblk - Move a numa_memblk from one numa_meminfo to another
183 dst->blk[dst->nr_blks++] = src->blk[idx]; in numa_move_tail_memblk()
188 * numa_add_memblk - Add one numa_memblk to numa_meminfo
196 * 0 on success, -errno on failure.
204 * numa_cleanup_meminfo - Cleanup a numa_meminfo
211 * 0 on success, -errno on failure.
220 for (i = 0; i < mi->nr_blks; i++) { in numa_cleanup_meminfo()
221 struct numa_memblk *bi = &mi->blk[i]; in numa_cleanup_meminfo()
225 bi->start, bi->end - bi->start)) { in numa_cleanup_meminfo()
226 numa_move_tail_memblk(&numa_reserved_meminfo, i--, mi); in numa_cleanup_meminfo()
230 /* make sure all non-reserved blocks are inside the limits */ in numa_cleanup_meminfo()
231 bi->start = max(bi->start, low); in numa_cleanup_meminfo()
233 /* preserve info for non-RAM areas above 'max_pfn': */ in numa_cleanup_meminfo()
234 if (bi->end > high) { in numa_cleanup_meminfo()
235 numa_add_memblk_to(bi->nid, high, bi->end, in numa_cleanup_meminfo()
237 bi->end = high; in numa_cleanup_meminfo()
241 if (bi->start >= bi->end) in numa_cleanup_meminfo()
242 numa_remove_memblk_from(i--, mi); in numa_cleanup_meminfo()
246 for (i = 0; i < mi->nr_blks; i++) { in numa_cleanup_meminfo()
247 struct numa_memblk *bi = &mi->blk[i]; in numa_cleanup_meminfo()
249 for (j = i + 1; j < mi->nr_blks; j++) { in numa_cleanup_meminfo()
250 struct numa_memblk *bj = &mi->blk[j]; in numa_cleanup_meminfo()
258 if (bi->end > bj->start && bi->start < bj->end) { in numa_cleanup_meminfo()
259 if (bi->nid != bj->nid) { in numa_cleanup_meminfo()
260 pr_err("node %d [mem %#010Lx-%#010Lx] overlaps with node %d [mem %#010Lx-%#010Lx]\n", in numa_cleanup_meminfo()
261 bi->nid, bi->start, bi->end - 1, in numa_cleanup_meminfo()
262 bj->nid, bj->start, bj->end - 1); in numa_cleanup_meminfo()
263 return -EINVAL; in numa_cleanup_meminfo()
265 pr_warn("Warning: node %d [mem %#010Lx-%#010Lx] overlaps with itself [mem %#010Lx-%#010Lx]\n", in numa_cleanup_meminfo()
266 bi->nid, bi->start, bi->end - 1, in numa_cleanup_meminfo()
267 bj->start, bj->end - 1); in numa_cleanup_meminfo()
272 * between which don't overlap with memory on other in numa_cleanup_meminfo()
275 if (bi->nid != bj->nid) in numa_cleanup_meminfo()
277 start = min(bi->start, bj->start); in numa_cleanup_meminfo()
278 end = max(bi->end, bj->end); in numa_cleanup_meminfo()
279 for (k = 0; k < mi->nr_blks; k++) { in numa_cleanup_meminfo()
280 struct numa_memblk *bk = &mi->blk[k]; in numa_cleanup_meminfo()
282 if (bi->nid == bk->nid) in numa_cleanup_meminfo()
284 if (start < bk->end && end > bk->start) in numa_cleanup_meminfo()
287 if (k < mi->nr_blks) in numa_cleanup_meminfo()
289 pr_info("NUMA: Node %d [mem %#010Lx-%#010Lx] + [mem %#010Lx-%#010Lx] -> [mem %#010Lx-%#010Lx]\n", in numa_cleanup_meminfo()
290 bi->nid, bi->start, bi->end - 1, bj->start, in numa_cleanup_meminfo()
291 bj->end - 1, start, end - 1); in numa_cleanup_meminfo()
292 bi->start = start; in numa_cleanup_meminfo()
293 bi->end = end; in numa_cleanup_meminfo()
294 numa_remove_memblk_from(j--, mi); in numa_cleanup_meminfo()
299 for (i = mi->nr_blks; i < ARRAY_SIZE(mi->blk); i++) { in numa_cleanup_meminfo()
300 mi->blk[i].start = mi->blk[i].end = 0; in numa_cleanup_meminfo()
301 mi->blk[i].nid = NUMA_NO_NODE; in numa_cleanup_meminfo()
308 * Mark all currently memblock-reserved physical memory (which covers the
309 * kernel's own memory ranges) as hot-unswappable.
321 * At this time, all memory regions reserved by memblock are in numa_clear_kernel_node_hotplug()
335 ret = memblock_set_node(mb->start, mb->end - mb->start, in numa_clear_kernel_node_hotplug()
336 &memblock.reserved, mb->nid); in numa_clear_kernel_node_hotplug()
361 * on nodes that contain kernel memory - entire nodes in numa_clear_kernel_node_hotplug()
362 * become hot-unpluggable: in numa_clear_kernel_node_hotplug()
367 if (!node_isset(mb->nid, reserved_nodemask)) in numa_clear_kernel_node_hotplug()
370 memblock_clear_hotplug(mb->start, mb->end - mb->start); in numa_clear_kernel_node_hotplug()
382 return -EINVAL; in numa_register_meminfo()
384 for (i = 0; i < mi->nr_blks; i++) { in numa_register_meminfo()
385 struct numa_memblk *mb = &mi->blk[i]; in numa_register_meminfo()
387 memblock_set_node(mb->start, mb->end - mb->start, in numa_register_meminfo()
388 &memblock.memory, mb->nid); in numa_register_meminfo()
392 * At very early time, the kernel have to use some memory such as in numa_register_meminfo()
394 * node the kernel resides in should be un-hotpluggable. in numa_register_meminfo()
401 * If sections array is gonna be used for pfn -> nid mapping, check in numa_register_meminfo()
414 return -EINVAL; in numa_register_meminfo()
443 * We reset memblock back to the top-down direction in numa_memblks_init()
467 return (ma->start > mb->start) - (ma->start < mb->start); in cmp_memblk()
473 * numa_fill_memblks - Fill gaps in numa_meminfo memblks
478 * address range @start-@end
482 * NUMA_NO_MEMBLK : No memblks exist in address range @start-@end
494 * overlap start, end. The list is used to make in-place in numa_fill_memblks()
497 for (int i = 0; i < mi->nr_blks; i++) { in numa_fill_memblks()
498 struct numa_memblk *bi = &mi->blk[i]; in numa_fill_memblks()
500 if (memblock_addrs_overlap(start, end - start, bi->start, in numa_fill_memblks()
501 bi->end - bi->start)) { in numa_fill_memblks()
502 blk[count] = &mi->blk[i]; in numa_fill_memblks()
509 /* Sort the list of pointers in memblk->start order */ in numa_fill_memblks()
513 blk[0]->start = min(blk[0]->start, start); in numa_fill_memblks()
514 blk[count - 1]->end = max(blk[count - 1]->end, end); in numa_fill_memblks()
520 prev_end = blk[0]->end; in numa_fill_memblks()
524 if (prev_end >= curr->start) { in numa_fill_memblks()
525 if (prev_end < curr->end) in numa_fill_memblks()
526 prev_end = curr->end; in numa_fill_memblks()
528 curr->start = prev_end; in numa_fill_memblks()
529 prev_end = curr->end; in numa_fill_memblks()
540 for (i = 0; i < mi->nr_blks; i++) in meminfo_to_nid()
541 if (mi->blk[i].start <= start && mi->blk[i].end > start) in meminfo_to_nid()
542 return mi->blk[i].nid; in meminfo_to_nid()
552 * hot-added continue the search with reserved ranges. in phys_to_target_node()