Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux “在哪里?”;释放未使用的内核内存”;来自_Linux_Linux Kernel_Dmesg - Fatal编程技术网

Linux “在哪里?”;释放未使用的内核内存”;来自

Linux “在哪里?”;释放未使用的内核内存”;来自,linux,linux-kernel,dmesg,Linux,Linux Kernel,Dmesg,我经常看到从dmesg中释放未使用的内核内存:xxxK(…),但是在grep/rg的帮助下,我从内核源代码中永远找不到这个日志 它是从哪里来的?这行文本不是作为一个完整的字符串存在的,因此您无法将其grep。 当init/main.c中的free\u initmem()调用free\u initmem\u default()时,这一切都会发生 该行源自include/linux/mm.h中的free\u initmem\u default(): /* * Default method to f

我经常看到
dmesg
中释放未使用的内核内存:xxxK(…)
,但是在grep/rg的帮助下,我从内核源代码中永远找不到这个日志


它是从哪里来的?

这行文本不是作为一个完整的字符串存在的,因此您无法将其grep。
init/main.c中的free\u initmem()调用free\u initmem\u default()时,这一切都会发生

该行源自include/linux/mm.h中的free\u initmem\u default()

/*
 * Default method to free all the __init memory into the buddy system.
 * The freed pages will be poisoned with pattern "poison" if it's within
 * range [0, UCHAR_MAX].
 * Return pages freed into the buddy system.
 */
static inline unsigned long free_initmem_default(int poison)
{
    extern char __init_begin[], __init_end[];

    return free_reserved_area(&__init_begin, &__init_end,
                  poison, "unused kernel");
}
unsigned long free_reserved_area(void *start, void *end, int poison, const char *s)
{
    void *pos;
    unsigned long pages = 0;

    ...

    if (pages && s)
        pr_info("Freeing %s memory: %ldK\n",
            s, pages << (PAGE_SHIFT - 10));

    return pages;
}
该文本的其余部分来自mm/page\u alloc.c中的自由\u保留\u区域()

/*
 * Default method to free all the __init memory into the buddy system.
 * The freed pages will be poisoned with pattern "poison" if it's within
 * range [0, UCHAR_MAX].
 * Return pages freed into the buddy system.
 */
static inline unsigned long free_initmem_default(int poison)
{
    extern char __init_begin[], __init_end[];

    return free_reserved_area(&__init_begin, &__init_end,
                  poison, "unused kernel");
}
unsigned long free_reserved_area(void *start, void *end, int poison, const char *s)
{
    void *pos;
    unsigned long pages = 0;

    ...

    if (pages && s)
        pr_info("Freeing %s memory: %ldK\n",
            s, pages << (PAGE_SHIFT - 10));

    return pages;
}
unsigned long free\u reserved\u区域(void*start、void*end、int-poison、const-char*s)
{
void*pos;
无符号长页=0;
...
如果(第页和第页)
pr_信息(“正在释放%s内存:%ldK\n”,
s、 页数