Re: memory descriptor and kernel threads

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

 



On Thu, 2007-04-19 at 09:15 +0530, Adil Mujeeb wrote:
> Hi All,
> I have queries related to mm_struct and kernel thread.
>  
> As per my understanding mm_struct represent the process's address
> space (i.e. 0-3GB area).
>  
> Some of the points mentioned in the Linux kernel Development (by
> Robert Love) book about mm_struct and kernel thread are :
>  
> "Kernel threads do not have a process address space and therefore do
> not have an associated memory descriptor. Thus, the mm field of a
> kernel thread's process descriptor is NULL. "
>  
> "Because kernel threads do not have any pages in user-space, they do
> not really deserve their own memory descriptor and page tables (page
> tables are discussed later in the chapter). Despite this, kernel
> threads need some of the data, such as the page tables, even to access
> kernel memory."
>  
> "Kernel threads do not have an address space and mm is NULL.
> Therefore, when a kernel thread is scheduled, the kernel notices that
> mm is NULL and keeps the previous process's address space loaded. The
> kernel then updates the active_mm field of the kernel thread's process
> descriptor to refer to the previous process's memory descriptor. The
> kernel thread can then use the previous process's page tables as
> needed."
>  
> Now my queries are:
> 1. First it is mentioned that the kernel threads dont have any page in
> user space and hence they dont deserve memory desriptor and page
> tables and in the next line it says it needs some data such as page
> tables to access kernel memory. What page table it is referring here??
> Every process has its own page table for mapping the virtual to
> physical address, why kernel thread requires that?

the upper 256 entries of the page table (ie the pgds used for mapping 3g
to 4g) are same for all the processes....ie the same entries are copied
in every processes page tables when it is created.

now thw kernel thread is only goinng to access address > 3gb ...and as
these entries are same for all processes the kernel thread can use the
previous process's page tables....



>  
> 2. does kernel thread run in a process context? I mean it says when a
> kernel thread is scheduled, it keeps the previous process's address
> space loaded.
>  

yes it runs in process context.

> 3. Further it is mentioned in the same book as "Because kernel threads
> do not access user-space memory, they make use of only the information
> in the address space pertaining to kernel memory, which is the same
> for all processes.". That means the process's mm_struct or the page
> table contains the information about kernel memory?

yes..as I said earlier.

Hope it helps!!!


--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at 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