“释放未使用的内核内存"在哪里?来自? [英] Where does "Freeing unused kernel memory" come from?
问题描述
我经常看到从
,但是我从没有从内核源代码中找到该日志.grep/rg的帮助. dmesg
释放未使用的内核内存:xxxK(......)
I often see Freeing unused kernel memory: xxxK (......)
from dmesg
, but I can never find this log from kernel source code with the help of grep/rg.
它来自哪里?
推荐答案
该行文本不作为单个完整字符串存在,因此无法对它进行grep.
当 init/main.c 中的 free_initmem()调用 free_initmem_default()时,这一切都会滚动.
That line of text does not exist as a single, complete string, hence your failure to grep it.
This all gets rolling when free_initmem() in init/main.c calls free_initmem_default().
有问题的行源自 include/linux/mm.h 中的 free_initmem_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");
}
该文本的其余部分来自 mm/page_alloc.c 中的 free_reserved_area():
The rest of that text is from free_reserved_area() in mm/page_alloc.c:
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;
}
(v5.2中的代码摘录)
(Code excerpts from v5.2)
这篇关于“释放未使用的内核内存"在哪里?来自?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!