Message ID | 57bc9bb8823a295dc71d7e8ff8ae93a3af8c0be3.1683742429.git.alison.schofield@intel.com |
---|---|
State | New, archived |
Headers | show |
Series | Apply SRAT defined PXM to entire CFMWS | expand |
alison.schofield@ wrote: > From: Alison Schofield <alison.schofield@intel.com> > > Add support for removing memblks from numa_meminfo that are > within a start/end range, and of a node. > > numa_add_memblk() allows in kernel users to add a memblk to > a NUMA node. There is no method exposed to remove a memblk. > > The use case here is to allow the ACPI driver to remove > redundant memblks when it knows they exist, rather than > implementing a cleanup that needlessly walks all memblks > during a cleanup phase. Again this assumes a particular way to solve the memblk update problem, it's not clear that a remove method is the way to go versus an update method. I.e. its not clear to me where the "redundant" memblks appear. > numa_cleanup_meminfo() exists for merging memblks, however, > it only considers adjacent memblks, and, it actually moves the > memblks to numa_reserved_meminfo, before doing the cleanup. So either the algorithm for solving the extend memblks when they overlap CFMWS needs to be described here, or this patch needs to be squashed.
diff --git a/arch/x86/include/asm/numa.h b/arch/x86/include/asm/numa.h index 5f2b811f1a5f..cb8b9a8cae32 100644 --- a/arch/x86/include/asm/numa.h +++ b/arch/x86/include/asm/numa.h @@ -35,6 +35,7 @@ extern nodemask_t numa_nodes_parsed __initdata; extern int __init numa_add_memblk(int nodeid, u64 start, u64 end); extern void __init numa_set_distance(int from, int to, int distance); extern int __init numa_find_node(u64 start, u64 end); +extern void __init numa_remove_memblks(int node, u64 start, u64 end); static inline void set_apicid_to_node(int apicid, s16 node) { diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c index 62990977f720..42d70f01ca0a 100644 --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -239,6 +239,28 @@ int __init numa_find_node(u64 start, u64 end) return NUMA_NO_NODE; } +/** + * numa_remove_memblks - Remove memblocks from a node + * @node: node + * @start: start addr of memblks to remove + * @end: end addr of memblks to remove + * + * Remove any memblks of node within start/end range + */ +void __init numa_remove_memblks(int node, u64 start, u64 end) +{ + struct numa_meminfo *mi = &numa_meminfo; + + for (int i = 0; i < mi->nr_blks; i++) { + struct numa_memblk *bi = &mi->blk[i]; + + if (bi->nid != node) + continue; + if (start <= bi->start && end >= bi->end) + numa_remove_memblk_from(i--, &numa_meminfo); + } +} + /** * numa_cleanup_meminfo - Cleanup a numa_meminfo * @mi: numa_meminfo to clean up