#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/gfp.h>
#include <linux/mm.h>
int __init freepage_init()
{
unsigned long page;
page = __get_free_pages(GFP_KERNEL,3); //8 page
if(!page){
//no enough space
return -ENOMEM;
}
printk("<1>the vaddr of the first page is <%lx>..",page);
free_pages(page,3);
return 0;
}
void __exit freepage_exit()
{
return;
}
module_init(freepage_init);
module_exit(freepage_exit);
MODULE_LICENSE("GPL");
Makefile:
obj-m := freepage.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules