"include/ck/utility/tuple.hpp" did not exist on "7a7fe160866b7b2893be698d77b70cc8cf754fb5"
Commit 0553b51a authored by Antoine Kaufmann's avatar Antoine Kaufmann
Browse files

images/farmem: add drain_node feature

This allocates/leaks all pages from the numa node before adding far memory in
there.
parent 8fec5474
#include<linux/module.h>
#include<linux/kernel.h>
#include <linux/memory_hotplug.h>
#include <linux/vmalloc.h>
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Antoine Kaufmann");
......@@ -11,10 +12,39 @@ MODULE_VERSION("0.1");
static unsigned long base_addr = 0;
static unsigned long size = 0;
static int nnid = 1;
static bool drain_node = false;
module_param(base_addr, ulong, 0);
module_param(size, ulong, 0);
module_param(nnid, int, 0);
module_param(drain_node, bool, 0);
/**
* drains all available memory from the specified numa node by allocating (and
* leaking) it
*/
static void do_drain_node(int nid)
{
unsigned long eaten;
struct page *p;
printk(KERN_INFO "draining node %d\n", nid);
if (nid == 0) {
printk(KERN_ALERT "draining node 0 is probably a bad idea\n");
}
/* start with large chunks and move to smaller ones */
eaten = 0;
do {
p = alloc_pages_node(nid,
GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY | GFP_NOWAIT | __GFP_THISNODE,
0);
if (p)
eaten += PAGE_SIZE;
} while (p);
printk(KERN_INFO "drained %lu bytes\n", eaten);
}
static int __init farmem_mod_init(void)
{
......@@ -29,6 +59,9 @@ static int __init farmem_mod_init(void)
panic("invalid numa node spcified");
}
if (drain_node)
do_drain_node(nnid);
rc = add_memory_driver_managed(nnid, base_addr, size,
"System RAM (farmem)", MHP_NONE);
if (rc) {
......
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