"tests/git@developer.sourcefind.cn:OpenDAS/apex.git" did not exist on "80e0143e20c4addac2837440b77852f9b99b6538"
Commit 5db263ce authored by Jonas Kaufmann's avatar Jonas Kaufmann
Browse files

fix farmem module not draining all memory

parent 7c994f2b
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include<linux/kernel.h> #include<linux/kernel.h>
#include <linux/memory_hotplug.h> #include <linux/memory_hotplug.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/pfn_t.h>
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_AUTHOR("Antoine Kaufmann"); MODULE_AUTHOR("Antoine Kaufmann");
...@@ -41,7 +42,9 @@ static void do_drain_node(int nid) ...@@ -41,7 +42,9 @@ static void do_drain_node(int nid)
0); 0);
if (p) if (p)
eaten += PAGE_SIZE; eaten += PAGE_SIZE;
} while (p); }
/* Local memory is drained before farmem, therefore the following works. Tested on kernel 5.15.69.*/
while (p && pfn_t_to_phys(page_to_pfn_t(p)) < base_addr);
printk(KERN_INFO "drained %lu bytes\n", eaten); printk(KERN_INFO "drained %lu bytes\n", eaten);
} }
...@@ -69,6 +72,10 @@ static int __init farmem_mod_init(void) ...@@ -69,6 +72,10 @@ static int __init farmem_mod_init(void)
} }
node_set_online(nnid); node_set_online(nnid);
/* Some local memory still remains usable, drain again to get it all. */
if (drain_node)
do_drain_node(nnid);
return 0; return 0;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment