Re: active_mm versus mm

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Roy

> I fail to understand the difference between task->mm and
> task->active_mm. I've noticed that upon forking a task, both mm and
> active_mm get the same memory descriptor.

Well, here is my understanding. task_struct->mm points to memory 
descriptor which is unique to each process (unless they are on the same 
thread group, forked with CLONE_VM). active_mm points to the *actual* 
memory descriptor used by the process when it is executed.

So why it is separated? IMHO the reason is to identify which process is 
kernel thread (doesn't own a process address space) and which one is 
normal process (owns a process address space). As you can see on 
functions related with context switching, by checking task_struct->mm, 
the scheduler can decide whether it is going to switch onto kernel 
thread or not. if 

it is NULL, then the process doesn't have process address space, in 
other word this is a kernel thread. But you also aware that even kernel 
threads don't acess user space memory, it still needs to access kernel 
space. because kernel space is 100% identical for every process, kernel 
thread can freely use memory descriptor (mm) owned by previously 
running process. All the kernel thread needed is page tables 
referencing toward virtual address bigger than PAGE_OFFSET, other are 
simply ignored by it is assumed that kernel thread doesn't need to 
access user space (perhaps it is somehow can be abused?)

Hope it helps answering your question

regards

Mulyadi


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux