Date: Wed, 08 Aug 2001 03:23:46 -0700 From: Terry Lambert <tlambert2@mindspring.com> To: craig <craiglei@pasia.com.cn> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Why page enable in Kernel space? Message-ID: <3B711332.2A6DBE1F@mindspring.com> References: <002001c11fab$19acaca0$051a0a0a@fd.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> craig wrote: > In general a address in a process is just a linear address which > refer to physical address indirectly by page directory. Or a virtual address that does not have a physical page behind it. Some kernel memory is swappable, and some is overcommitted, and the pages backing the page entries aren't committed until they are needed. > This is reasonable in user space. However is it necessary to do > such thing in kernel? Only if you want to be able to handle differential loads. 8-). > It is sure to have penalty when converting a linear address to > physical thing. Actually, the hardware does it for free, for the most part. > Is it worth doing such thing in kernel. Yes. Consider how you would write fault on copyout in order to cause the user space buffer you were copying kernel data to to be there to be written to otherwise. Also, realize that the KVA space stops where the user space ends, and that the virtual address spaces are effectively butted up against each other, with the user space being readable/writable from the kernel, but not vice versa. This would be very hard to do; in fact, you would end up doing a lot more work for paging, and you would have to ptov/vtop to convert between kernel and user space addresses, where right now, you only have to do that to give physical addresses to devices. Likewise, the virtual space doesn't care if the physical space is fragmented (and most drivers will do scatter/gather anyway), but real fragmentation might mean that you would be unable to allocate kernel memory larger than your largest fragment (you could do it, but you'd have to defrag physical memory, which could be hard). > I think the performance is the most important in kernel, other > thing is second. I remember in linux linear address is real > physical address in kernel space(is it true?). Why freebsd > does not do in the same way? It's not true; Linux does the same thing FreeBSD does. When a protected mode OS that uses VM starts up, it generally loads itself into memory, builds a virtual address space that looks exactly like the physical address space where it was loaded, but relocated, and then relocates itself and starts using the virtual memory system instead of the physical one. This is really a gross oversimplification, but you get the idea. If you want to get a better understanding of this, get the book: Protected Mode Software Architecture Tom Shanley MindShare, Inc. Addison-Wesley Publishing Co. ISBN: 020155447X It costs about US$30, new on Amazon. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3B711332.2A6DBE1F>