On 7/22/05, mark brown <markbrowni1000@xxxxxxxxx> wrote: > > Mulyadi Santosa <mulyadi.santosa@xxxxxxxxx> wrote: > > AFAIK, user level mem. requests is deferred until they > are actually needed, at least Understanding the Linux > Kernel book says so... > Yes thats true for user level memory requests ... > > yes, IMHO this is correct. Like Fawaad said, memory > > area that is mapped into kernel address space (above PAGE_OFFSET) always > > has same virtual address no matter what context you are in (process > > context, interrupt context. In this case, since module is also a part > > of kernel, any allocation done via kmalloc is also mapped on kernel > > address space, thus has constant virtual address on every situation. > > Can you give me a pointer in the kernel sources? I > think buddy allcator is responsible for it. i.e. is it > done at mm initialization phase or not? The virtual address coresponding to a physical address for the kernel module is always the same ..... that doesn't depends on the contexts ...... I think the __va and __pa are well self explainatory or I m not getting what you can't understand or want to know ..... AFAIK the virtual mappings of ZONE_NORMAL (__page_tables__) (0MB to 896MB) are created at the boot time and they are related to the __page_table_management__ not to the __process_managemet__ > I looked at sources and see in mm/page_alloc.c > > #ifdef WANT_PAGE_VIRTUAL > /* The shift won't overflow because ZONE_NORMAL is > below 4G. */ > if (!is_highmem_idx(zone)) > set_page_address(page, __va(start_pfn << > PAGE_SHIFT)); > #endif > > But this assumes WANT_PAGE_VIRTUAL... > I don't think on i386 __normally__ that WANT_PAGE_VIRTUAL is defined in kernel configuration, although this is used to add one more field to the " struct page " at compile time, so that if the architecture is slow in multiplication then keeps the virtual address mapping in the "struct page" ..... here the lines from the include/linux/mm.h struct page { ................. /*other fields*/ ................. /* * On machines where all RAM is mapped into kernel address space, * we can simply calculate the virtual address. On machines with * highmem some memory is mapped into kernel virtual memory * dynamically, so we need a place to store that address. * Note that this field could be 16 bits on x86 ... ;) * * Architectures with slow multiplication can define * WANT_PAGE_VIRTUAL in asm/page.h */ #if defined(WANT_PAGE_VIRTUAL) void *virtual; /* Kernel virtual address (NULL if not kmapped, ie. highmem) */ #endif /* WANT_PAGE_VIRTUAL */ }; Now I hope it will be more clear then before !!!!! -- Fawad Lateef -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/