должен выводить значение page
напрямую, а не адрес page
.
, как показано ниже:
struct page *page;
page = alloc_pages(GFP_KERNEL, 0);
pr_info("physical address GFP_KERNEL - %p\n", page);
page = alloc_pages(GFP_HIGHUSER, 2);
pr_info("physical address of GFP_High - %p\n", page);
Полный код модуля:
#include <linux/kernel.h>
#include <linux/module.h>
struct page *page1;
struct page *page2;
static int __init test_alloc_pages_init(void)
{
struct page *page;
page = alloc_pages(GFP_KERNEL, 0);
pr_info("physical address GFP_KERNEL - %p\n", page);
page1 = page;
page = alloc_pages(GFP_HIGHUSER, 2);
pr_info("physical address of GFP_High - %p\n", page);
page2 = page;
return 0;
}
static void __exit test_alloc_pages_exit(void)
{
if (page1) {
pr_info("free page1: %p\n", page1);
__free_pages(page1, 0);
}
if (page2) {
pr_info("free page2: %p\n", page2);
__free_pages(page2, 2);
}
return;
}
module_init(test_alloc_pages_init);
module_exit(test_alloc_pages_exit);
MODULE_LICENSE("GPL");
dmesg info:
[117582.127432] physical address GFP_KERNEL - ffffea002e1cf2c0
[117582.127434] physical address of GFP_High - ffffea002e0ec500
[117584.214921] free page1: ffffea002e1cf2c0
[117584.214922] free page2: ffffea002e0ec500