Linux 内核如何创建 /proc/$pid/maps 文件?

How does the Linux kernel create the /proc/$pid/maps file?

我正在做一些内存自省,它要求我知道 proc/$pid/maps 是如何创建的。我对第 2750 行 http://lxr.free-electrons.com/source/fs/proc/base.c 中的代码感到有点困惑 我注意到此结构中有一个映射定义,但我想知道每个 pid_entry 哪个内核函数创建映射文件. link 到内核模块或代码块就足够了。

你对 link 做了一些奇怪的事情。

点击几个定义显示文件是按需生成的: https://github.com/torvalds/linux/blob/bcf876870b95592b52519ed4aafcf9d95999bc9c/fs/proc/task_mmu.c#L271

(至少对于常见的 mmu 情况)

常见问题:你为什么问?