Linux 内核函数“lookup_page_ext”返回 NULL

Linux 内核函数“lookup_page_ext”返回 NULL

我是 Linux 内核编程新手。我正在为 Linux kernel-6.0 编写一个内核模块

这是下面的代码

static int count_wired_pages(unsigned long start_pfn, unsigned long end_pfn)
{
    unsigned long pfn;
    int nr_pages=0, page_mt, count = 0;
    struct page *page;
    struct page_ext *page_ext;
    struct page_owner *page_owner;

    for (pfn = start_pfn; pfn < end_pfn; pfn++) {
        if (!pfn_valid(pfn))
            continue;
        /*some code*/

        page = pfn_to_page(pfn);
        page_ext = lookup_page_ext(page);
        if (unlikely(!page_ext))
            continue;

        if (!test_bit(PAGE_EXT_OWNER_ALLOCATED, &page_ext->flags))
            continue;

        page_owner = get_page_owner(page_ext);
        page_mt = gfp_migratetype(page_owner->gfp_mask);
        nr_pages = (1UL << page_owner->order);
        
        /*some code*/

}

在上面的代码中,我正在调用该函数lookup_page_ext()。在内核.config文件中,我启用了CONFIG_PAGE_EXTENSIONCONFIG_PAGE_OWNER。另外,我还添加了EXPORT_SYMBOL函数lookup_page_ext(),以便它对我的模块可见。

尽管完成了所有这些操作,该函数还是返回了NULL。我有什么遗漏的吗?

相关内容