Memory management 当前->;mm在linux内核中给出NULL
我想遍历页面表,所以我访问了current->mm,但它给出了NULL值 我在linux内核3.9上工作,我不明白current->mm怎么可能是零Memory management 当前->;mm在linux内核中给出NULL,memory-management,linux-kernel,Memory Management,Linux Kernel,我想遍历页面表,所以我访问了current->mm,但它给出了NULL值 我在linux内核3.9上工作,我不明白current->mm怎么可能是零 我在这里错过了什么吗?这意味着您处于内核线程中 在Linux中,内核线程没有mm结构。内核线程从上一个用户线程借用mm,并将其记录在活动线程中。因此您应该改用active_mm 更多详细信息: 在/kernel/sched/core.c中可以找到以下代码: static inline void context_switch(struct rq *
我在这里错过了什么吗?这意味着您处于内核线程中 在Linux中,内核线程没有mm结构。内核线程从上一个用户线程借用mm,并将其记录在活动线程中。因此您应该改用active_mm
更多详细信息: 在
/kernel/sched/core.c
中可以找到以下代码:
static inline void
context_switch(struct rq *rq, struct task_struct *prev,
struct task_struct *next)
{
...
if (!mm) {
next->active_mm = oldmm;
atomic_inc(&oldmm->mm_count);
enter_lazy_tlb(oldmm, next);
} else
switch_mm(oldmm, mm, next);
...
}
如果下一个线程没有mm(内核线程),调度程序将不会切换mm,而只是重用上一个线程的mm。需要活动的\u mm分配:通过“借用”可以避免调用
开关\u mm()
,从而导致TLB刷新上一个任务使用的mm_结构
,并将其放置在任务struct中→活动\u mm
。这项技术大大改进了上下文切换时间