Because it mades no sense, since the kernel itself is responsible for maintaining the page tables up to date. When a page failure occurs (that is, the MMU doesn't know how to translate a logical adress to a physical one), the page failure routine must be directly accessible for the processor in order to update the TLBs. If this routine (which is part of the kernel) is on a paged memory zone, and it's corresponding page(s) are not in the TLB (which is quite easy), then you enter in an endless loop of page failures: I can't find this page A, so I'm going to ask the kernel, but first I must find out where's this other page B, which forces me to ask the kernel, and then I have to find out where's page B again, which forces me to ask the kernel, and... and so on.
There are parts of the kernel that perhaps could be in a paged memory zone, but that depends on the architecture, and tends to complicate things a lot. It's much easier to have all the kernel in a non-paged memory zone.
Because it mades no sense, since the kernel itself is responsible for maintaining the page tables up to date. When a page failure occurs (that is, the MMU doesn't know how to translate a logical adress to a physical one), the page failure routine must be directly accessible for the processor in order to update the TLBs. If this routine (which is part of the kernel) is on a paged memory zone, and it's corresponding page(s) are not in the TLB (which is quite easy), then you enter in an endless loop of page failures: I can't find this page A, so I'm going to ask the kernel, but first I must find out where's this other page B, which forces me to ask the kernel, and then I have to find out where's page B again, which forces me to ask the kernel, and... and so on.
There are parts of the kernel that perhaps could be in a paged memory zone, but that depends on the architecture, and tends to complicate things a lot. It's much easier to have all the kernel in a non-paged memory zone.
Of course the code needs a stack and at least some of the data to run, e.g. the page tables and process information needed to do its work in an efficient way. Data that gets big enough to be a problem is shrunk automatically and actively: if free memory falls below a watermark, caches such as the dentry cache are purged from old entries.
The general rule is: if something is unimportant enough that you can tolerate it to be paged out, it belongs into user space. The kernel only is a place for non-pageable things or things that don't work in user space for another reason. Apart from that coding for user space is far more comfortable, no memory limitations, memory protection, easy debugging, ...
I'm taking an OS class right now, so I'm learning but I still don't understand all the interesting details. When you say that the kernel exists in a non-paged memory zone, does this mean that the kernel exists in pages that are "pinned" and cannot be swapped out, or does it exist in some sort of memory completely outside of the virtual memory system? Or am I totally off base here?
It just means that, when the processor runs on kernel mode, the MMU is disabled. So, when the processor issues a memory access in kernel mode, that adress must be a physical one. The kernel is always stored in a known memory zone, which is not "pageable" for the kernel. This memory zone is like any other memory zone, only difference is the kernel doesn't count it as a pageable one (or, to put it in another way, it's not on the list of available pages). In fact, we can say that this memory is /outside/ the virtual memory system, because the kernel doesn't provide virtual memory support for his own pages.
the addresses are virtual, not physical, though. i.e. the MMU is used to map the physical memory at another -- constant -- place in the linear address space. and not switching off the MMU is important for user space accesses as well, the kernel's user space accessor functions are far easier and faster, if they can use the MMU.
hi guys,
as far as i heard , even kernel has a seperate page table.
Linear address of all the process is divided into two for user level and kernel level. all the address above 0xc0000000 are addressed in kernel page table. i am new to kernel coding, but i am sure in this. what's ur suggestion...........
Because it mades no sense, si
Because it mades no sense, since the kernel itself is responsible for maintaining the page tables up to date. When a page failure occurs (that is, the MMU doesn't know how to translate a logical adress to a physical one), the page failure routine must be directly accessible for the processor in order to update the TLBs. If this routine (which is part of the kernel) is on a paged memory zone, and it's corresponding page(s) are not in the TLB (which is quite easy), then you enter in an endless loop of page failures: I can't find this page A, so I'm going to ask the kernel, but first I must find out where's this other page B, which forces me to ask the kernel, and then I have to find out where's page B again, which forces me to ask the kernel, and... and so on.
There are parts of the kernel that perhaps could be in a paged memory zone, but that depends on the architecture, and tends to complicate things a lot. It's much easier to have all the kernel in a non-paged memory zone.
Because it mades no sense
Because it mades no sense, since the kernel itself is responsible for maintaining the page tables up to date. When a page failure occurs (that is, the MMU doesn't know how to translate a logical adress to a physical one), the page failure routine must be directly accessible for the processor in order to update the TLBs. If this routine (which is part of the kernel) is on a paged memory zone, and it's corresponding page(s) are not in the TLB (which is quite easy), then you enter in an endless loop of page failures: I can't find this page A, so I'm going to ask the kernel, but first I must find out where's this other page B, which forces me to ask the kernel, and then I have to find out where's page B again, which forces me to ask the kernel, and... and so on.
There are parts of the kernel that perhaps could be in a paged memory zone, but that depends on the architecture, and tends to complicate things a lot. It's much easier to have all the kernel in a non-paged memory zone.
Confusing the meaning...
It's good that the kernel code space is in non-paged memory zone, but "and the kernel data space & stack space"?
It's better that they are in paged memory zone.
What kmalloc & allocate_stack about?
code without data??
Of course the code needs a stack and at least some of the data to run, e.g. the page tables and process information needed to do its work in an efficient way. Data that gets big enough to be a problem is shrunk automatically and actively: if free memory falls below a watermark, caches such as the dentry cache are purged from old entries.
The general rule is: if something is unimportant enough that you can tolerate it to be paged out, it belongs into user space. The kernel only is a place for non-pageable things or things that don't work in user space for another reason. Apart from that coding for user space is far more comfortable, no memory limitations, memory protection, easy debugging, ...
More input
I'm taking an OS class right now, so I'm learning but I still don't understand all the interesting details. When you say that the kernel exists in a non-paged memory zone, does this mean that the kernel exists in pages that are "pinned" and cannot be swapped out, or does it exist in some sort of memory completely outside of the virtual memory system? Or am I totally off base here?
What it means
It just means that, when the processor runs on kernel mode, the MMU is disabled. So, when the processor issues a memory access in kernel mode, that adress must be a physical one. The kernel is always stored in a known memory zone, which is not "pageable" for the kernel. This memory zone is like any other memory zone, only difference is the kernel doesn't count it as a pageable one (or, to put it in another way, it's not on the list of available pages). In fact, we can say that this memory is /outside/ the virtual memory system, because the kernel doesn't provide virtual memory support for his own pages.
addresses
the addresses are virtual, not physical, though. i.e. the MMU is used to map the physical memory at another -- constant -- place in the linear address space. and not switching off the MMU is important for user space accesses as well, the kernel's user space accessor functions are far easier and faster, if they can use the MMU.
kernel page table
hi guys,
as far as i heard , even kernel has a seperate page table.
Linear address of all the process is divided into two for user level and kernel level. all the address above 0xc0000000 are addressed in kernel page table. i am new to kernel coding, but i am sure in this. what's ur suggestion...........