This patch series enhances the weighted interleave policy in mempolicy to support memory hotplug, ensuring that newly added memory nodes are properly recognized and integrated into the weighted interleave mechanism. The weighted interleave policy distributes page allocations across multiple NUMA nodes based on their performance weight, optimizing memory bandwidth utilization. The weight values for each node are configured through sysfs. However, the existing implementation only created sysfs entries at initialization, leading to the following issues: Unnecessary sysfs entries: Nodes without memory were included in sysfs at boot. Missing hotplug support: Nodes that became online after initialization were not recognized, causing incomplete interleave configurations. To resolve these issues, the first patch introduces two key changes: Filtered sysfs creation at initialization Only nodes that are online and have memory are registered. Dynamic sysfs updates for hotplugged nodes New memory nodes are recognized and integrated via the memory hotplug mechanism. Subsequent patches refine this functionality: Patch 2: Enables sysfs registration for memory nodes added via hotplug. Patch 3: Fixes a race condition that caused duplicate sysfs entries when registering interleave settings. Patch 4: Ensures proper deallocation of kobjects and memory, preventing resource leaks in mempolicy_sysfs_init(). With these changes, the weighted interleave policy can dynamically adapt to memory hotplug events, improving NUMA memory management and system stability. Patch Summary [PATCH 1/4] mm/mempolicy: Support memory hotplug in weighted interleave Adds dynamic sysfs integration for memory hotplug in weighted interleave. [PATCH 2/4] mm/mempolicy: Enable sysfs support for memory hotplug in weighted interleave Implements sysfs attribute registration for newly detected memory nodes. [PATCH 3/4] mm/mempolicy: Fix duplicate node addition in sysfs for weighted interleave Prevents redundant sysfs entries when configuring interleave settings. [PATCH 4/4] mm/mempolicy: Fix memory leaks in mempolicy_sysfs_init() Ensures proper kobject and memory deallocation to prevent resource leaks. These patches have been tested to ensure correct memory node detection, proper sysfs updates, and stability improvements in memory hotplug scenarios. mm/mempolicy.c | 172 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 122 insertions(+), 50 deletions(-) base-commit: 7eb172143d5508b4da468ed59ee857c6e5e01da6 -- 2.34.1